@takazudo/zudo-sg 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/README.md +59 -61
- package/dist/catalog/catalog-thumb.d.ts +1 -6
- package/dist/catalog/catalog-thumb.js +1 -2
- package/dist/catalog/component-thumb.d.ts +1 -6
- package/dist/catalog/component-thumb.js +8 -7
- package/dist/catalog/descriptor-thumb.d.ts +1 -6
- package/dist/catalog/descriptor-thumb.js +1 -2
- package/dist/chrome/_styleguide-layout.d.ts +8 -9
- package/dist/chrome/_styleguide-layout.js +3 -6
- package/dist/chrome/panel-scripts.d.ts +1 -3
- package/dist/chrome/panel-scripts.js +3 -3
- package/dist/cli/scaffold/component-scaffold.js +35 -16
- package/dist/code-panel/code-panel.d.ts +2 -8
- package/dist/code-panel/code-panel.js +34 -35
- package/dist/code-panel/copy-button.d.ts +1 -7
- package/dist/code-panel/copy-button.js +31 -48
- package/dist/code-panel/copy-text.d.ts +1 -0
- package/dist/code-panel/copy-text.js +26 -0
- package/dist/code-panel/editor-setup.d.ts +3 -0
- package/dist/code-panel/editor-setup.js +15 -3
- package/dist/code-panel/editor-theme.d.ts +2 -0
- package/dist/code-panel/editor-theme.js +54 -0
- package/dist/code-panel/source-editor.d.ts +10 -2
- package/dist/code-panel/source-editor.js +20 -19
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +6 -1
- package/dist/config/wind.d.ts +265 -0
- package/dist/config/wind.js +133 -0
- package/dist/plugins/preview-css.d.ts +9 -7
- package/dist/plugins/preview-css.js +58 -37
- package/dist/preview/detail-workbench.d.ts +2 -6
- package/dist/preview/detail-workbench.js +100 -65
- package/dist/preview/index.d.ts +4 -2
- package/dist/preview/index.js +7 -7
- package/dist/preview/preview-app.d.ts +2 -5
- package/dist/preview/preview-app.js +76 -46
- package/dist/preview/variant-frame-config.d.ts +47 -0
- package/dist/preview/variant-frame-config.js +50 -0
- package/dist/preview/variant-frame.d.ts +9 -53
- package/dist/preview/variant-frame.js +158 -149
- package/dist/preview-css/compile.d.ts +15 -29
- package/dist/preview-css/compile.js +183 -31
- package/dist/search/catalog-filter.d.ts +2 -6
- package/dist/search/catalog-filter.js +50 -42
- package/dist/stories/types.d.ts +5 -3
- package/dist/token-dashboard/create-token-dashboards.d.ts +3 -5
- package/dist/token-dashboard/create-token-dashboards.js +14 -44
- package/dist/token-dashboard/dashboard-inventory.d.ts +1 -1
- package/dist/token-dashboard/token-dashboard-adapter.d.ts +2 -0
- package/dist/token-dashboard/token-dashboard-adapter.js +9 -0
- package/dist/token-dashboard/token-dashboard-mount.d.ts +6 -0
- package/dist/token-dashboard/token-dashboard-mount.js +33 -0
- package/dist/token-tweak/preview-token-panel-bootstrap.d.ts +1 -6
- package/dist/token-tweak/preview-token-panel-bootstrap.js +4 -2
- package/dist/token-tweak/preview-tokens-button.d.ts +1 -5
- package/dist/token-tweak/preview-tokens-button.js +5 -4
- package/dist/wind.json +119 -0
- package/package.json +16 -19
- package/routes-src/_chrome.tsx +1 -3
- package/routes-src/_preview-app.tsx +3 -8
- package/routes-src/components-index.tsx +5 -10
- package/routes-src/components-preview.tsx +3 -9
- package/routes-src/components-slug.tsx +21 -24
- package/routes-src/tokens.tsx +4 -9
- package/styles.css +36 -11
- package/dist/safelist.css +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,68 @@ All notable changes to `@takazudo/zudo-sg` are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on Keep a Changelog, and release notes are generated from the changelog MDX pages.
|
|
6
6
|
|
|
7
|
+
## [0.5.0] - 2026-10-12
|
|
8
|
+
|
|
9
|
+
This release ports the styleguide engine to zfb 4.3.1 and zudo-doc 6.0.0.
|
|
10
|
+
Catalog, preview, descriptor mode, and token editing remain available on the
|
|
11
|
+
new renderer and CSS pipeline.
|
|
12
|
+
|
|
13
|
+
### Breaking Changes
|
|
14
|
+
|
|
15
|
+
- Hosts must use zfb 4.3.1 or later in the 4.x line, zudo-doc 6.0.0 or later in
|
|
16
|
+
the 6.x line, and zdtp 0.8.6 or later in the 0.8.x line. Story renderers and
|
|
17
|
+
engine route components use zudo-react instead of Preact. Hosts should follow
|
|
18
|
+
the zfb 4 and zudo-doc 6 migration guides before upgrading.
|
|
19
|
+
- The engine now publishes a `wind.json` utility manifest in place of its
|
|
20
|
+
Tailwind safelist stylesheet. Host wind configuration must include the engine
|
|
21
|
+
manifest and its declared CSS variables; the old Tailwind source and theme
|
|
22
|
+
directives no longer generate engine utilities.
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
|
|
26
|
+
- Render the catalog, thumbnails, detail workbench, preview frames, and search
|
|
27
|
+
islands with zudo-react. Descriptor mode and external preview routes retain
|
|
28
|
+
their framework-free data and message contracts.
|
|
29
|
+
- Compile the isolated preview stylesheet through the `zfb css` CLI with
|
|
30
|
+
preview-root scoping, preserving the preview URL and host override behavior.
|
|
31
|
+
- Keep `/tokens` available through a client-mounted zdtp dashboard adapter with
|
|
32
|
+
a truthful server-rendered loading shell. The engine owns the adapter's
|
|
33
|
+
Preact dependency; hosts do not need a Preact renderer.
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
- Serve preview CSS correctly from a host mounted under a non-root base path in
|
|
38
|
+
both development and preview mode.
|
|
39
|
+
- Activate the engine-route preview token panel after hydration so early clicks
|
|
40
|
+
and SPA navigation keep working in packed foreign hosts.
|
|
41
|
+
|
|
42
|
+
## [0.4.1] - 2026-09-27
|
|
43
|
+
|
|
44
|
+
This release replaces the code panel's fixed dark editor theme with an
|
|
45
|
+
engine-owned theme that meets WCAG AA text contrast, follows the page's light
|
|
46
|
+
or dark scheme, and exposes the editor colors as host-overridable tokens.
|
|
47
|
+
|
|
48
|
+
### Features
|
|
49
|
+
|
|
50
|
+
- Color the code panel's CodeMirror editors from 16 `--sg-code-*` custom
|
|
51
|
+
properties (background, text, gutter, active line, selection, cursor, and
|
|
52
|
+
nine syntax roles). Their defaults are `light-dark()` pairs chosen so every
|
|
53
|
+
text and syntax color reaches at least 4.5:1 against the surface it sits on,
|
|
54
|
+
so the editor is light on light pages, dark on dark pages, and switches when
|
|
55
|
+
the page theme toggles. Override any token on `:root` to match the host's
|
|
56
|
+
palette.
|
|
57
|
+
- Highlight the active line and its gutter number in the editable Live CSS
|
|
58
|
+
editor. The read-only source view is unchanged.
|
|
59
|
+
- Add an `extensions` option to `SourceEditor` for hosts that mount it
|
|
60
|
+
directly. The engine theme is low precedence, so a host-supplied CodeMirror
|
|
61
|
+
theme wins on conflicting rules. It is read once at mount, like `value`.
|
|
62
|
+
|
|
63
|
+
### Bug Fixes
|
|
64
|
+
|
|
65
|
+
- The editor gutter and comment text no longer fall below WCAG AA contrast:
|
|
66
|
+
the previous `oneDark` theme drew them at 3.86:1 and stayed dark on light
|
|
67
|
+
pages. `@codemirror/theme-one-dark` is no longer a dependency.
|
|
68
|
+
|
|
7
69
|
## [0.4.0] - 2026-09-27
|
|
8
70
|
|
|
9
71
|
This release lets a non-Preact host adopt the catalog, nav, search, and
|
package/README.md
CHANGED
|
@@ -22,13 +22,13 @@ dogfoods the engine as its own styleguide host — see
|
|
|
22
22
|
`Story<P>`, `StoryControl<P>`, `StoryModule`, `defineStory`. Categories are
|
|
23
23
|
open, host-ordered data (`categoryOrder: string[]`), never a closed type.
|
|
24
24
|
- A standalone preview stylesheet compiler
|
|
25
|
-
(`@takazudo/zudo-sg/plugins/preview-css`) that
|
|
26
|
-
|
|
27
|
-
`:root[data-sg-preview-doc]` so it coexists with the
|
|
28
|
-
stylesheet.
|
|
29
|
-
- Generated
|
|
30
|
-
`@takazudo/zudo-sg/styles.css`) so the catalog
|
|
31
|
-
|
|
25
|
+
(`@takazudo/zudo-sg/plugins/preview-css`) that invokes the host-installed
|
|
26
|
+
`zfb css` command with the composed wind config and component sources, then
|
|
27
|
+
scopes the output under `:root[data-sg-preview-doc]` so it coexists with the
|
|
28
|
+
host's global stylesheet.
|
|
29
|
+
- Generated wind manifest and chrome styles (`@takazudo/zudo-sg/wind.json`,
|
|
30
|
+
`@takazudo/zudo-sg/styles.css`) so zfb includes the catalog's utility
|
|
31
|
+
candidates without depending on the host's source scan.
|
|
32
32
|
- Token dashboards and a preview design-token panel, driven by a
|
|
33
33
|
`gen-token-manifest`-produced manifest.
|
|
34
34
|
|
|
@@ -96,9 +96,11 @@ inside detail-page iframes.
|
|
|
96
96
|
|
|
97
97
|
## Framework scope
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
Module-mode stories use zfb's zudo-react runtime. Hosts using another
|
|
100
|
+
framework can use descriptor mode with an external preview document; see the
|
|
101
|
+
ADR's "Framework scope" decision. The `/tokens` dashboard is the one renderer
|
|
102
|
+
exception: its opaque adapter mounts zdtp's Preact widget internally, with
|
|
103
|
+
Preact installed as an engine dependency rather than a host peer.
|
|
102
104
|
|
|
103
105
|
## Quick start with the initializer
|
|
104
106
|
|
|
@@ -113,7 +115,7 @@ pnpm gen-token-manifest
|
|
|
113
115
|
pnpm dev
|
|
114
116
|
```
|
|
115
117
|
|
|
116
|
-
It copies a private starter with three example
|
|
118
|
+
It copies a private starter with three example zudo-react components, stories,
|
|
117
119
|
token CSS, a preview entry, and the zfb/zudo-doc composition already wired.
|
|
118
120
|
The CLI prints the same next steps after scaffolding.
|
|
119
121
|
|
|
@@ -130,20 +132,20 @@ output as drift and never writes it.
|
|
|
130
132
|
## Installation
|
|
131
133
|
|
|
132
134
|
```sh
|
|
133
|
-
pnpm add @takazudo/zudo-sg@latest @takazudo/zfb@^
|
|
135
|
+
pnpm add @takazudo/zudo-sg@latest @takazudo/zfb@^4.3.1 @takazudo/zfb-md-wasm@^4.3.1 @takazudo/zfb-runtime@^4.3.1 @takazudo/zudo-doc@^6.0.0 @takazudo/zdtp@^0.8.6 diff@^8.0.4 katex@^0.16.38 zod@^4.3.6
|
|
134
136
|
```
|
|
135
137
|
|
|
136
|
-
The engine peers are `@takazudo/zfb ^
|
|
137
|
-
`@takazudo/zdtp ^0.8.
|
|
138
|
-
the injected `/tokens` route
|
|
138
|
+
The engine peers are `@takazudo/zfb ^4.3.1`, `@takazudo/zudo-doc ^6.0.0`,
|
|
139
|
+
and `@takazudo/zdtp ^0.8.6`. `@takazudo/zdtp` is required:
|
|
140
|
+
the injected `/tokens` route loads its dashboard through the engine-owned
|
|
141
|
+
opaque Preact adapter. Preact is a regular engine dependency, not a host peer. The
|
|
139
142
|
`@takazudo/zfb-md-wasm`, `@takazudo/zfb-runtime`, `diff`, `katex`, and `zod`
|
|
140
143
|
entries are prerequisites inherited from zfb/zudo-doc; zudo-doc's published
|
|
141
144
|
route dist imports `diff` and `katex` even when those features are disabled
|
|
142
145
|
(see [zudolab/zudo-doc#4206](https://github.com/zudolab/zudo-doc/issues/4206)).
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
fixture dependency set.
|
|
146
|
+
The host renders components with zudo-react and compiles preview utilities with
|
|
147
|
+
zfb's zudo-wind compiler. The command above reproduces the full fixture
|
|
148
|
+
dependency set.
|
|
147
149
|
|
|
148
150
|
Keep the `tokens` block in `zudo-sg.config.mjs`: the initializer's config
|
|
149
151
|
typing treats it as required, and `gen-token-manifest` needs its two CSS paths
|
|
@@ -180,11 +182,11 @@ control. Any non-empty host navigation stays authoritative; set
|
|
|
180
182
|
`chromeDefaults: false` in the second argument to keep an intentionally empty
|
|
181
183
|
header. The engine requires `packageOwnedRoutes: true` on the host (its
|
|
182
184
|
routes import zudo-doc's route-context virtual modules). On the engine's zfb
|
|
183
|
-
peer floor (
|
|
185
|
+
peer floor (4.3.1) nothing else is needed: `zfb dev` seeds its island
|
|
184
186
|
scanner from the injected routes. `@takazudo/zudo-sg/islands` remains
|
|
185
187
|
exported as a side-effect module that statically imports every engine
|
|
186
188
|
island — importing it once from a host `pages/` file is optional and
|
|
187
|
-
harmless (it was required
|
|
189
|
+
harmless (it was required before zfb 2.18.0).
|
|
188
190
|
|
|
189
191
|
`uiPackageName` is optional. When set, it names the package used in generated
|
|
190
192
|
usage snippets and catalog labels; when omitted, scaffolded usage snippets
|
|
@@ -208,25 +210,15 @@ this entry already. Use this import order, replacing `ui-tokens.css` with
|
|
|
208
210
|
your own token stylesheet as needed:
|
|
209
211
|
|
|
210
212
|
```css
|
|
211
|
-
@layer
|
|
212
|
-
/* One element reset: theme.css resets color tokens, not elements. */
|
|
213
|
-
@import "tailwindcss/preflight" layer(zd-preflight);
|
|
214
|
-
@import "tailwindcss/utilities";
|
|
213
|
+
@layer zw-reset, zd-flow;
|
|
215
214
|
@import "@takazudo/zudo-doc/theme.css";
|
|
216
215
|
@import "./ui-tokens.css";
|
|
217
216
|
/* Add your component package stylesheet here. */
|
|
218
|
-
@import "@takazudo/zudo-doc/safelist.css";
|
|
219
217
|
@import "@takazudo/zudo-doc/content.css";
|
|
220
218
|
@import "@takazudo/zudo-doc/features.css";
|
|
221
219
|
@import "@takazudo/zudo-doc/page-loading.css";
|
|
222
220
|
@import "@takazudo/zdtp/dashboard/styles.css";
|
|
223
221
|
@import "@takazudo/zudo-sg/styles.css";
|
|
224
|
-
@import "@takazudo/zudo-sg/safelist.css";
|
|
225
|
-
|
|
226
|
-
/* zfb global-entry paths are project-root-relative; add your UI package here. */
|
|
227
|
-
@source "pages/**/*.{tsx,ts,jsx,js}";
|
|
228
|
-
@source "ui/**/*.{tsx,ts,jsx,js,mdx,md}";
|
|
229
|
-
@source "src/content/**/*.{mdx,md}";
|
|
230
222
|
```
|
|
231
223
|
|
|
232
224
|
### Three token worlds and the engine override hook
|
|
@@ -235,15 +227,15 @@ The host contains three independent color-token worlds:
|
|
|
235
227
|
|
|
236
228
|
- zudo-doc's `--zd-*` roles style the documentation shell and doc chrome.
|
|
237
229
|
- zudo-sg's raw `--sg-*` roles style the catalog engine chrome.
|
|
238
|
-
- The host component library owns its own
|
|
230
|
+
- The host component library owns its own `:root` color tokens, usually the
|
|
239
231
|
`--color-*` semantic roles used by previews.
|
|
240
232
|
|
|
241
233
|
The engine's eleven public chrome roles are `--sg-bg`, `--sg-fg`, `--sg-surface`,
|
|
242
234
|
`--sg-surface-2`, `--sg-border`, `--sg-border-strong`, `--sg-muted`, `--sg-accent`,
|
|
243
235
|
`--sg-on-accent`, `--sg-focus`, and `--sg-success`. They are plain properties in a
|
|
244
|
-
zero-specificity `:where(:root)` block, not an engine
|
|
245
|
-
`theme.css`
|
|
246
|
-
the engine
|
|
236
|
+
zero-specificity `:where(:root)` block, not an engine color tier. zudo-doc 6's
|
|
237
|
+
`theme.css` supplies package token values without resetting host `--color-*`
|
|
238
|
+
properties; the engine's raw `--sg-*` namespace remains separate.
|
|
247
239
|
|
|
248
240
|
Override engine chrome from the host with an ordinary, unlayered root rule:
|
|
249
241
|
|
|
@@ -259,31 +251,37 @@ migrate that declaration to `--sg-border` (and use the matching `--sg-*` role fo
|
|
|
259
251
|
other chrome color). Bare `--color-border` remains a valid host component token, but it
|
|
260
252
|
no longer controls zudo-sg chrome.
|
|
261
253
|
|
|
262
|
-
The
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
254
|
+
The code panel's editor surface has its own sixteen `--sg-code-*` roles (background,
|
|
255
|
+
foreground, gutter, active line, selection, cursor, and the syntax token colors), themed
|
|
256
|
+
the same order-independent way. Their `light-dark()` defaults hold WCAG AA (≥ 4.5:1)
|
|
257
|
+
contrast and follow the host's `color-scheme`; any override must preserve that contrast.
|
|
258
|
+
`SourceEditor`'s `extensions` prop lets a host mounting the editor directly pass its own
|
|
259
|
+
CodeMirror extensions, which win over the engine's theme extension — it's read once at
|
|
260
|
+
mount, so change it by remounting with a new `key`. `CodePanel` doesn't expose this prop,
|
|
261
|
+
since island props must be JSON-serializable. See
|
|
262
|
+
[Tokens and preview CSS](../../src/content/docs/architecture/tokens-and-preview-css.mdx)
|
|
263
|
+
for the full token list and override example.
|
|
264
|
+
|
|
265
|
+
Declare host tokens as ordinary `:root` custom properties and map utilities to
|
|
266
|
+
those live variables in `wind.tokens`. Pass the host's `wind` configuration in
|
|
267
|
+
the preset fragment given to `withZudoSg()`. The helper deep-merges engine tokens
|
|
268
|
+
with explicit host entries last, preserves host source controls, and registers
|
|
269
|
+
`@takazudo/zudo-sg/wind.json` automatically. Hosts need no manual manifest import.
|
|
270
|
+
The defaults declare sm/md/lg/xl at 640/768/1024/1280px, strict compilation,
|
|
271
|
+
`dark: false`, `reset: "owned-v1"` and utilities placed before authored CSS.
|
|
272
|
+
|
|
273
|
+
Keep utility overrides and engine styles unlayered. The `zw-reset` layer precedes
|
|
274
|
+
`zd-flow`; the dashboard stylesheet belongs after zudo-doc content CSS.
|
|
275
|
+
Configure consumer source roots in `wind.sources`; the engine manifest covers
|
|
276
|
+
only engine utility candidates.
|
|
277
|
+
|
|
278
|
+
`previewStyles` remains an independent CSS entry containing your component
|
|
279
|
+
tokens and authored component styles. The preview plugin invokes the host's
|
|
280
|
+
installed `zfb css` with composed wind configuration and component roots, then
|
|
281
|
+
scopes token roots to `:root[data-sg-preview-doc]`. CSS imports and component
|
|
282
|
+
source changes refresh without a restart. Host config or imported token-config
|
|
283
|
+
changes require zfb config reload/restart so the snapshot contains fresh data.
|
|
284
|
+
This token precedence rule does not isolate every host stylesheet selector.
|
|
287
285
|
|
|
288
286
|
## Release scheme
|
|
289
287
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/** @jsxImportSource preact */
|
|
3
|
-
import type { JSX } from "preact";
|
|
1
|
+
import type { JSX } from "@takazudo/zfb/zudo-react/jsx-runtime";
|
|
4
2
|
import type { CatalogEntry } from "../registry/catalog.js";
|
|
5
3
|
export interface CatalogThumbProps {
|
|
6
4
|
entry: CatalogEntry;
|
|
@@ -14,6 +12,3 @@ export interface CatalogThumbProps {
|
|
|
14
12
|
* through `DescriptorThumb`.
|
|
15
13
|
*/
|
|
16
14
|
export declare function CatalogThumb({ entry, base }: CatalogThumbProps): JSX.Element;
|
|
17
|
-
export declare namespace CatalogThumb {
|
|
18
|
-
var displayName: string;
|
|
19
|
-
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { jsx } from "
|
|
1
|
+
import { jsx } from "@takazudo/zfb/zudo-react/jsx-runtime";
|
|
2
2
|
import { ComponentThumb } from "./component-thumb.js";
|
|
3
3
|
import { DescriptorThumb } from "./descriptor-thumb.js";
|
|
4
4
|
function CatalogThumb({ entry, base }) {
|
|
5
5
|
if (entry.source === "module") return /* @__PURE__ */ jsx(ComponentThumb, { entry: entry.storyEntry });
|
|
6
6
|
return /* @__PURE__ */ jsx(DescriptorThumb, { entry, base });
|
|
7
7
|
}
|
|
8
|
-
CatalogThumb.displayName = "CatalogThumb";
|
|
9
8
|
export {
|
|
10
9
|
CatalogThumb
|
|
11
10
|
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/** @jsxImportSource preact */
|
|
3
|
-
import type { JSX } from "preact";
|
|
1
|
+
import type { JSX } from "@takazudo/zfb/zudo-react/jsx-runtime";
|
|
4
2
|
import type { StoryEntry } from "../registry/registry.js";
|
|
5
3
|
/** Virtual-viewport width (CSS px) a thumbnail lays its component out at. */
|
|
6
4
|
export declare const THUMB_VIEWPORT_W = 720;
|
|
@@ -73,6 +71,3 @@ export interface ComponentThumbProps {
|
|
|
73
71
|
* `aria-hidden` subtree is an accessibility defect, not just noise.
|
|
74
72
|
*/
|
|
75
73
|
export declare function ComponentThumb({ entry }: ComponentThumbProps): JSX.Element;
|
|
76
|
-
export declare namespace ComponentThumb {
|
|
77
|
-
var displayName: string;
|
|
78
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { jsx } from "@takazudo/zfb/zudo-react/jsx-runtime";
|
|
2
|
+
import { renderToString as renderToStaticHtml } from "@takazudo/zfb/zudo-react/server";
|
|
3
3
|
const THUMB_VIEWPORT_W = 720;
|
|
4
4
|
const THUMB_VIEWPORT_W_ATOM = 400;
|
|
5
5
|
const ATOM_SCALE_CATEGORIES = [
|
|
@@ -56,9 +56,11 @@ function buildThumb(entry) {
|
|
|
56
56
|
const variant = entry.variants[0];
|
|
57
57
|
if (!variant) return { kind: "note", reason: "No variants declared" };
|
|
58
58
|
try {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
let StorySnapshot2 = function() {
|
|
60
|
+
return variant.story.render(defaultsFromControls(variant.story.controls));
|
|
61
|
+
};
|
|
62
|
+
var StorySnapshot = StorySnapshot2;
|
|
63
|
+
const html = renderToStaticHtml(/* @__PURE__ */ jsx(StorySnapshot2, {}));
|
|
62
64
|
return { kind: "html", html: scopeThumbHtml(html, thumbIdPrefix(entry.slug)) };
|
|
63
65
|
} catch (error) {
|
|
64
66
|
return {
|
|
@@ -90,13 +92,12 @@ function ComponentThumb({ entry }) {
|
|
|
90
92
|
"div",
|
|
91
93
|
{
|
|
92
94
|
class: "sg-thumb-inner",
|
|
93
|
-
|
|
95
|
+
rawHtml: thumb.html
|
|
94
96
|
}
|
|
95
97
|
)
|
|
96
98
|
}
|
|
97
99
|
);
|
|
98
100
|
}
|
|
99
|
-
ComponentThumb.displayName = "ComponentThumb";
|
|
100
101
|
export {
|
|
101
102
|
ATOM_SCALE_CATEGORIES,
|
|
102
103
|
ComponentThumb,
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/** @jsxImportSource preact */
|
|
3
|
-
import type { JSX } from "preact";
|
|
1
|
+
import type { JSX } from "@takazudo/zfb/zudo-react/jsx-runtime";
|
|
4
2
|
import type { DescriptorCatalogEntry } from "../registry/catalog.js";
|
|
5
3
|
/** Note shown when a descriptor declares no `thumbnail` at all. */
|
|
6
4
|
export declare const DESCRIPTOR_THUMB_MISSING_NOTE = "No thumbnail provided";
|
|
@@ -15,6 +13,3 @@ export interface DescriptorThumbProps {
|
|
|
15
13
|
* snapshots out of the tab order and the accessibility tree the same way.
|
|
16
14
|
*/
|
|
17
15
|
export declare function DescriptorThumb({ entry, base }: DescriptorThumbProps): JSX.Element;
|
|
18
|
-
export declare namespace DescriptorThumb {
|
|
19
|
-
var displayName: string;
|
|
20
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx } from "
|
|
1
|
+
import { jsx } from "@takazudo/zfb/zudo-react/jsx-runtime";
|
|
2
2
|
const DESCRIPTOR_THUMB_MISSING_NOTE = "No thumbnail provided";
|
|
3
3
|
function withThumbBase(base, src) {
|
|
4
4
|
if (!src.startsWith("/")) return src;
|
|
@@ -24,7 +24,6 @@ function DescriptorThumb({ entry, base = "" }) {
|
|
|
24
24
|
}
|
|
25
25
|
) });
|
|
26
26
|
}
|
|
27
|
-
DescriptorThumb.displayName = "DescriptorThumb";
|
|
28
27
|
export {
|
|
29
28
|
DESCRIPTOR_THUMB_MISSING_NOTE,
|
|
30
29
|
DescriptorThumb
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { ComponentChildren, JSX, VNode } from "preact";
|
|
1
|
+
import type { Child, Description } from "@takazudo/zfb/zudo-react";
|
|
2
|
+
import type { JSX } from "@takazudo/zfb/zudo-react/jsx-runtime";
|
|
4
3
|
import type { NavNode } from "../registry/nav-nodes.js";
|
|
5
4
|
export interface StyleguideLayoutProps {
|
|
6
5
|
/**
|
|
@@ -21,19 +20,19 @@ export interface StyleguideLayoutProps {
|
|
|
21
20
|
/** Hide the component sidebar for standalone pages such as /tokens. */
|
|
22
21
|
hideSidebar?: boolean;
|
|
23
22
|
/** `<head>` content — the host passes its `HeadWithDefaults` output. */
|
|
24
|
-
head:
|
|
23
|
+
head: Child;
|
|
25
24
|
/** Header region — the host passes its `HeaderWithDefaults` output. */
|
|
26
|
-
header:
|
|
25
|
+
header: Child;
|
|
27
26
|
/** Footer region — the host passes its `FooterWithDefaults` output. */
|
|
28
|
-
footer:
|
|
27
|
+
footer: Child;
|
|
29
28
|
/** Body-end islands — the host passes its `BodyEndIslands` output. */
|
|
30
|
-
bodyEnd:
|
|
29
|
+
bodyEnd: Child;
|
|
31
30
|
/**
|
|
32
31
|
* Right-region code panel content (detail pages only, #49). When present the
|
|
33
32
|
* TOC slot hosts it; when absent the slot is empty and `hideToc` frees the
|
|
34
33
|
* width.
|
|
35
34
|
*/
|
|
36
|
-
codePanel?:
|
|
35
|
+
codePanel?: Description | null;
|
|
37
36
|
/**
|
|
38
37
|
* Opt the content band into the DocLayout **wide** layout — forwarded
|
|
39
38
|
* verbatim to `DocLayoutWithDefaults contentWide`. Defaults to `false`.
|
|
@@ -54,6 +53,6 @@ export interface StyleguideLayoutProps {
|
|
|
54
53
|
enableClientRouter: boolean;
|
|
55
54
|
/** Mirrors the host's `settings.noindex`. */
|
|
56
55
|
noindex: boolean;
|
|
57
|
-
children:
|
|
56
|
+
children: Child;
|
|
58
57
|
}
|
|
59
58
|
export declare function StyleguideLayout({ title, activeSlug, lang, hideSidebar, head, header, footer, bodyEnd, codePanel, contentWide, navNodes, sidebarToggle, enableClientRouter, noindex, children, }: StyleguideLayoutProps): JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "
|
|
1
|
+
import { Fragment, jsx, jsxs } from "@takazudo/zfb/zudo-react/jsx-runtime";
|
|
2
2
|
import { Island } from "@takazudo/zfb";
|
|
3
3
|
import { DocLayoutWithDefaults } from "@takazudo/zudo-doc/doclayout";
|
|
4
4
|
import { SidebarTree } from "@takazudo/zudo-doc/sidebar-tree-island";
|
|
@@ -28,11 +28,8 @@ function StyleguideLayout({
|
|
|
28
28
|
const sidebarToggleSettings = { sidebarToggle };
|
|
29
29
|
const SidebarPrepaint = createSidebarPrepaint(sidebarToggleSettings);
|
|
30
30
|
const SidebarVisibilityPrepaint = createSidebarVisibilityPrepaint(sidebarToggleSettings);
|
|
31
|
-
const sidebarOverride = hideSidebar ? /* @__PURE__ */ jsx(Fragment, {}) : Island({
|
|
32
|
-
|
|
33
|
-
children: /* @__PURE__ */ jsx(SidebarTree, { nodes: navNodes, currentSlug: activeSlug })
|
|
34
|
-
});
|
|
35
|
-
const tocOverride = showCodePanel ? codePanel : /* @__PURE__ */ jsx(Fragment, {});
|
|
31
|
+
const sidebarOverride = hideSidebar ? /* @__PURE__ */ jsx(Fragment, {}) : /* @__PURE__ */ jsx(Island, { when: "load", children: /* @__PURE__ */ jsx(SidebarTree, { nodes: navNodes, ...activeSlug !== void 0 ? { currentSlug: activeSlug } : {} }) });
|
|
32
|
+
const tocOverride = codePanel ?? /* @__PURE__ */ jsx(Fragment, {});
|
|
36
33
|
const composedHead = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
37
34
|
head,
|
|
38
35
|
/* @__PURE__ */ jsx(SidebarVisibilityPrepaint, { hideSidebar }),
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
/** @jsxImportSource preact */
|
|
3
|
-
import type { JSX } from "preact";
|
|
1
|
+
import type { JSX } from "@takazudo/zfb/zudo-react/jsx-runtime";
|
|
4
2
|
export declare function PanelStateHeadScript(): JSX.Element;
|
|
5
3
|
export declare function PanelResizersInitScript(): JSX.Element;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx } from "
|
|
1
|
+
import { jsx } from "@takazudo/zfb/zudo-react/jsx-runtime";
|
|
2
2
|
import { RESIZER_SCRIPT, RESTORE_SCRIPT } from "./panel-scripts-source";
|
|
3
3
|
function PanelStateHeadScript() {
|
|
4
|
-
return /* @__PURE__ */ jsx("script", {
|
|
4
|
+
return /* @__PURE__ */ jsx("script", { rawHtml: RESTORE_SCRIPT });
|
|
5
5
|
}
|
|
6
6
|
function PanelResizersInitScript() {
|
|
7
|
-
return /* @__PURE__ */ jsx("script", {
|
|
7
|
+
return /* @__PURE__ */ jsx("script", { rawHtml: RESIZER_SCRIPT });
|
|
8
8
|
}
|
|
9
9
|
export {
|
|
10
10
|
PanelResizersInitScript,
|
|
@@ -29,14 +29,15 @@ function toPascalCase(kebabName) {
|
|
|
29
29
|
}
|
|
30
30
|
function componentTemplate({ pascalName }) {
|
|
31
31
|
const lines = [
|
|
32
|
-
`import type {
|
|
32
|
+
`import type { Child } from "@takazudo/zfb/zudo-react";`,
|
|
33
|
+
`import type { JSX } from "@takazudo/zfb/zudo-react/jsx-runtime";`,
|
|
33
34
|
``,
|
|
34
35
|
`export type ${pascalName}Variant = "primary" | "secondary";`,
|
|
35
36
|
``,
|
|
36
37
|
`export type ${pascalName}Props = {`,
|
|
37
38
|
` variant?: ${pascalName}Variant;`,
|
|
38
39
|
` class?: string;`,
|
|
39
|
-
` children?:
|
|
40
|
+
` children?: Child;`,
|
|
40
41
|
`};`,
|
|
41
42
|
``,
|
|
42
43
|
`const base =`,
|
|
@@ -53,7 +54,7 @@ function componentTemplate({ pascalName }) {
|
|
|
53
54
|
`/**`,
|
|
54
55
|
` * TODO: describe ${pascalName} \u2014 what it renders and when to use it.`,
|
|
55
56
|
` */`,
|
|
56
|
-
`export function ${pascalName}({ variant = "primary", class: cls, children }: ${pascalName}Props) {`,
|
|
57
|
+
`export function ${pascalName}({ variant = "primary", class: cls, children }: ${pascalName}Props): JSX.Element {`,
|
|
57
58
|
` const className = [base, variants[variant], cls].filter(Boolean).join(" ");`,
|
|
58
59
|
` return <div class={className}>{children}</div>;`,
|
|
59
60
|
`}`
|
|
@@ -68,6 +69,7 @@ function storiesTemplate({
|
|
|
68
69
|
}) {
|
|
69
70
|
const usageImport = uiPackageName ?? `./${kebabName}`;
|
|
70
71
|
const lines = [
|
|
72
|
+
`import type { Child } from "@takazudo/zfb/zudo-react";`,
|
|
71
73
|
`import type { StoryMeta, Story } from "@takazudo/zudo-sg/stories";`,
|
|
72
74
|
`import { ${pascalName}, type ${pascalName}Props } from "./${kebabName}";`,
|
|
73
75
|
``,
|
|
@@ -100,7 +102,7 @@ function storiesTemplate({
|
|
|
100
102
|
` defaultValue: "Content",`,
|
|
101
103
|
` },`,
|
|
102
104
|
` ],`,
|
|
103
|
-
` render: (args = {}) => (`,
|
|
105
|
+
` render: (args = {}): Child => (`,
|
|
104
106
|
` <${pascalName} variant={args.variant}>{args.children}</${pascalName}>`,
|
|
105
107
|
` ),`,
|
|
106
108
|
`};`
|
|
@@ -109,26 +111,43 @@ function storiesTemplate({
|
|
|
109
111
|
}
|
|
110
112
|
function testTemplate({ pascalName, kebabName }) {
|
|
111
113
|
const lines = [
|
|
112
|
-
|
|
114
|
+
`// @vitest-environment happy-dom`,
|
|
115
|
+
`import { renderToString } from "@takazudo/zfb/zudo-react/server";`,
|
|
116
|
+
`import { createIslandTest } from "@takazudo/zfb/zudo-react/testing";`,
|
|
113
117
|
`import { describe, expect, it } from "vitest";`,
|
|
114
|
-
`import { ${pascalName} } from "../${kebabName}";`,
|
|
118
|
+
`import { ${pascalName}, type ${pascalName}Props } from "../${kebabName}";`,
|
|
119
|
+
``,
|
|
120
|
+
`function ${pascalName}Fixture({ variant }: Pick<${pascalName}Props, "variant">) {`,
|
|
121
|
+
` return <${pascalName} variant={variant}>Content</${pascalName}>;`,
|
|
122
|
+
`}`,
|
|
115
123
|
``,
|
|
116
124
|
`describe("${pascalName}", () => {`,
|
|
117
125
|
` it("renders its children", () => {`,
|
|
118
|
-
`
|
|
119
|
-
` expect(screen.getByText("Content")).toBeInTheDocument();`,
|
|
126
|
+
` expect(renderToString(<${pascalName}>Content</${pascalName}>)).toContain("Content");`,
|
|
120
127
|
` });`,
|
|
121
128
|
``,
|
|
122
|
-
` it("defaults to the primary variant", () => {`,
|
|
123
|
-
`
|
|
124
|
-
`
|
|
125
|
-
`
|
|
129
|
+
` it("defaults to the primary variant", async () => {`,
|
|
130
|
+
` const test = createIslandTest(${pascalName}Fixture, {}, { document });`,
|
|
131
|
+
` try {`,
|
|
132
|
+
` test.hydrate();`,
|
|
133
|
+
` await test.flush();`,
|
|
134
|
+
` expect(test.host.querySelector("div")?.classList.contains("bg-accent")).toBe(true);`,
|
|
135
|
+
` } finally {`,
|
|
136
|
+
` test.dispose();`,
|
|
137
|
+
` expect(test.diagnostics).toEqual([]);`,
|
|
138
|
+
` }`,
|
|
126
139
|
` });`,
|
|
127
140
|
``,
|
|
128
|
-
` it("applies the secondary variant classes", () => {`,
|
|
129
|
-
`
|
|
130
|
-
`
|
|
131
|
-
`
|
|
141
|
+
` it("applies the secondary variant classes", async () => {`,
|
|
142
|
+
` const test = createIslandTest(${pascalName}Fixture, { variant: "secondary" }, { document });`,
|
|
143
|
+
` try {`,
|
|
144
|
+
` test.hydrate();`,
|
|
145
|
+
` await test.flush();`,
|
|
146
|
+
` expect(test.host.querySelector("div")?.classList.contains("border-border")).toBe(true);`,
|
|
147
|
+
` } finally {`,
|
|
148
|
+
` test.dispose();`,
|
|
149
|
+
` expect(test.diagnostics).toEqual([]);`,
|
|
150
|
+
` }`,
|
|
132
151
|
` });`,
|
|
133
152
|
`});`
|
|
134
153
|
];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { JSX } from "preact";
|
|
2
1
|
export interface CodePanelVariant {
|
|
3
2
|
exportName: string;
|
|
4
3
|
name: string;
|
|
@@ -13,13 +12,8 @@ export interface CodePanelProps {
|
|
|
13
12
|
/**
|
|
14
13
|
* Story slug, used to build stable variant-tab/tabpanel ids that match
|
|
15
14
|
* SSR output (mirrors `DetailWorkbench`'s `tabsId`). Falls back to
|
|
16
|
-
*
|
|
17
|
-
* not stable across an SSR/hydration boundary.
|
|
15
|
+
* a deterministic title-derived id when the host does not pass one.
|
|
18
16
|
*/
|
|
19
17
|
slug?: string;
|
|
20
18
|
}
|
|
21
|
-
|
|
22
|
-
declare namespace CodePanel {
|
|
23
|
-
var displayName: string;
|
|
24
|
-
}
|
|
25
|
-
export default CodePanel;
|
|
19
|
+
export default function CodePanel({ storyTitle, variants, previewUrl, slug, }: CodePanelProps): import("@takazudo/zfb").Description;
|