@takazudo/zudo-sg 0.3.6 → 0.4.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 +65 -0
- package/README.md +2 -2
- package/dist/catalog/catalog-thumb.d.ts +19 -0
- package/dist/catalog/catalog-thumb.js +11 -0
- package/dist/catalog/descriptor-thumb.d.ts +20 -0
- package/dist/catalog/descriptor-thumb.js +31 -0
- package/dist/catalog/index.d.ts +4 -0
- package/dist/catalog/index.js +5 -0
- package/dist/code-panel/code-panel.d.ts +8 -1
- package/dist/code-panel/code-panel.js +76 -24
- package/dist/code-panel/editor-setup.d.ts +2 -0
- package/dist/code-panel/editor-setup.js +3 -0
- package/dist/code-panel/source-editor.d.ts +3 -1
- package/dist/code-panel/source-editor.js +10 -1
- package/dist/config/index.d.ts +54 -5
- package/dist/config/index.js +72 -12
- package/dist/host-paths.d.ts +2 -0
- package/dist/host-paths.js +5 -0
- package/dist/plugins/routes.d.ts +60 -11
- package/dist/plugins/routes.js +135 -23
- package/dist/preview/detail-workbench.d.ts +63 -1
- package/dist/preview/detail-workbench.js +112 -22
- package/dist/preview/index.d.ts +3 -3
- package/dist/preview/index.js +7 -1
- package/dist/preview/messages.d.ts +34 -5
- package/dist/preview/messages.js +34 -6
- package/dist/preview/preview-app.js +22 -10
- package/dist/preview/variant-frame.d.ts +50 -2
- package/dist/preview/variant-frame.js +64 -23
- package/dist/registry/catalog.d.ts +64 -0
- package/dist/registry/catalog.js +79 -0
- package/dist/registry/descriptors.d.ts +46 -0
- package/dist/registry/descriptors.js +148 -0
- package/dist/registry/index.d.ts +5 -1
- package/dist/registry/index.js +7 -1
- package/dist/registry/nav-nodes.d.ts +4 -1
- package/dist/registry/nav-nodes.js +4 -1
- package/dist/registry/registry.d.ts +15 -0
- package/dist/registry/registry.js +18 -9
- package/dist/safelist.css +1 -1
- package/dist/sg-context.d.ts +29 -0
- package/dist/sg-routes.d.ts +49 -1
- package/dist/sg-routes.js +15 -1
- package/dist/shared/tablist-keyboard.d.ts +14 -0
- package/dist/shared/tablist-keyboard.js +19 -0
- package/package.json +9 -4
- package/routes-src/_preview-app.tsx +2 -2
- package/routes-src/_registry.ts +31 -6
- package/routes-src/components-index.tsx +15 -8
- package/routes-src/components-preview.tsx +5 -0
- package/routes-src/components-slug.tsx +63 -31
- package/routes-src/tokens.tsx +9 -4
- package/styles.css +10 -0
- package/virtual-modules.d.ts +6 -0
package/dist/safelist.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* generated by gen-safelist.mjs — do not edit by hand */
|
|
2
|
-
@source inline("-components [--check] [--nested] [--skip-barrel] [data-sg-card] [data-sg-catalog] [data-sg-empty] [data-sg-section] [data-sg-tile] [options] [slug] [zudo-sg] a accent accent-0 accent-1 accent-2 accent-3 accent/state accept across add adjusted after alias all allow-forms allow-same-origin allow-scripts alphabetical alphabetically already always among an and any anything appear application/json apply-css-vars are arguments aria-activedescendant aria-controls aria-describedby aria-details aria-expanded aria-hidden aria-label aria-labelledby aria-live aria-orientation aria-owns aria-pressed aria-selected array arrays as aside assumes async at authored await back bar barrel barrel-export base be because before below beneath bg bg-[var(--sg-accent)] bg-[var(--sg-bg)] bg-[var(--sg-surface)] bg-[var(--sg-surface-2)] bg-bg block body bogus boolean border border-[color:var(--sg-accent)] border-[color:var(--sg-border)] border-[color:var(--sg-border-strong)] border-b border-t border-transparent both break build builds but button by cache-control cannot canvas carries cascading case catalog catch categories category caution change changing checkbox children circle clamp class classes clear-css-vars clickable client code codegen collapsing collection collides color colors command commit compact compare compile compiled component components components2026 config configured confirm const contain content-type continue control copy count counts css cursor-pointer custom custom-property danger dark dashboard dashboards data-category data-copied data-keywords data-name data-sg-card data-sg-catalog data-sg-catalog-intro data-sg-code-panel-hidden data-sg-code-panel-resizer data-sg-empty data-sg-engine-route data-sg-injected-css data-sg-preview-css data-sg-preview-doc data-sg-preview-loading data-sg-preview-scope data-sg-section data-sg-stage-grid data-sg-tile data-sg-tile-size data-sg-variant-root data-theme data-zudo-sg-tokens-empty date debugger declaration declarations declare declared default defaults delete demo derived describe description descriptors design design-token desktop detail detect dev different differs digit directory disabled discovered display distinct div do doc doc-chrome does drift driven dual-scheme duplicate duration each edit editing edits either el element else empty en endpoint engine entries entry entrypoint enum equivalent eval every exactly exists expected explicit export exported exports exposes expressions extends extension failed fails false family fg field file files filled finally find finite first first-authored five fixed flag flex flex-1 flex-col flex-wrap focus-visible:-outline-offset-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-[color:var(--sg-focus)] focus-visible:outline-offset-2 follow followed follows font font-bold font-family font-medium font-semibold font-size font-size-lh font-weight for form found frame frames free-form from frost full function g gap-hsp-2xs gap-hsp-3xs gap-hsp-md gap-hsp-sm gap-hsp-xs gap-vsp-2xs gap-vsp-lg gap-vsp-md gap-x-hsp-xl gap-y-vsp-xl gate gen-registry gen-token-manifest gen:sg-registry generated get give glob-relative grid grid-cols-1 grid-cols-[repeat(auto-fit,minmax(min(18rem,100%),1fr))] group groups guards h-[1.5rem] h-full h1 h2 h3 hand handle hands has have head header headers height here hex hidden hold host hover:text-[color:var(--sg-fg)] hover:text-fg hsp html human-friendly id if iframe iframes implements import important in include including inert info init inject inline-block inline-flex input inserting inserts inside installed instanceof instead interface into intro invalid inventory is isolated it items-center items-start its itself justify-between justify-center kebab-case keeps key key-enumeration keyboard keydown keyed kind known label large layout lazy leading leading-normal left length let lh light like line line-beauty-accent line-beauty-accent-dark line-beauty-hover line-beauty-hover-dark line-height line-laser-accent line-laser-accent-dark line-laser-hover line-laser-hover-dark line-meeting-accent line-meeting-accent-dark line-meeting-hover line-meeting-hover-dark line-process-accent line-process-accent-dark line-process-hover line-process-hover-dark line-vacuum-accent line-vacuum-accent-dark line-vacuum-hover line-vacuum-hover-dark link lint:tokens list listed lists live load loading m-0 m21 makes manifest map marker markers match matching material max-w-[56rem] may mb-vsp-2xs mb-vsp-lg mb-vsp-sm mb-vsp-xl message meta metadata min-h-0 mirroring missing mobile mode mode-dependent mode-independent model module ms ms-auto mt-vsp-2xs mt-vsp-3xs mt-vsp-xl mt-vsp-xs must mx-auto name name/value named named-export names namespace navigation needs neutral-0 neutral-1 neutral-2 neutral-3 never new new-component new:component no no-store node:crypto node:fs node:fs/promises node:module node:path node:url noindex non-empty none not note nowhere null number object of off oklch omit omitted on once one one-sentence only option options opts or order ordered other out outline-none overflow-auto overflow-hidden overflow-x-auto overriding p p-hsp-2xs p-hsp-md p-hsp-sm package pages pairs palette palette- panel panels parse parsed parser pass passes path per-element per-variant pick pill placeholder placeholders plain plugin plugins pnpm polite polyline portable positive postcss pre preact-render-to-string preact/hooks preact/jsx-runtime presentation preserve preview previews primary private property protected pt-vsp-xl public pushes px px-hsp-2xs px-hsp-md px-hsp-sm px-hsp-xs py-vsp-2xs py-vsp-3xs py-vsp-xs radius rail ramp ramps range raw re-executed re-run read-only readonly ready real recover rect reference references regenerated region registration relative rem rem-aware rem-based renamed/removed render rendered renders replace require required requires resolve resolved return returns rhythm robots root-absolute round rounded rounded-full rounded-md rounded-sm route router routes routes-src row rows run runtime s same saved scaffold scaffolds screen scrim script search secondary section segment segments select semantic separator set settings sg-catalog-tile-size sg-chip sg-chip-row sg-code-panel sg-code-panel-hidden sg-code-panel-resizer sg-code-panel-width sg-copy-btn sg-filter sg-filter-row sg-gallery-section sg-grid sg-injected- sg-preview-design-token-panel-modal sg-preview-design-tokens sg-preview-design-tokens/v1 sg-preview-tokens-trigger sg-preview-tweak sg-registry sg-search-clear sg-search-field sg-search-input sg-seg sg-seg-btn sg-thumb sg-thumb-inner sg-thumb-note sg-tile sg-tile-count sg-tile-desc sg-tile-meta sg-tile-title sg-workbench-toolbar sg:height sg:ready sgt- shadow shape shared show shown shrink-0 sidebar sidebar- single-axis site size skipped skips slider slug so solid sorts source spacing span spec specimen stacked starting state state-danger state-danger-dark state-info state-info-dark state-success state-success-dark state-warning state-warning-dark static stay step still story string strings stroke-linecap stroke-linejoin stroke-width style stylesheet super supplies supply support supported surface surfaces svg swaps swatch switch tab tablet tablist tabs tabular-nums text text-2xl text-[color:var(--sg-accent)] text-[color:var(--sg-fg)] text-[color:var(--sg-muted)] text-[color:var(--sg-on-accent)] text-caption text-fg text-heading text-muted text-right text-sm text-small text-xl text-xs text/icons textarea that the their them theme then these this three-tier throw tier tier-model tile time tip title to toggle toggle-design-token-panel toggle-preview-token-panel token tokens total tracking-wide transition-colors true try tsx tweaks twice two type typechecks typeof ui- ui-color ui-defaults-dark ui-defaults-light ui-defaults-shared undefined under underline underline-offset-2 unique unit unitless units unknown unsupported unwired up uppercase us use used uses utf-8 utf8 valid value values var variant variants vertical via viewport views virtual:zudo-doc-chrome-bindings virtual:zudo-doc-route-context virtual:zudo-sg-context virtual:zudo-sg-preview-token-panel virtual:zudo-sg-registry virtual:zudo-sg-tokens visible visit void vs vsp w-[2.5rem] w-[5rem] warning was weight were what when which while whole whose will window with without would written yield you your zd-content zdtp-preview-prehydrate zfb zfb:after-swap zudo-doc zudo-doc-sidebar-width zudo-sg zudo-sg-token-tweak-bridge");
|
|
2
|
+
@source inline("-components -mb-px -panel -tab- [--check] [--nested] [--skip-barrel] [data-sg-card] [data-sg-catalog] [data-sg-empty] [data-sg-section] [data-sg-tile] [options] [slug] [zudo-sg] a accent accent-0 accent-1 accent-2 accent-3 accent/state accept across add adjusted after alias all allow-forms allow-same-origin allow-scripts alphabetical alphabetically already always among an and any anything appear application/json apply-css-vars are arguments aria-activedescendant aria-controls aria-describedby aria-details aria-expanded aria-hidden aria-label aria-labelledby aria-live aria-orientation aria-owns aria-pressed aria-selected array arrays as aside assumes async at authored auto await back bar barrel barrel-export base be because before below beneath bg bg-[var(--sg-accent)] bg-[var(--sg-bg)] bg-[var(--sg-surface)] bg-[var(--sg-surface-2)] bg-bg block body bogus boolean border border-[color:var(--sg-accent)] border-[color:var(--sg-border)] border-[color:var(--sg-border-strong)] border-b border-b-2 border-t border-transparent both break build builds but button by cache-control cannot canvas carries cascading case catalog catch categories category caution change changing checkbox children circle clamp class classes clear-css-vars clickable client code codegen collapsing collection collides color colors command commit compact compare compile compiled component components components2026 config configured confirm const contain content-type continue control controls copy count counts css cursor-pointer custom custom-property danger dark dashboard dashboards data data-category data-copied data-keywords data-name data-sg-card data-sg-catalog data-sg-catalog-intro data-sg-code-panel-hidden data-sg-code-panel-resizer data-sg-code-region data-sg-empty data-sg-engine-route data-sg-injected-css data-sg-preview-css data-sg-preview-doc data-sg-preview-loading data-sg-preview-scope data-sg-section data-sg-stage-grid data-sg-thumb-image data-sg-thumb-note data-sg-tile data-sg-tile-size data-sg-variant-root data-theme data-zudo-sg-tokens-empty date dead debugger declaration declarations declare declared default defaults delete demo derived describe description descriptor descriptors design design-token desktop detail detect dev different differs digit directory disabled discovered display distinct div do doc doc-chrome does drift driven dual-scheme duplicate duration each edit editing edits either el element else empty en enabled endpoint engine entries entry entrypoint enum equivalent eval every exactly exists expected explicit explicitly export exported exports exposes expressions extends extension failed fails false family fg field file files filled finally find finite first first-authored five fixed flag flex flex-1 flex-col flex-wrap focus-visible:-outline-offset-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-[color:var(--sg-focus)] focus-visible:outline-offset-2 follow followed follows font font-bold font-family font-medium font-semibold font-size font-size-lh font-weight for form found frame frames free-form from frost full function g gap-hsp-2xs gap-hsp-3xs gap-hsp-md gap-hsp-sm gap-hsp-xs gap-vsp-2xs gap-vsp-lg gap-vsp-md gap-x-hsp-xl gap-y-vsp-xl gate gen-registry gen-token-manifest gen:sg-registry generated get give glob-relative grid grid-cols-1 grid-cols-[repeat(auto-fit,minmax(min(18rem,100%),1fr))] group groups guards h-[1.5rem] h-full h1 h2 h3 hand handle hands has have head header headers height here hex hidden hold host hover:text-[color:var(--sg-fg)] hover:text-fg hsp html human-friendly id if iframe iframes image img implements import important in in-engine include including inert info init inject inline-block inline-flex input inserting inserts inside installed instanceof instead interface into intro invalid inventory is isolated it items-center items-start its itself justify-between justify-center kebab-case keeps key key-enumeration keyboard keydown keyed kind known label large layout lazy leading leading-normal left length let lh light like line line-beauty-accent line-beauty-accent-dark line-beauty-hover line-beauty-hover-dark line-height line-laser-accent line-laser-accent-dark line-laser-hover line-laser-hover-dark line-meeting-accent line-meeting-accent-dark line-meeting-hover line-meeting-hover-dark line-process-accent line-process-accent-dark line-process-hover line-process-hover-dark line-vacuum-accent line-vacuum-accent-dark line-vacuum-hover line-vacuum-hover-dark link lint:tokens list listed lists live live-css load loading m-0 m21 makes malformed manifest map marker markers match matching material max-w-[56rem] may mb-vsp-2xs mb-vsp-lg mb-vsp-sm mb-vsp-xl message meta metadata min-h-0 mirroring missing mobile mode mode-dependent mode-independent model module ms ms-auto mt-vsp-2xs mt-vsp-3xs mt-vsp-xl mt-vsp-xs must mx-auto name name/value named named-export names namespace navigation needs neutral-0 neutral-1 neutral-2 neutral-3 never new new-component new:component no no-store node:crypto node:fs node:fs/promises node:module node:path node:url noindex non-empty none not note nowhere null number object of off oklch omit omitted on once one one-sentence only option options opts or order ordered other out outline-none outside overflow-auto overflow-hidden overflow-x-auto overriding p p-hsp-2xs p-hsp-md p-hsp-sm package pages pairs palette palette- panel panels parse parsed parser pass passes path per-element per-variant pick pill placeholder placeholders plain plugin plugins pnpm point polite polyline portable positive postcss pre preact-render-to-string preact/hooks preact/jsx-runtime presentation preserve preview previews primary private property protected provided pt-vsp-xl public pushes px px-hsp-2xs px-hsp-md px-hsp-sm px-hsp-xs py-vsp-2xs py-vsp-3xs py-vsp-xs radius rail ramp ramps range raw re-executed re-run read-only readonly ready real recover rect reference references regenerated region registration registry relative rem rem-aware rem-based renamed/removed render rendered renders replace replaces require required requires reserved resolve resolved return returns rhythm robots root-absolute round rounded rounded-full rounded-md rounded-sm rounded-t-sm route router routes routes-src row rows run runtime s same saved scaffold scaffolds screen scrim script search secondary section segment segments select semantic separator set settings sg-catalog-tile-size sg-chip sg-chip-row sg-code-live-css sg-code-panel sg-code-panel- sg-code-panel-hidden sg-code-panel-resizer sg-code-panel-width sg-code-source sg-copy-btn sg-filter sg-filter-row sg-gallery-section sg-grid sg-injected- sg-preview-design-token-panel-modal sg-preview-design-tokens sg-preview-design-tokens/v1 sg-preview-tokens-trigger sg-preview-tweak sg-registry sg-search-clear sg-search-field sg-search-input sg-seg sg-seg-btn sg-single-stage sg-thumb sg-thumb-img sg-thumb-inner sg-thumb-note sg-tile sg-tile-count sg-tile-desc sg-tile-meta sg-tile-title sg-workbench- sg-workbench-toolbar sg:height sg:ready sgt- shadow shape shared show shown shrink-0 sidebar sidebar- single single-axis site size skipped skips slider slug so solid sorts source spacing span spec specimen stacked starting state state-danger state-danger-dark state-info state-info-dark state-success state-success-dark state-warning state-warning-dark static stay step still stories story string strings stroke-linecap stroke-linejoin stroke-width style styleguide stylesheet super supplies supply support supported surface surfaces svg swaps swatch switch tab tablet tablist tabpanel tabs tabular-nums text text-2xl text-[color:var(--sg-accent)] text-[color:var(--sg-fg)] text-[color:var(--sg-muted)] text-[color:var(--sg-on-accent)] text-caption text-fg text-heading text-muted text-right text-sm text-small text-xl text-xs text/icons textarea that the their them theme then these this three-tier throw thumbnail tier tier-model tile time tip title to together toggle toggle-design-token-panel toggle-preview-token-panel token tokens toolbar total tracking-wide transition-colors trigger true try tsx tweaks twice two type typechecks typeof ui- ui-color ui-defaults-dark ui-defaults-light ui-defaults-shared undefined under underline underline-offset-2 unique unit unitless units unknown unsupported until unwired up uppercase url us use used uses utf-8 utf8 valid value values var variant variants vertical via viewport views virtual:zudo-doc-chrome-bindings virtual:zudo-doc-route-context virtual:zudo-sg-context virtual:zudo-sg-preview-token-panel virtual:zudo-sg-registry virtual:zudo-sg-tokens visible visit void vs vsp w-[2.5rem] w-[5rem] warning was weight were what when which while whole whose width will window with without would written yield you your zd-content zdtp-preview-prehydrate zfb zfb:after-swap zudo-doc zudo-doc-sidebar-width zudo-sg zudo-sg-token-tweak-bridge");
|
package/dist/sg-context.d.ts
CHANGED
|
@@ -9,10 +9,17 @@ export interface SgCatalogText {
|
|
|
9
9
|
/** Host intro paragraph; `null` lets the catalog route render its built-in intro. */
|
|
10
10
|
intro: string | null;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Where the catalog's stories come from. `"module"`: the generated StoryModule
|
|
14
|
+
* registry (`registryModule`). `"descriptor"`: host-supplied plain-data
|
|
15
|
+
* `StoryDescriptor`s (`descriptorModule`) — no render functions reach the engine.
|
|
16
|
+
*/
|
|
17
|
+
export type SgRegistryMode = "module" | "descriptor";
|
|
12
18
|
export interface SgContext {
|
|
13
19
|
/** zfb `config.base` (`"/"` when unset). */
|
|
14
20
|
base: string;
|
|
15
21
|
routes: SgRoutes;
|
|
22
|
+
registryMode: SgRegistryMode;
|
|
16
23
|
categoryOrder: string[];
|
|
17
24
|
/** Package name shown in code-panel import snippets; `null` when the host did not set one. */
|
|
18
25
|
uiPackageName: string | null;
|
|
@@ -21,4 +28,26 @@ export interface SgContext {
|
|
|
21
28
|
catalog: SgCatalogText;
|
|
22
29
|
/** One entry per components root: its registry key prefix + MDX docs collection (`[]` = no docs). */
|
|
23
30
|
componentDocs: ComponentDocsRoot[];
|
|
31
|
+
/**
|
|
32
|
+
* Route keys with no injected `injectRoute()` call (`routes.<key>: false`,
|
|
33
|
+
* or implied — `componentsPreview` when `externalPreview` is set, `tokens`
|
|
34
|
+
* in descriptor mode with no token manifest). Kept separate from `routes`
|
|
35
|
+
* (which stays all-strings) rather than widening `SgRoutes` to `string | false`.
|
|
36
|
+
*/
|
|
37
|
+
disabledRoutes: Array<keyof SgRoutes>;
|
|
38
|
+
/**
|
|
39
|
+
* Root-absolute host document URL (before the base prefix) that replaces
|
|
40
|
+
* the in-engine preview route, or `null` when none is configured. The
|
|
41
|
+
* detail route passes `withBase(externalPreviewUrl ?? routes.componentsPreview)`
|
|
42
|
+
* as `previewUrl` to `DetailWorkbench` and the code panel.
|
|
43
|
+
*/
|
|
44
|
+
externalPreviewUrl: string | null;
|
|
45
|
+
/**
|
|
46
|
+
* Whether `zdtpApplyProxy.tabsModule` is configured (issue #872's
|
|
47
|
+
* `isPreviewTokenPanelWired()` verdict, `sg-routes.ts`). Gates the `/tokens`
|
|
48
|
+
* "Preview tokens" button and the detail route's `DetailWorkbench`
|
|
49
|
+
* `toolbar.tokenPanel` flag — an unwired host renders neither, instead of a
|
|
50
|
+
* dead control that dispatches to nothing.
|
|
51
|
+
*/
|
|
52
|
+
previewTokenPanel: boolean;
|
|
24
53
|
}
|
package/dist/sg-routes.d.ts
CHANGED
|
@@ -6,6 +6,16 @@ export interface SgRoutes {
|
|
|
6
6
|
tokens: string;
|
|
7
7
|
}
|
|
8
8
|
export declare const DEFAULT_SG_ROUTES: Readonly<SgRoutes>;
|
|
9
|
+
/**
|
|
10
|
+
* Route keys a host may opt out of injecting entirely (`routes.<key>: false`).
|
|
11
|
+
* `componentsIndex` / `componentsSlug` are the engine's point and stay
|
|
12
|
+
* required — see `plugins/routes.ts`'s `normalizeRoutes`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DISABLEABLE_ROUTE_KEYS: ReadonlySet<keyof SgRoutes>;
|
|
15
|
+
/** `routes` option shape: a pattern string, or `false` for the two opt-outable routes. */
|
|
16
|
+
export type SgRoutesOption = {
|
|
17
|
+
[K in keyof SgRoutes]?: K extends "componentsPreview" | "tokens" ? string | false : string;
|
|
18
|
+
};
|
|
9
19
|
/** Fills unset route patterns with the defaults. */
|
|
10
20
|
export declare function resolveSgRoutes(routes?: Partial<SgRoutes>): SgRoutes;
|
|
11
21
|
/** Substitutes `[slug]` in `routes.componentsSlug` (`"/components/[slug]"` + `"button"` → `"/components/button"`). */
|
|
@@ -14,5 +24,43 @@ export declare function componentHref(routes: Pick<SgRoutes, "componentsSlug">,
|
|
|
14
24
|
* The story slug occupied by the preview endpoint, if that endpoint falls
|
|
15
25
|
* inside the detail route pattern. Paths with and without a trailing slash
|
|
16
26
|
* name the same static page. An outside-namespace preview reserves nothing.
|
|
27
|
+
*
|
|
28
|
+
* `disabled: true` (the in-engine preview route is opted out, or replaced by
|
|
29
|
+
* an `externalPreview`) short-circuits to `null`: there is no in-catalog
|
|
30
|
+
* preview page to reserve a slug against.
|
|
31
|
+
*/
|
|
32
|
+
export declare function previewCollisionSlug(routes?: Partial<SgRoutes>, options?: {
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
}): string | null;
|
|
35
|
+
export interface TokensRouteVisibilityInput {
|
|
36
|
+
registryMode: "module" | "descriptor";
|
|
37
|
+
/** `options.routes.tokens` as given by the host: a pattern, `false`, or absent. */
|
|
38
|
+
tokensRouteOption: string | false | undefined;
|
|
39
|
+
/** Whether the host configured a token manifest (`zudo-sg.config.mjs` `tokens.manifestOut` / the resolved `tokensManifestModule`). */
|
|
40
|
+
hasTokensManifest: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Whether the `/tokens` route should be injected and linked from chrome.
|
|
44
|
+
* Shared by `config/index.ts` (`withStyleguideChromeDefaults`'s nav item) and
|
|
45
|
+
* `plugins/routes.ts` (route injection / `disabledRoutes`), so the two
|
|
46
|
+
* cannot disagree about it (issue #884 do-item 4).
|
|
47
|
+
*
|
|
48
|
+
* An explicit `routes.tokens` (string or `false`) always wins. Absent that,
|
|
49
|
+
* descriptor mode with no token manifest implies the route off — a narrowing
|
|
50
|
+
* of pgen E2 scoped to descriptor mode only, so module-mode hosts are
|
|
51
|
+
* unaffected (epic #879 delegated decision 2).
|
|
52
|
+
*/
|
|
53
|
+
export declare function isTokensRouteEnabled({ registryMode, tokensRouteOption, hasTokensManifest }: TokensRouteVisibilityInput): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the preview token panel is wired at all (issue #872): `zdtpApplyProxy`
|
|
56
|
+
* is what re-exports `tabs` into `virtual:zudo-sg-preview-token-panel`
|
|
57
|
+
* (`plugins/zdtp-apply-proxy.ts`), and every trigger's click handler dispatches
|
|
58
|
+
* to `PreviewTokenPanelBootstrap`, which no-ops silently when `tabs` is absent.
|
|
59
|
+
* A host without `tabsModule` has nothing to render, so the shared verdict here
|
|
60
|
+
* gates whether a trigger renders/injects at all — the single source of truth
|
|
61
|
+
* `config/index.ts` (header trigger default + the routes plugin's
|
|
62
|
+
* `previewTokenPanel` context flag) and `plugins/routes.ts` must agree on.
|
|
17
63
|
*/
|
|
18
|
-
export declare function
|
|
64
|
+
export declare function isPreviewTokenPanelWired(zdtpApplyProxy: {
|
|
65
|
+
tabsModule?: string;
|
|
66
|
+
} | undefined): boolean;
|
package/dist/sg-routes.js
CHANGED
|
@@ -4,13 +4,15 @@ const DEFAULT_SG_ROUTES = Object.freeze({
|
|
|
4
4
|
componentsPreview: "/components/preview",
|
|
5
5
|
tokens: "/tokens"
|
|
6
6
|
});
|
|
7
|
+
const DISABLEABLE_ROUTE_KEYS = /* @__PURE__ */ new Set(["componentsPreview", "tokens"]);
|
|
7
8
|
function resolveSgRoutes(routes = {}) {
|
|
8
9
|
return { ...DEFAULT_SG_ROUTES, ...routes };
|
|
9
10
|
}
|
|
10
11
|
function componentHref(routes, slug) {
|
|
11
12
|
return routes.componentsSlug.replace("[slug]", slug);
|
|
12
13
|
}
|
|
13
|
-
function previewCollisionSlug(routes = {}) {
|
|
14
|
+
function previewCollisionSlug(routes = {}, options) {
|
|
15
|
+
if (options?.disabled) return null;
|
|
14
16
|
const resolved = resolveSgRoutes(routes);
|
|
15
17
|
const pattern = resolved.componentsSlug.replace(/\/+$/, "");
|
|
16
18
|
const preview = resolved.componentsPreview.replace(/\/+$/, "");
|
|
@@ -25,9 +27,21 @@ function previewCollisionSlug(routes = {}) {
|
|
|
25
27
|
const slug = preview.slice(prefix.length, suffix ? -suffix.length : void 0);
|
|
26
28
|
return /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(slug) ? slug : null;
|
|
27
29
|
}
|
|
30
|
+
function isTokensRouteEnabled({ registryMode, tokensRouteOption, hasTokensManifest }) {
|
|
31
|
+
if (tokensRouteOption === false) return false;
|
|
32
|
+
if (typeof tokensRouteOption === "string") return true;
|
|
33
|
+
if (registryMode === "descriptor" && !hasTokensManifest) return false;
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
function isPreviewTokenPanelWired(zdtpApplyProxy) {
|
|
37
|
+
return Boolean(zdtpApplyProxy?.tabsModule);
|
|
38
|
+
}
|
|
28
39
|
export {
|
|
29
40
|
DEFAULT_SG_ROUTES,
|
|
41
|
+
DISABLEABLE_ROUTE_KEYS,
|
|
30
42
|
componentHref,
|
|
43
|
+
isPreviewTokenPanelWired,
|
|
44
|
+
isTokensRouteEnabled,
|
|
31
45
|
previewCollisionSlug,
|
|
32
46
|
resolveSgRoutes
|
|
33
47
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves the tab index a tablist keydown moves focus to. ArrowRight/
|
|
3
|
+
* ArrowLeft wrap around the ends; Home/End jump to them. Returns `undefined`
|
|
4
|
+
* for any other key, so callers can let the event bubble untouched.
|
|
5
|
+
*/
|
|
6
|
+
export declare function nextTablistIndex(key: string, index: number, length: number): number | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Shared keydown handler for a roving-tabindex tablist: moves focus to the
|
|
9
|
+
* target tab AND activates it in the same keystroke (APG "automatic
|
|
10
|
+
* activation"). `activate` selects the tab at the resolved index; `focusTab`
|
|
11
|
+
* moves DOM focus there — callers differ in how they look up their tab
|
|
12
|
+
* elements, so both are left to the caller.
|
|
13
|
+
*/
|
|
14
|
+
export declare function handleTablistKeyDown(e: KeyboardEvent, index: number, length: number, activate: (index: number) => void, focusTab: (index: number) => void): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function nextTablistIndex(key, index, length) {
|
|
2
|
+
if (length <= 0) return void 0;
|
|
3
|
+
if (key === "ArrowRight") return (index + 1) % length;
|
|
4
|
+
if (key === "ArrowLeft") return (index - 1 + length) % length;
|
|
5
|
+
if (key === "Home") return 0;
|
|
6
|
+
if (key === "End") return length - 1;
|
|
7
|
+
return void 0;
|
|
8
|
+
}
|
|
9
|
+
function handleTablistKeyDown(e, index, length, activate, focusTab) {
|
|
10
|
+
const next = nextTablistIndex(e.key, index, length);
|
|
11
|
+
if (next === void 0) return;
|
|
12
|
+
e.preventDefault();
|
|
13
|
+
activate(next);
|
|
14
|
+
focusTab(next);
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
handleTablistKeyDown,
|
|
18
|
+
nextTablistIndex
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takazudo/zudo-sg",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "zudo-sg styleguide engine — story registry, catalog routes and preview machinery for zfb + zudo-doc hosts.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,6 +59,10 @@
|
|
|
59
59
|
"types": "./dist/preview/index.d.ts",
|
|
60
60
|
"default": "./dist/preview/index.js"
|
|
61
61
|
},
|
|
62
|
+
"./preview/messages": {
|
|
63
|
+
"types": "./dist/preview/messages.d.ts",
|
|
64
|
+
"default": "./dist/preview/messages.js"
|
|
65
|
+
},
|
|
62
66
|
"./code-panel": {
|
|
63
67
|
"types": "./dist/code-panel/index.d.ts",
|
|
64
68
|
"default": "./dist/code-panel/index.js"
|
|
@@ -118,6 +122,7 @@
|
|
|
118
122
|
},
|
|
119
123
|
"files": [
|
|
120
124
|
"dist",
|
|
125
|
+
"!dist/.build-stamp",
|
|
121
126
|
"bin",
|
|
122
127
|
"routes-src",
|
|
123
128
|
"virtual-modules.d.ts",
|
|
@@ -139,13 +144,13 @@
|
|
|
139
144
|
},
|
|
140
145
|
"peerDependencies": {
|
|
141
146
|
"@takazudo/zfb": "^2.20.3",
|
|
142
|
-
"@takazudo/zdtp": "^0.8.
|
|
147
|
+
"@takazudo/zdtp": "^0.8.5",
|
|
143
148
|
"@takazudo/zudo-doc": "^5.27.0",
|
|
144
149
|
"preact": "^10.29.8"
|
|
145
150
|
},
|
|
146
151
|
"devDependencies": {
|
|
147
|
-
"@takazudo/zdtp": "0.8.
|
|
148
|
-
"@takazudo/zfb": "2.
|
|
152
|
+
"@takazudo/zdtp": "0.8.5",
|
|
153
|
+
"@takazudo/zfb": "2.21.1",
|
|
149
154
|
"@takazudo/zudo-doc": "5.27.0",
|
|
150
155
|
"@testing-library/jest-dom": "^6.9.1",
|
|
151
156
|
"@testing-library/preact": "^3.2.4",
|
|
@@ -23,11 +23,11 @@ import type { JSX } from "preact";
|
|
|
23
23
|
import { useEffect } from "preact/hooks";
|
|
24
24
|
import { PreviewApp } from "@takazudo/zudo-sg/preview";
|
|
25
25
|
import { installIframeReceiver } from "@takazudo/zudo-sg/token-tweak";
|
|
26
|
-
import {
|
|
26
|
+
import { storyRegistry } from "./_registry.js";
|
|
27
27
|
|
|
28
28
|
export default function ConfiguredPreviewApp(): JSX.Element {
|
|
29
29
|
useEffect(() => installIframeReceiver(window), []);
|
|
30
|
-
return <PreviewApp registry={
|
|
30
|
+
return <PreviewApp registry={storyRegistry} />;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
ConfiguredPreviewApp.displayName = "ConfiguredPreviewApp";
|
package/routes-src/_registry.ts
CHANGED
|
@@ -1,13 +1,38 @@
|
|
|
1
1
|
// Sole importer of `virtual:zudo-sg-registry` (ADR docs/adr/styleguide-engine.md
|
|
2
|
-
// decision 10): builds the host
|
|
3
|
-
//
|
|
2
|
+
// decision 10): builds the host catalog once; every entrypoint imports
|
|
3
|
+
// `registry` from here, and the preview wrapper imports `storyRegistry`.
|
|
4
|
+
//
|
|
5
|
+
// The virtual module has the same three exports in both registry modes, so
|
|
6
|
+
// this file never branches on imports — only on `ctx.registryMode`. Descriptor
|
|
7
|
+
// validation runs at module evaluation, i.e. during the build.
|
|
4
8
|
|
|
5
|
-
import { storyExportOrder, storyModules } from "virtual:zudo-sg-registry";
|
|
6
|
-
import {
|
|
9
|
+
import { storyDescriptors, storyExportOrder, storyModules } from "virtual:zudo-sg-registry";
|
|
10
|
+
import {
|
|
11
|
+
catalogEntriesFromDescriptors,
|
|
12
|
+
catalogEntriesFromRegistry,
|
|
13
|
+
createCatalog,
|
|
14
|
+
createRegistry,
|
|
15
|
+
validateStoryDescriptors,
|
|
16
|
+
} from "@takazudo/zudo-sg/registry";
|
|
7
17
|
import { ctx } from "./_context.js";
|
|
8
18
|
|
|
9
|
-
|
|
19
|
+
// The detail-URL slug to reserve is the one the served preview document
|
|
20
|
+
// occupies: the host's `externalPreview` URL when set (the in-engine
|
|
21
|
+
// `componentsPreview` route is then not injected), else `componentsPreview`.
|
|
22
|
+
const collisionRoutes =
|
|
23
|
+
ctx.externalPreviewUrl ? { ...ctx.routes, componentsPreview: ctx.externalPreviewUrl } : ctx.routes;
|
|
24
|
+
|
|
25
|
+
/** Module-mode StoryModule registry (render closures, for the preview app). Empty in descriptor mode. */
|
|
26
|
+
export const storyRegistry = createRegistry(storyModules, {
|
|
10
27
|
categoryOrder: ctx.categoryOrder,
|
|
11
28
|
storyExportOrder,
|
|
12
|
-
routes:
|
|
29
|
+
routes: collisionRoutes,
|
|
13
30
|
});
|
|
31
|
+
|
|
32
|
+
/** The mode-neutral catalog every route, the nav and search read. */
|
|
33
|
+
export const registry =
|
|
34
|
+
ctx.registryMode === "descriptor"
|
|
35
|
+
? createCatalog(catalogEntriesFromDescriptors(validateStoryDescriptors(storyDescriptors, { routes: collisionRoutes })), {
|
|
36
|
+
categoryOrder: ctx.categoryOrder,
|
|
37
|
+
})
|
|
38
|
+
: createCatalog(catalogEntriesFromRegistry(storyRegistry), { categoryOrder: storyRegistry.categoryOrder });
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
// landing: category-grouped tiles, each carrying its component rendered
|
|
5
5
|
// INLINE server-side (no preview iframes), filtered client-side by the
|
|
6
6
|
// CatalogFilter island, inside the StyleguideLayout docs-section shell.
|
|
7
|
+
// Reads the mode-neutral `CatalogEntry` fields, so module and descriptor
|
|
8
|
+
// registries render through the same markup.
|
|
7
9
|
|
|
8
10
|
import type { JSX, VNode } from "preact";
|
|
9
11
|
import { Island } from "@takazudo/zfb";
|
|
10
|
-
import {
|
|
12
|
+
import { CatalogThumb, TILE_SIZE_RESTORE_SCRIPT } from "@takazudo/zudo-sg/catalog";
|
|
11
13
|
import { StyleguideLayout } from "@takazudo/zudo-sg/chrome";
|
|
12
14
|
import { OVERVIEW_SLUG } from "@takazudo/zudo-sg/registry";
|
|
13
15
|
import { CatalogFilter } from "@takazudo/zudo-sg/search";
|
|
@@ -44,13 +46,18 @@ export default function ComponentsIndexRoute(): JSX.Element {
|
|
|
44
46
|
<header class="mb-vsp-lg max-w-[56rem]">
|
|
45
47
|
<h1 class="text-heading font-bold mb-vsp-2xs">{ctx.catalog.title}</h1>
|
|
46
48
|
<p class="text-[color:var(--sg-muted)] text-small" data-sg-catalog-intro>
|
|
47
|
-
{ctx.catalog.intro ?? (
|
|
49
|
+
{ctx.catalog.intro ?? (ctx.registryMode === "descriptor" ? (
|
|
50
|
+
<>
|
|
51
|
+
{total} components{ctx.uiPackageName ? <> from <code>{ctx.uiPackageName}</code></> : null}, listed from
|
|
52
|
+
the host's story descriptors.
|
|
53
|
+
</>
|
|
54
|
+
) : (
|
|
48
55
|
<>
|
|
49
56
|
{total} components{ctx.uiPackageName ? <> from <code>{ctx.uiPackageName}</code></> : null},
|
|
50
57
|
discovered from their <code>.stories.tsx</code> files. Each tile previews the
|
|
51
58
|
component's first variant, rendered here on the server.
|
|
52
59
|
</>
|
|
53
|
-
)}
|
|
60
|
+
))}
|
|
54
61
|
</p>
|
|
55
62
|
</header>
|
|
56
63
|
|
|
@@ -63,19 +70,19 @@ export default function ComponentsIndexRoute(): JSX.Element {
|
|
|
63
70
|
<div class="sg-grid">
|
|
64
71
|
{group.stories.map((story) => (
|
|
65
72
|
<div class="sg-tile" data-sg-tile>
|
|
66
|
-
<
|
|
73
|
+
<CatalogThumb entry={story} base={ctx.base} />
|
|
67
74
|
<a
|
|
68
75
|
href={withBase(componentHref(ctx.routes, story.slug))}
|
|
69
76
|
class="sg-tile-meta"
|
|
70
77
|
data-sg-card
|
|
71
|
-
data-name={story.
|
|
78
|
+
data-name={story.title.toLowerCase()}
|
|
72
79
|
data-category={group.category}
|
|
73
|
-
data-keywords={[story.
|
|
80
|
+
data-keywords={[story.title, story.description, story.category ?? ""]
|
|
74
81
|
.join(" ")
|
|
75
82
|
.toLowerCase()}
|
|
76
83
|
>
|
|
77
|
-
<h3 class="sg-tile-title">{story.
|
|
78
|
-
<p class="sg-tile-desc">{story.
|
|
84
|
+
<h3 class="sg-tile-title">{story.title}</h3>
|
|
85
|
+
<p class="sg-tile-desc">{story.description}</p>
|
|
79
86
|
<p class="sg-tile-count">
|
|
80
87
|
{story.variants.length} variant
|
|
81
88
|
{story.variants.length === 1 ? "" : "s"}
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
// `:root[data-sg-preview-doc]`, so the preview world's tokens beat the host
|
|
15
15
|
// bundle zfb injects into every route. This entrypoint links assets only; it
|
|
16
16
|
// never calls plugin helpers.
|
|
17
|
+
//
|
|
18
|
+
// Descriptor mode never reaches this file: `resolveRoutesPluginOptions`
|
|
19
|
+
// (issue #884) requires an `externalPreview` in descriptor mode, which
|
|
20
|
+
// implies `componentsPreview` disabled — the route plugin never injects this
|
|
21
|
+
// entrypoint there, so it needs no descriptor-mode branch of its own.
|
|
17
22
|
|
|
18
23
|
import type { JSX, VNode } from "preact";
|
|
19
24
|
import { Island } from "@takazudo/zfb";
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
// base-prefixed preview URL (VariantFrame builds iframe `src` from it; the
|
|
10
10
|
// code panel's CSS injection selects iframes by it). The optional co-located
|
|
11
11
|
// component MDX doc renders as a trailing section.
|
|
12
|
+
//
|
|
13
|
+
// Descriptor-mode entries carry no story source, so they get no CodePanel
|
|
14
|
+
// island, no component doc and no live-demo link — only the header and the
|
|
15
|
+
// workbench, built from the mode-neutral `CatalogEntry` fields.
|
|
12
16
|
|
|
13
17
|
import type { JSX, VNode } from "preact";
|
|
14
18
|
import { Island } from "@takazudo/zfb";
|
|
@@ -47,9 +51,12 @@ export function paths(): Array<{ params: { slug: string }; props: SlugProps }> {
|
|
|
47
51
|
export default function ComponentsSlugRoute(props: SlugProps & { params: { slug: string } }): JSX.Element {
|
|
48
52
|
const slug = props.slug ?? props.params.slug;
|
|
49
53
|
const entry = registry.getStoryBySlug(slug);
|
|
50
|
-
|
|
54
|
+
// `externalPreviewUrl` (issue #884) replaces the in-engine preview route
|
|
55
|
+
// when the host serves its own preview document — same-shape `previewUrl`
|
|
56
|
+
// either way, so DetailWorkbench and the code panel need no branching.
|
|
57
|
+
const previewUrl = withBase(ctx.externalPreviewUrl ?? ctx.routes.componentsPreview);
|
|
51
58
|
const chrome = chromeProps({
|
|
52
|
-
pageTitle: entry ? entry.
|
|
59
|
+
pageTitle: entry ? entry.title : "Not found",
|
|
53
60
|
path: componentHref(ctx.routes, slug),
|
|
54
61
|
activeSlug: slug,
|
|
55
62
|
});
|
|
@@ -62,36 +69,58 @@ export default function ComponentsSlugRoute(props: SlugProps & { params: { slug:
|
|
|
62
69
|
);
|
|
63
70
|
}
|
|
64
71
|
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
72
|
+
const storyEntry = entry.source === "module" ? entry.storyEntry : undefined;
|
|
73
|
+
|
|
74
|
+
let codePanel: VNode | null = null;
|
|
75
|
+
if (storyEntry) {
|
|
76
|
+
const panelVariants: CodePanelVariant[] = storyEntry.variants.map((v) => ({
|
|
77
|
+
exportName: v.exportName,
|
|
78
|
+
name: v.name,
|
|
79
|
+
source: v.story.source ?? storyEntry.meta.usage,
|
|
80
|
+
}));
|
|
81
|
+
const codePanelIsland = Island({
|
|
82
|
+
when: "load",
|
|
83
|
+
children: (
|
|
84
|
+
<CodePanel
|
|
85
|
+
storyTitle={entry.title}
|
|
86
|
+
variants={panelVariants}
|
|
87
|
+
previewUrl={previewUrl}
|
|
88
|
+
slug={slug}
|
|
89
|
+
/>
|
|
90
|
+
),
|
|
91
|
+
}) as unknown as VNode;
|
|
92
|
+
codePanel = (
|
|
93
|
+
<aside id="sg-code-panel" class="sg-code-panel" aria-label="Code panel">
|
|
94
|
+
<div
|
|
95
|
+
class="sg-code-panel-resizer"
|
|
96
|
+
data-sg-code-panel-resizer
|
|
97
|
+
role="separator"
|
|
98
|
+
aria-label="Resize code panel"
|
|
99
|
+
aria-orientation="vertical"
|
|
100
|
+
tabindex={0}
|
|
101
|
+
/>
|
|
102
|
+
{codePanelIsland}
|
|
103
|
+
</aside>
|
|
104
|
+
) as unknown as VNode;
|
|
105
|
+
}
|
|
87
106
|
|
|
88
107
|
// The collection of the components root this story's registry key belongs to
|
|
89
108
|
// (`./<keyPrefix>/<dir>/<name>.stories.tsx` → `<dir>/<name>`).
|
|
90
|
-
const docRef = resolveComponentDoc(
|
|
109
|
+
const docRef = storyEntry ? resolveComponentDoc(storyEntry.path, ctx.componentDocs) : null;
|
|
91
110
|
const doc = docRef ? getEntry(docRef.collection, docRef.slug) : undefined;
|
|
111
|
+
const previewRoute = storyEntry?.meta.previewRoute;
|
|
92
112
|
|
|
93
113
|
// `when: "load"`: the toolbar is the page's primary control surface; each
|
|
94
114
|
// iframe is `loading="lazy"`, so below-the-fold previews still defer.
|
|
115
|
+
//
|
|
116
|
+
// The engine's own detail route opts the two toolbar groups that default OFF
|
|
117
|
+
// (#883, issue #872) back in explicitly, matching what this route actually
|
|
118
|
+
// mounts: `codePanel` only when `storyEntry` exists — module mode, where the
|
|
119
|
+
// CodePanel island above is mounted (descriptor-mode entries get none, S2b) —
|
|
120
|
+
// and `tokenPanel` following `ctx.previewTokenPanel`, so the button is absent
|
|
121
|
+
// rather than dead when no `zdtpApplyProxy.tabsModule` is wired.
|
|
122
|
+
// `selection`/`theme` are passed at their pre-#883 defaults, unconditionally,
|
|
123
|
+
// to keep this route's behavior spelled out rather than implicit.
|
|
95
124
|
const workbench = Island({
|
|
96
125
|
when: "load",
|
|
97
126
|
children: (
|
|
@@ -101,8 +130,11 @@ export default function ComponentsSlugRoute(props: SlugProps & { params: { slug:
|
|
|
101
130
|
variants={entry.variants.map((v) => ({
|
|
102
131
|
exportName: v.exportName,
|
|
103
132
|
name: v.name,
|
|
104
|
-
controls: v.
|
|
133
|
+
controls: v.controls,
|
|
105
134
|
}))}
|
|
135
|
+
selection={{ mode: "all" }}
|
|
136
|
+
theme={{ mode: "toolbar" }}
|
|
137
|
+
toolbar={{ codePanel: Boolean(storyEntry), tokenPanel: ctx.previewTokenPanel }}
|
|
106
138
|
/>
|
|
107
139
|
),
|
|
108
140
|
}) as unknown as VNode;
|
|
@@ -111,18 +143,18 @@ export default function ComponentsSlugRoute(props: SlugProps & { params: { slug:
|
|
|
111
143
|
<StyleguideLayout {...chrome} activeSlug={slug} codePanel={codePanel} contentWide>
|
|
112
144
|
<div>
|
|
113
145
|
<header class="mb-vsp-lg max-w-[56rem]">
|
|
114
|
-
<h1 class="text-2xl font-bold text-[color:var(--sg-fg)]">{entry.
|
|
115
|
-
<p class="mt-vsp-xs text-[color:var(--sg-muted)]">{entry.
|
|
146
|
+
<h1 class="text-2xl font-bold text-[color:var(--sg-fg)]">{entry.title}</h1>
|
|
147
|
+
<p class="mt-vsp-xs text-[color:var(--sg-muted)]">{entry.description}</p>
|
|
116
148
|
<span class="mt-vsp-xs inline-block rounded-full border border-[color:var(--sg-border)] px-hsp-sm py-vsp-3xs text-caption leading-normal text-[color:var(--sg-muted)]">
|
|
117
|
-
{entry.
|
|
149
|
+
{entry.category}
|
|
118
150
|
</span>
|
|
119
151
|
</header>
|
|
120
152
|
|
|
121
|
-
{
|
|
153
|
+
{previewRoute && (
|
|
122
154
|
<section class="mb-vsp-xl max-w-[56rem] rounded-md border border-[color:var(--sg-border)] bg-[var(--sg-surface-2)] p-hsp-md">
|
|
123
155
|
<h2 class="mb-vsp-2xs text-small font-semibold uppercase tracking-wide text-[color:var(--sg-muted)]">Live demo</h2>
|
|
124
156
|
<a
|
|
125
|
-
href={withBase(
|
|
157
|
+
href={withBase(previewRoute)}
|
|
126
158
|
class="text-sm font-medium text-[color:var(--sg-accent)] underline underline-offset-2"
|
|
127
159
|
>
|
|
128
160
|
Open live demo →
|
package/routes-src/tokens.tsx
CHANGED
|
@@ -39,10 +39,15 @@ function buildDashboardChromeStyle(): Record<string, string> | undefined {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export default function TokensRoute(): JSX.Element {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
// Gated on `ctx.previewTokenPanel` (issue #872): with no `zdtpApplyProxy.tabsModule`
|
|
43
|
+
// wired, `PreviewTokenPanelBootstrap` no-ops and this button would dispatch to
|
|
44
|
+
// nothing.
|
|
45
|
+
const previewTokensButton = ctx.previewTokenPanel
|
|
46
|
+
? (Island({
|
|
47
|
+
when: "load",
|
|
48
|
+
children: <PreviewTokensButton />,
|
|
49
|
+
}) as unknown as VNode)
|
|
50
|
+
: null;
|
|
46
51
|
|
|
47
52
|
return (
|
|
48
53
|
<StyleguideLayout
|
package/styles.css
CHANGED
|
@@ -495,6 +495,16 @@
|
|
|
495
495
|
transform-origin: top left;
|
|
496
496
|
}
|
|
497
497
|
|
|
498
|
+
/* Descriptor-mode image thumbnail (epic #879, E3): a pre-captured snapshot,
|
|
499
|
+
* not a live layout, so it fills the tile frame directly rather than going
|
|
500
|
+
* through the virtual-viewport transform above. */
|
|
501
|
+
.sg-thumb-img {
|
|
502
|
+
display: block;
|
|
503
|
+
width: 100%;
|
|
504
|
+
height: 100%;
|
|
505
|
+
object-fit: cover;
|
|
506
|
+
}
|
|
507
|
+
|
|
498
508
|
/* Documented per-component opt-out (THUMB_OPT_OUTS): a static, legible note in
|
|
499
509
|
* place of a rendered component, at tile scale rather than virtual scale. */
|
|
500
510
|
.sg-thumb-note {
|
package/virtual-modules.d.ts
CHANGED
|
@@ -18,6 +18,12 @@ declare module "virtual:zudo-sg-context" {
|
|
|
18
18
|
declare module "virtual:zudo-sg-registry" {
|
|
19
19
|
export const storyModules: Record<string, import("@takazudo/zudo-sg/stories").StoryModule>;
|
|
20
20
|
export const storyExportOrder: Record<string, string[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Descriptor mode: the host module's raw `storyDescriptors` (validated by
|
|
23
|
+
* `_registry.ts` at build time). Module mode: `[]`. Both other names are `{}`
|
|
24
|
+
* in descriptor mode.
|
|
25
|
+
*/
|
|
26
|
+
export const storyDescriptors: unknown;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
declare module "virtual:zudo-sg-tokens" {
|