# Frontend Complete Refactoring & Standardization Plan ## ✅ STATUS: TAILWIND DEFAULT COLORS DISABLED **As of 2026-01-01**: All Tailwind default color palettes (blue-500, red-600, green-400, etc.) have been **disabled** via `@theme` in `design-system.css`. Only our custom design system colors work now. ### What's Disabled (via `@theme { --color-*-*: initial; }`) - `red-*`, `orange-*`, `amber-*`, `yellow-*`, `lime-*` - `green-*`, `emerald-*`, `teal-*`, `cyan-*`, `sky-*` - `blue-*`, `indigo-*`, `violet-*`, `fuchsia-*`, `pink-*`, `rose-*` - `slate-*`, `zinc-*`, `neutral-*`, `stone-*` ### What WORKS (our design system) - `brand-*` (25-950) - derived from `--color-primary` - `success-*` (25-950) - derived from `--color-success` - `warning-*` (25-950) - derived from `--color-warning` - `error-*` (25-950) - derived from `--color-danger` - `purple-*` (25-950) - derived from `--color-purple` - `gray-*` (25-950) - derived from `--color-gray-base` - `blue-light-*` - info/link colors (derived from primary) --- ## 🎯 Objective **Completely remove Tailwind default styles** and refactor the entire frontend to use **ONLY** the custom design system defined in `/src/styles/design-system.css`. ### Why This Refactor? - AI agents keep defaulting to Tailwind's standard colors instead of our custom tokens - Mixed Tailwind + custom styles cause conflicts and inconsistencies - No single source of truth - styles scattered across files - Inline components duplicated across multiple pages ### End Goal - **Single CSS file** (`design-system.css`) as the ONLY source for all design tokens - **All colors** come from CSS variables defined in `:root` - **All components** extracted to `/components/ui/` - NO inline component definitions - **Zero Tailwind default colors** - only our custom palette (brand, success, error, warning, purple, gray) --- ## 📂 Single Source of Truth: `/src/styles/design-system.css` This file contains: - **Section 1**: Design Tokens (CSS Variables) - colors, radius, shadows, gradients - **Section 2**: Dark Mode Overrides - **Section 3**: Tailwind Configuration (DEFAULT COLORS DISABLED) - **Section 4**: Base Styles - **Section 5**: Component Utilities - **Section 6**: Form Element Styles - **Section 7**: Table Styles - **Section 8**: Header Metrics - **Section 9**: Badge Styles - **Section 10-13**: Library overrides, utilities, animations --- ## 🎨 Color Architecture: 6 Primary Colors Only ### Why Only 6 Primary Hex Colors? 1. **Dynamic Theming**: Users can customize theme colors in the frontend 2. **Single Change = Entire System Updates**: Change one primary color → all shades/variants update automatically 3. **Consistency**: Whole app looks designed by ONE person, not scattered/mismatched 4. **Maintainability**: No hunting for hardcoded hex values scattered everywhere ### The 6 Primary Color Tokens (ONLY THESE USE HEX) ```css :root { /* ===== THE ONLY 6 HEX VALUES IN THE ENTIRE SYSTEM ===== */ --color-primary: #2C7AA1; /* Brand Blue - main CTA, links, primary actions */ --color-success: #2CA18E; /* Success Green - confirmations, positive states */ --color-warning: #D9A12C; /* Warning Amber - alerts, cautions */ --color-danger: #A12C40; /* Danger Red - errors, destructive actions */ --color-purple: #2C40A1; /* Purple - premium features, special emphasis */ --color-gray-base: #667085; /* Gray Base - neutral text, borders, backgrounds */ } ``` ### ALL Other Colors MUST Derive From These 6 ```css /* ✅ CORRECT - Derived from primary tokens */ --color-primary-dark: color-mix(in srgb, var(--color-primary) 80%, black); --color-primary-light: color-mix(in srgb, var(--color-primary) 60%, white); --color-primary-subtle: color-mix(in srgb, var(--color-primary) 8%, white); --color-brand-500: var(--color-primary); --color-brand-600: color-mix(in srgb, var(--color-primary) 85%, black); --color-brand-400: color-mix(in srgb, var(--color-primary) 75%, white); /* ... all shades computed from the primary */ /* ❌ WRONG - Hardcoded hex for variants */ --color-primary-dark: #005A8C; /* NO! Must derive from --color-primary */ --color-brand-600: #0369a1; /* NO! Must use color-mix() */ ``` ### Color Derivation Rules | Shade | Derivation Formula | |-------|-------------------| | `*-25` | `color-mix(in srgb, var(--color-*) 3%, white)` | | `*-50` | `color-mix(in srgb, var(--color-*) 8%, white)` | | `*-100` | `color-mix(in srgb, var(--color-*) 15%, white)` | | `*-200` | `color-mix(in srgb, var(--color-*) 25%, white)` | | `*-300` | `color-mix(in srgb, var(--color-*) 40%, white)` | | `*-400` | `color-mix(in srgb, var(--color-*) 60%, white)` | | `*-500` | `var(--color-*)` (the primary itself) | | `*-600` | `color-mix(in srgb, var(--color-*) 85%, black)` | | `*-700` | `color-mix(in srgb, var(--color-*) 70%, black)` | | `*-800` | `color-mix(in srgb, var(--color-*) 55%, black)` | | `*-900` | `color-mix(in srgb, var(--color-*) 40%, black)` | | `*-950` | `color-mix(in srgb, var(--color-*) 25%, black)` | ### Future Theming Support When user selects a theme, we only change these 6 values: ```javascript // Theme switcher (future feature) document.documentElement.style.setProperty('--color-primary', '#NEW_HEX'); document.documentElement.style.setProperty('--color-success', '#NEW_HEX'); // ... and the ENTIRE app updates automatically! ``` --- ## Phase 1: Audit Detection Scripts ### 1.1 Run These Detection Commands ```bash # Create audit results folder mkdir -p /data/app/igny8/frontend/audit-results # ===================================================== # STYLE VIOLATIONS - Must be 0 after refactor # ===================================================== # 1. ALL inline styles (style={{) grep -rn "style={{" src/pages/ src/components/ --include="*.tsx" > audit-results/01-inline-styles.txt echo "Inline styles found: $(wc -l < audit-results/01-inline-styles.txt)" # 2. ALL hardcoded hex colors in className (text-[#xxx], bg-[#xxx]) grep -rn "\[#[0-9a-fA-F]\{3,6\}\]" src/pages/ src/components/ --include="*.tsx" > audit-results/02-hardcoded-hex-class.txt echo "Hardcoded hex in className: $(wc -l < audit-results/02-hardcoded-hex-class.txt)" # 3. ALL hardcoded hex colors anywhere (outside CSS) grep -rn "#[0-9a-fA-F]\{6\}" src/pages/ src/components/ --include="*.tsx" > audit-results/03-hardcoded-hex-all.txt echo "Hardcoded hex anywhere: $(wc -l < audit-results/03-hardcoded-hex-all.txt)" # 4. ALL rgb/rgba inline values grep -rn "rgba\?(" src/pages/ src/components/ --include="*.tsx" > audit-results/04-rgb-values.txt echo "RGB/RGBA values: $(wc -l < audit-results/04-rgb-values.txt)" # 5. TAILWIND DEFAULT COLORS (should NOT exist - we disabled them) grep -rn "bg-blue-\|text-blue-\|border-blue-\|bg-red-\|text-red-\|border-red-\|bg-green-\|text-green-\|border-green-\|bg-yellow-\|text-yellow-\|bg-emerald-\|text-emerald-\|bg-indigo-\|text-indigo-\|bg-pink-\|text-pink-\|bg-rose-\|text-rose-\|bg-amber-\|text-amber-\|bg-cyan-\|text-cyan-\|bg-teal-\|text-teal-\|bg-violet-\|text-violet-\|bg-fuchsia-\|text-fuchsia-\|bg-lime-\|text-lime-\|bg-orange-\|text-orange-\|bg-sky-\|text-sky-\|bg-slate-\|text-slate-\|bg-zinc-\|text-zinc-\|bg-neutral-\|text-neutral-\|bg-stone-\|text-stone-" src/pages/ src/components/ --include="*.tsx" > audit-results/05-tailwind-default-colors.txt echo "Tailwind default colors: $(wc -l < audit-results/05-tailwind-default-colors.txt)" # ===================================================== # COMPONENT VIOLATIONS # ===================================================== # 6. External UI library imports (MUI, Chakra, Ant, etc.) grep -rn "from '@mui\|from '@chakra\|from 'antd\|from '@headlessui\|from '@radix" src/pages/ src/components/ --include="*.tsx" > audit-results/06-external-ui-imports.txt echo "External UI imports: $(wc -l < audit-results/06-external-ui-imports.txt)" # 7. lucide-react imports (should use /icons/) grep -rn "from 'lucide-react" src/pages/ src/components/ --include="*.tsx" > audit-results/07-lucide-imports.txt echo "Lucide imports: $(wc -l < audit-results/07-lucide-imports.txt)" # 8. Inline component definitions (const ComponentName = () => { inside pages) grep -rn "const [A-Z][a-zA-Z]*\s*=\s*(" src/pages/ --include="*.tsx" > audit-results/08-inline-components.txt echo "Inline component definitions: $(wc -l < audit-results/08-inline-components.txt)" # 9. Raw HTML buttons (should use Button component) grep -rn " // ❌ WRONG import { Button } from '@mui/material'; import { Check } from 'lucide-react'; ``` ### Where Hex Values ARE Allowed ```css /* ✅ ONLY in design-system.css - the 6 primary tokens */ :root { --color-primary: #2C7AA1; --color-success: #2CA18E; --color-warning: #D9A12C; --color-danger: #A12C40; --color-purple: #2C40A1; --color-gray-base: #667085; } /* ✅ All other colors derived using color-mix() */ --color-primary-dark: color-mix(in srgb, var(--color-primary) 75%, black); --color-brand-600: color-mix(in srgb, var(--color-primary) 85%, black); --color-gray-700: color-mix(in srgb, var(--color-gray-base) 70%, black); ``` --- ## 🚨 CRITICAL RULES 1. **6 PRIMARY HEX ONLY**: Only `--color-primary`, `--color-success`, `--color-warning`, `--color-danger`, `--color-purple`, `--color-gray-base` use hex values (plus `#ffffff` for white) 2. **ALL SHADES DERIVED**: Every shade (25-950) is computed from primary using `color-mix()` 3. **NO TAILWIND DEFAULTS**: blue-*, red-*, green-*, etc. are DISABLED 4. **NO INLINE STYLES**: Never use `style={{}}` for colors/spacing 5. **NO HARDCODED HEX IN TSX**: All hex lives in design-system.css only 6. **EXTRACT COMPONENTS**: Any UI used 2+ times → `/components/ui/` 7. **USE STANDARD COMPONENTS**: Button, Modal, Alert, Badge from `/components/ui/` --- ## 🎯 Design Consistency Goals ### The "One Designer" Principle The entire application must look like it was designed and built by **ONE person**: | Aspect | Requirement | |--------|-------------| | **Colors** | Exact same 6 color palettes everywhere | | **Spacing** | Consistent padding/margins (use Tailwind spacing scale) | | **Typography** | Same font sizes, weights, line heights | | **Borders** | Same border radius, colors, widths | | **Shadows** | Same shadow tokens everywhere | | **Buttons** | All use `