HTML Structure & Semantics
1. Document Structure
<!DOCTYPE html> <html lang="en"> <head> <!-- Meta tags, title, and resource links --> </head> <body class="bg-gray-50 text-gray-800 min-h-screen dark:bg-gray-900 dark:text-gray-200"> <!-- Page content with dark mode classes --> </body> </html>
2. Component Hierarchy
Body ├── Header (Fixed top bar) │ ├── Logo + Menu button (mobile) │ ├── Search bar (desktop) │ └── Action buttons ├── Main Container │ ├── Sidebar (Left, fixed on mobile) │ │ ├── Navigation menu │ │ ├── Categories │ │ ├── Quick links │ │ └── Pro banner │ └── Main Content (Right) │ ├── Home section (default) │ ├── Category cards │ ├── Reference system demo │ └── Quick templates └── Bottom Navigation (Mobile only)
CSS & Styling System
1. Color System (Tailwind-based)
Primary Colors: Blue-purple gradient (#667eea → #764ba2)
Backgrounds:
Light:
bg-gray-50Dark:
dark:bg-gray-900
Text Colors:
Light:
text-gray-800Dark:
dark:text-gray-200
Component Colors:
Sidebar:
bg-white/dark:bg-gray-800Cards: Gradient backgrounds with specific color combinations
Borders:
border-gray-300/dark:border-gray-700
2. Typography
Font Family: Inter (Google Fonts)
Font Weights: 300-700 range
Font Sizes:
Headers:
text-3xl,text-2xl,text-xlBody: Default (1rem)
Small:
text-sm,text-xs
Special Text Effects:
Gradient text:
.gradient-textclass
3. Layout System
/* Fixed positioning */ .fixed, .absolute, .relative /* Flexbox */ .flex, .flex-col, .flex-row, .items-center, .justify-between /* Grid */ .grid, .grid-cols-1, .grid-cols-2, .grid-cols-3, .grid-cols-4 /* Spacing */ .p-*, .m-*, .space-y-*, .gap-* /* Sizing */ .w-*, .h-*, .min-h-screen, .max-w-*
4. Responsive Design
/* Mobile-first approach with breakpoints */ /* Default: Mobile (< 640px) */ /* sm: 640px, md: 768px, lg: 1024px, xl: 1280px */ /* Example responsive classes */ .lg:hidden /* Hide on large screens */ .md:block /* Show on medium screens */
5. Animation & Transitions
/* Fade in animations */ .fade-in { animation: fadeIn 0.5s ease-in; } @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } /* Hover effects */ .card-hover:hover { transform: translateY(-5px); box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); } /* Transitions */ .transition, .transition-all, .duration-*
6. Custom Components Styling
Gradient Backgrounds
.gradient-bg { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); } /* Specific gradient combinations: - Blue to Blue: from-blue-500 to-blue-600 - Green to Green: from-green-500 to-green-600 - Purple to Purple: from-purple-500 to-purple-600 - Orange to Orange: from-orange-500 to-orange-600 */
Active State Indicators
.active-category::after { content: ''; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%); width: 6px; height: 6px; background: #667eea; border-radius: 50%; }
Shadow Systems
/* Light mode */ .shadow-md, .shadow-lg, .bottom-nav-shadow /* Dark mode adjustments */ .dark .bottom-nav-shadow { box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3); }
Custom Scrollbar
.sidebar-scroll::-webkit-scrollbar { width: 6px; } .sidebar-scroll::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; } /* Dark mode variants */ .dark .sidebar-scroll::-webkit-scrollbar-track { background: #374151; }
Component-Specific Styles
1. Header Component
<header class="fixed top-0 left-0 right-0 z-50 bg-white shadow-md dark:bg-gray-800"> <div class="container mx-auto px-4 py-3"> <div class="flex items-center justify-between"> <!-- Content --> </div> </div> </header>
2. Sidebar Component
<aside class="fixed lg:static top-16 left-0 h-[calc(100vh-4rem)] w-64 bg-white shadow-lg lg:shadow-none sidebar-transition transform lg:translate-x-0 z-40 -translate-x-full"> <!-- Content --> </aside>
3. Card Components
<div class="bg-gradient-to-br from-blue-500 to-blue-600 text-white p-6 rounded-2xl shadow-lg card-hover"> <!-- Card content --> </div>
4. Bottom Navigation (Mobile)
<nav class="fixed bottom-0 left-0 right-0 bg-white bottom-nav-shadow lg:hidden z-40"> <div class="flex justify-around py-3 px-2"> <!-- Navigation items --> </div> </nav>
JavaScript Architecture
1. State Management Pattern
const state = { darkMode: localStorage.getItem('darkMode') === 'true', sidebarOpen: false };
2. DOM Element Caching
const elements = { sidebar: document.getElementById('sidebar'), sidebarToggle: document.getElementById('sidebarToggle'), darkModeToggle: document.getElementById('darkModeToggle'), darkModeIcon: document.getElementById('darkModeIcon'), body: document.body };
3. Event-Driven Architecture
// Event listener setup elements.sidebarToggle.addEventListener('click', toggleSidebar); elements.darkModeToggle.addEventListener('click', toggleDarkMode); // Event delegation for dynamic elements document.addEventListener('click', function(event) { // Handle clicks outside sidebar on mobile });
4. Utility Functions
// Toggle functions function toggleSidebar() { /* ... */ } function toggleDarkMode() { /* ... */ } // Navigation functions function showCategory(category) { /* ... */ } function highlightCurrentPage() { /* ... */ }
Theme System Implementation
1. Dark/Light Mode Switch
function toggleDarkMode() { state.darkMode = !state.darkMode; if (state.darkMode) { elements.body.classList.add('dark'); elements.darkModeIcon.classList.remove('fa-moon'); elements.darkModeIcon.classList.add('fa-sun'); } else { elements.body.classList.remove('dark'); elements.darkModeIcon.classList.remove('fa-sun'); elements.darkModeIcon.classList.add('fa-moon'); } localStorage.setItem('darkMode', state.darkMode); }
2. Theme-Aware Components
<!-- Components with dark mode variants --> <div class="bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-700"> <!-- Content --> </div>
Responsive Design Patterns
1. Mobile-First Breakpoints
/* Mobile (default) */ .w-full, .p-4, .block /* Tablet (md: 768px) */ .md:grid-cols-2, .md:block /* Desktop (lg: 1024px) */ .lg:grid-cols-4, .lg:static, .lg:ml-64
2. Conditional Visibility
<!-- Hidden on mobile, visible on desktop --> <div class="hidden md:block"> <!-- Search bar --> </div> <!-- Bottom nav only on mobile --> <nav class="lg:hidden"> <!-- Mobile navigation --> </nav>
Accessibility Features
1. Semantic HTML
<header>, <main>, <aside>, <nav>, <section> <!-- Proper heading hierarchy --> <h1>, <h2>, <h3>
2. Interactive Elements
<button> elements for all interactive actions
aria-label attributes where needed
focus states with Tailwind focus: classesPerformance Optimizations
1. Efficient CSS
Utility-first approach with Tailwind
Minimal custom CSS
Efficient selectors
2. JavaScript Optimization
Event delegation for dynamic elements
Local storage for persistent state
Debounced/resize handlers
This structure provides a clean, maintainable, and scalable foundation for building responsive web applications with consistent theming and good performance characteristics.
0 Comments