@zazz-ui/core 0.6.1 → 0.6.3
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/AUTHORING.md +5 -3
- package/CHANGELOG.md +46 -0
- package/README.md +5 -5
- package/dist/csp-D72qtdXZ.js +1 -0
- package/dist/sri.json +18 -15
- package/dist/zazz.css +1 -1
- package/dist/zazz.js +1 -1
- package/editor/zazz.css-data.json +2028 -0
- package/editor/zazz.language-data.json +15 -3
- package/package.json +1 -1
- package/src/base/_reset.css +9 -17
- package/src/base/_utilities-color.css +3 -0
- package/src/base/_utilities-spacing.css +35 -0
- package/src/base/_variables.css +4 -0
- package/src/base/csp.d.ts +19 -0
- package/src/base/csp.d.ts.map +1 -0
- package/src/base/csp.js +131 -0
- package/src/base/csp.ts +137 -0
- package/src/base/declarations.d.ts +36 -0
- package/src/base/declarations.d.ts.map +1 -0
- package/src/base/declarations.js +70 -0
- package/src/base/declarations.ts +97 -0
- package/src/base/style-format.d.ts +3 -22
- package/src/base/style-format.d.ts.map +1 -1
- package/src/base/style-format.js +4 -62
- package/src/base/style-format.ts +4 -71
- package/src/base/utilities.d.ts.map +1 -1
- package/src/base/utilities.js +35 -17
- package/src/base/utilities.ts +42 -20
- package/src/head.d.ts +6 -0
- package/src/head.d.ts.map +1 -1
- package/src/head.js +21 -14
- package/src/head.ts +38 -11
- package/src/index.js +22 -0
- package/src/index.ts +19 -0
- package/src/manifest.d.ts +21 -1
- package/src/manifest.d.ts.map +1 -1
- package/src/manifest.js +10 -1
- package/src/manifest.ts +25 -1
- package/src/primitives/badge/badge.css +61 -111
- package/src/primitives/badge/badge.html +5 -0
- package/src/primitives/button/button.css +55 -53
- package/src/primitives/button/button.html +4 -0
- package/src/primitives/callout/callout.css +35 -10
- package/src/primitives/debug/audit-core.d.ts +1 -1
- package/src/primitives/debug/audit-core.d.ts.map +1 -1
- package/src/primitives/debug/audit-core.js +35 -5
- package/src/primitives/debug/audit-core.ts +42 -4
- package/src/primitives/prose/prose.html +3 -3
- package/src/primitives/table/table-size-sm.html +12 -12
- package/src/primitives/utilities/aspect-ratio.html +1 -0
- package/src/primitives/utilities/margin-auto.html +1 -1
- package/src/primitives/utilities/overflow.html +5 -6
- package/src/primitives/utilities/position.html +1 -1
- package/src/primitives/utilities/width.html +2 -1
package/src/head.ts
CHANGED
|
@@ -75,6 +75,9 @@ const CORE_RUNTIME_JS = [
|
|
|
75
75
|
"base/zazz-element.js",
|
|
76
76
|
// dynamically imported by index.js where container scroll-state queries are unsupported
|
|
77
77
|
"base/scroll-state.js",
|
|
78
|
+
// dynamically imported by index.js where the page's CSP blocks inline style attributes
|
|
79
|
+
"base/csp.js",
|
|
80
|
+
"base/declarations.js",
|
|
78
81
|
];
|
|
79
82
|
|
|
80
83
|
/**
|
|
@@ -176,7 +179,7 @@ function fontsBlock(display: "swap" | "optional"): string {
|
|
|
176
179
|
* @returns The import-map script tag.
|
|
177
180
|
* @private
|
|
178
181
|
*/
|
|
179
|
-
function importMapBlock(extraIntegrity: Record<string, string> = {}): string {
|
|
182
|
+
function importMapBlock(extraIntegrity: Record<string, string> = {}, nonce?: string): string {
|
|
180
183
|
const imports: Record<string, string> = {};
|
|
181
184
|
const integrity: Record<string, string> = { ...extraIntegrity };
|
|
182
185
|
for (const dep of ESM_DEPENDENCIES) {
|
|
@@ -186,7 +189,7 @@ function importMapBlock(extraIntegrity: Record<string, string> = {}): string {
|
|
|
186
189
|
}
|
|
187
190
|
const json = JSON.stringify({ imports, integrity }, null, 2);
|
|
188
191
|
return `<!-- Import map: bare specifiers in Zazz scripts resolve to pinned, SRI-checked files -->
|
|
189
|
-
<script type="importmap">
|
|
192
|
+
<script type="importmap"${nonceAttr(nonce)}>
|
|
190
193
|
${json}
|
|
191
194
|
</script>`;
|
|
192
195
|
}
|
|
@@ -205,14 +208,21 @@ function polyfillsBlock(): string {
|
|
|
205
208
|
<script type="module" src="${cdnUrl(interest)}" integrity="${interest.integrity}" crossorigin="anonymous"></script>`;
|
|
206
209
|
}
|
|
207
210
|
|
|
211
|
+
/** ` nonce="…"` for an inline script under a strict `script-src`, or nothing. */
|
|
212
|
+
function nonceAttr(nonce?: string): string {
|
|
213
|
+
return nonce ? ` nonce="${nonce.replace(/"/g, """)}"` : "";
|
|
214
|
+
}
|
|
215
|
+
|
|
208
216
|
/**
|
|
209
217
|
* The theme-persistence script. Runs inline (no `defer`) while the parser is
|
|
210
218
|
* still in `<head>`, so the `theme-*` switch lands on `<html>` before first paint. The
|
|
211
219
|
* try/catch covers contexts where storage access throws (sandboxed iframes,
|
|
212
220
|
* blocked site data).
|
|
213
221
|
*/
|
|
214
|
-
const
|
|
215
|
-
|
|
222
|
+
const themeScript = (
|
|
223
|
+
nonce?: string,
|
|
224
|
+
) => `<!-- Theme: apply the persisted (or preferred) scheme before first paint -->
|
|
225
|
+
<script${nonceAttr(nonce)}>
|
|
216
226
|
(() => {
|
|
217
227
|
try {
|
|
218
228
|
// A stored choice pins the scheme with the theme-dark / theme-light
|
|
@@ -272,6 +282,12 @@ export interface HeadOptions {
|
|
|
272
282
|
fontDisplay?: "swap" | "optional" | false;
|
|
273
283
|
/** Include the inline theme-persistence script (last in head). Default `true`. */
|
|
274
284
|
theme?: boolean;
|
|
285
|
+
/**
|
|
286
|
+
* A CSP nonce for the two inline scripts (the import map and the theme
|
|
287
|
+
* script), so a strict `script-src 'nonce-…'` allows them. The page's own
|
|
288
|
+
* value, generated per response; never a constant.
|
|
289
|
+
*/
|
|
290
|
+
nonce?: string;
|
|
275
291
|
/**
|
|
276
292
|
* Local granular grain: the primitives this page uses, loaded file by file
|
|
277
293
|
* from `base` (base layers, the closure's stylesheets in cascade order, one
|
|
@@ -295,7 +311,14 @@ export interface HeadOptions {
|
|
|
295
311
|
* buildHead({ base: "/zazz/src", scripts: false, fontDisplay: "optional" });
|
|
296
312
|
*/
|
|
297
313
|
export function buildHead(options: HeadOptions = {}): string {
|
|
298
|
-
const {
|
|
314
|
+
const {
|
|
315
|
+
base = "./zazz",
|
|
316
|
+
cdn,
|
|
317
|
+
scripts = true,
|
|
318
|
+
fontDisplay = "swap",
|
|
319
|
+
theme = true,
|
|
320
|
+
nonce,
|
|
321
|
+
} = options;
|
|
299
322
|
|
|
300
323
|
const parts: string[] = [
|
|
301
324
|
`<meta charset="utf-8">`,
|
|
@@ -307,7 +330,7 @@ export function buildHead(options: HeadOptions = {}): string {
|
|
|
307
330
|
if (fontDisplay !== false) parts.push(fontsBlock(fontDisplay));
|
|
308
331
|
|
|
309
332
|
if (cdn) {
|
|
310
|
-
parts.push(...cdnBlocks(cdn, scripts));
|
|
333
|
+
parts.push(...cdnBlocks(cdn, scripts, nonce));
|
|
311
334
|
} else if (options.primitives) {
|
|
312
335
|
parts.push(
|
|
313
336
|
...granularBlocks(
|
|
@@ -315,6 +338,8 @@ export function buildHead(options: HeadOptions = {}): string {
|
|
|
315
338
|
(path) => `${base}/${path}`,
|
|
316
339
|
() => "",
|
|
317
340
|
scripts,
|
|
341
|
+
{},
|
|
342
|
+
nonce,
|
|
318
343
|
),
|
|
319
344
|
);
|
|
320
345
|
} else {
|
|
@@ -327,7 +352,7 @@ export function buildHead(options: HeadOptions = {}): string {
|
|
|
327
352
|
parts.push(
|
|
328
353
|
// The import map must precede EVERY module load — including the
|
|
329
354
|
// modulepreload hint — or the browser rejects it and bare specifiers fail.
|
|
330
|
-
importMapBlock(),
|
|
355
|
+
importMapBlock({}, nonce),
|
|
331
356
|
`<link rel="modulepreload" href="${base}/index.js">`,
|
|
332
357
|
polyfillsBlock(),
|
|
333
358
|
`<!-- Zazz behavior: one ES module imports every component script in dependency order -->`,
|
|
@@ -336,7 +361,7 @@ export function buildHead(options: HeadOptions = {}): string {
|
|
|
336
361
|
}
|
|
337
362
|
}
|
|
338
363
|
|
|
339
|
-
if (theme) parts.push(
|
|
364
|
+
if (theme) parts.push(themeScript(nonce));
|
|
340
365
|
|
|
341
366
|
return parts.join("\n");
|
|
342
367
|
}
|
|
@@ -355,7 +380,7 @@ export function buildHead(options: HeadOptions = {}): string {
|
|
|
355
380
|
* @returns The head fragments between the fonts block and the theme script.
|
|
356
381
|
* @private
|
|
357
382
|
*/
|
|
358
|
-
function cdnBlocks(cdn: CdnHeadOptions, scripts: boolean): string[] {
|
|
383
|
+
function cdnBlocks(cdn: CdnHeadOptions, scripts: boolean, nonce?: string): string[] {
|
|
359
384
|
const { version, primitives, sri } = cdn;
|
|
360
385
|
if (!EXACT_VERSION.test(version)) {
|
|
361
386
|
throw new Error(
|
|
@@ -377,7 +402,7 @@ function cdnBlocks(cdn: CdnHeadOptions, scripts: boolean): string[] {
|
|
|
377
402
|
);
|
|
378
403
|
if (scripts) {
|
|
379
404
|
parts.push(
|
|
380
|
-
importMapBlock(),
|
|
405
|
+
importMapBlock({}, nonce),
|
|
381
406
|
`<link rel="modulepreload" href="${url("dist/zazz.js")}"${attrs("dist/zazz.js")}>`,
|
|
382
407
|
polyfillsBlock(),
|
|
383
408
|
`<!-- Zazz behavior: the whole kit, one module -->`,
|
|
@@ -402,6 +427,7 @@ function cdnBlocks(cdn: CdnHeadOptions, scripts: boolean): string[] {
|
|
|
402
427
|
(path) => attrs(`src/${path}`),
|
|
403
428
|
scripts,
|
|
404
429
|
transitive,
|
|
430
|
+
nonce,
|
|
405
431
|
);
|
|
406
432
|
}
|
|
407
433
|
|
|
@@ -423,6 +449,7 @@ function granularBlocks(
|
|
|
423
449
|
attrs: (path: string) => string,
|
|
424
450
|
scripts: boolean,
|
|
425
451
|
transitive: Record<string, string> = {},
|
|
452
|
+
nonce?: string,
|
|
426
453
|
): string[] {
|
|
427
454
|
const parts: string[] = [];
|
|
428
455
|
const closure = resolveClosure(primitives);
|
|
@@ -453,7 +480,7 @@ function granularBlocks(
|
|
|
453
480
|
]),
|
|
454
481
|
];
|
|
455
482
|
parts.push(
|
|
456
|
-
importMapBlock(transitive),
|
|
483
|
+
importMapBlock(transitive, nonce),
|
|
457
484
|
polyfillsBlock(),
|
|
458
485
|
`<!-- Zazz behavior: side-effect modules by tag; the rest via module imports -->`,
|
|
459
486
|
...scriptFiles.map(
|
package/src/index.js
CHANGED
|
@@ -38,3 +38,25 @@ import "./base/navigation.js";
|
|
|
38
38
|
if (typeof CSS !== "undefined" && !CSS.supports("container-type", "scroll-state")) {
|
|
39
39
|
void import("./base/scroll-state.js");
|
|
40
40
|
}
|
|
41
|
+
// A Content Security Policy that blocks inline style attributes leaves the
|
|
42
|
+
// attribute text in the DOM with an empty declaration block, and with it every
|
|
43
|
+
// utility unapplied; load the CSSOM fallback. A page that allows them
|
|
44
|
+
// (`style-src-attr 'unsafe-inline'`) never fetches it.
|
|
45
|
+
function blockedInlineStyles() {
|
|
46
|
+
for (const el of document.querySelectorAll("[style]")) {
|
|
47
|
+
const text = el.getAttribute("style");
|
|
48
|
+
if (text?.includes(":") && el.style.length === 0)
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if (typeof document !== "undefined") {
|
|
54
|
+
const check = () => {
|
|
55
|
+
if (blockedInlineStyles())
|
|
56
|
+
void import("./base/csp.js");
|
|
57
|
+
};
|
|
58
|
+
if (document.readyState === "loading")
|
|
59
|
+
document.addEventListener("DOMContentLoaded", check);
|
|
60
|
+
else
|
|
61
|
+
check();
|
|
62
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -40,3 +40,22 @@ import "./base/navigation.ts";
|
|
|
40
40
|
if (typeof CSS !== "undefined" && !CSS.supports("container-type", "scroll-state")) {
|
|
41
41
|
void import("./base/scroll-state.ts");
|
|
42
42
|
}
|
|
43
|
+
|
|
44
|
+
// A Content Security Policy that blocks inline style attributes leaves the
|
|
45
|
+
// attribute text in the DOM with an empty declaration block, and with it every
|
|
46
|
+
// utility unapplied; load the CSSOM fallback. A page that allows them
|
|
47
|
+
// (`style-src-attr 'unsafe-inline'`) never fetches it.
|
|
48
|
+
function blockedInlineStyles(): boolean {
|
|
49
|
+
for (const el of document.querySelectorAll("[style]")) {
|
|
50
|
+
const text = el.getAttribute("style");
|
|
51
|
+
if (text?.includes(":") && (el as HTMLElement).style.length === 0) return true;
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
if (typeof document !== "undefined") {
|
|
56
|
+
const check = () => {
|
|
57
|
+
if (blockedInlineStyles()) void import("./base/csp.ts");
|
|
58
|
+
};
|
|
59
|
+
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", check);
|
|
60
|
+
else check();
|
|
61
|
+
}
|
package/src/manifest.d.ts
CHANGED
|
@@ -87,9 +87,29 @@ export interface RuntimePolyfill {
|
|
|
87
87
|
/**
|
|
88
88
|
* Polyfills `index.ts` imports dynamically behind a `CSS.supports` test, so a
|
|
89
89
|
* browser with the feature never fetches them. Vendored with the core runtime;
|
|
90
|
-
* an entry script loads each one the way `index.ts` does.
|
|
90
|
+
* an entry script loads each one the way `index.ts` does. Every entry has a
|
|
91
|
+
* `supports` pair: the published CLI drops the whole list when one does not.
|
|
91
92
|
*/
|
|
92
93
|
export declare const CORE_POLYFILLS: RuntimePolyfill[];
|
|
94
|
+
/** A runtime fallback, loaded only where a document check (not a CSS feature) says the page needs it. */
|
|
95
|
+
export interface RuntimeFallback {
|
|
96
|
+
/** The script, `src/`-relative. */
|
|
97
|
+
file: string;
|
|
98
|
+
/** Scripts it imports, `src/`-relative, vendored with it. */
|
|
99
|
+
requires: string[];
|
|
100
|
+
/**
|
|
101
|
+
* The check an entry script runs before importing it. `blocked-inline-styles`:
|
|
102
|
+
* some element's `style` attribute holds a declaration while its declaration
|
|
103
|
+
* block is empty, the shape of an attribute a Content Security Policy blocked.
|
|
104
|
+
*/
|
|
105
|
+
gate: "blocked-inline-styles";
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Fallbacks `index.ts` imports dynamically behind a document check, so a page
|
|
109
|
+
* that does not need one never fetches it. Vendored with the core runtime by a
|
|
110
|
+
* CLI that knows the gate; an older CLI ignores the list.
|
|
111
|
+
*/
|
|
112
|
+
export declare const CORE_FALLBACKS: RuntimeFallback[];
|
|
93
113
|
/** Every tag form in the kit; the generator excludes them from no-base emissions. */
|
|
94
114
|
export declare const TAG_FORMS: string[];
|
|
95
115
|
export declare const CSS_CASCADE_ORDER: string[];
|
package/src/manifest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["manifest.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAIH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAIlC,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC7B,6EAA6E;IAC7E,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,qDAAqD;IACrD,EAAE,EAAE,MAAM,EAAE,CAAC;IACb;;;;OAIG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,0EAA0E;IAC1E,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB;;;;;OAKG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,uDAAuD;IACvD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,uGAAuG;IACvG,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAgBD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CA8erD,CAAC;AAIF;;;;;;GAMG;AACH;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,EAOhC,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,aAAa,EAAE,MAAM,EA2CjC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,EAMhC,CAAC;AAEF,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAC9B,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAA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AE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,CAmC/E,CAAC"}
|
package/src/manifest.js
CHANGED
|
@@ -618,11 +618,20 @@ export const CORE_RUNTIME = [
|
|
|
618
618
|
/**
|
|
619
619
|
* Polyfills `index.ts` imports dynamically behind a `CSS.supports` test, so a
|
|
620
620
|
* browser with the feature never fetches them. Vendored with the core runtime;
|
|
621
|
-
* an entry script loads each one the way `index.ts` does.
|
|
621
|
+
* an entry script loads each one the way `index.ts` does. Every entry has a
|
|
622
|
+
* `supports` pair: the published CLI drops the whole list when one does not.
|
|
622
623
|
*/
|
|
623
624
|
export const CORE_POLYFILLS = [
|
|
624
625
|
{ file: "base/scroll-state.js", supports: ["container-type", "scroll-state"] },
|
|
625
626
|
];
|
|
627
|
+
/**
|
|
628
|
+
* Fallbacks `index.ts` imports dynamically behind a document check, so a page
|
|
629
|
+
* that does not need one never fetches it. Vendored with the core runtime by a
|
|
630
|
+
* CLI that knows the gate; an older CLI ignores the list.
|
|
631
|
+
*/
|
|
632
|
+
export const CORE_FALLBACKS = [
|
|
633
|
+
{ file: "base/csp.js", requires: ["base/declarations.js"], gate: "blocked-inline-styles" },
|
|
634
|
+
];
|
|
626
635
|
/** Every tag form in the kit; the generator excludes them from no-base emissions. */
|
|
627
636
|
export const TAG_FORMS = Object.values(PRIMITIVES)
|
|
628
637
|
.flatMap((entry) => entry.tags ?? [])
|
package/src/manifest.ts
CHANGED
|
@@ -667,12 +667,36 @@ export interface RuntimePolyfill {
|
|
|
667
667
|
/**
|
|
668
668
|
* Polyfills `index.ts` imports dynamically behind a `CSS.supports` test, so a
|
|
669
669
|
* browser with the feature never fetches them. Vendored with the core runtime;
|
|
670
|
-
* an entry script loads each one the way `index.ts` does.
|
|
670
|
+
* an entry script loads each one the way `index.ts` does. Every entry has a
|
|
671
|
+
* `supports` pair: the published CLI drops the whole list when one does not.
|
|
671
672
|
*/
|
|
672
673
|
export const CORE_POLYFILLS: RuntimePolyfill[] = [
|
|
673
674
|
{ file: "base/scroll-state.js", supports: ["container-type", "scroll-state"] },
|
|
674
675
|
];
|
|
675
676
|
|
|
677
|
+
/** A runtime fallback, loaded only where a document check (not a CSS feature) says the page needs it. */
|
|
678
|
+
export interface RuntimeFallback {
|
|
679
|
+
/** The script, `src/`-relative. */
|
|
680
|
+
file: string;
|
|
681
|
+
/** Scripts it imports, `src/`-relative, vendored with it. */
|
|
682
|
+
requires: string[];
|
|
683
|
+
/**
|
|
684
|
+
* The check an entry script runs before importing it. `blocked-inline-styles`:
|
|
685
|
+
* some element's `style` attribute holds a declaration while its declaration
|
|
686
|
+
* block is empty, the shape of an attribute a Content Security Policy blocked.
|
|
687
|
+
*/
|
|
688
|
+
gate: "blocked-inline-styles";
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Fallbacks `index.ts` imports dynamically behind a document check, so a page
|
|
693
|
+
* that does not need one never fetches it. Vendored with the core runtime by a
|
|
694
|
+
* CLI that knows the gate; an older CLI ignores the list.
|
|
695
|
+
*/
|
|
696
|
+
export const CORE_FALLBACKS: RuntimeFallback[] = [
|
|
697
|
+
{ file: "base/csp.js", requires: ["base/declarations.js"], gate: "blocked-inline-styles" },
|
|
698
|
+
];
|
|
699
|
+
|
|
676
700
|
/** Every tag form in the kit; the generator excludes them from no-base emissions. */
|
|
677
701
|
export const TAG_FORMS: string[] = Object.values(PRIMITIVES)
|
|
678
702
|
.flatMap((entry) => entry.tags ?? [])
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
|
|
40
40
|
/* dual-mode: a scale number or a length */
|
|
41
41
|
--ui-badge-gap: var(--spacing);
|
|
42
|
-
--ui-badge-px: calc(var(--spacing) * 1.
|
|
43
|
-
--ui-badge-h: calc(var(--spacing) * 5
|
|
42
|
+
--ui-badge-px: calc(var(--spacing) * 1.25);
|
|
43
|
+
--ui-badge-h: calc(var(--spacing) * 5);
|
|
44
44
|
--ui-badge-rounded: var(--radius-sm);
|
|
45
45
|
|
|
46
46
|
--ui-badge-icon-size: calc(var(--spacing) * 3);
|
|
@@ -381,92 +381,79 @@
|
|
|
381
381
|
--_badge-border-color--active: transparent;
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
+
/* Status variants (info, success, warning, destructive) share one soft
|
|
385
|
+
design: the status color at 10% alpha (20% in dark) as the surface, and
|
|
386
|
+
the status hue as the text with its lightness clamped (at most 0.45 in
|
|
387
|
+
light, at least 0.82 in dark) so it holds 4.5:1 on the tint and on the
|
|
388
|
+
hover and active steps; status-contrast.browser.test.ts checks it. No border. One rule derives the states from the
|
|
389
|
+
surface; each variant names only its colors. */
|
|
390
|
+
:where(
|
|
391
|
+
[data-ui~="badge"]:is(
|
|
392
|
+
[data-badge-variant="info"],
|
|
393
|
+
[data-badge-variant="success"],
|
|
394
|
+
[data-badge-variant="warning"],
|
|
395
|
+
[data-badge-variant="destructive"]
|
|
396
|
+
)
|
|
397
|
+
) {
|
|
398
|
+
--_badge-bg--hover: oklch(from var(--_badge-bg) l c h / calc(alpha + 0.1));
|
|
399
|
+
--_badge-bg--active: oklch(from var(--_badge-bg) l c h / calc(alpha + 0.15));
|
|
400
|
+
|
|
401
|
+
--_badge-text--hover: var(--_badge-text);
|
|
402
|
+
--_badge-text--active: var(--_badge-text);
|
|
403
|
+
|
|
404
|
+
--_badge-border-color: transparent;
|
|
405
|
+
--_badge-border-color--hover: transparent;
|
|
406
|
+
--_badge-border-color--active: transparent;
|
|
407
|
+
|
|
408
|
+
--_badge-shadow: 0 0 transparent;
|
|
409
|
+
}
|
|
410
|
+
|
|
384
411
|
:where([data-ui~="badge"][data-badge-variant="info"]) {
|
|
385
|
-
--_badge-
|
|
386
|
-
--_badge-bg
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
--_badge-text: color-mix(in xyz, var(--color-info) 100%, contrast-color(var(--_badge-bg)) 100%);
|
|
390
|
-
--_badge-text--hover: color-mix(
|
|
391
|
-
in xyz,
|
|
392
|
-
var(--color-info) 100%,
|
|
393
|
-
contrast-color(var(--_badge-bg--hover)) 100%
|
|
412
|
+
--_badge-ring-color: var(--color-info);
|
|
413
|
+
--_badge-bg: light-dark(
|
|
414
|
+
oklch(from var(--color-info) l c h / 0.1),
|
|
415
|
+
oklch(from var(--color-info) l c h / 0.2)
|
|
394
416
|
);
|
|
395
|
-
--_badge-text
|
|
396
|
-
|
|
397
|
-
var(--color-info)
|
|
398
|
-
contrast-color(var(--_badge-bg--active)) 100%
|
|
417
|
+
--_badge-text: light-dark(
|
|
418
|
+
oklch(from var(--color-info) min(l, 0.45) c h),
|
|
419
|
+
oklch(from var(--color-info) max(l, 0.82) c h)
|
|
399
420
|
);
|
|
400
|
-
|
|
401
|
-
--_badge-border-color: oklch(from var(--color-info) l c h / 0.2);
|
|
402
|
-
--_badge-border-color--hover: oklch(from var(--color-info) l c h / 0.15);
|
|
403
|
-
--_badge-border-color--active: oklch(from var(--color-info) l c h / 0.1);
|
|
404
421
|
}
|
|
405
422
|
|
|
406
423
|
:where([data-ui~="badge"][data-badge-variant="success"]) {
|
|
407
|
-
--_badge-
|
|
408
|
-
--_badge-bg
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
--_badge-text: color-mix(
|
|
412
|
-
in xyz,
|
|
413
|
-
var(--color-success) 100%,
|
|
414
|
-
contrast-color(var(--_badge-bg)) 100%
|
|
415
|
-
);
|
|
416
|
-
--_badge-text--hover: color-mix(
|
|
417
|
-
in xyz,
|
|
418
|
-
var(--color-success) 100%,
|
|
419
|
-
contrast-color(var(--_badge-bg--hover)) 100%
|
|
424
|
+
--_badge-ring-color: var(--color-success);
|
|
425
|
+
--_badge-bg: light-dark(
|
|
426
|
+
oklch(from var(--color-success) l c h / 0.1),
|
|
427
|
+
oklch(from var(--color-success) l c h / 0.2)
|
|
420
428
|
);
|
|
421
|
-
--_badge-text
|
|
422
|
-
|
|
423
|
-
var(--color-success)
|
|
424
|
-
contrast-color(var(--_badge-bg--active)) 100%
|
|
429
|
+
--_badge-text: light-dark(
|
|
430
|
+
oklch(from var(--color-success) min(l, 0.45) c h),
|
|
431
|
+
oklch(from var(--color-success) max(l, 0.82) c h)
|
|
425
432
|
);
|
|
426
|
-
|
|
427
|
-
--_badge-border-color: oklch(from var(--color-success) l c h / 0.2);
|
|
428
|
-
--_badge-border-color--hover: oklch(from var(--color-success) l c h / 0.15);
|
|
429
|
-
--_badge-border-color--active: oklch(from var(--color-success) l c h / 0.1);
|
|
430
433
|
}
|
|
431
434
|
|
|
432
435
|
:where([data-ui~="badge"][data-badge-variant="warning"]) {
|
|
433
|
-
--_badge-
|
|
434
|
-
--_badge-bg
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
--_badge-text: color-mix(
|
|
438
|
-
in xyz,
|
|
439
|
-
var(--color-warning) 100%,
|
|
440
|
-
contrast-color(var(--_badge-bg)) 100%
|
|
441
|
-
);
|
|
442
|
-
--_badge-text--hover: color-mix(
|
|
443
|
-
in xyz,
|
|
444
|
-
var(--color-warning) 100%,
|
|
445
|
-
contrast-color(var(--_badge-bg--hover)) 100%
|
|
436
|
+
--_badge-ring-color: var(--color-warning);
|
|
437
|
+
--_badge-bg: light-dark(
|
|
438
|
+
oklch(from var(--color-warning) l c h / 0.1),
|
|
439
|
+
oklch(from var(--color-warning) l c h / 0.2)
|
|
446
440
|
);
|
|
447
|
-
--_badge-text
|
|
448
|
-
|
|
449
|
-
var(--color-warning)
|
|
450
|
-
contrast-color(var(--_badge-bg--active)) 100%
|
|
441
|
+
--_badge-text: light-dark(
|
|
442
|
+
oklch(from var(--color-warning) min(l, 0.45) c h),
|
|
443
|
+
oklch(from var(--color-warning) max(l, 0.82) c h)
|
|
451
444
|
);
|
|
452
|
-
|
|
453
|
-
--_badge-border-color: oklch(from var(--color-warning) l c h / 0.2);
|
|
454
|
-
--_badge-border-color--hover: oklch(from var(--color-warning) l c h / 0.15);
|
|
455
|
-
--_badge-border-color--active: oklch(from var(--color-warning) l c h / 0.1);
|
|
456
445
|
}
|
|
457
446
|
|
|
458
447
|
:where([data-ui~="badge"][data-badge-variant="destructive"]) {
|
|
459
|
-
--_badge-
|
|
460
|
-
--_badge-bg
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
--_badge-text
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
--_badge-border-color--hover: var(--_badge-bg--hover);
|
|
469
|
-
--_badge-border-color--active: var(--_badge-bg--active);
|
|
448
|
+
--_badge-ring-color: var(--color-destructive);
|
|
449
|
+
--_badge-bg: light-dark(
|
|
450
|
+
oklch(from var(--color-destructive) l c h / 0.1),
|
|
451
|
+
oklch(from var(--color-destructive) l c h / 0.2)
|
|
452
|
+
);
|
|
453
|
+
--_badge-text: light-dark(
|
|
454
|
+
oklch(from var(--color-destructive) min(l, 0.45) c h),
|
|
455
|
+
oklch(from var(--color-destructive) max(l, 0.82) c h)
|
|
456
|
+
);
|
|
470
457
|
}
|
|
471
458
|
|
|
472
459
|
:where([data-ui~="badge"][data-badge-variant="link"]) {
|
|
@@ -475,8 +462,8 @@
|
|
|
475
462
|
--_badge-bg--active: transparent;
|
|
476
463
|
|
|
477
464
|
--_badge-text: var(--color-foreground);
|
|
478
|
-
--_badge-text--hover: var(--color-primary);
|
|
479
|
-
--_badge-text--active: oklch(from var(--color-primary) l c h / 0.
|
|
465
|
+
--_badge-text--hover: oklch(from var(--color-primary) l c h / 0.6);
|
|
466
|
+
--_badge-text--active: oklch(from var(--color-primary) l c h / 0.5);
|
|
480
467
|
|
|
481
468
|
--_badge-border-style: none;
|
|
482
469
|
|
|
@@ -484,43 +471,6 @@
|
|
|
484
471
|
--_badge-rounded: 0;
|
|
485
472
|
|
|
486
473
|
--_badge-shadow: 0 0 transparent;
|
|
487
|
-
|
|
488
|
-
/* the link sizes to its text (dual mode cannot carry fit-content) */
|
|
489
|
-
block-size: auto;
|
|
490
|
-
|
|
491
|
-
text-decoration-line: var(--decoration-line);
|
|
492
|
-
text-decoration-style: var(--decoration-style);
|
|
493
|
-
text-decoration-color: var(--decoration-color);
|
|
494
|
-
text-underline-offset: var(--decoration-offset);
|
|
495
|
-
text-decoration-thickness: var(--decoration-thickness);
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
@media (hover: hover) {
|
|
499
|
-
:where([data-ui~="badge"][data-badge-variant="link"]):is(button, a[href]):hover:not(
|
|
500
|
-
:disabled,
|
|
501
|
-
[aria-disabled="true"]
|
|
502
|
-
) {
|
|
503
|
-
--decoration-offset: calc(var(--decoration-thickness) * 2);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
:where([data-ui~="badge"][data-badge-variant="link"]):is(button, a[href]):active:not(
|
|
508
|
-
:disabled,
|
|
509
|
-
[aria-disabled="true"]
|
|
510
|
-
) {
|
|
511
|
-
--decoration-offset: inherit;
|
|
512
|
-
/* back to the base offset while pressed */
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/* after the variants at zero specificity: a disabled badge is muted whatever its variant */
|
|
516
|
-
:where([data-ui~="badge"]:is(button, a[href]):is(:disabled, [aria-disabled="true"])) {
|
|
517
|
-
--_badge-text: var(--color-muted-foreground);
|
|
518
|
-
--_badge-bg: var(--color-muted);
|
|
519
|
-
--_badge-shadow: 0 0 transparent;
|
|
520
|
-
|
|
521
|
-
cursor: default;
|
|
522
|
-
opacity: 0.5;
|
|
523
|
-
outline: none;
|
|
524
474
|
}
|
|
525
475
|
|
|
526
476
|
/* ===========================================================================
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<div
|
|
2
2
|
style="
|
|
3
3
|
--display: flex;
|
|
4
|
+
--flex-wrap: wrap;
|
|
4
5
|
--items: center;
|
|
5
6
|
--gap: 4;
|
|
6
7
|
"
|
|
@@ -9,5 +10,9 @@
|
|
|
9
10
|
<button type="button" data-ui="badge" data-badge-variant="primary">New</button>
|
|
10
11
|
<button type="button" data-ui="badge" data-badge-variant="muted">Draft</button>
|
|
11
12
|
<button type="button" data-ui="badge" data-badge-variant="ghost">Inline</button>
|
|
13
|
+
<button type="button" data-ui="badge" data-badge-variant="info">Update</button>
|
|
14
|
+
<button type="button" data-ui="badge" data-badge-variant="success">Paid</button>
|
|
15
|
+
<button type="button" data-ui="badge" data-badge-variant="warning">Pending</button>
|
|
16
|
+
<button type="button" data-ui="badge" data-badge-variant="destructive">Overdue</button>
|
|
12
17
|
<button type="button" data-ui="badge" data-badge-variant="link">Posts</button>
|
|
13
18
|
</div>
|