Glassmorphism Design System Implementation

πŸ—οΈ Component Architecture

The admin panel follows a component separation pattern to maintain clean architecture:

πŸ“š Component Categories

1. UI Primitives (packages/ui/src/components/ui/)

Purpose: Reusable design system components with no business logic Examples:
  • Button, Card, Badge, Avatar
  • GlassButton, GlassCard (styled variants)
  • Input, SearchBar, Table, ProgressBar
Characteristics:
  • βœ… Generic and reusable
  • βœ… No domain-specific data
  • βœ… Style and interaction focused
  • βœ… Can be used across any page

2. Layout Components (packages/ui/src/components/layout/)

Purpose: Structural components for page layout Examples:
  • MainLayout - Main page wrapper
  • Sidebar - Navigation sidebar
  • Navbar - Top navigation bar
Characteristics:
  • βœ… Define page structure
  • βœ… Handle navigation
  • βœ… Responsive layouts

3. Page-Specific Components (apps/panel/src/components/pages/)

Purpose: Domain logic and page-specific features Examples:
  • StatCard - Dashboard statistics with trends
  • DepartmentUsage - HR department metrics
  • UpcomingHolidays - Holiday calendar widget
  • ProtectedRoute - Auth route wrapper
Characteristics:
  • βœ… Contains business logic
  • βœ… Uses domain-specific data
  • βœ… Organized by feature/page
  • βœ… Imports UI primitives from @monorepo/solid-pkg-ui

βœ… Completed Components

Global Theme

  • βœ… packages/ui/src/styles/theme.css
    • CSS custom properties for colors, spacing, shadows
    • Glassmorphism effects
    • Dark mode support
    • Custom scrollbar styling
    • Animation utilities

Layout Components

  • βœ… MainLayout.tsx - Main page wrapper with sidebar + navbar
  • βœ… Sidebar.tsx - Navigation with sections, badges, icons
  • βœ… Navbar.tsx - Search bar, theme toggle, notifications, user menu

UI Primitives

  • βœ… Button.tsx - Variants: primary, secondary, outline, ghost, etc.
  • βœ… Card.tsx - CardHeader, CardBody, CardFooter subcomponents
  • βœ… Badge.tsx - Status badges with variants
  • βœ… Avatar.tsx - User avatars with fallbacks
  • βœ… Input.tsx - Form inputs with validation states
  • βœ… SearchBar.tsx - Search input with glass effect
  • βœ… Table.tsx - Data table with hover effects
  • βœ… ProgressBar.tsx - Progress indicators
  • βœ… HolidayCard.tsx - Calendar date display
  • βœ… GlassButton.tsx - Glassmorphism button variant
  • βœ… GlassCard.tsx - Glassmorphism card variant

Page-Specific Components

  • βœ… StatCard.tsx - Dashboard statistics with trend indicators
  • βœ… DepartmentUsage.tsx - Department leave usage widget
  • βœ… UpcomingHolidays.tsx - Holiday calendar widget
  • βœ… ProtectedRoute.tsx - Authentication route guard

🎨 Color System

πŸ“¦ Icon Library (solid-icons)

🎯 Usage Guidelines

When to Create a UI Primitive

Create a component in packages/ui/src/components/ui/ when:
  • βœ… It’s a generic, reusable design element
  • βœ… It has no business logic or domain data
  • βœ… It can be used across multiple pages
  • βœ… It’s part of the design system
Examples: Button, Input, Card, Badge, Avatar

When to Create a Page Component

Create a component in apps/panel/src/components/pages/[feature]/ when:
  • βœ… It contains domain-specific logic
  • βœ… It uses business data (e.g., statistics, department info)
  • βœ… It’s specific to a particular page or feature
  • βœ… It combines multiple UI primitives
Examples: StatCard, DepartmentUsage, UpcomingHolidays

Import Patterns

πŸ’‘ Design Principles

1. Glassmorphism

  • Frosted glass effect with backdrop blur
  • Semi-transparent backgrounds
  • Layered depth with shadows
  • Border highlights

2. Micro-interactions

  • Scale animations on hover
  • Smooth transitions (300ms duration)
  • Backdrop blur effects
  • Color shifts on interaction

3. Dark Mode

  • Automatic system preference detection
  • Persistent storage
  • Smooth transitions
  • Optimized contrast ratios

4. Accessibility

  • ARIA labels on all interactive elements
  • Keyboard navigation support
  • Focus indicators
  • Screen reader compatibility

5. Responsive Design

  • Mobile-first approach
  • Tailwind breakpoints (sm, md, lg, xl)
  • Touch-friendly targets (min 44x44px)
  • Collapsible sidebar on mobile

πŸš€ Adding New Components

For UI Primitives:

  1. Create component in packages/ui/src/components/ui/[ComponentName].tsx
  2. Add export to packages/ui/src/components/ui/index.ts
  3. Add export to packages/ui/src/index.ts
  4. Document props and usage

For Page Components:

  1. Create component in apps/panel/src/components/pages/[feature]/[ComponentName].tsx
  2. Add export to apps/panel/src/components/pages/[feature]/index.ts
  3. Import UI primitives from @monorepo/solid-pkg-ui
  4. Use in your page routes

πŸ“ Example: Creating a New Page Component

πŸ”§ Utility Functions

cn() - Class Name Utility

Combines Tailwind classes with conditional logic:
This utility uses clsx and tailwind-merge to handle class name conflicts intelligently.