From 01f3e52eeea993e73983cd5eb8a01a213efb5628 Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Tue, 29 Sep 2026 18:44:53 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=9E=20fix:=20Publish=20the=20Theme=20D?= =?UTF-8?q?efaults=20and=20Scale=20Mapping=20to=20Package=20Consumers=20(#?= =?UTF-8?q?16479)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: publish the theme defaults and scale mapping with the package Move the radius, font and shadow utility mapping from the app stylesheet into tokens.css, and the stock values of every theme-owned property (the 94 color roles, the appearance roles and the brand colors, with the primitive scales they are written against) into a new defaults.css that tokens.css imports and the build ships beside it. The app reads both through its existing tokens.css import, so @librechat/client/theme.css now gives a consumer the same utilities and values the app renders. controls.css folds into the defaults, and the preset no longer pins rounded-sm, rounded-md and rounded-lg to --radius. A new mock scenario compiles the app and a consumer from what each loads, checks the build output and exports, and compares computed styles in light and dark; defaults.spec.ts holds defaults.css equal to the runtime themes. * docs: note that hosts load the stock Inter and Roboto Mono faces (cherry picked from commit a50612f70f56b4f07cb405395d014394891c191a) Original-PR: https://github.com/LibreChat-AI/LibreChat/pull/16479 --- client/src/style.css | 378 ------------------ .../published-consumer-appearance.spec.ts | 39 +- .../scenarios/published-theme-parity.spec.ts | 252 ++++++++++++ packages/client/src/theme/README.md | 54 +-- .../src/theme/context/ThemeProvider.tsx | 1 - packages/client/src/theme/controls.css | 36 -- packages/client/src/theme/defaults.css | 367 +++++++++++++++++ packages/client/src/theme/defaults.spec.ts | 101 +++++ .../client/src/theme/semanticTokens.spec.ts | 123 ++---- packages/client/src/theme/tailwind.spec.js | 44 +- packages/client/src/theme/tokens.css | 52 ++- packages/client/tailwind.preset.cjs | 20 +- packages/client/tsdown.config.mjs | 4 +- 13 files changed, 888 insertions(+), 583 deletions(-) create mode 100644 e2e/specs/mock/scenarios/published-theme-parity.spec.ts delete mode 100644 packages/client/src/theme/controls.css create mode 100644 packages/client/src/theme/defaults.css create mode 100644 packages/client/src/theme/defaults.spec.ts diff --git a/client/src/style.css b/client/src/style.css index 80789a03df..f10918ce0e 100644 --- a/client/src/style.css +++ b/client/src/style.css @@ -11,45 +11,6 @@ --color-green-*: initial; } -/* The plain radius, font and shadow utilities read theme-owned properties, so a theme definition - * reshapes the existing `rounded-*`, `font-sans`, `font-mono`, `text-*` and `shadow-*` call sites without a - * migration. The defaults in the `html` block reproduce the scale these utilities resolved to - * before. Bare `rounded` stays Tailwind's fixed 0.25rem: `sm` keeps its px offset, so the two part - * at a non-16px root. Bare `shadow` reads `--shadow`, which has always equalled `sm`, and follows - * it. A shadow held in a variable cannot be recolored by a `shadow-` modifier; nothing here - * uses one. App-only: the published preset keeps its own `sm` radius, which differs from this - * scale, so consumers' corners do not move. */ -@theme inline { - --radius-sm: var(--theme-radius-sm); - --radius-md: var(--theme-radius-md); - --radius-lg: var(--theme-radius-lg); - --radius-xl: var(--theme-radius-xl); - --radius-2xl: var(--theme-radius-2xl); - --radius-3xl: var(--theme-radius-3xl); - --font-sans: var(--theme-font-family); - --font-mono: var(--theme-mono-font-family); - --text-xs: var(--theme-text-xs); - --text-xs--line-height: var(--theme-text-xs-leading); - --text-sm: var(--theme-text-sm); - --text-sm--line-height: var(--theme-text-sm-leading); - --text-base: var(--theme-text-base); - --text-base--line-height: var(--theme-text-base-leading); - --text-lg: var(--theme-text-lg); - --text-lg--line-height: var(--theme-text-lg-leading); - --text-xl: var(--theme-text-xl); - --text-xl--line-height: var(--theme-text-xl-leading); - --text-2xl: var(--theme-text-2xl); - --text-2xl--line-height: var(--theme-text-2xl-leading); - --shadow: var(--theme-shadow-sm); - --shadow-2xs: var(--theme-shadow-2xs); - --shadow-xs: var(--theme-shadow-xs); - --shadow-sm: var(--theme-shadow-sm); - --shadow-md: var(--theme-shadow-md); - --shadow-lg: var(--theme-shadow-lg); - --shadow-xl: var(--theme-shadow-xl); - --shadow-2xl: var(--theme-shadow-2xl); -} - /* Tailwind v4 changed two preflight defaults this app was built against. Each rule below * restores the v3 default rather than adopting the new one, so the upgrade carries no visual * change; drop one only as a deliberate design decision. @@ -78,67 +39,6 @@ /* Custom Variables */ :root { - --white: 255 255 255; - --black: 0 0 0; - --gray-20: 236 236 241; - --gray-50: 247 247 248; - --gray-100: 236 236 236; - --gray-200: 227 227 227; - --gray-300: 205 205 205; - --gray-400: 153 150 150; - --gray-500: 89 89 89; - --gray-600: 66 66 66; - --gray-650: 57 57 57; - --gray-700: 47 47 47; - --gray-800: 33 33 33; - --gray-850: 23 23 23; - --gray-875: 18 18 18; - --gray-900: 13 13 13; - --green-50: 236 253 245; - --green-100: 209 250 229; - --green-200: 167 243 208; - --green-300: 110 231 183; - --green-400: 52 211 153; - --green-500: 16 185 129; - --green-600: 5 150 105; - --green-700: 4 120 87; - --green-800: 6 95 70; - --green-900: 6 78 59; - --green-950: 2 44 34; - --red-50: 254 242 242; - --red-100: 254 226 226; - --red-200: 254 202 202; - --red-300: 252 165 165; - --red-400: 248 113 113; - --red-500: 239 68 68; - --red-600: 220 38 38; - --red-700: 185 28 28; - --red-800: 153 27 27; - --red-900: 127 29 29; - --red-950: 69 10 10; - --amber-50: 255 251 235; - --amber-100: 254 243 199; - --amber-200: 253 230 138; - --amber-300: 252 211 77; - --amber-400: 251 191 36; - --amber-500: 245 158 11; - --amber-600: 217 119 6; - --amber-700: 180 83 9; - --amber-800: 146 64 14; - --amber-900: 120 53 15; - --amber-950: 69 26 3; - --blue-50: 239 246 255; - --blue-100: 219 234 254; - --blue-200: 191 219 254; - --blue-300: 147 197 253; - --blue-400: 96 165 250; - --blue-500: 59 130 246; - --blue-600: 37 99 235; - --blue-700: 29 78 216; - --blue-800: 30 64 175; - --blue-900: 30 58 138; - --blue-950: 23 37 84; - --brand-purple: 126 34 206; --gizmo-gray-500: 153 153 153; --gizmo-gray-600: 102 102 102; --gizmo-gray-950: 15 15 15; @@ -216,284 +116,6 @@ } } -html { - --brand-purple: 126 34 206; - --presentation: var(--white); - --text-primary: var(--gray-800); - --text-secondary: var(--gray-600); - --text-secondary-alt: var(--gray-500); - --text-tertiary: var(--gray-500); - --text-muted: 105 110 121; /* Click UI global.color.text.muted #696e79 */ - --shimmer-dip: 129 130 134; - --shimmer-dip-alpha: 0.18; - --text-warning: var(--amber-700); - --text-destructive: var(--red-600); - --link: var(--blue-600); - --link-hover: var(--blue-700); - --link-visited: 147 51 234; - --link-prose: var(--link); - --accent-primary: 18 110 107; - --accent-primary-hover: 10 79 83; - --ring-primary: var(--gray-500); - --focus-outline: 0 0 0; - --header-primary: var(--white); - --header-hover: var(--gray-50); - --header-button-hover: var(--gray-50); - --surface-active: var(--gray-100); - --surface-active-alt: var(--gray-200); - --surface-hover: var(--gray-200); - --surface-hover-alt: var(--gray-300); - --surface-composer-hover: var(--gray-200); - --surface-primary: var(--white); - --chart-widget-surface: 255 255 255; /* Click UI dashboards.chartWidget.color.background.default #ffffff */ - --chart-widget-stroke: 230 231 233; /* Click UI dashboards.chartWidget.color.stroke.default #e6e7e9 */ - --surface-primary-alt: var(--gray-50); - --surface-primary-contrast: var(--gray-100); - --surface-secondary: var(--gray-50); - --surface-secondary-alt: var(--gray-200); - --surface-tertiary: var(--gray-100); - --surface-tertiary-alt: var(--white); - --surface-dialog: var(--white); - --surface-overlay: var(--gray-500); - --surface-submit: var(--green-700); - --surface-submit-hover: var(--green-800); - --surface-destructive: var(--red-700); - --surface-destructive-hover: var(--red-800); - --surface-chat: var(--white); - --surface-code: var(--surface-primary-alt); - --surface-code-body: var(--surface-chat); - --surface-qr: var(--white); - --border-light: var(--gray-200); - --border-light-alpha: 1; - --border-medium-alt: var(--gray-300); - --border-medium: var(--gray-300); - --border-medium-alpha: 1; - --border-heavy: var(--gray-400); - --border-heavy-alpha: 1; - --border-xheavy: var(--gray-500); - --border-xheavy-alpha: 1; - --border-destructive: var(--red-600); - --status-success: var(--green-700); - --status-success-subtle: var(--green-50); - --status-success-border: var(--green-300); - --status-success-strong: 2 133 94; - --status-info: var(--blue-600); - --status-info-subtle: var(--blue-50); - --status-info-border: var(--blue-300); - --status-info-strong: var(--gray-500); - --status-warning: var(--amber-700); - --status-warning-subtle: var(--amber-50); - --status-warning-border: var(--amber-300); - --status-warning-strong: 199 82 9; - --status-error: var(--red-700); - --status-error-subtle: var(--red-50); - --status-error-border: var(--red-300); - --status-error-strong: 224 47 31; - --status-neutral: var(--gray-600); - --status-neutral-subtle: var(--gray-100); - --status-neutral-border: var(--gray-300); - --status-verified: 37 99 235; - --text-on-status: var(--white); - - /* Categorical series scale — slot order is the CVD-safety mechanism */ - --series-1: 5 110 189; - --series-2: 233 86 13; - --series-3: 0 148 142; - --series-4: 182 123 5; - --series-5: 216 90 142; - --series-6: 126 35 205; - --series-7: 1 131 1; - --series-8: 63 81 181; - - /* Code syntax highlighting */ - --syntax-text: var(--gray-800); - --syntax-comment: var(--gray-500); - --syntax-meta: var(--gray-600); - --syntax-builtin: 154 103 0; - --syntax-keyword: 5 80 174; - --syntax-string: 10 123 98; - --syntax-attr: 154 47 106; - --syntax-title: 180 35 24; - - --surface-inverted: var(--gray-850); - --surface-inverted-hover: var(--gray-700); - --text-inverted: var(--white); - --surface-fixed: var(--white); - --surface-fixed-hover: var(--gray-100); - --text-fixed: var(--gray-800); - --theme-control-radius: 0.75rem; - --theme-round-control-radius: 9999px; - --theme-surface-radius: 1rem; - --theme-large-surface-radius: 1.5rem; - --theme-radius-sm: calc(0.5rem - 4px); - --theme-radius-md: calc(0.5rem - 2px); - --theme-radius-lg: 0.5rem; - --theme-radius-xl: 0.75rem; - --theme-radius-2xl: 1rem; - --theme-radius-3xl: 1.5rem; - --theme-control-height: 2.25rem; - --theme-space-compact: 0.375rem; - --theme-space-normal: 0.75rem; - --theme-disabled-style: dim; - --theme-scrim-opacity: 0.8; - --theme-alert-scrim-opacity: 0.9; - --theme-modal-scrim-opacity: 0.65; - --theme-font-family: Inter, sans-serif; - --theme-display-font-family: Inter, sans-serif; - --theme-text-xs: 0.75rem; - --theme-text-xs-leading: calc(1 / 0.75); - --theme-text-sm: 0.875rem; - --theme-text-sm-leading: calc(1.25 / 0.875); - --theme-text-base: 1rem; - --theme-text-base-leading: calc(1.5 / 1); - --theme-text-lg: 1.125rem; - --theme-text-lg-leading: calc(1.75 / 1.125); - --theme-text-xl: 1.25rem; - --theme-text-xl-leading: calc(1.75 / 1.25); - --theme-text-2xl: 1.5rem; - --theme-text-2xl-leading: calc(2 / 1.5); - /* Roboto Mono is self-hosted (the `@font-face` block below), so code renders the same on every - * platform with real bold and italic faces. The tail is reached while the font loads, if it - * fails, and per glyph for what the bundled latin subset omits (box drawing in terminal output - * most visibly), ordered so those glyphs keep Roboto Mono's advance width: `ui-monospace` is SF - * Mono on macOS, Cascadia Mono ships with Windows Terminal, and Consolas is last because it is - * narrower than the rest. */ - --theme-mono-font-family: - 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, 'Cascadia Mono', 'Liberation Mono', - Consolas, monospace; - --theme-elevation-surface: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); - --theme-shadow-2xs: 0 1px rgb(0 0 0 / 0.05); - --theme-shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05); - --theme-shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1); - --theme-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); - --theme-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); - --theme-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1); - --theme-shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25); - --theme-motion-fast: 150ms; - --theme-motion-normal: 200ms; - --switch-unchecked: 148 148 148; - --provider-openai: #19c37d; - --provider-openai-gpt4: #ab68ff; - --provider-openai-reasoning: #000000; - --provider-anthropic: #d09a74; - --provider-azure: linear-gradient(0.375turn, #61bde2, #4389d0); - --provider-bedrock: #268672; - --provider-foreground: #ffffff; -} -.dark { - --brand-purple: 171 104 255; - --presentation: var(--gray-800); - --text-primary: var(--gray-100); - --focus-outline: 255 255 255; - --text-secondary: var(--gray-300); - --text-secondary-alt: var(--gray-400); - --text-tertiary: var(--gray-400); - --text-muted: 179 182 189; /* Click UI global.color.text.muted #b3b6bd */ - --shimmer-base: 255 255 255; - --shimmer-base-alpha: 0.8; - --shimmer-dip: 179 179 179; - --shimmer-dip-alpha: 0.25; - --text-warning: var(--amber-500); - --text-destructive: var(--red-400); - --link: var(--blue-400); - --link-hover: var(--blue-300); - --link-visited: 192 132 252; - --link-prose: var(--text-primary); - --accent-primary: 65 167 157; - --accent-primary-hover: 109 200 185; - --header-primary: var(--gray-700); - --header-hover: var(--gray-600); - --header-button-hover: var(--gray-700); - --surface-active: var(--gray-500); - --surface-active-alt: var(--gray-700); - --surface-hover: var(--gray-650); - --surface-hover-alt: var(--gray-600); - --surface-composer-hover: var(--gray-600); - --surface-primary: var(--gray-900); - --chart-widget-surface: 40 40 40; /* Click UI dashboards.chartWidget.color.background.default #282828 */ - --chart-widget-stroke: 50 50 50; /* Click UI dashboards.chartWidget.color.stroke.default #323232 */ - --surface-primary-alt: var(--gray-850); - --surface-primary-contrast: var(--gray-850); - --surface-secondary: var(--gray-800); - --surface-secondary-alt: var(--gray-800); - --surface-tertiary: var(--gray-700); - --surface-tertiary-alt: var(--gray-700); - --surface-dialog: var(--gray-875); - --surface-overlay: 0 0 0; - --surface-submit: var(--green-700); - --surface-submit-hover: var(--green-800); - --surface-destructive: var(--red-800); - --surface-destructive-hover: var(--red-900); - --surface-chat: var(--gray-700); - --surface-code: var(--presentation); - --surface-code-body: var(--surface-primary-alt); - --surface-qr: var(--white); - /* One step off the page instead of two: in dark the edge only has to separate - a surface from the one behind it, and a brighter line reads as a seam. */ - --border-light: var(--gray-800); - --border-medium-alt: var(--gray-650); - --border-medium: var(--gray-650); - --border-heavy: var(--gray-500); - --border-xheavy: var(--gray-400); - --border-destructive: var(--red-500); - --status-success: var(--green-300); - --status-success-subtle: var(--green-950); - --status-success-border: var(--green-800); - --status-success-strong: 8 135 89; - --status-info: var(--blue-300); - --status-info-subtle: var(--blue-950); - --status-info-border: var(--blue-800); - --status-info-strong: var(--gray-600); - --status-warning: var(--amber-300); - --status-warning-subtle: var(--amber-950); - --status-warning-border: var(--amber-800); - --status-warning-strong: var(--amber-800); - --status-error: var(--red-300); - --status-error-subtle: var(--red-950); - --status-error-border: var(--red-800); - --status-error-strong: var(--red-800); - --status-neutral: var(--gray-300); - --status-neutral-subtle: var(--gray-800); - --status-neutral-border: var(--gray-700); - --status-verified: 26 127 216; - --text-on-status: var(--white); - - /* Categorical series scale — same hues, stepped for the dark surface */ - --series-1: 9 140 238; - --series-2: 217 87 35; - --series-3: 6 158 152; - --series-4: 200 133 12; - --series-5: 213 82 130; - --series-6: 171 104 254; - --series-7: 80 167 49; - --series-8: 120 130 190; - - /* Code syntax highlighting. Comment and meta are the flattened equivalents of - the 50% and 60% alpha whites this palette used before it was tokenized. */ - --syntax-text: var(--white); - --syntax-comment: 144 144 144; - --syntax-meta: 166 166 166; - --syntax-builtin: 233 149 12; - --syntax-keyword: 46 149 211; - --syntax-string: 0 166 125; - --syntax-attr: 223 48 121; - --syntax-title: 242 44 61; - - --surface-inverted: var(--white); - --surface-inverted-hover: var(--gray-100); - --text-inverted: var(--gray-850); - --surface-fixed: var(--white); - --surface-fixed-hover: var(--gray-100); - --text-fixed: var(--gray-800); - --switch-unchecked: 102 102 102; - --provider-openai: #19c37d; - --provider-openai-gpt4: #ab68ff; - --provider-openai-reasoning: #000000; - --provider-anthropic: #d09a74; - --provider-azure: linear-gradient(0.375turn, #61bde2, #4389d0); - --provider-bedrock: #268672; - --provider-foreground: #ffffff; -} .gizmo { --text-primary: var(--gizmo-gray-950); --text-secondary: var(--gizmo-gray-600); diff --git a/e2e/specs/mock/scenarios/published-consumer-appearance.spec.ts b/e2e/specs/mock/scenarios/published-consumer-appearance.spec.ts index e04ddb2b5e..96406b927f 100644 --- a/e2e/specs/mock/scenarios/published-consumer-appearance.spec.ts +++ b/e2e/specs/mock/scenarios/published-consumer-appearance.spec.ts @@ -12,8 +12,8 @@ import { repoRoot, run } from './lint.helpers'; * - an uncoloured `border-b` is painted with `currentColor`, so a divider * drawn by a primitive follows the text ink unless the primitive names a * role. - * - the radius scale is Tailwind's, not ours, so `rounded-sm` means whatever - * the current major says it means. + * - the radius scale is Tailwind's unless the package states its own, so + * `rounded-sm` would mean whatever the current major says it means. * * The scenario builds what a consumer actually installs: the package's own * stylesheet and its published preset, compiled by Tailwind through the @@ -121,10 +121,10 @@ Promise.all(${JSON.stringify([ expect(compile.status, `the consumer stylesheet did not compile:\n${compile.output}`).toBe(0); const consumerCss = readFileSync(compiled, 'utf8'); - /** The consumer's own page sets no `--radius`: the setup in the theme README - * never mentions one, so this is what a consumer following it gets. The - * border token is set because the ThemeProvider writes those as channel - * triplets. */ + /** The consumer's own page restates two roles as channel triplets, the way + * the ThemeProvider writes them, so the probe can tell them from the stock + * values `theme.css` ships. Everything else is what a consumer following + * the theme README gets. */ await page.setContent( `