kss-modern 1.3.0 → 1.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/README.md +1 -1
- package/dist/node/lib/index.d.mts +81 -11
- package/dist/node/lib/index.d.ts +81 -11
- package/dist/node/lib/index.mjs +68 -29
- package/dist/styleguide-assets/.vite/manifest.json +35 -11
- package/dist/styleguide-assets/{a11y-report-DJQyYaLp.js → a11y-report-BFnWMaWr.js} +3 -3
- package/dist/styleguide-assets/{fullpage-B7IV3eSt.js → fullpage-DSD6-0qF.js} +129 -128
- package/dist/styleguide-assets/global-theme-select-DCnqGEUr.js +7 -0
- package/dist/styleguide-assets/{html-validator-Cp2OkhS9.js → html-validator-sgeZtEeH.js} +2 -2
- package/dist/styleguide-assets/{preview-CWqxR9nN.js → preview-CCjPdowU.js} +8 -6
- package/dist/styleguide-assets/preview-theme-DIgnwL5g.js +57 -0
- package/dist/styleguide-assets/{section-previews-V4M5aSu6.js → section-previews-CnlrC8Gz.js} +3 -3
- package/dist/styleguide-assets/section-theme-select-CVOwp7VZ.js +12 -0
- package/dist/styleguide-assets/theme-document-CtY2qFyJ.js +12 -0
- package/package.json +1 -1
- package/dist/styleguide-assets/section-theme-select-ygaSXIuK.js +0 -48
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ A modern, KSS-compatible styleguide generator. Parses KSS comment blocks from CS
|
|
|
6
6
|
|
|
7
7
|
- KSS-compatible comment parsing from CSS/SCSS files
|
|
8
8
|
- Live component previews with modifier variants
|
|
9
|
-
-
|
|
9
|
+
- Theme dropdowns — a global one in the header (`previewThemes` option) and per-section ones (`Themes:`) — switch previews between the default and themed views, optionally loading a stylesheet per theme
|
|
10
10
|
- Pug template support via worker thread pool
|
|
11
11
|
- Color palette and icon gallery documentation
|
|
12
12
|
- Figma embed integration with light/dark theme sync
|
|
@@ -99,7 +99,37 @@ declare function createLogger(tag?: string): Logger;
|
|
|
99
99
|
/** Shared styleguide logger instance. */
|
|
100
100
|
declare const logger: Logger;
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
/** The styleguide's accent colour: one value, or one per color scheme. */
|
|
103
|
+
type StyleguideBrandColor = string | {
|
|
104
|
+
light: string;
|
|
105
|
+
dark: string;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* One entry of the header's **Theme** dropdown — an alternative theme context the previews can be
|
|
109
|
+
* shown in, not a color scheme (that is the separate System/Light/Dark toggle).
|
|
110
|
+
*/
|
|
111
|
+
interface PreviewTheme {
|
|
112
|
+
/**
|
|
113
|
+
* The theme's class or class list — `'theme-midnight'`, `'.theme-midnight.compact'` — added to
|
|
114
|
+
* the `<html>` of every preview iframe while the theme is selected.
|
|
115
|
+
*/
|
|
116
|
+
value: string;
|
|
117
|
+
/** The label shown in the dropdown. */
|
|
118
|
+
label: string;
|
|
119
|
+
/**
|
|
120
|
+
* Stylesheets loaded into a preview while this theme is selected, layered on top of
|
|
121
|
+
* `html.assets.css` (they are never replaced). Every preview document carries a `<link>` for
|
|
122
|
+
* each of these from the start — inert until the theme is selected — so switching costs no
|
|
123
|
+
* request and shows no flash.
|
|
124
|
+
*
|
|
125
|
+
* The CSS is keyed on the theme's class list, so a section's `Themes:` entry gets the same
|
|
126
|
+
* stylesheets as soon as it resolves to the same classes (`.theme-midnight` here and in the
|
|
127
|
+
* KSS comment); a section theme that matches no configured entry simply loads no extra CSS.
|
|
128
|
+
*/
|
|
129
|
+
css?: string[];
|
|
130
|
+
}
|
|
131
|
+
/** Every styleguide option except the accent colour, which carries the deprecated `theme` alias. */
|
|
132
|
+
interface StyleguideOptions {
|
|
103
133
|
mode: 'development' | 'production';
|
|
104
134
|
outDir: string;
|
|
105
135
|
contentDir: `${string}/`;
|
|
@@ -108,10 +138,21 @@ interface StyleguideConfiguration {
|
|
|
108
138
|
launchInEditor?: boolean | {
|
|
109
139
|
rootDir: string;
|
|
110
140
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
141
|
+
/** The themes offered by the header's **Theme** dropdown. */
|
|
142
|
+
previewThemes?: PreviewTheme[];
|
|
143
|
+
/** @deprecated Renamed to `previewThemes`, to tell it apart from `brandColor`. */
|
|
144
|
+
themes?: PreviewTheme[];
|
|
145
|
+
/**
|
|
146
|
+
* Reload a preview iframe when its theme changes, instead of swapping the theme's classes and
|
|
147
|
+
* stylesheets into the loaded document.
|
|
148
|
+
*
|
|
149
|
+
* Off by default: the in-place swap is instant and keeps the preview's state. Turn it on when a
|
|
150
|
+
* preview's own JavaScript reads styling at startup — components that measure, canvas/chart
|
|
151
|
+
* rendering, web components that snapshot tokens on connect — and so needs to run again against
|
|
152
|
+
* the new theme. A preview is reloaded only when the visitor actually changes a theme, never on
|
|
153
|
+
* the initial page load.
|
|
154
|
+
*/
|
|
155
|
+
reloadPreviewsOnThemeChange?: boolean;
|
|
115
156
|
logoSignet?: {
|
|
116
157
|
href: string;
|
|
117
158
|
} | {
|
|
@@ -135,6 +176,35 @@ interface StyleguideConfiguration {
|
|
|
135
176
|
ogImage?: (section: in2Section) => string;
|
|
136
177
|
};
|
|
137
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* The styleguide configuration. The accent colour is required under one of its two names:
|
|
181
|
+
* `brandColor`, or the deprecated `theme`.
|
|
182
|
+
*
|
|
183
|
+
* `theme` never had anything to do with the preview themes; it is the colour behind
|
|
184
|
+
* `<meta name="theme-color">`, the generated favicons and the styleguide UI's highlight — hence
|
|
185
|
+
* the rename, which also ends its collision with `themes` / `previewThemes`.
|
|
186
|
+
*/
|
|
187
|
+
type StyleguideConfiguration = (StyleguideOptions & {
|
|
188
|
+
brandColor: StyleguideBrandColor;
|
|
189
|
+
theme?: never;
|
|
190
|
+
}) | (StyleguideOptions & {
|
|
191
|
+
/** @deprecated Renamed to `brandColor` — this is the accent colour, not a preview theme. */
|
|
192
|
+
theme: StyleguideBrandColor;
|
|
193
|
+
brandColor?: never;
|
|
194
|
+
});
|
|
195
|
+
/**
|
|
196
|
+
* A configuration with the deprecated aliases resolved away. Everything past
|
|
197
|
+
* {@link resolveConfiguration} works with this, so no internal code has to know about the old names.
|
|
198
|
+
*/
|
|
199
|
+
interface ResolvedStyleguideConfiguration extends StyleguideOptions {
|
|
200
|
+
brandColor: StyleguideBrandColor;
|
|
201
|
+
previewThemes: PreviewTheme[];
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Resolve the deprecated `theme` / `themes` aliases into `brandColor` / `previewThemes`, warning
|
|
205
|
+
* once per option. Idempotent, so the public entry points can each call it without re-warning.
|
|
206
|
+
*/
|
|
207
|
+
declare function resolveConfiguration(config: StyleguideConfiguration | ResolvedStyleguideConfiguration): ResolvedStyleguideConfiguration;
|
|
138
208
|
interface StyleguideBuildOutput {
|
|
139
209
|
errors?: {
|
|
140
210
|
overwrittenSectionsIds?: string[];
|
|
@@ -188,7 +258,7 @@ declare function parseStyleguide(contentDir: StyleguideConfiguration['contentDir
|
|
|
188
258
|
* Full build: parse, compile every section, and write all fullpage + preview files. Returns the
|
|
189
259
|
* reusable context so the watcher can perform targeted incremental rebuilds afterwards.
|
|
190
260
|
*/
|
|
191
|
-
declare function buildAll(
|
|
261
|
+
declare function buildAll(input: StyleguideConfiguration | ResolvedStyleguideConfiguration): Promise<{
|
|
192
262
|
errors: StyleguideBuildOutput['errors'];
|
|
193
263
|
context: StyleguideContext;
|
|
194
264
|
}>;
|
|
@@ -202,7 +272,7 @@ declare function buildStyleguide(config: StyleguideConfiguration): Promise<Style
|
|
|
202
272
|
* (cache-aware), re-resolve <insert-markup>, and rewrite just their fullpage + owning preview files.
|
|
203
273
|
* `changedSectionIds` are the sections whose pug (or a dependency) changed.
|
|
204
274
|
*/
|
|
205
|
-
declare function rebuildSections(config:
|
|
275
|
+
declare function rebuildSections(config: ResolvedStyleguideConfiguration, context: StyleguideContext, changedSectionIds: Iterable<string>): Promise<void>;
|
|
206
276
|
/**
|
|
207
277
|
* What triggered a {@link watchStyleguide} rebuild:
|
|
208
278
|
* - `structural` — a CSS/SCSS/Markdown edit that can change section structure; the whole styleguide is rebuilt.
|
|
@@ -217,11 +287,11 @@ type StyleguideChange = {
|
|
|
217
287
|
};
|
|
218
288
|
/**
|
|
219
289
|
* Builds the styleguide and watches for changes
|
|
220
|
-
* @param
|
|
290
|
+
* @param input - The configuration for the styleguide
|
|
221
291
|
* @param onChange - Optional callback invoked after each rebuild, with the change that triggered it
|
|
222
292
|
* @param onError - Optional callback function to call when an error occurs while building the styleguide
|
|
223
293
|
*/
|
|
224
|
-
declare function watchStyleguide(
|
|
294
|
+
declare function watchStyleguide(input: StyleguideConfiguration | ResolvedStyleguideConfiguration, onChange?: (change: StyleguideChange) => void, onError?: (errorData: StyleguideBuildOutput['errors']) => void): Promise<void>;
|
|
225
295
|
|
|
226
|
-
export { buildAll, buildStyleguide, createLogger, logger, parseStyleguide, rebuildSections, watchStyleguide };
|
|
227
|
-
export type { LogBox, Logger, StyleguideChange, StyleguideConfiguration, StyleguideContext };
|
|
296
|
+
export { buildAll, buildStyleguide, createLogger, logger, parseStyleguide, rebuildSections, resolveConfiguration, watchStyleguide };
|
|
297
|
+
export type { LogBox, Logger, PreviewTheme, ResolvedStyleguideConfiguration, StyleguideBrandColor, StyleguideChange, StyleguideConfiguration, StyleguideContext };
|
package/dist/node/lib/index.d.ts
CHANGED
|
@@ -99,7 +99,37 @@ declare function createLogger(tag?: string): Logger;
|
|
|
99
99
|
/** Shared styleguide logger instance. */
|
|
100
100
|
declare const logger: Logger;
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
/** The styleguide's accent colour: one value, or one per color scheme. */
|
|
103
|
+
type StyleguideBrandColor = string | {
|
|
104
|
+
light: string;
|
|
105
|
+
dark: string;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* One entry of the header's **Theme** dropdown — an alternative theme context the previews can be
|
|
109
|
+
* shown in, not a color scheme (that is the separate System/Light/Dark toggle).
|
|
110
|
+
*/
|
|
111
|
+
interface PreviewTheme {
|
|
112
|
+
/**
|
|
113
|
+
* The theme's class or class list — `'theme-midnight'`, `'.theme-midnight.compact'` — added to
|
|
114
|
+
* the `<html>` of every preview iframe while the theme is selected.
|
|
115
|
+
*/
|
|
116
|
+
value: string;
|
|
117
|
+
/** The label shown in the dropdown. */
|
|
118
|
+
label: string;
|
|
119
|
+
/**
|
|
120
|
+
* Stylesheets loaded into a preview while this theme is selected, layered on top of
|
|
121
|
+
* `html.assets.css` (they are never replaced). Every preview document carries a `<link>` for
|
|
122
|
+
* each of these from the start — inert until the theme is selected — so switching costs no
|
|
123
|
+
* request and shows no flash.
|
|
124
|
+
*
|
|
125
|
+
* The CSS is keyed on the theme's class list, so a section's `Themes:` entry gets the same
|
|
126
|
+
* stylesheets as soon as it resolves to the same classes (`.theme-midnight` here and in the
|
|
127
|
+
* KSS comment); a section theme that matches no configured entry simply loads no extra CSS.
|
|
128
|
+
*/
|
|
129
|
+
css?: string[];
|
|
130
|
+
}
|
|
131
|
+
/** Every styleguide option except the accent colour, which carries the deprecated `theme` alias. */
|
|
132
|
+
interface StyleguideOptions {
|
|
103
133
|
mode: 'development' | 'production';
|
|
104
134
|
outDir: string;
|
|
105
135
|
contentDir: `${string}/`;
|
|
@@ -108,10 +138,21 @@ interface StyleguideConfiguration {
|
|
|
108
138
|
launchInEditor?: boolean | {
|
|
109
139
|
rootDir: string;
|
|
110
140
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
141
|
+
/** The themes offered by the header's **Theme** dropdown. */
|
|
142
|
+
previewThemes?: PreviewTheme[];
|
|
143
|
+
/** @deprecated Renamed to `previewThemes`, to tell it apart from `brandColor`. */
|
|
144
|
+
themes?: PreviewTheme[];
|
|
145
|
+
/**
|
|
146
|
+
* Reload a preview iframe when its theme changes, instead of swapping the theme's classes and
|
|
147
|
+
* stylesheets into the loaded document.
|
|
148
|
+
*
|
|
149
|
+
* Off by default: the in-place swap is instant and keeps the preview's state. Turn it on when a
|
|
150
|
+
* preview's own JavaScript reads styling at startup — components that measure, canvas/chart
|
|
151
|
+
* rendering, web components that snapshot tokens on connect — and so needs to run again against
|
|
152
|
+
* the new theme. A preview is reloaded only when the visitor actually changes a theme, never on
|
|
153
|
+
* the initial page load.
|
|
154
|
+
*/
|
|
155
|
+
reloadPreviewsOnThemeChange?: boolean;
|
|
115
156
|
logoSignet?: {
|
|
116
157
|
href: string;
|
|
117
158
|
} | {
|
|
@@ -135,6 +176,35 @@ interface StyleguideConfiguration {
|
|
|
135
176
|
ogImage?: (section: in2Section) => string;
|
|
136
177
|
};
|
|
137
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* The styleguide configuration. The accent colour is required under one of its two names:
|
|
181
|
+
* `brandColor`, or the deprecated `theme`.
|
|
182
|
+
*
|
|
183
|
+
* `theme` never had anything to do with the preview themes; it is the colour behind
|
|
184
|
+
* `<meta name="theme-color">`, the generated favicons and the styleguide UI's highlight — hence
|
|
185
|
+
* the rename, which also ends its collision with `themes` / `previewThemes`.
|
|
186
|
+
*/
|
|
187
|
+
type StyleguideConfiguration = (StyleguideOptions & {
|
|
188
|
+
brandColor: StyleguideBrandColor;
|
|
189
|
+
theme?: never;
|
|
190
|
+
}) | (StyleguideOptions & {
|
|
191
|
+
/** @deprecated Renamed to `brandColor` — this is the accent colour, not a preview theme. */
|
|
192
|
+
theme: StyleguideBrandColor;
|
|
193
|
+
brandColor?: never;
|
|
194
|
+
});
|
|
195
|
+
/**
|
|
196
|
+
* A configuration with the deprecated aliases resolved away. Everything past
|
|
197
|
+
* {@link resolveConfiguration} works with this, so no internal code has to know about the old names.
|
|
198
|
+
*/
|
|
199
|
+
interface ResolvedStyleguideConfiguration extends StyleguideOptions {
|
|
200
|
+
brandColor: StyleguideBrandColor;
|
|
201
|
+
previewThemes: PreviewTheme[];
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Resolve the deprecated `theme` / `themes` aliases into `brandColor` / `previewThemes`, warning
|
|
205
|
+
* once per option. Idempotent, so the public entry points can each call it without re-warning.
|
|
206
|
+
*/
|
|
207
|
+
declare function resolveConfiguration(config: StyleguideConfiguration | ResolvedStyleguideConfiguration): ResolvedStyleguideConfiguration;
|
|
138
208
|
interface StyleguideBuildOutput {
|
|
139
209
|
errors?: {
|
|
140
210
|
overwrittenSectionsIds?: string[];
|
|
@@ -188,7 +258,7 @@ declare function parseStyleguide(contentDir: StyleguideConfiguration['contentDir
|
|
|
188
258
|
* Full build: parse, compile every section, and write all fullpage + preview files. Returns the
|
|
189
259
|
* reusable context so the watcher can perform targeted incremental rebuilds afterwards.
|
|
190
260
|
*/
|
|
191
|
-
declare function buildAll(
|
|
261
|
+
declare function buildAll(input: StyleguideConfiguration | ResolvedStyleguideConfiguration): Promise<{
|
|
192
262
|
errors: StyleguideBuildOutput['errors'];
|
|
193
263
|
context: StyleguideContext;
|
|
194
264
|
}>;
|
|
@@ -202,7 +272,7 @@ declare function buildStyleguide(config: StyleguideConfiguration): Promise<Style
|
|
|
202
272
|
* (cache-aware), re-resolve <insert-markup>, and rewrite just their fullpage + owning preview files.
|
|
203
273
|
* `changedSectionIds` are the sections whose pug (or a dependency) changed.
|
|
204
274
|
*/
|
|
205
|
-
declare function rebuildSections(config:
|
|
275
|
+
declare function rebuildSections(config: ResolvedStyleguideConfiguration, context: StyleguideContext, changedSectionIds: Iterable<string>): Promise<void>;
|
|
206
276
|
/**
|
|
207
277
|
* What triggered a {@link watchStyleguide} rebuild:
|
|
208
278
|
* - `structural` — a CSS/SCSS/Markdown edit that can change section structure; the whole styleguide is rebuilt.
|
|
@@ -217,11 +287,11 @@ type StyleguideChange = {
|
|
|
217
287
|
};
|
|
218
288
|
/**
|
|
219
289
|
* Builds the styleguide and watches for changes
|
|
220
|
-
* @param
|
|
290
|
+
* @param input - The configuration for the styleguide
|
|
221
291
|
* @param onChange - Optional callback invoked after each rebuild, with the change that triggered it
|
|
222
292
|
* @param onError - Optional callback function to call when an error occurs while building the styleguide
|
|
223
293
|
*/
|
|
224
|
-
declare function watchStyleguide(
|
|
294
|
+
declare function watchStyleguide(input: StyleguideConfiguration | ResolvedStyleguideConfiguration, onChange?: (change: StyleguideChange) => void, onError?: (errorData: StyleguideBuildOutput['errors']) => void): Promise<void>;
|
|
225
295
|
|
|
226
|
-
export { buildAll, buildStyleguide, createLogger, logger, parseStyleguide, rebuildSections, watchStyleguide };
|
|
227
|
-
export type { LogBox, Logger, StyleguideChange, StyleguideConfiguration, StyleguideContext };
|
|
296
|
+
export { buildAll, buildStyleguide, createLogger, logger, parseStyleguide, rebuildSections, resolveConfiguration, watchStyleguide };
|
|
297
|
+
export type { LogBox, Logger, PreviewTheme, ResolvedStyleguideConfiguration, StyleguideBrandColor, StyleguideChange, StyleguideConfiguration, StyleguideContext };
|
package/dist/node/lib/index.mjs
CHANGED
|
@@ -1353,6 +1353,7 @@ async function generateFullPageFile(data) {
|
|
|
1353
1353
|
const computedStyleTags = data.css.filter((entry) => entry.type !== "overwriteStyleguide").map((css) => {
|
|
1354
1354
|
return `<link rel="stylesheet" type="text/css" href="${css.src}">`;
|
|
1355
1355
|
}).join("\n");
|
|
1356
|
+
const computedThemeStyleTags = (data.previewThemes ?? []).flatMap((theme) => (theme.css ?? []).map((src) => ({ src, classList: themeClassList(theme.value) }))).filter((entry) => entry.classList).map((entry) => `<link rel="stylesheet" type="text/css" href="${entry.src}" media="not all" data-theme-css="${sanitizeSpecialCharacters(entry.classList)}">`).join("\n");
|
|
1356
1357
|
const content = `
|
|
1357
1358
|
<!DOCTYPE html>
|
|
1358
1359
|
<html lang="${data.page.lang}"${data.page.htmlclass ? ` class="scroll-smooth ${data.page.htmlclass}"` : ""} data-styleguide-dark-mode="${supportsDarkMode}">
|
|
@@ -1364,12 +1365,13 @@ async function generateFullPageFile(data) {
|
|
|
1364
1365
|
<meta name="generator" content="styleguide">
|
|
1365
1366
|
<link rel="icon" type="image/svg+xml" href="/styleguide-assets/favicon/fullpage.svg">
|
|
1366
1367
|
${data.ogImageUrl ? `<meta property="og:image" content="${data.ogImageUrl}">` : ""}
|
|
1367
|
-
${typeof data.
|
|
1368
|
-
<meta name="theme-color" media="(prefers-color-scheme: light)" content="${data.
|
|
1369
|
-
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="${data.
|
|
1370
|
-
` : `<meta name="theme-color" content="${data.
|
|
1371
|
-
<script type="module" src="/styleguide-assets/fullpage-
|
|
1368
|
+
${typeof data.brandColor === "object" && "dark" in data.brandColor && "light" in data.brandColor ? `
|
|
1369
|
+
<meta name="theme-color" media="(prefers-color-scheme: light)" content="${data.brandColor.light}">
|
|
1370
|
+
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="${data.brandColor.dark}">
|
|
1371
|
+
` : `<meta name="theme-color" content="${data.brandColor}">`}
|
|
1372
|
+
<script type="module" src="/styleguide-assets/fullpage-DSD6-0qF.js"><\/script>
|
|
1372
1373
|
${computedStyleTags}
|
|
1374
|
+
${computedThemeStyleTags}
|
|
1373
1375
|
</head>
|
|
1374
1376
|
<body${data.page.bodyclass ? ` class="${data.page.bodyclass}"` : ""}>
|
|
1375
1377
|
${data.html}
|
|
@@ -1435,6 +1437,7 @@ function getHeaderHtml(config) {
|
|
|
1435
1437
|
</button>
|
|
1436
1438
|
|
|
1437
1439
|
<div class="flex gap-4">
|
|
1440
|
+
${config.previewThemes.length > 0 ? renderGlobalThemeSelect(config.previewThemes) : ""}
|
|
1438
1441
|
${config.mode === "development" && config.launchInEditor ? `
|
|
1439
1442
|
<form class="hidden editor-select md:block">
|
|
1440
1443
|
<fieldset class="flex items-center rounded-3xl border border-styleguide-border">
|
|
@@ -1612,19 +1615,19 @@ function renderTab(data, aside = "") {
|
|
|
1612
1615
|
</div>
|
|
1613
1616
|
`;
|
|
1614
1617
|
}
|
|
1615
|
-
function
|
|
1616
|
-
const
|
|
1618
|
+
function renderThemeSelectControl(id, themes, scope) {
|
|
1619
|
+
const wrapperClass = scope === "global" ? "hidden md:inline-flex" : "inline-flex";
|
|
1617
1620
|
return `
|
|
1618
|
-
<div class="
|
|
1619
|
-
<label for="${
|
|
1621
|
+
<div class="${wrapperClass} items-center gap-2 text-sm">
|
|
1622
|
+
<label for="${id}" class="select-none">Theme</label>
|
|
1620
1623
|
<span class="relative inline-flex">
|
|
1621
1624
|
<select
|
|
1622
|
-
id="${
|
|
1623
|
-
class="
|
|
1624
|
-
data-
|
|
1625
|
+
id="${id}"
|
|
1626
|
+
class="appearance-none cursor-pointer rounded-md border py-1.5 pl-3 pr-8 text-sm transition duration-200 border-styleguide-border bg-styleguide-bg-highlight hover:text-styleguide-highlight focus:text-styleguide-highlight focus-visible:outline focus-visible:outline-blue-600"
|
|
1627
|
+
data-${scope}-theme-select
|
|
1625
1628
|
>
|
|
1626
1629
|
<option value="">Default</option>
|
|
1627
|
-
${themes.map((theme) => `<option value="${sanitizeSpecialCharacters(themeClassList(theme.value))}">${sanitizeSpecialCharacters(theme.
|
|
1630
|
+
${themes.map((theme) => `<option value="${sanitizeSpecialCharacters(themeClassList(theme.value))}">${sanitizeSpecialCharacters(theme.label)}</option>`).join("\n")}
|
|
1628
1631
|
</select>
|
|
1629
1632
|
<svg class="pointer-events-none absolute top-1/2 right-2.5 size-3.5 -translate-y-1/2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
|
|
1630
1633
|
<path fill-rule="evenodd" d="M4.22 6.22a.75.75 0 0 1 1.06 0L8 8.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd"/>
|
|
@@ -1633,6 +1636,16 @@ function renderThemeSelect(section, themes) {
|
|
|
1633
1636
|
</div>
|
|
1634
1637
|
`;
|
|
1635
1638
|
}
|
|
1639
|
+
function renderGlobalThemeSelect(themes) {
|
|
1640
|
+
return renderThemeSelectControl("global-theme-select", themes, "global");
|
|
1641
|
+
}
|
|
1642
|
+
function renderThemeSelect(section, themes) {
|
|
1643
|
+
return renderThemeSelectControl(
|
|
1644
|
+
`theme-select-${sectionSanitizeId(section.id)}`,
|
|
1645
|
+
themes.map((theme) => ({ value: theme.value, label: theme.description })),
|
|
1646
|
+
"section"
|
|
1647
|
+
);
|
|
1648
|
+
}
|
|
1636
1649
|
function getMainContentHtml(secondLevelSection, config) {
|
|
1637
1650
|
let output = "";
|
|
1638
1651
|
function renderSection(section) {
|
|
@@ -2208,7 +2221,7 @@ async function generatePreviewFile(data) {
|
|
|
2208
2221
|
const shouldRenderMetaDescription = data.page.description && data.page.description.length > 0 && !(data.page.description.includes("<") && data.page.description.includes(">"));
|
|
2209
2222
|
const content = `
|
|
2210
2223
|
<!DOCTYPE html>
|
|
2211
|
-
<html lang="${data.page.lang}" class="scroll-smooth">
|
|
2224
|
+
<html lang="${data.page.lang}" class="scroll-smooth"${data.reloadPreviewsOnThemeChange ? " data-reload-previews-on-theme-change" : ""}>
|
|
2212
2225
|
<head>
|
|
2213
2226
|
<title>${sanitizeSpecialCharacters(data.page.title)}</title>
|
|
2214
2227
|
${data.page.description && shouldRenderMetaDescription ? `<meta name="description" content="${data.page.description.replaceAll(`'`, "").replaceAll(`"`, "")}">` : ""}
|
|
@@ -2217,10 +2230,10 @@ async function generatePreviewFile(data) {
|
|
|
2217
2230
|
<meta name="generator" content="styleguide">
|
|
2218
2231
|
<link rel="icon" type="image/svg+xml" href="/styleguide-assets/favicon/preview.svg">
|
|
2219
2232
|
${data.ogImageUrl ? `<meta property="og:image" content="${data.ogImageUrl}">` : ""}
|
|
2220
|
-
${typeof data.
|
|
2221
|
-
<meta name="theme-color" media="(prefers-color-scheme: light)" content="${data.
|
|
2222
|
-
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="${data.
|
|
2223
|
-
` : `<meta name="theme-color" content="${data.
|
|
2233
|
+
${typeof data.brandColor === "object" && "dark" in data.brandColor && "light" in data.brandColor ? `
|
|
2234
|
+
<meta name="theme-color" media="(prefers-color-scheme: light)" content="${data.brandColor.light}">
|
|
2235
|
+
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="${data.brandColor.dark}">
|
|
2236
|
+
` : `<meta name="theme-color" content="${data.brandColor}">`}
|
|
2224
2237
|
<link rel="stylesheet" type="text/css" href="/styleguide-assets/kss-modern-Cg1aeKi1.css">
|
|
2225
2238
|
<script>
|
|
2226
2239
|
//#region client/lib/iframe-resize.ts
|
|
@@ -2384,7 +2397,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
2384
2397
|
//#endregion
|
|
2385
2398
|
;
|
|
2386
2399
|
<\/script>
|
|
2387
|
-
<script type="module" src="/styleguide-assets/preview-
|
|
2400
|
+
<script type="module" src="/styleguide-assets/preview-CCjPdowU.js"><\/script>
|
|
2388
2401
|
<link rel="preload" href="/styleguide-assets/fonts/geist-mono-latin-400-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
|
|
2389
2402
|
<link rel="preload" href="/styleguide-assets/fonts/geist-mono-latin-600-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
|
|
2390
2403
|
<link rel="preload" href="/styleguide-assets/fonts/geist-mono-latin-300-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
|
|
@@ -2394,7 +2407,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
2394
2407
|
${computedStyleTags}
|
|
2395
2408
|
<style>
|
|
2396
2409
|
:root {
|
|
2397
|
-
--styleguide-color-theme-highlight: ${typeof data.
|
|
2410
|
+
--styleguide-color-theme-highlight: ${typeof data.brandColor === "string" ? data.brandColor : `light-dark(${data.brandColor.light}, ${data.brandColor.dark})`};
|
|
2398
2411
|
}
|
|
2399
2412
|
</style>
|
|
2400
2413
|
</head>
|
|
@@ -2584,6 +2597,28 @@ function watchStyleguideForChanges(watchPath, handlers) {
|
|
|
2584
2597
|
});
|
|
2585
2598
|
}
|
|
2586
2599
|
|
|
2600
|
+
const warnedDeprecations = /* @__PURE__ */ new Set();
|
|
2601
|
+
function warnDeprecatedOption(deprecated, replacement) {
|
|
2602
|
+
if (warnedDeprecations.has(deprecated))
|
|
2603
|
+
return;
|
|
2604
|
+
warnedDeprecations.add(deprecated);
|
|
2605
|
+
logger.warn(`\`${deprecated}\` is deprecated and will be removed in the next major \u2014 rename it to \`${replacement}\`.`);
|
|
2606
|
+
}
|
|
2607
|
+
function resolveConfiguration(config) {
|
|
2608
|
+
const { theme, themes, ...options } = config;
|
|
2609
|
+
if (theme !== void 0)
|
|
2610
|
+
warnDeprecatedOption("theme", "brandColor");
|
|
2611
|
+
if (themes !== void 0)
|
|
2612
|
+
warnDeprecatedOption("themes", "previewThemes");
|
|
2613
|
+
const brandColor = options.brandColor ?? theme;
|
|
2614
|
+
if (brandColor === void 0)
|
|
2615
|
+
throw new Error("Styleguide configuration is missing `brandColor` (the styleguide accent colour).");
|
|
2616
|
+
return {
|
|
2617
|
+
...options,
|
|
2618
|
+
brandColor,
|
|
2619
|
+
previewThemes: options.previewThemes ?? themes ?? []
|
|
2620
|
+
};
|
|
2621
|
+
}
|
|
2587
2622
|
async function parseStyleguide(contentDir) {
|
|
2588
2623
|
const styleguideContentPaths = await glob(`${contentDir}/**/*.{css,scss}`);
|
|
2589
2624
|
const styleguideContent = await Promise.all(
|
|
@@ -2654,8 +2689,9 @@ async function writeFullPageFile(config, baseDirectory, section) {
|
|
|
2654
2689
|
},
|
|
2655
2690
|
css: config.html.assets.css,
|
|
2656
2691
|
js: config.html.assets.js,
|
|
2692
|
+
previewThemes: config.previewThemes,
|
|
2657
2693
|
html: htmlMarkup,
|
|
2658
|
-
|
|
2694
|
+
brandColor: config.brandColor,
|
|
2659
2695
|
deactivateDarkMode: config.deactivateDarkMode,
|
|
2660
2696
|
ogImageUrl: config.plugins?.ogImage ? config.plugins.ogImage(section) : void 0
|
|
2661
2697
|
});
|
|
@@ -2712,8 +2748,9 @@ function writePreviewFile(config, context, firstLevelIndex, secondLevelIndex) {
|
|
|
2712
2748
|
alerts: getAlerts(),
|
|
2713
2749
|
preloadIframes
|
|
2714
2750
|
},
|
|
2715
|
-
|
|
2751
|
+
brandColor: config.brandColor,
|
|
2716
2752
|
deactivateDarkMode: config.deactivateDarkMode,
|
|
2753
|
+
reloadPreviewsOnThemeChange: config.reloadPreviewsOnThemeChange,
|
|
2717
2754
|
ogImageUrl: config.plugins?.ogImage ? config.plugins.ogImage(secondLevelSection) : void 0
|
|
2718
2755
|
});
|
|
2719
2756
|
}
|
|
@@ -2794,9 +2831,9 @@ async function buildContext(config) {
|
|
|
2794
2831
|
};
|
|
2795
2832
|
}
|
|
2796
2833
|
const ASSETS_MARKER_FILE = ".kss-modern-assets";
|
|
2797
|
-
function getAssetsBuildId(
|
|
2834
|
+
function getAssetsBuildId(brandColor) {
|
|
2798
2835
|
return `kss-modern-Cg1aeKi1.css
|
|
2799
|
-
${JSON.stringify(
|
|
2836
|
+
${JSON.stringify(brandColor)}
|
|
2800
2837
|
`;
|
|
2801
2838
|
}
|
|
2802
2839
|
async function readAssetsBuildId(markerPath) {
|
|
@@ -2818,17 +2855,18 @@ async function copyStyleguideAssets(config) {
|
|
|
2818
2855
|
const assetsDirectoryPath = findAssetsDirectoryPath();
|
|
2819
2856
|
const assetsDirectoryOutputPath = path.join(config.outDir, "styleguide-assets");
|
|
2820
2857
|
const markerPath = path.join(assetsDirectoryOutputPath, ASSETS_MARKER_FILE);
|
|
2821
|
-
const expectedBuildId = getAssetsBuildId(config.
|
|
2858
|
+
const expectedBuildId = getAssetsBuildId(config.brandColor);
|
|
2822
2859
|
const currentBuildId = await readAssetsBuildId(markerPath);
|
|
2823
2860
|
if (currentBuildId === expectedBuildId) {
|
|
2824
2861
|
return;
|
|
2825
2862
|
}
|
|
2826
2863
|
await fs.remove(assetsDirectoryOutputPath);
|
|
2827
2864
|
await fs.copy(assetsDirectoryPath, assetsDirectoryOutputPath);
|
|
2828
|
-
await generateFaviconFiles(assetsDirectoryOutputPath, config.
|
|
2865
|
+
await generateFaviconFiles(assetsDirectoryOutputPath, config.brandColor);
|
|
2829
2866
|
await fs.writeFile(markerPath, expectedBuildId);
|
|
2830
2867
|
}
|
|
2831
|
-
async function buildAll(
|
|
2868
|
+
async function buildAll(input) {
|
|
2869
|
+
const config = resolveConfiguration(input);
|
|
2832
2870
|
if (config.mode === "production" && await fs.exists(config.outDir)) {
|
|
2833
2871
|
const files = await glob(`${config.outDir}/**/*.html`);
|
|
2834
2872
|
await Promise.all(files.map((file) => fs.remove(file)));
|
|
@@ -2915,7 +2953,8 @@ async function rebuildSections(config, context, changedSectionIds) {
|
|
|
2915
2953
|
}
|
|
2916
2954
|
await Promise.all(writeTasks);
|
|
2917
2955
|
}
|
|
2918
|
-
async function watchStyleguide(
|
|
2956
|
+
async function watchStyleguide(input, onChange, onError) {
|
|
2957
|
+
const config = resolveConfiguration(input);
|
|
2919
2958
|
const initialBuild = await buildAll(config);
|
|
2920
2959
|
if (onError && initialBuild.errors) {
|
|
2921
2960
|
onError(initialBuild.errors);
|
|
@@ -2955,4 +2994,4 @@ async function watchStyleguide(config, onChange, onError) {
|
|
|
2955
2994
|
});
|
|
2956
2995
|
}
|
|
2957
2996
|
|
|
2958
|
-
export { buildAll, buildStyleguide, logger, parseStyleguide, rebuildSections, watchStyleguide };
|
|
2997
|
+
export { buildAll, buildStyleguide, logger, parseStyleguide, rebuildSections, resolveConfiguration, watchStyleguide };
|
|
@@ -11,12 +11,20 @@
|
|
|
11
11
|
"file": "code-highlight-Fm7cxf-E.js",
|
|
12
12
|
"name": "code-highlight"
|
|
13
13
|
},
|
|
14
|
+
"_preview-theme-DIgnwL5g.js": {
|
|
15
|
+
"file": "preview-theme-DIgnwL5g.js",
|
|
16
|
+
"name": "preview-theme",
|
|
17
|
+
"imports": [
|
|
18
|
+
"_theme-document-CtY2qFyJ.js",
|
|
19
|
+
"_section-previews-CnlrC8Gz.js"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
14
22
|
"_rolldown-runtime-B1bRi_D7.js": {
|
|
15
23
|
"file": "rolldown-runtime-B1bRi_D7.js",
|
|
16
24
|
"name": "rolldown-runtime"
|
|
17
25
|
},
|
|
18
|
-
"_section-previews-
|
|
19
|
-
"file": "section-previews-
|
|
26
|
+
"_section-previews-CnlrC8Gz.js": {
|
|
27
|
+
"file": "section-previews-CnlrC8Gz.js",
|
|
20
28
|
"name": "section-previews"
|
|
21
29
|
},
|
|
22
30
|
"_shared-hGcWlnRM.js": {
|
|
@@ -27,18 +35,23 @@
|
|
|
27
35
|
"file": "signal-ZVBNTRLw.js",
|
|
28
36
|
"name": "signal"
|
|
29
37
|
},
|
|
38
|
+
"_theme-document-CtY2qFyJ.js": {
|
|
39
|
+
"file": "theme-document-CtY2qFyJ.js",
|
|
40
|
+
"name": "theme-document"
|
|
41
|
+
},
|
|
30
42
|
"_utils-DtB-AzJa.js": {
|
|
31
43
|
"file": "utils-DtB-AzJa.js",
|
|
32
44
|
"name": "utils"
|
|
33
45
|
},
|
|
34
46
|
"client/fullpage.ts": {
|
|
35
|
-
"file": "fullpage-
|
|
47
|
+
"file": "fullpage-DSD6-0qF.js",
|
|
36
48
|
"name": "fullpage",
|
|
37
49
|
"src": "client/fullpage.ts",
|
|
38
50
|
"isEntry": true,
|
|
39
51
|
"imports": [
|
|
40
52
|
"_rolldown-runtime-B1bRi_D7.js",
|
|
41
|
-
"_shared-hGcWlnRM.js"
|
|
53
|
+
"_shared-hGcWlnRM.js",
|
|
54
|
+
"_theme-document-CtY2qFyJ.js"
|
|
42
55
|
],
|
|
43
56
|
"dynamicImports": [
|
|
44
57
|
"node_modules/axe-core/axe.js",
|
|
@@ -46,14 +59,14 @@
|
|
|
46
59
|
]
|
|
47
60
|
},
|
|
48
61
|
"client/lib/a11y-report.ts": {
|
|
49
|
-
"file": "a11y-report-
|
|
62
|
+
"file": "a11y-report-BFnWMaWr.js",
|
|
50
63
|
"name": "a11y-report",
|
|
51
64
|
"src": "client/lib/a11y-report.ts",
|
|
52
65
|
"isDynamicEntry": true,
|
|
53
66
|
"imports": [
|
|
54
67
|
"_utils-DtB-AzJa.js",
|
|
55
68
|
"_audit-runner-Ch009v98.js",
|
|
56
|
-
"_section-previews-
|
|
69
|
+
"_section-previews-CnlrC8Gz.js"
|
|
57
70
|
]
|
|
58
71
|
},
|
|
59
72
|
"client/lib/clipboard.ts": {
|
|
@@ -73,8 +86,17 @@
|
|
|
73
86
|
"src": "client/lib/editor-select.ts",
|
|
74
87
|
"isDynamicEntry": true
|
|
75
88
|
},
|
|
89
|
+
"client/lib/global-theme-select.ts": {
|
|
90
|
+
"file": "global-theme-select-DCnqGEUr.js",
|
|
91
|
+
"name": "global-theme-select",
|
|
92
|
+
"src": "client/lib/global-theme-select.ts",
|
|
93
|
+
"isDynamicEntry": true,
|
|
94
|
+
"imports": [
|
|
95
|
+
"_preview-theme-DIgnwL5g.js"
|
|
96
|
+
]
|
|
97
|
+
},
|
|
76
98
|
"client/lib/html-validator.ts": {
|
|
77
|
-
"file": "html-validator-
|
|
99
|
+
"file": "html-validator-sgeZtEeH.js",
|
|
78
100
|
"name": "html-validator",
|
|
79
101
|
"src": "client/lib/html-validator.ts",
|
|
80
102
|
"isDynamicEntry": true,
|
|
@@ -83,7 +105,7 @@
|
|
|
83
105
|
"_utils-DtB-AzJa.js",
|
|
84
106
|
"_shared-hGcWlnRM.js",
|
|
85
107
|
"_audit-runner-Ch009v98.js",
|
|
86
|
-
"_section-previews-
|
|
108
|
+
"_section-previews-CnlrC8Gz.js"
|
|
87
109
|
]
|
|
88
110
|
},
|
|
89
111
|
"client/lib/icons.ts": {
|
|
@@ -97,12 +119,13 @@
|
|
|
97
119
|
]
|
|
98
120
|
},
|
|
99
121
|
"client/lib/section-theme-select.ts": {
|
|
100
|
-
"file": "section-theme-select-
|
|
122
|
+
"file": "section-theme-select-CVOwp7VZ.js",
|
|
101
123
|
"name": "section-theme-select",
|
|
102
124
|
"src": "client/lib/section-theme-select.ts",
|
|
103
125
|
"isDynamicEntry": true,
|
|
104
126
|
"imports": [
|
|
105
|
-
"_section-previews-
|
|
127
|
+
"_section-previews-CnlrC8Gz.js",
|
|
128
|
+
"_preview-theme-DIgnwL5g.js"
|
|
106
129
|
]
|
|
107
130
|
},
|
|
108
131
|
"client/preview-inline.ts": {
|
|
@@ -112,7 +135,7 @@
|
|
|
112
135
|
"isEntry": true
|
|
113
136
|
},
|
|
114
137
|
"client/preview.ts": {
|
|
115
|
-
"file": "preview-
|
|
138
|
+
"file": "preview-CCjPdowU.js",
|
|
116
139
|
"name": "preview",
|
|
117
140
|
"src": "client/preview.ts",
|
|
118
141
|
"isEntry": true,
|
|
@@ -128,6 +151,7 @@
|
|
|
128
151
|
"client/lib/html-validator.ts",
|
|
129
152
|
"client/lib/icons.ts",
|
|
130
153
|
"client/lib/clipboard.ts",
|
|
154
|
+
"client/lib/global-theme-select.ts",
|
|
131
155
|
"client/lib/section-theme-select.ts",
|
|
132
156
|
"client/lib/editor-select.ts"
|
|
133
157
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as e } from "./utils-DtB-AzJa.js";
|
|
2
2
|
import { a as t, i as n, n as r, o as i, r as a } from "./audit-runner-Ch009v98.js";
|
|
3
|
-
import { n as o,
|
|
3
|
+
import { n as o, r as s } from "./section-previews-CnlrC8Gz.js";
|
|
4
4
|
//#region client/lib/a11y-report.ts
|
|
5
5
|
var c = {
|
|
6
6
|
violations: ["violations", "incomplete"],
|
|
@@ -10,8 +10,8 @@ function l(t) {
|
|
|
10
10
|
return e(t.trim()).replace(/^section-/, "");
|
|
11
11
|
}
|
|
12
12
|
function u() {
|
|
13
|
-
return Array.from(document.querySelectorAll(
|
|
14
|
-
let { base: t, modifiers: n } =
|
|
13
|
+
return Array.from(document.querySelectorAll(o)).flatMap((e) => {
|
|
14
|
+
let { base: t, modifiers: n } = s(e);
|
|
15
15
|
if (!t) return [];
|
|
16
16
|
let r = Number.parseInt(e.dataset.sourceLine ?? "", 10);
|
|
17
17
|
return [{
|