Skip to content

Commit fc2bb3c

Browse files
committed
fix(json-render-ui): add the missing CSS reset to the SPA and Storybook
`btn-action` / `btn-action-sm` (what `Button.ts` maps the `secondary` and `ghost` variants onto) set a border and `op75` but no base `background-color` — only one on `:hover`. Without a CSS reset the UA default `button { background-color: buttonface }` therefore wins, and every non-primary button renders as a solid light-grey box on the dark canvas. `scripts/build-css.ts` prepends `@unocss/reset/tailwind.css` to the shadow-root stylesheet, so the dock renderer was never affected. The two light-DOM surfaces have to import the reset themselves and neither did: the shipped SPA bundle and the Storybook canvas both contained zero reset rules (`-webkit-appearance:button`, `background-image:none`, `box-sizing:border-box` all absent from the built CSS). `packages/hub-ui/.storybook/preview.ts` already does exactly this, with a comment describing the same symptom; `json-render-ui` simply never got the same line. `hub-ui` ships no light-DOM SPA, so it is not affected.
1 parent 938b222 commit fc2bb3c

5 files changed

Lines changed: 28 additions & 1 deletion

File tree

packages/json-render-ui/.storybook/preview.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import type { Decorator, Preview } from '@storybook/vue3-vite'
2+
// Before `virtual:uno.css`, mirroring the SPA entry and the shadow-root build —
3+
// see `src/spa/main.ts` for why the reset is load-bearing here.
4+
import '@unocss/reset/tailwind.css'
25
import 'virtual:uno.css'
36
import '@antfu/design/styles.css'
47

packages/json-render-ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"@storybook/addon-docs": "catalog:storybook",
5959
"@storybook/vue3-vite": "catalog:storybook",
6060
"@unocss/preset-icons": "catalog:frontend",
61+
"@unocss/reset": "catalog:frontend",
6162
"@vitejs/plugin-vue": "catalog:build",
6263
"devframe": "workspace:*",
6364
"storybook": "catalog:storybook",

packages/json-render-ui/src/JsonRender.stories.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,16 @@ const dockRendererContext = {
127127
rpc: { call: rpc.call, connectionMeta: undefined },
128128
} as unknown as Parameters<typeof jsonRenderDockRenderer>[0]['context']
129129

130-
/** Mounts the shipped dock renderer so the story exercises its shadow root and adopted stylesheet. */
130+
/**
131+
* Mounts the shipped dock renderer so the story exercises its shadow root and
132+
* adopted stylesheet.
133+
*
134+
* It renders `gallerySpec`, so it should look **the same** as `Gallery` — the
135+
* two differ only in how the stylesheet reaches the components (Storybook's
136+
* `virtual:uno.css` in the light DOM vs. the prebuilt `.generated/css` adopted
137+
* into a shadow root). A visible divergence between them means one of the two
138+
* pipelines has drifted, not that the shadow root is "styled differently".
139+
*/
131140
export const InShadowRoot: StoryObj = {
132141
render: () => ({
133142
setup() {

packages/json-render-ui/src/spa/main.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ import { JSON_RENDER_INDEX_KEY } from '@devframes/json-render'
44
import { connectDevframe } from 'devframe/client'
55
import { computed, createApp, defineComponent, h, ref, shallowReactive, shallowRef, watch } from 'vue'
66
import { JsonRenderView } from '../renderer'
7+
// The same Tailwind preflight `scripts/build-css.ts` prepends to the shipped
8+
// shadow-root stylesheet — first, so `virtual:uno.css`'s utilities win over its
9+
// resets, matching the production build's `[reset, userStyle, unoCss]` order.
10+
// The `@antfu/design` component ports depend on it: `btn-action` (what
11+
// `Button.ts` maps `secondary`/`ghost` onto) sets a border and `op75` but *no*
12+
// base `background-color` — only one on `:hover` — so without the reset the UA
13+
// default `button { background-color: buttonface }` wins and every non-primary
14+
// button renders as a solid light-grey box. The dock renderer never showed this
15+
// because its stylesheet is built with the reset baked in; this SPA and the
16+
// Storybook canvas are the two surfaces that have to import it themselves.
17+
import '@unocss/reset/tailwind.css'
718
import 'virtual:uno.css'
819
import '@antfu/design/styles.css'
920

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)