This document establishes consistent design patterns for all visualizers to ensure a cohesive learning experience.
- Every interaction should teach something about CSS
- Real-time visual feedback for all changes
- Code examples that reflect actual usage
- Progressive complexity from basic to advanced
- Uniform visual language across all modules
- Consistent interaction patterns
- Shared color palette and typography
- Standardized spacing and layout
- WCAG 2.1 AA compliance
- Keyboard navigation support
- Screen reader compatibility
- High contrast ratios
- Touch-friendly interactions
- Responsive breakpoints at 640px and 1024px
- Optimized for small screens
- Progressive enhancement
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>[Feature Name] - CSS Visual Learner</title>
<link rel="stylesheet" href="../style.css">
<link rel="stylesheet" href="../styles/[feature-name].css">
<!-- Standard Meta Tags -->
<meta name="description" content="Interactive tool to learn [CSS Feature] with real-time visual feedback.">
<meta name="keywords" content="CSS, [feature], Web Design, Learning Tool">
<meta name="author" content="Fahdi">
<!-- Social Media Meta Tags -->
<!-- ... standard social tags ... -->
</head>
<body>
<header style="text-align: center">
<button class="hamburger-menu" onclick="toggleSidebar()">...</button>
<a href="../index.html" class="logo-link">...</a>
</header>
<div id="sidebar"></div>
<div id="content">
<h1>[Feature Name]</h1>
<p>Brief description of what this visualizer teaches.</p>
<div id="css-rule-display">
<pre>Hover over elements to see CSS in action!</pre>
</div>
<div class="controls">
<!-- Interactive controls -->
</div>
<div class="interactive-elements">
<!-- Main demo elements -->
</div>
<div class="info-panel">
<!-- Key concepts and tips -->
</div>
</div>
<script src="../scripts/main.js"></script>
<script src="../scripts/[feature-name].js"></script>
</body>
</html>:root {
--primary-color: #3498db; /* Blue - primary actions */
--secondary-color: #e74c3c; /* Red - secondary actions */
--success-color: #27ae60; /* Green - success states */
--warning-color: #f39c12; /* Orange - warnings */
--purple-color: #9b59b6; /* Purple - special cases */
--border-radius: 8px;
--transition-duration: 0.3s;
--box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}- Font Family: Arial, sans-serif (system fonts)
- Headings:
- H1: Main feature title
- H2: Section titles with bottom border
- H3: Subsection titles
- Body Text: 14px base, 1.6 line-height
- Code: Monaco, Menlo, Ubuntu Mono (monospace)
- Micro: 0.25rem (4px)
- Small: 0.5rem (8px)
- Medium: 1rem (16px)
- Large: 1.5rem (24px)
- XL: 2rem (32px)
.controls {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1.5rem;
padding: 1.5rem;
background: #f8f9fa;
border-radius: var(--border-radius);
margin-bottom: 2rem;
}
.control-group {
display: flex;
flex-direction: column;
gap: 0.5rem;
align-items: center;
}.interactive-element {
cursor: pointer;
transition: transform var(--transition-duration) ease,
box-shadow var(--transition-duration) ease;
border-radius: var(--border-radius);
position: relative;
overflow: hidden;
}
.interactive-element:hover {
transform: translateY(-2px);
box-shadow: var(--box-shadow);
}.info-panel {
background: #e8f4fd;
border: 1px solid #b3d9ff;
border-radius: var(--border-radius);
padding: 1.5rem;
margin-top: 2rem;
}// [Feature Name] Visualizer JavaScript
document.addEventListener('DOMContentLoaded', function() {
// Load sidebar
loadSidebar();
// Get DOM elements
const cssRuleDisplay = document.getElementById('css-rule-display');
const controls = document.querySelectorAll('.control-element');
const interactiveElements = document.querySelectorAll('.interactive-element');
// Helper function for smooth CSS display updates
function updateCSSDisplay(content) {
cssRuleDisplay.classList.add('updating');
setTimeout(() => {
cssRuleDisplay.innerHTML = `<pre>${content}</pre>`;
cssRuleDisplay.classList.remove('updating');
}, 100);
}
// Main feature functions
function updateFeature(element, value) {
// Update visual state
// Update CSS rule display
}
function displayRule(element) {
const css = generateCSSRule(element);
updateCSSDisplay(css);
}
// Event listeners
controls.forEach(control => {
control.addEventListener('input', handleControlChange);
});
interactiveElements.forEach(element => {
element.addEventListener('mouseenter', () => displayRule(element));
element.addEventListener('mouseleave', resetDisplay);
});
// Initialize
initializeDefaults();
showIntroduction();
// Export utilities
window.featureDemo = {
updateFeature,
displayRule
};
});- updateCSSDisplay() - Smooth content transitions
- loadSidebar() - Standard navigation
- displayRule() - Show relevant CSS
- Event handlers - Mouse and touch interactions
- Initialize - Set default states
- Export - Utility functions for testing
/* Base: Mobile (320px+) */
.element {
/* Mobile styles */
}
/* Tablet (640px+) */
@media (min-width: 640px) {
.element {
/* Tablet styles */
}
}
/* Desktop (1024px+) */
@media (min-width: 1024px) {
.element {
/* Desktop styles */
}
}- Show CSS rules in sticky display
- Visual feedback (transform, shadow)
- Smooth transitions (0.3s ease)
- Range sliders for numerical values
- Color pickers for color properties
- Dropdowns for discrete options
- Real-time updates
- Immediate response to interactions
- Clear cause-and-effect relationships
- Progressive disclosure of complexity
- Follows HTML structure pattern
- Uses consistent CSS design system
- Implements smooth CSS rule display
- Mobile-responsive across all breakpoints
- Keyboard navigation works
- Screen reader compatible
- Performance optimized (< 3s load time)
- Cross-browser tested
- Educational value clear
- Code examples accurate
- No hardcoded values (uses CSS variables)
- Semantic HTML structure
- Accessible form controls
- Error handling in JavaScript
- Clean, commented code
- No console errors
- Teaches real-world CSS concepts
- Progressive complexity
- Clear explanations
- Practical examples
- Common use cases covered
- Monitor user interactions
- A/B test design changes
- Regular accessibility audits
- Performance monitoring
- Update patterns based on learnings
- Maintain backward compatibility
- Document all changes
- Communicate updates to team
This document should be updated as patterns evolve and new visualizers are added.