diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 29a75eb..c60fc43 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,6 +26,14 @@ repos: types: [text] files: ^frontend/ + # Font sizes come from the Tailwind scale only; see the Typography + # section in the root DESIGN-GUIDELINES.md. + - id: no-arbitrary-font-size + name: no arbitrary text-[…] font sizes + entry: 'text-\[[0-9.]+(rem|px|em)\]' + language: pygrep + files: ^frontend/src/.*\.tsx$ + - id: local-ruff-check name: ruff check entry: uv run ruff check --force-exclude --fix --exit-non-zero-on-fix diff --git a/DESIGN.md b/DESIGN.md new file mode 100644 index 0000000..cba28d7 --- /dev/null +++ b/DESIGN.md @@ -0,0 +1,30 @@ +# Design system (Fluksio) + +`fluksio` (dashboard SPA + API) and `website` (marketing site) are **separate +repos** that share one visual design. The full, canonical spec — palette, +radius, elevation, motion, component map, and shell patterns — lives in the +parent repo's [`DESIGN-GUIDELINES.md`](../DESIGN-GUIDELINES.md). Read it before +any UI work. + +## Sync rule (read before touching tokens) + +The `@theme inline`, `:root`, and `.dark` blocks in `fluksio/frontend/src/index.css` +and `website/src/index.css` **must be kept byte-identical**, and +`frontend/src/lib/motion.ts` is duplicated verbatim. Any palette / radius / +elevation / motion-token change is made in *both* repos in the same change. +There is intentionally no shared npm package — the duplicated blocks are the +sync point. Components (`src/components/ui/*`) are copied per repo (the shadcn +model) and may diverge; only the tokens and motion presets must match. + +Both repos share `components.json`: style `new-york`, `cssVariables: true`, +icon library `lucide`. + +Verify with `make design-check` from the workspace root. + +## Shell + +The authenticated area is a `bg-card` region (`SidebarProvider`) with a floating +translucent `AppSidebar` (`variant="floating"`, `bg-card/80 backdrop-blur-md`). +The flow editor floats its chrome over a full-bleed node canvas using the same +frosted-surface model. See DESIGN-GUIDELINES.md → Shells and → Overlay surfaces +& content chips. diff --git a/frontend/public/fonts/inter-latin-variable.woff2 b/frontend/public/fonts/inter-latin-variable.woff2 new file mode 100644 index 0000000..d15208d Binary files /dev/null and b/frontend/public/fonts/inter-latin-variable.woff2 differ diff --git a/frontend/src/index.css b/frontend/src/index.css index 47e5696..5f6ad47 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -3,11 +3,40 @@ @custom-variant dark (&:is(.dark *)); +/* + * Self-hosted font, duplicated verbatim across the fluksio and website repos (a + * sync point like `lib/motion.ts`; see the root DESIGN-GUIDELINES.md, + * Typography). Kept OUT of the byte-identical `@theme inline` / `:root` / + * `.dark` blocks. Inter is used for both body (set on `body` in `@layer base`) + * and the display face applied via the `.font-display` class below. + */ +@font-face { + font-family: "Inter"; + font-style: normal; + font-weight: 100 900; + font-display: swap; + src: url("/fonts/inter-latin-variable.woff2") format("woff2"); +} + @theme inline { - --radius-sm: calc(var(--radius) - 4px); - --radius-md: calc(var(--radius) - 2px); - --radius-lg: var(--radius); - --radius-xl: calc(var(--radius) + 4px); + --radius: 1rem; /* base: surface radius (16px) */ + --radius-sm: 0.5rem; /* 8px: checkbox, small chips, nested items */ + --radius-md: 0.75rem; /* 12px: menus, popovers, dropdowns, tooltips, textarea */ + --radius-lg: 1rem; /* 16px: cards, panels, dialogs, alerts, sidebar */ + --radius-xl: 1.75rem; /* 28px: large / hero containers */ + /* Controls (button/input/toggle/chip) use the `rounded-full` utility (pill). */ + + /* Two-layer elevation: cards rest low (e1); floating surfaces e2; modals e3. */ + --shadow-e1: 0 1px 2px rgb(0 0 0 / 0.06), 0 1px 3px rgb(0 0 0 / 0.1); + --shadow-e2: 0 2px 6px rgb(0 0 0 / 0.08), 0 4px 12px rgb(0 0 0 / 0.12); + --shadow-e3: 0 8px 24px rgb(0 0 0 / 0.18), 0 2px 8px rgb(0 0 0 / 0.12); + + /* Shared motion timing, consumed by CSS transitions and the lib/motion.ts presets. */ + --ease-emphasized: cubic-bezier(0.2, 0, 0, 1); + --ease-standard: cubic-bezier(0.4, 0, 0.2, 1); + --duration-fast: 150ms; + --duration-base: 200ms; + --duration-slow: 300ms; --color-background: var(--background); --color-foreground: var(--foreground); --color-card: var(--card); @@ -16,6 +45,8 @@ --color-popover-foreground: var(--popover-foreground); --color-primary: var(--primary); --color-primary-foreground: var(--primary-foreground); + --color-brand-secondary: var(--brand-secondary); + --color-brand-secondary-foreground: var(--brand-secondary-foreground); --color-secondary: var(--secondary); --color-secondary-foreground: var(--secondary-foreground); --color-muted: var(--muted); @@ -26,11 +57,6 @@ --color-border: var(--border); --color-input: var(--input); --color-ring: var(--ring); - --color-chart-1: var(--chart-1); - --color-chart-2: var(--chart-2); - --color-chart-3: var(--chart-3); - --color-chart-4: var(--chart-4); - --color-chart-5: var(--chart-5); --color-sidebar: var(--sidebar); --color-sidebar-foreground: var(--sidebar-foreground); --color-sidebar-primary: var(--sidebar-primary); @@ -41,73 +67,74 @@ --color-sidebar-ring: var(--sidebar-ring); } +/* + * Fluksio palette. Neutral surfaces, brand on controls only. + * + * `--primary` is #4a7189, not the identity blue #59849b: the latter measures + * 4.04:1 against white, below AA for the label sitting on a bg-primary fill. + * #59849b remains the wordmark colour (org/design/fluksio-*.svg). See the root + * DESIGN-GUIDELINES.md → Colour tokens. + */ :root { - --radius: 0.625rem; - --background: oklch(1 0 0); - --foreground: oklch(0.145 0 0); - --card: oklch(1 0 0); - --card-foreground: oklch(0.145 0 0); - --popover: oklch(1 0 0); - --popover-foreground: oklch(0.145 0 0); - --primary: oklch(0.5982 0.10687 182.4689); - --primary-foreground: oklch(0.985 0 0); - --secondary: oklch(0.97 0 0); - --secondary-foreground: oklch(0.205 0 0); - --muted: oklch(0.97 0 0); - --muted-foreground: oklch(0.556 0 0); - --accent: oklch(0.97 0 0); - --accent-foreground: oklch(0.205 0 0); - --destructive: oklch(0.577 0.245 27.325); - --border: oklch(0.922 0 0); - --input: oklch(0.922 0 0); - --ring: oklch(0.708 0 0); - --chart-1: oklch(0.646 0.222 41.116); - --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 0); - --sidebar-foreground: oklch(0.145 0 0); - --sidebar-primary: oklch(0.5982 0.10687 182.4689); - --sidebar-primary-foreground: oklch(0.985 0 0); - --sidebar-accent: oklch(0.97 0 0); - --sidebar-accent-foreground: oklch(0.205 0 0); - --sidebar-border: oklch(0.922 0 0); - --sidebar-ring: oklch(0.708 0 0); + --background: #ffffff; + --foreground: #333232; + --card: #ffffff; + --card-foreground: #333232; + --popover: #ffffff; + --popover-foreground: #333232; + --primary: #4a7189; + --primary-foreground: #ffffff; + --brand-secondary: #de8f6e; + --brand-secondary-foreground: #333232; + --secondary: #f2f2f2; + --secondary-foreground: #333232; + --muted: #f2f2f2; + --muted-foreground: #6b6b6b; + --accent: #f5f5f5; + --accent-foreground: #333232; + --destructive: #b94d4d; + --border: #e4e4e4; + --input: #e4e4e4; + --ring: #4a7189; + --sidebar: #ffffff; + --sidebar-foreground: #333232; + --sidebar-primary: #4a7189; + --sidebar-primary-foreground: #ffffff; + --sidebar-accent: #f5f5f5; + --sidebar-accent-foreground: #333232; + --sidebar-border: #e4e4e4; + --sidebar-ring: #4a7189; } .dark { - --background: oklch(0.145 0 0); - --foreground: oklch(0.985 0 0); - --card: oklch(0.205 0 0); - --card-foreground: oklch(0.985 0 0); - --popover: oklch(0.205 0 0); - --popover-foreground: oklch(0.985 0 0); - --primary: oklch(0.65 0.10687 182.4689); - --primary-foreground: oklch(0.985 0 0); - --secondary: oklch(0.269 0 0); - --secondary-foreground: oklch(0.985 0 0); - --muted: oklch(0.269 0 0); - --muted-foreground: oklch(0.708 0 0); - --accent: oklch(0.269 0 0); - --accent-foreground: oklch(0.985 0 0); - --destructive: oklch(0.704 0.191 22.216); - --border: oklch(1 0 0 / 10%); - --input: oklch(1 0 0 / 15%); - --ring: oklch(0.556 0 0); - --chart-1: oklch(0.488 0.243 264.376); - --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.205 0 0); - --sidebar-foreground: oklch(0.985 0 0); - --sidebar-primary: oklch(0.65 0.10687 182.4689); - --sidebar-primary-foreground: oklch(0.985 0 0); - --sidebar-accent: oklch(0.269 0 0); - --sidebar-accent-foreground: oklch(0.985 0 0); - --sidebar-border: oklch(1 0 0 / 10%); - --sidebar-ring: oklch(0.556 0 0); + --background: #0a0a0a; + --foreground: #f5f5f5; + --card: #1a1a1a; + --card-foreground: #f5f5f5; + --popover: #1a1a1a; + --popover-foreground: #f5f5f5; + --primary: #7ba3b8; + --primary-foreground: #0a0a0a; + --brand-secondary: #e5a184; + --brand-secondary-foreground: #0a0a0a; + --secondary: #232323; + --secondary-foreground: #f5f5f5; + --muted: #232323; + --muted-foreground: #a3a3a3; + --accent: #262626; + --accent-foreground: #f5f5f5; + --destructive: #cf6666; + --border: #2a2a2a; + --input: #2a2a2a; + --ring: #7ba3b8; + --sidebar: #1a1a1a; + --sidebar-foreground: #f5f5f5; + --sidebar-primary: #7ba3b8; + --sidebar-primary-foreground: #0a0a0a; + --sidebar-accent: #262626; + --sidebar-accent-foreground: #f5f5f5; + --sidebar-border: #2a2a2a; + --sidebar-ring: #7ba3b8; } @layer base { @@ -115,10 +142,18 @@ @apply border-border outline-ring/50; } body { - @apply bg-background text-foreground; + @apply bg-background text-foreground antialiased; + font-family: "Inter", "Helvetica Neue", Arial, sans-serif; } button, [role="button"] { cursor: pointer; } } + +/* Display face for headings / wordmarks. Plain class so it stays outside the + byte-identical token blocks; falls back to the body stack. */ +.font-display { + font-family: "Inter", "Helvetica Neue", Arial, sans-serif; + letter-spacing: -0.01em; +} diff --git a/frontend/src/lib/motion.ts b/frontend/src/lib/motion.ts new file mode 100644 index 0000000..bcdf24e --- /dev/null +++ b/frontend/src/lib/motion.ts @@ -0,0 +1,70 @@ +/** + * Shared motion presets (Fluksio design system). + * + * Pure data: variants and transitions consumed by `motion/react` components + * across the app. Mirrors the `--ease-*` / `--duration-*` timing tokens defined + * in `index.css`, so CSS transitions and JS animations stay in sync. + * + * This file is duplicated verbatim in `fluksio` and `website` (the shadcn model, + * see ../../DESIGN.md / the root DESIGN-GUIDELINES.md). Keep the two copies + * identical; `make design-check` at the workspace root verifies it. + * + * Reduced motion: wrap each app root in `` so + * transform/layout animations are disabled automatically when the OS requests it. + */ +import type { Transition, Variants } from "motion/react" + +/** Easing curves, mirroring the `--ease-*` tokens. */ +export const easeEmphasized: [number, number, number, number] = [0.2, 0, 0, 1] +export const easeStandard: [number, number, number, number] = [0.4, 0, 0.2, 1] + +/** Durations in seconds, mirroring the `--duration-*` tokens (ms). */ +export const duration = { fast: 0.15, base: 0.2, slow: 0.3 } as const + +export const transitions = { + /** Enter / expressive moves (decelerate). */ + emphasized: { duration: duration.base, ease: easeEmphasized }, + /** Neutral state changes. */ + standard: { duration: duration.base, ease: easeStandard }, + /** Springy, for hover tilt / direct-manipulation feedback. */ + spring: { type: "spring", stiffness: 250, damping: 20, mass: 0.5 }, +} satisfies Record + +const exitFast: Transition = { duration: duration.fast, ease: easeStandard } + +/** Opacity fade. */ +export const fadeIn: Variants = { + hidden: { opacity: 0 }, + visible: { opacity: 1, transition: transitions.standard }, + exit: { opacity: 0, transition: exitFast }, +} + +/** Fade + subtle scale: popovers, dialogs, floating panels. */ +export const scaleIn: Variants = { + hidden: { opacity: 0, scale: 0.96 }, + visible: { opacity: 1, scale: 1, transition: transitions.emphasized }, + exit: { opacity: 0, scale: 0.96, transition: exitFast }, +} + +/** Fade + rise: list/grid items, toolbars, content blocks. */ +export const slideUp: Variants = { + hidden: { opacity: 0, y: 8 }, + visible: { opacity: 1, y: 0, transition: transitions.emphasized }, + exit: { opacity: 0, y: 8, transition: exitFast }, +} + +/** Dialog / drawer scrim. */ +export const overlayFade: Variants = { + hidden: { opacity: 0 }, + visible: { opacity: 1, transition: exitFast }, + exit: { opacity: 0, transition: exitFast }, +} + +/** + * Stagger container for lists/grids. Children animate with `slideUp` / `fadeIn` + * via `variants` inheritance (set the same `initial`/`animate` state names). + */ +export const listStagger: Variants = { + hidden: {}, + visible: { transition: { staggerChildren: 0.05, delayChildren: 0.02 } }, +}