From 7b0984579d806a9b84b3a4c6335fefc6b3501fef Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Tue, 4 Aug 2026 10:39:45 -0400 Subject: [PATCH] feat(design): preview any design system, resolved from the record MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The record view listed values as text and drew a swatch only where the value looked like a colour. Two problems, one cause: a derived value such as color-mix(in srgb, var(--accent) 15%, transparent) was drawn by resolving --accent against THIS app, so previewing another project's system showed Scribe's palette. It looked right, which is why nobody noticed. TokenPreview draws the system from its own record. Every value is resolved on an offscreen probe carrying only that system's declarations, so a system whose app this browser has never loaded renders in its own colours — which is the difference between a tool and a mirror. Specimens are chosen by value SHAPE, never by name: colours become swatches, lengths become rules drawn to scale, gradients and shadows get a surface, font stacks are set in themselves. Nothing matches --fs-space-* or any other convention, because the convention belongs to the install (rule #115) — a system that calls its spacing --gap-N gets the same treatment. Translucent values sit on a checkerboard, or a 15% tint over a solid card reads as opaque and shows the wrong colour. Modes come from the system, not from the app: a system declaring base and light offers both, independent of the theme this page is in. The provenance list keeps its swatches only for self-contained colours — the ones needing no resolution, which it can therefore draw honestly. Everything with a var() inside is left to the preview built for it. Step 2 of milestone #274. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01UaYUaouG9jjhATyuxCKrQs --- frontend/src/components/TokenPreview.vue | 298 +++++++++++++++++++++++ frontend/src/views/DesignSystemsView.vue | 42 +++- 2 files changed, 333 insertions(+), 7 deletions(-) create mode 100644 frontend/src/components/TokenPreview.vue diff --git a/frontend/src/components/TokenPreview.vue b/frontend/src/components/TokenPreview.vue new file mode 100644 index 0000000..4accb5e --- /dev/null +++ b/frontend/src/components/TokenPreview.vue @@ -0,0 +1,298 @@ + + + + + diff --git a/frontend/src/views/DesignSystemsView.vue b/frontend/src/views/DesignSystemsView.vue index 856957a..d574c1d 100644 --- a/frontend/src/views/DesignSystemsView.vue +++ b/frontend/src/views/DesignSystemsView.vue @@ -46,6 +46,7 @@ import { import { ApiError } from "@/api/client"; import { useToastStore } from "@/stores/toast"; import StarterRolePicker from "@/components/StarterRolePicker.vue"; +import TokenPreview from "@/components/TokenPreview.vue"; const toast = useToastStore(); @@ -492,8 +493,23 @@ watch(selectedId, () => { snippetCheck.value = null; }); -function isColourish(value: string): boolean { - return /^(#|rgba?\(|hsla?\(|color-mix\()/.test(value.trim()); +/** + * A colour this row can draw HONESTLY — self-contained, no `var()` inside. + * + * The provenance list below shows values as the record states them, and a + * `var()` reference states nothing on its own: rendering + * `color-mix(in srgb, var(--accent) 15%, transparent)` as a background resolves + * `--accent` against THIS app, so a system that isn't the one Scribe runs on + * would be drawn in Scribe's palette. It looked right, which is why it went + * unnoticed (#274). + * + * The preview above resolves values properly, on a probe carrying only that + * system's declarations. So this list draws only what needs no resolving, and + * leaves the rest to the surface built for it. + */ +function isSelfContainedColour(value: string): boolean { + const v = value.trim(); + return /^(#|rgba?\(|hsla?\(|color-mix\()/.test(v) && !v.includes("var("); } @@ -770,7 +786,7 @@ function isColourish(value: string): boolean { + +
+

Preview

+

+ {{ selected.title }} as it would render — resolved from the record, + not from the stylesheet this app happens to be running. +

+ +
+

Effective tokens

@@ -1022,7 +1050,7 @@ function isColourish(value: string): boolean {