Glassmorphism Design System Implementation

πŸ—οΈ Component Architecture

The admin panel follows a component separation pattern to maintain clean architecture:
admin/
β”œβ”€β”€ packages/ui/                        # Shared UI Library
β”‚   └── src/
β”‚       β”œβ”€β”€ styles/
β”‚       β”‚   └── theme.css               βœ… Global theme & glassmorphism
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   β”œβ”€β”€ layout/                 # Layout Components
β”‚       β”‚   β”‚   β”œβ”€β”€ index.ts            βœ… Barrel export
β”‚       β”‚   β”‚   β”œβ”€β”€ MainLayout.tsx      βœ… Main page layout
β”‚       β”‚   β”‚   β”œβ”€β”€ Sidebar.tsx         βœ… Navigation sidebar
β”‚       β”‚   β”‚   └── Navbar.tsx          βœ… Top navbar
β”‚       β”‚   └── ui/                     # UI Primitives
β”‚       β”‚       β”œβ”€β”€ index.ts            βœ… Barrel export
β”‚       β”‚       β”œβ”€β”€ Avatar.tsx          βœ… User avatars
β”‚       β”‚       β”œβ”€β”€ Badge.tsx           βœ… Status badges
β”‚       β”‚       β”œβ”€β”€ Button.tsx          βœ… Action buttons
β”‚       β”‚       β”œβ”€β”€ Card.tsx            βœ… Content cards
β”‚       β”‚       β”œβ”€β”€ GlassButton.tsx     βœ… Glassmorphism styled button
β”‚       β”‚       β”œβ”€β”€ GlassCard.tsx       βœ… Glassmorphism styled card
β”‚       β”‚       β”œβ”€β”€ HolidayCard.tsx     βœ… Calendar date display
β”‚       β”‚       β”œβ”€β”€ Input.tsx           βœ… Form inputs
β”‚       β”‚       β”œβ”€β”€ ProgressBar.tsx     βœ… Progress indicators
β”‚       β”‚       β”œβ”€β”€ SearchBar.tsx       βœ… Search input
β”‚       β”‚       └── Table.tsx           βœ… Data tables
β”‚       β”œβ”€β”€ utils/
β”‚       β”‚   └── cn.ts                   βœ… Class name utility
β”‚       β”œβ”€β”€ index.ts                    βœ… Public API exports
β”‚       └── package.json
β”‚
└── apps/panel/                         # Admin Application
    └── src/
        β”œβ”€β”€ components/
        β”‚   └── pages/                  # Page-Specific Components
        β”‚       β”œβ”€β”€ dashboard/          # Dashboard Domain
        β”‚       β”‚   β”œβ”€β”€ index.ts        βœ… Barrel export
        β”‚       β”‚   β”œβ”€β”€ StatCard.tsx    βœ… Statistics widget
        β”‚       β”‚   β”œβ”€β”€ DepartmentUsage.tsx  βœ… Dept. metrics
        β”‚       β”‚   └── UpcomingHolidays.tsx βœ… Holiday calendar
        β”‚       └── auth/               # Auth Domain
        β”‚           β”œβ”€β”€ index.ts        βœ… Barrel export
        β”‚           └── ProtectedRoute.tsx   βœ… Route guard
        └── routes/
            └── index.tsx               # Dashboard page

πŸ“š 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

// Primary Colors
primary: '#14b8a6'      // Teal 500
secondary: '#10b981'    // Emerald 500

// Semantic
success: '#10b981'      // Emerald 500
warning: '#f59e0b'      // Amber 500
danger: '#ef4444'       // Red 500
info: '#3b82f6'         // Blue 500

// Light Mode
background: Radial gradient (blue β†’ cyan β†’ teal)
glass: rgba(255, 255, 255, 0.45)
border: rgba(255, 255, 255, 0.6)

// Dark Mode
background: Radial gradient (slate-800 β†’ slate-900 β†’ black)
glass: rgba(30, 41, 59, 0.6)
border: rgba(255, 255, 255, 0.1)

πŸ“¦ Icon Library (solid-icons)

Icon ComponentUsage
TbDashboardDashboard
TbUsersEmployees
TbCalendarEventLeave Requests
TbCalendarCalendar
TbChartBarReports
TbUserGroupUser Groups
TbSettingsSettings
TbLogoutLogout
TbSearchSearch
TbBellNotifications
TbMoon/TbSunTheme Toggle
TbMenu2Mobile Menu
TbLeafCompany Logo
TbTrendingUpStats Increase
TbAlertCircleWarning
TbClockPending
TbBeachVacation
TbCircleCheckApproved
TbCheckApprove Action
TbXReject Action
TbDotsVerticalMore Options

🎯 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

// βœ… CORRECT: Import UI primitives from package
import { Card, Badge, Avatar } from "@monorepo/solid-pkg-ui";

// βœ… CORRECT: Import page components locally
import { StatCard, DepartmentUsage } from "../components/pages/dashboard";

// βœ… CORRECT: Import utilities from package
import { cn } from "@monorepo/solid-pkg-ui/utils";

// ❌ WRONG: Don't import page-specific components from the package
import { StatCard } from "@monorepo/solid-pkg-ui"; // This won't work!

πŸ’‘ 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

// apps/panel/src/components/pages/dashboard/TeamStats.tsx
import { Card, CardBody } from "@monorepo/solid-pkg-ui";
import { cn } from "@monorepo/solid-pkg-ui/utils";
import { TbUsers } from "solid-icons/tb";

export const TeamStats = () => {
  return (
    <Card>
      <CardBody>
        <div class="flex items-center gap-4">
          <TbUsers size={32} class="text-primary" />
          <div>
            <h3 class="text-2xl font-bold">24</h3>
            <p class="text-sm text-slate-500">Team Members</p>
          </div>
        </div>
      </CardBody>
    </Card>
  );
};

// apps/panel/src/components/pages/dashboard/index.ts
export { TeamStats } from "./TeamStats";
export { StatCard } from "./StatCard";
export { DepartmentUsage } from "./DepartmentUsage";
export { UpcomingHolidays } from "./UpcomingHolidays";

// apps/panel/src/routes/index.tsx
import { TeamStats } from "../components/pages/dashboard";

export default function DashboardPage() {
  return <TeamStats />;
}

πŸ”§ Utility Functions

cn() - Class Name Utility

Combines Tailwind classes with conditional logic:
import { cn } from "@monorepo/solid-pkg-ui/utils";

<div class={cn("base-class", isActive && "active-class", props.class)} />;
This utility uses clsx and tailwind-merge to handle class name conflicts intelligently.