Files
CodePilot/src/app/globals.css
T
7418andClaude Opus 4.6 5d7850a180 refactor: complete UI governance — lint rules, icon/color unification, component splits
Design pattern & component consistency governance across 120 files:

ESLint governance (eslint.config.mjs):
- Enforce ui/ components over native HTML controls (warn)
- Ban Lucide imports (error), require Phosphor via ui/icon.tsx (warn)
- Component file size limit 500 lines (warn, skip blanks+comments)
- Patterns layer isolation (error: no hooks/lib imports)
- Exclude 资料/ from lint scope

Icon unification (ui/icon.tsx):
- Unified barrel export with 86+ Phosphor icons
- Decoupled types/index.ts from icon library (generic IconComponent type)
- Separated command data (lib/constants/commands.ts) from icons (command-icons.ts)

Color token system (globals.css):
- Added semantic status tokens: success/warning/error/info with muted/foreground/border variants
- Migrated 39 files from raw green/red/orange/amber/blue to semantic tokens
- grep-based lint:colors script covers green/emerald/red/orange/yellow/amber/blue

Component splits (all under 500 lines):
- MessageInput 1659→444: MessageInputParts, SlashCommandPopover, 7 hooks, 2 libs
- ChatView ~850→419: useStreamSubscription, useAssistantTrigger
- ProviderManager 1081→406: provider-presets, PresetConnectDialog, useProviderModels
- AppShell 527→470: useUpdateChecker
- AssistantWorkspaceSection 908→499: WorkspaceTabPanels/ConfirmDialogs/StatusCards
- ChatListPanel 677→484: SessionListItem, ProjectGroupHeader, chat-list-utils

Other:
- Migrated 80 native HTML controls to ui/ components across 38 files
- Fixed 22 hook dependency / set-state-in-effect issues
- Cleaned 7 dead code warnings
- Rebuilt better-sqlite3 for ARM architecture
- Added handover doc: docs/handover/ui-governance.md

Lint status: 0 errors 0 warnings on touched files; typecheck pass; 374/374 tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 01:02:28 +08:00

255 lines
9.2 KiB
CSS

@import "tailwindcss";
@import "tw-animate-css";
@custom-variant dark (&:is(.dark *));
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--font-sans: var(--font-geist-sans);
--font-mono: var(--font-geist-mono);
--color-sidebar-ring: var(--sidebar-ring);
--color-sidebar-border: var(--sidebar-border);
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
--color-sidebar-accent: var(--sidebar-accent);
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
--color-sidebar-primary: var(--sidebar-primary);
--color-sidebar-foreground: var(--sidebar-foreground);
--color-sidebar: var(--sidebar);
--color-chart-5: var(--chart-5);
--color-chart-4: var(--chart-4);
--color-chart-3: var(--chart-3);
--color-chart-2: var(--chart-2);
--color-chart-1: var(--chart-1);
--color-ring: var(--ring);
--color-input: var(--input);
--color-border: var(--border);
--color-destructive: var(--destructive);
--color-accent-foreground: var(--accent-foreground);
--color-accent: var(--accent);
--color-muted-foreground: var(--muted-foreground);
--color-muted: var(--muted);
--color-secondary-foreground: var(--secondary-foreground);
--color-secondary: var(--secondary);
--color-primary-foreground: var(--primary-foreground);
--color-primary: var(--primary);
--color-popover-foreground: var(--popover-foreground);
--color-popover: var(--popover);
--color-card-foreground: var(--card-foreground);
--color-card: var(--card);
--radius-sm: calc(var(--radius) - 4px);
--radius-md: calc(var(--radius) - 2px);
--radius-lg: var(--radius);
--radius-xl: calc(var(--radius) + 4px);
--radius-2xl: calc(var(--radius) + 8px);
--radius-3xl: calc(var(--radius) + 12px);
--radius-4xl: calc(var(--radius) + 16px);
/* Status semantic colors */
--color-status-success: var(--status-success);
--color-status-success-foreground: var(--status-success-foreground);
--color-status-success-muted: var(--status-success-muted);
--color-status-success-border: var(--status-success-border);
--color-status-warning: var(--status-warning);
--color-status-warning-foreground: var(--status-warning-foreground);
--color-status-warning-muted: var(--status-warning-muted);
--color-status-warning-border: var(--status-warning-border);
--color-status-error: var(--status-error);
--color-status-error-foreground: var(--status-error-foreground);
--color-status-error-muted: var(--status-error-muted);
--color-status-error-border: var(--status-error-border);
--color-status-info: var(--status-info);
--color-status-info-foreground: var(--status-info-foreground);
--color-status-info-muted: var(--status-info-muted);
--color-status-info-border: var(--status-info-border);
}
:root {
--radius: 0.75rem;
--background: oklch(1 0 0);
--foreground: oklch(0.147 0.004 49.25);
--card: oklch(1 0 0);
--card-foreground: oklch(0.147 0.004 49.25);
--popover: oklch(1 0 0);
--popover-foreground: oklch(0.147 0.004 49.25);
--primary: oklch(0.546 0.245 262.881);
--primary-foreground: oklch(0.985 0.001 106.423);
--secondary: oklch(0.97 0.001 106.424);
--secondary-foreground: oklch(0.216 0.006 56.043);
--muted: oklch(0.97 0.001 106.424);
--muted-foreground: oklch(0.553 0.013 58.071);
--accent: oklch(0.97 0.001 106.424);
--accent-foreground: oklch(0.216 0.006 56.043);
--destructive: oklch(0.577 0.245 27.325);
--border: oklch(0.923 0.003 48.717);
--input: oklch(0.923 0.003 48.717);
--ring: oklch(0.546 0.245 262.881);
--chart-1: oklch(0.546 0.245 262.881);
--chart-2: oklch(0.6 0.118 184.704);
--chart-3: oklch(0.398 0.07 227.392);
--chart-4: oklch(0.828 0.189 84.429);
--chart-5: oklch(0.769 0.188 70.08);
--sidebar: oklch(0.985 0.001 106.423);
--sidebar-foreground: oklch(0.147 0.004 49.25);
--sidebar-primary: oklch(0.546 0.245 262.881);
--sidebar-primary-foreground: oklch(0.985 0.001 106.423);
--sidebar-accent: oklch(0.97 0.001 106.424);
--sidebar-accent-foreground: oklch(0.216 0.006 56.043);
--sidebar-border: oklch(0.923 0.003 48.717);
--sidebar-ring: oklch(0.546 0.245 262.881);
--user-bubble: oklch(0.22 0.005 250);
--user-bubble-foreground: oklch(0.985 0.001 106.423);
/* Status semantic tokens */
--status-success: oklch(0.527 0.154 150.069);
--status-success-foreground: oklch(0.393 0.124 148.697);
--status-success-muted: oklch(0.527 0.154 150.069 / 10%);
--status-success-border: oklch(0.527 0.154 150.069 / 20%);
--status-warning: oklch(0.705 0.213 47.604);
--status-warning-foreground: oklch(0.646 0.222 41.116);
--status-warning-muted: oklch(0.705 0.213 47.604 / 10%);
--status-warning-border: oklch(0.705 0.213 47.604 / 20%);
--status-error: oklch(0.577 0.245 27.325);
--status-error-foreground: oklch(0.577 0.245 27.325);
--status-error-muted: oklch(0.577 0.245 27.325 / 10%);
--status-error-border: oklch(0.577 0.245 27.325 / 20%);
--status-info: oklch(0.546 0.245 262.881);
--status-info-foreground: oklch(0.546 0.245 262.881);
--status-info-muted: oklch(0.546 0.245 262.881 / 10%);
--status-info-border: oklch(0.546 0.245 262.881 / 20%);
}
.dark {
--background: oklch(0.147 0.004 49.25);
--foreground: oklch(0.985 0.001 106.423);
--card: oklch(0.216 0.006 56.043);
--card-foreground: oklch(0.985 0.001 106.423);
--popover: oklch(0.216 0.006 56.043);
--popover-foreground: oklch(0.985 0.001 106.423);
--primary: oklch(0.623 0.214 259.815);
--primary-foreground: oklch(0.985 0.001 106.423);
--secondary: oklch(0.268 0.007 34.298);
--secondary-foreground: oklch(0.985 0.001 106.423);
--muted: oklch(0.268 0.007 34.298);
--muted-foreground: oklch(0.709 0.01 56.259);
--accent: oklch(0.268 0.007 34.298);
--accent-foreground: oklch(0.985 0.001 106.423);
--destructive: oklch(0.704 0.191 22.216);
--border: oklch(1 0 0 / 10%);
--input: oklch(1 0 0 / 15%);
--ring: oklch(0.623 0.214 259.815);
--chart-1: oklch(0.623 0.214 259.815);
--chart-2: oklch(0.696 0.17 162.48);
--chart-3: oklch(0.769 0.188 70.08);
--chart-4: oklch(0.627 0.265 303.9);
--chart-5: oklch(0.645 0.246 16.439);
--sidebar: oklch(0.216 0.006 56.043);
--sidebar-foreground: oklch(0.985 0.001 106.423);
--sidebar-primary: oklch(0.623 0.214 259.815);
--sidebar-primary-foreground: oklch(0.985 0.001 106.423);
--sidebar-accent: oklch(0.268 0.007 34.298);
--sidebar-accent-foreground: oklch(0.985 0.001 106.423);
--sidebar-border: oklch(1 0 0 / 10%);
--sidebar-ring: oklch(0.623 0.214 259.815);
--user-bubble: oklch(0.90 0.003 106);
--user-bubble-foreground: oklch(0.147 0.004 49.25);
/* Status semantic tokens */
--status-success: oklch(0.527 0.154 150.069);
--status-success-foreground: oklch(0.448 0.133 148.697);
--status-success-muted: oklch(0.527 0.154 150.069 / 10%);
--status-success-border: oklch(0.527 0.154 150.069 / 20%);
--status-warning: oklch(0.705 0.213 47.604);
--status-warning-foreground: oklch(0.705 0.213 47.604);
--status-warning-muted: oklch(0.705 0.213 47.604 / 10%);
--status-warning-border: oklch(0.705 0.213 47.604 / 20%);
--status-error: oklch(0.704 0.191 22.216);
--status-error-foreground: oklch(0.704 0.191 22.216);
--status-error-muted: oklch(0.704 0.191 22.216 / 10%);
--status-error-border: oklch(0.704 0.191 22.216 / 20%);
--status-info: oklch(0.623 0.214 259.815);
--status-info-foreground: oklch(0.623 0.214 259.815);
--status-info-muted: oklch(0.623 0.214 259.815 / 10%);
--status-info-border: oklch(0.623 0.214 259.815 / 20%);
}
@layer base {
* {
@apply border-border outline-ring/50;
}
body {
@apply bg-background text-foreground;
}
/* Selection color — derives from primary */
::selection {
background: color-mix(in oklch, var(--primary) 30%, transparent);
}
.dark ::selection {
background: color-mix(in oklch, var(--primary) 35%, transparent);
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: color-mix(in oklch, var(--muted-foreground) 25%, transparent);
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: color-mix(in oklch, var(--muted-foreground) 40%, transparent);
}
.dark ::-webkit-scrollbar-thumb {
background: color-mix(in oklch, var(--muted-foreground) 30%, transparent);
}
.dark ::-webkit-scrollbar-thumb:hover {
background: color-mix(in oklch, var(--muted-foreground) 50%, transparent);
}
/* Prose (markdown) refinements */
.prose {
--tw-prose-headings: var(--foreground);
line-height: 1.7;
}
.prose p {
margin-top: 0.75em;
margin-bottom: 0.75em;
}
.prose h1,
.prose h2,
.prose h3 {
margin-top: 1.25em;
margin-bottom: 0.5em;
font-weight: 600;
}
.prose ul,
.prose ol {
margin-top: 0.5em;
margin-bottom: 0.5em;
}
.prose li {
margin-top: 0.25em;
margin-bottom: 0.25em;
}
.prose blockquote {
border-left-color: color-mix(in oklch, var(--primary) 40%, transparent);
font-style: normal;
}
.prose a {
color: var(--primary);
text-decoration: underline;
text-underline-offset: 2px;
}
.dark .prose a {
color: var(--primary);
}
.prose hr {
border-color: var(--border);
}
.prose table th {
font-weight: 600;
}
}