diff options
| author | Adam <[email protected]> | 2026-03-25 11:29:31 -0500 |
|---|---|---|
| committer | Adam <[email protected]> | 2026-03-25 11:30:41 -0500 |
| commit | d6fc5f414b1f78994fffd550d4104627dbbfac51 (patch) | |
| tree | 9979068865fb2088d510fd3255104c1c31682445 /packages/ui | |
| parent | 77fc88c8ade8e5a620ebbe1197f3a572d29ae91a (diff) | |
| download | opencode-d6fc5f414b1f78994fffd550d4104627dbbfac51.tar.gz opencode-d6fc5f414b1f78994fffd550d4104627dbbfac51.zip | |
chore: storybook tweaks
Diffstat (limited to 'packages/ui')
| -rw-r--r-- | packages/ui/src/components/timeline-playground.stories.tsx | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/packages/ui/src/components/timeline-playground.stories.tsx b/packages/ui/src/components/timeline-playground.stories.tsx index 1e2d1bbc6..e57886279 100644 --- a/packages/ui/src/components/timeline-playground.stories.tsx +++ b/packages/ui/src/components/timeline-playground.stories.tsx @@ -1082,13 +1082,21 @@ function Playground() { let previewRef: HTMLDivElement | undefined let pick: HTMLInputElement | undefined + const sample = (ctrl: CSSControl) => { + if (!ctrl.group.startsWith("Markdown")) return ctrl.selector + return ctrl.selector.replace( + '[data-component="markdown"]', + '[data-component="text-part"] [data-component="markdown"]', + ) + } + /** Read computed styles from the DOM to seed slider defaults */ const readDefaults = () => { const root = previewRef if (!root) return const next: Record<string, string> = {} for (const ctrl of CSS_CONTROLS) { - const el = root.querySelector(ctrl.selector) as HTMLElement | null + const el = (root.querySelector(sample(ctrl)) ?? root.querySelector(ctrl.selector)) as HTMLElement | null if (!el) continue const styles = getComputedStyle(el) // Use bracket access — getPropertyValue doesn't resolve shorthands @@ -1439,9 +1447,14 @@ function Playground() { } setApplyResult(lines.join("\n")) - if (ok > 0) { - // Clear overrides — values are now in source CSS, Vite will HMR. - resetCss() + if (ok === edits.length) { + batch(() => { + for (const ctrl of controls) { + setDefaults(ctrl.key, css[ctrl.key]!) + setCss(ctrl.key, undefined as any) + } + }) + updateStyle() // Wait for Vite HMR then re-read computed defaults setTimeout(readDefaults, 500) } |
