@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
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
--ui-button-font-family: var(--font-family-body);
|
|
27
27
|
--ui-button-font-size: var(--font-size-sm);
|
|
28
28
|
--ui-button-font-weight: var(--font-weight-strong);
|
|
29
|
-
--ui-button-leading:
|
|
29
|
+
--ui-button-leading: 1;
|
|
30
30
|
|
|
31
31
|
--ui-button-bg: var(--color-background);
|
|
32
32
|
--ui-button-bg--hover: oklch(from var(--color-background) calc(l - 0.025) c h);
|
|
@@ -411,16 +411,25 @@
|
|
|
411
411
|
--_button-shadow: 0 0 transparent;
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
414
|
+
/* Status variants (info, success, warning, destructive) share one soft
|
|
415
|
+
design: the status color at 10% alpha (20% in dark) as the surface, and
|
|
416
|
+
the status hue as the text with its lightness clamped (at most 0.45 in
|
|
417
|
+
light, at least 0.82 in dark) so it holds 4.5:1 on the tint and on the
|
|
418
|
+
hover and active steps; status-contrast.browser.test.ts checks it. No border. One rule derives the states from the
|
|
419
|
+
surface; each variant names only its colors. */
|
|
420
|
+
:where(
|
|
421
|
+
[data-ui~="button"]:is(
|
|
422
|
+
[data-button-variant="info"],
|
|
423
|
+
[data-button-variant="success"],
|
|
424
|
+
[data-button-variant="warning"],
|
|
425
|
+
[data-button-variant="destructive"]
|
|
426
|
+
)
|
|
427
|
+
) {
|
|
428
|
+
--_button-bg--hover: oklch(from var(--_button-bg) l c h / calc(alpha + 0.1));
|
|
429
|
+
--_button-bg--active: oklch(from var(--_button-bg) l c h / calc(alpha + 0.15));
|
|
420
430
|
|
|
421
|
-
--_button-text: var(--
|
|
422
|
-
--_button-text--
|
|
423
|
-
--_button-text--active: var(--color-info-foreground);
|
|
431
|
+
--_button-text--hover: var(--_button-text);
|
|
432
|
+
--_button-text--active: var(--_button-text);
|
|
424
433
|
|
|
425
434
|
--_button-border-color: transparent;
|
|
426
435
|
--_button-border-color--hover: transparent;
|
|
@@ -429,58 +438,52 @@
|
|
|
429
438
|
--_button-shadow: 0 0 transparent;
|
|
430
439
|
}
|
|
431
440
|
|
|
441
|
+
:where([data-ui~="button"][data-button-variant="info"]) {
|
|
442
|
+
--_button-ring-color: var(--color-info);
|
|
443
|
+
--_button-bg: light-dark(
|
|
444
|
+
oklch(from var(--color-info) l c h / 0.1),
|
|
445
|
+
oklch(from var(--color-info) l c h / 0.2)
|
|
446
|
+
);
|
|
447
|
+
--_button-text: light-dark(
|
|
448
|
+
oklch(from var(--color-info) min(l, 0.45) c h),
|
|
449
|
+
oklch(from var(--color-info) max(l, 0.82) c h)
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
|
|
432
453
|
:where([data-ui~="button"][data-button-variant="success"]) {
|
|
433
454
|
--_button-ring-color: var(--color-success);
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
--_button-border-color: transparent;
|
|
444
|
-
--_button-border-color--hover: transparent;
|
|
445
|
-
--_button-border-color--active: transparent;
|
|
446
|
-
|
|
447
|
-
--_button-shadow: 0 0 transparent;
|
|
455
|
+
--_button-bg: light-dark(
|
|
456
|
+
oklch(from var(--color-success) l c h / 0.1),
|
|
457
|
+
oklch(from var(--color-success) l c h / 0.2)
|
|
458
|
+
);
|
|
459
|
+
--_button-text: light-dark(
|
|
460
|
+
oklch(from var(--color-success) min(l, 0.45) c h),
|
|
461
|
+
oklch(from var(--color-success) max(l, 0.82) c h)
|
|
462
|
+
);
|
|
448
463
|
}
|
|
449
464
|
|
|
450
465
|
:where([data-ui~="button"][data-button-variant="warning"]) {
|
|
451
466
|
--_button-ring-color: var(--color-warning);
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
--_button-border-color: transparent;
|
|
462
|
-
--_button-border-color--hover: transparent;
|
|
463
|
-
--_button-border-color--active: transparent;
|
|
464
|
-
|
|
465
|
-
--_button-shadow: 0 0 transparent;
|
|
467
|
+
--_button-bg: light-dark(
|
|
468
|
+
oklch(from var(--color-warning) l c h / 0.1),
|
|
469
|
+
oklch(from var(--color-warning) l c h / 0.2)
|
|
470
|
+
);
|
|
471
|
+
--_button-text: light-dark(
|
|
472
|
+
oklch(from var(--color-warning) min(l, 0.45) c h),
|
|
473
|
+
oklch(from var(--color-warning) max(l, 0.82) c h)
|
|
474
|
+
);
|
|
466
475
|
}
|
|
467
476
|
|
|
468
477
|
:where([data-ui~="button"][data-button-variant="destructive"]) {
|
|
469
478
|
--_button-ring-color: var(--color-destructive);
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
--_button-border-color: transparent;
|
|
480
|
-
--_button-border-color--hover: transparent;
|
|
481
|
-
--_button-border-color--active: transparent;
|
|
482
|
-
|
|
483
|
-
--_button-shadow: 0 0 transparent;
|
|
479
|
+
--_button-bg: light-dark(
|
|
480
|
+
oklch(from var(--color-destructive) l c h / 0.1),
|
|
481
|
+
oklch(from var(--color-destructive) l c h / 0.2)
|
|
482
|
+
);
|
|
483
|
+
--_button-text: light-dark(
|
|
484
|
+
oklch(from var(--color-destructive) min(l, 0.45) c h),
|
|
485
|
+
oklch(from var(--color-destructive) max(l, 0.82) c h)
|
|
486
|
+
);
|
|
484
487
|
}
|
|
485
488
|
|
|
486
489
|
:where([data-ui~="button"][data-button-variant="link"]) {
|
|
@@ -494,7 +497,6 @@
|
|
|
494
497
|
|
|
495
498
|
--_button-border-style: none;
|
|
496
499
|
|
|
497
|
-
/* no minimum: the link sizes to its text (dual mode cannot carry fit-content) */
|
|
498
500
|
--_button-min-h: 0;
|
|
499
501
|
--_button-px: 0;
|
|
500
502
|
--_button-rounded: 0;
|
|
@@ -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
|
"
|
|
@@ -10,6 +11,9 @@
|
|
|
10
11
|
<button data-ui="button" data-button-variant="muted" type="button">Muted</button>
|
|
11
12
|
<button data-ui="button" data-button-variant="ghost" type="button">Ghost</button>
|
|
12
13
|
<button data-ui="button" data-button-variant="outline" type="button">Outline</button>
|
|
14
|
+
<button data-ui="button" data-button-variant="info" type="button">Info</button>
|
|
15
|
+
<button data-ui="button" data-button-variant="success" type="button">Success</button>
|
|
16
|
+
<button data-ui="button" data-button-variant="warning" type="button">Warning</button>
|
|
13
17
|
<button data-ui="button" data-button-variant="destructive" type="button">Destructive</button>
|
|
14
18
|
<button data-ui="button" data-button-variant="link" type="button">Link</button>
|
|
15
19
|
</div>
|
|
@@ -86,29 +86,54 @@
|
|
|
86
86
|
--_callout-border-color: transparent;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
/* status variants: the
|
|
89
|
+
/* status variants: the soft status colors buttons and badges use (see
|
|
90
|
+
button.css), plus a faint status border that outlines the block */
|
|
90
91
|
|
|
91
92
|
:where([data-ui~="callout"][data-callout-variant="info"]) {
|
|
92
|
-
--_callout-bg:
|
|
93
|
-
|
|
93
|
+
--_callout-bg: light-dark(
|
|
94
|
+
oklch(from var(--color-info) l c h / 0.1),
|
|
95
|
+
oklch(from var(--color-info) l c h / 0.2)
|
|
96
|
+
);
|
|
97
|
+
--_callout-text: light-dark(
|
|
98
|
+
oklch(from var(--color-info) min(l, 0.45) c h),
|
|
99
|
+
oklch(from var(--color-info) max(l, 0.82) c h)
|
|
100
|
+
);
|
|
94
101
|
--_callout-border-color: oklch(from var(--color-info) l c h / 0.2);
|
|
95
102
|
}
|
|
96
103
|
|
|
97
104
|
:where([data-ui~="callout"][data-callout-variant="success"]) {
|
|
98
|
-
--_callout-bg:
|
|
99
|
-
|
|
105
|
+
--_callout-bg: light-dark(
|
|
106
|
+
oklch(from var(--color-success) l c h / 0.1),
|
|
107
|
+
oklch(from var(--color-success) l c h / 0.2)
|
|
108
|
+
);
|
|
109
|
+
--_callout-text: light-dark(
|
|
110
|
+
oklch(from var(--color-success) min(l, 0.45) c h),
|
|
111
|
+
oklch(from var(--color-success) max(l, 0.82) c h)
|
|
112
|
+
);
|
|
100
113
|
--_callout-border-color: oklch(from var(--color-success) l c h / 0.2);
|
|
101
114
|
}
|
|
102
115
|
|
|
103
116
|
:where([data-ui~="callout"][data-callout-variant="warning"]) {
|
|
104
|
-
--_callout-bg:
|
|
105
|
-
|
|
117
|
+
--_callout-bg: light-dark(
|
|
118
|
+
oklch(from var(--color-warning) l c h / 0.1),
|
|
119
|
+
oklch(from var(--color-warning) l c h / 0.2)
|
|
120
|
+
);
|
|
121
|
+
--_callout-text: light-dark(
|
|
122
|
+
oklch(from var(--color-warning) min(l, 0.45) c h),
|
|
123
|
+
oklch(from var(--color-warning) max(l, 0.82) c h)
|
|
124
|
+
);
|
|
106
125
|
--_callout-border-color: oklch(from var(--color-warning) l c h / 0.2);
|
|
107
126
|
}
|
|
108
127
|
|
|
109
128
|
:where([data-ui~="callout"][data-callout-variant="destructive"]) {
|
|
110
|
-
--_callout-bg:
|
|
111
|
-
|
|
112
|
-
|
|
129
|
+
--_callout-bg: light-dark(
|
|
130
|
+
oklch(from var(--color-destructive) l c h / 0.1),
|
|
131
|
+
oklch(from var(--color-destructive) l c h / 0.2)
|
|
132
|
+
);
|
|
133
|
+
--_callout-text: light-dark(
|
|
134
|
+
oklch(from var(--color-destructive) min(l, 0.45) c h),
|
|
135
|
+
oklch(from var(--color-destructive) max(l, 0.82) c h)
|
|
136
|
+
);
|
|
137
|
+
--_callout-border-color: oklch(from var(--color-destructive) l c h / 0.2);
|
|
113
138
|
}
|
|
114
139
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** A stable name per finding, so a linter can switch each one off. */
|
|
2
|
-
export type RuleId = "unknown-utility" | "pseudo-form" | "group-needs-state" | "border-value" | "not-integer" | "tier-unsupported" | "tier-without-base" | "dual-value" | "keyword-number" | "raw-shadows-utility" | "flattens-state" | "gradient-incomplete" | "font-weight-name" | "scroll-state" | "whitespace-before-colon" | "attribute-outside-identity" | "field-id-or-name" | "persist";
|
|
2
|
+
export type RuleId = "unknown-utility" | "pseudo-form" | "group-needs-state" | "border-value" | "not-integer" | "tier-unsupported" | "tier-without-base" | "dual-value" | "keyword-number" | "raw-shadows-utility" | "flattens-state" | "gradient-incomplete" | "font-weight-name" | "scroll-state" | "whitespace-before-colon" | "whitespace-after-colon" | "attribute-outside-identity" | "field-id-or-name" | "persist";
|
|
3
3
|
export declare const RULE_IDS: readonly RuleId[];
|
|
4
4
|
/** `[start, end)` offsets into the `style` attribute's value. */
|
|
5
5
|
export type Span = [number, number];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-core.d.ts","sourceRoot":"","sources":["audit-core.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"audit-core.d.ts","sourceRoot":"","sources":["audit-core.ts"],"names":[],"mappings":"AA0BA,sEAAsE;AACtE,MAAM,MAAM,MAAM,GACd,iBAAiB,GACjB,aAAa,GACb,mBAAmB,GACnB,cAAc,GACd,aAAa,GACb,kBAAkB,GAClB,mBAAmB,GACnB,YAAY,GACZ,gBAAgB,GAChB,qBAAqB,GACrB,gBAAgB,GAChB,qBAAqB,GACrB,kBAAkB,GAClB,cAAc,GACd,yBAAyB,GACzB,wBAAwB,GACxB,4BAA4B,GAC5B,kBAAkB,GAClB,SAAS,CAAC;AAEd,eAAO,MAAM,QAAQ,EAAE,SAAS,MAAM,EAoBrC,CAAC;AAEF,iEAAiE;AACjE,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEpC,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,+CAA+C;AAC/C,MAAM,WAAW,SAAS;IACxB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC1C,iBAAiB,IAAI,MAAM,EAAE,CAAC;IAC9B,oGAAoG;IACpG,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC;CACtE;AAED,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAChC,kEAAkE;IAClE,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,wGAAwG;IACxG,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;CACrC;AAyFD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,SAAS,MAAM,EAAE,GAC5B,OAAO,CAOT;AAED,4DAA4D;AAC5D,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,EAAE,CAkT3E;AAED,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,EAAE,EAAE,CAAC,CAAC;IACN,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,2FAA2F;AAC3F,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,IAAI,EAAE,OAAO,EACb,SAAS,EAAE,CAAC,EAAE,EACd,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,MAAM,EACvB,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,YAAY,GAAG,IAAI,EACvC,SAAS,GAAE,iBAAiB,GAAG,wBAA4C,GAC1E;IAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,CAAA;CAAE,CAgD9C"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* where it can, the span of the declaration it is about (offsets into the
|
|
8
8
|
* `style` attribute) and a suggested rewrite.
|
|
9
9
|
*/
|
|
10
|
-
import { BORDER_SHORTHANDS, GRADIENT_TYPES, UTILITIES, PSEUDO_ONLY, FONT_WEIGHT_NAMES, STUCK_STATE, STATES, parseUtilityName, tiersOf, } from "../../base/utilities.js";
|
|
10
|
+
import { BORDER_SHORTHANDS, DISPLAY_SHORTHANDS, GRADIENT_TYPES, UTILITIES, PSEUDO_ONLY, FONT_WEIGHT_NAMES, STUCK_STATE, STATES, parseUtilityName, tiersOf, } from "../../base/utilities.js";
|
|
11
11
|
export const RULE_IDS = [
|
|
12
12
|
"unknown-utility",
|
|
13
13
|
"pseudo-form",
|
|
@@ -24,6 +24,7 @@ export const RULE_IDS = [
|
|
|
24
24
|
"font-weight-name",
|
|
25
25
|
"scroll-state",
|
|
26
26
|
"whitespace-before-colon",
|
|
27
|
+
"whitespace-after-colon",
|
|
27
28
|
"attribute-outside-identity",
|
|
28
29
|
"field-id-or-name",
|
|
29
30
|
"persist",
|
|
@@ -37,6 +38,19 @@ const BUTTON_TYPES = new Set(["button", "submit", "reset", "image"]);
|
|
|
37
38
|
const NUMBER = /^-?(\d+\.?\d*|\.\d+)$/;
|
|
38
39
|
const DIMENSION = /^-?(\d+\.?\d*|\.\d+)(px|r?em|%|v[wh]|v[ib]|[sld]v[wh]|ch|ex|cap|ic|lh|rlh|cq[iwhb]|cqmin|cqmax|pt|cm|mm|in)$/;
|
|
39
40
|
const FUNCTION = /^(calc|clamp|min|max|var|env|round|mod|rem|abs|sign)\(/;
|
|
41
|
+
/**
|
|
42
|
+
* True when the kit matches `value` as text (`[style*="--w: auto"]`): a
|
|
43
|
+
* keyword, a token by name, a `--display` shorthand, `none` on `--bg`, or
|
|
44
|
+
* `sticky` on `--position`. Those forms need exactly one space after the colon;
|
|
45
|
+
* a tier gate (`--p:`) reads the property itself and takes any spacing.
|
|
46
|
+
*/
|
|
47
|
+
function gatedValue(utility, value) {
|
|
48
|
+
return ((utility.keywords ?? []).includes(value) ||
|
|
49
|
+
value in (utility.aliases ?? {}) ||
|
|
50
|
+
(utility.name === "display" && value in DISPLAY_SHORTHANDS) ||
|
|
51
|
+
(utility.name === "bg" && value === "none") ||
|
|
52
|
+
(utility.name === "position" && value === "sticky"));
|
|
53
|
+
}
|
|
40
54
|
/** Splits a `style` attribute into declarations with their spans. */
|
|
41
55
|
function declarations(text) {
|
|
42
56
|
const found = [];
|
|
@@ -49,12 +63,11 @@ function declarations(text) {
|
|
|
49
63
|
continue;
|
|
50
64
|
const lead = part.length - part.trimStart().length;
|
|
51
65
|
const trail = part.length - part.trimEnd().length;
|
|
66
|
+
const raw = part.slice(colon + 1);
|
|
52
67
|
found.push({
|
|
53
68
|
name: part.slice(0, colon),
|
|
54
|
-
value:
|
|
55
|
-
|
|
56
|
-
.replace(/!\s*important\s*$/i, "")
|
|
57
|
-
.trim(),
|
|
69
|
+
value: raw.replace(/!\s*important\s*$/i, "").trim(),
|
|
70
|
+
raw,
|
|
58
71
|
span: [start + lead, start + part.length - trail],
|
|
59
72
|
});
|
|
60
73
|
}
|
|
@@ -131,6 +144,18 @@ export function auditNode(node, context) {
|
|
|
131
144
|
for (const [parsed, name, declaration] of parsedPairs) {
|
|
132
145
|
const { value, span } = declaration;
|
|
133
146
|
const warn = (rule, message, suggestion) => found.push({ rule, message, span, ...(suggestion ? { suggestion } : {}) });
|
|
147
|
+
// the gated forms match the attribute text, so `--w:auto` and `--w: auto` miss
|
|
148
|
+
const spacing = () => {
|
|
149
|
+
const { raw } = declaration;
|
|
150
|
+
if (raw === ` ${value}` || /!\s*important/i.test(raw))
|
|
151
|
+
return;
|
|
152
|
+
const colon = span[0] + declaration.name.trimStart().length;
|
|
153
|
+
warn("whitespace-after-colon", `\`${name}:${raw}\` is matched as text, so it needs exactly one space after the colon: \`${name}: ${value}\`.`, {
|
|
154
|
+
description: `Write \`${name}: ${value}\`.`,
|
|
155
|
+
span: [colon + 1, span[1]],
|
|
156
|
+
text: ` ${value}`,
|
|
157
|
+
});
|
|
158
|
+
};
|
|
134
159
|
// --stuck-state names the side a sticky container reports as stuck
|
|
135
160
|
if (parsed.name === STUCK_STATE.modifier && !parsed.group && !parsed.side) {
|
|
136
161
|
if (parsed.tier) {
|
|
@@ -139,6 +164,9 @@ export function auditNode(node, context) {
|
|
|
139
164
|
else if (!STUCK_STATE.sides.includes(value)) {
|
|
140
165
|
warn("scroll-state", `\`${name}: ${value}\` is not a side the stuck state matches: ${STUCK_STATE.sides.join(", ")}.`);
|
|
141
166
|
}
|
|
167
|
+
else {
|
|
168
|
+
spacing();
|
|
169
|
+
}
|
|
142
170
|
continue;
|
|
143
171
|
}
|
|
144
172
|
const utility = UTILITY_BY_NAME.get(parsed.name);
|
|
@@ -159,6 +187,8 @@ export function auditNode(node, context) {
|
|
|
159
187
|
warn("pseudo-form", `\`${name}\` exists only as \`--before-${utility.name}\` / \`--after-${utility.name}\`.`);
|
|
160
188
|
continue;
|
|
161
189
|
}
|
|
190
|
+
if (!parsed.side && gatedValue(utility, value))
|
|
191
|
+
spacing();
|
|
162
192
|
const baseName = (parsed.side ? `${parsed.side}-` : "") + utility.name;
|
|
163
193
|
if (parsed.group && parsed.tier === "stuck") {
|
|
164
194
|
warn("scroll-state", `\`${name}\` has no group form: the sticky container is the trigger, so write \`--${utility.name}--stuck\` inside it.`);
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
13
|
BORDER_SHORTHANDS,
|
|
14
|
+
DISPLAY_SHORTHANDS,
|
|
14
15
|
GRADIENT_TYPES,
|
|
15
16
|
UTILITIES,
|
|
16
17
|
PSEUDO_ONLY,
|
|
@@ -40,6 +41,7 @@ export type RuleId =
|
|
|
40
41
|
| "font-weight-name"
|
|
41
42
|
| "scroll-state"
|
|
42
43
|
| "whitespace-before-colon"
|
|
44
|
+
| "whitespace-after-colon"
|
|
43
45
|
| "attribute-outside-identity"
|
|
44
46
|
| "field-id-or-name"
|
|
45
47
|
| "persist";
|
|
@@ -60,6 +62,7 @@ export const RULE_IDS: readonly RuleId[] = [
|
|
|
60
62
|
"font-weight-name",
|
|
61
63
|
"scroll-state",
|
|
62
64
|
"whitespace-before-colon",
|
|
65
|
+
"whitespace-after-colon",
|
|
63
66
|
"attribute-outside-identity",
|
|
64
67
|
"field-id-or-name",
|
|
65
68
|
"persist",
|
|
@@ -122,9 +125,27 @@ interface Declaration {
|
|
|
122
125
|
/** The name as written; its whitespace is a finding. */
|
|
123
126
|
name: string;
|
|
124
127
|
value: string;
|
|
128
|
+
/** The text after the colon as written (`!important` included), for the whitespace check. */
|
|
129
|
+
raw: string;
|
|
125
130
|
span: Span;
|
|
126
131
|
}
|
|
127
132
|
|
|
133
|
+
/**
|
|
134
|
+
* True when the kit matches `value` as text (`[style*="--w: auto"]`): a
|
|
135
|
+
* keyword, a token by name, a `--display` shorthand, `none` on `--bg`, or
|
|
136
|
+
* `sticky` on `--position`. Those forms need exactly one space after the colon;
|
|
137
|
+
* a tier gate (`--p:`) reads the property itself and takes any spacing.
|
|
138
|
+
*/
|
|
139
|
+
function gatedValue(utility: Utility, value: string): boolean {
|
|
140
|
+
return (
|
|
141
|
+
(utility.keywords ?? []).includes(value) ||
|
|
142
|
+
value in (utility.aliases ?? {}) ||
|
|
143
|
+
(utility.name === "display" && value in DISPLAY_SHORTHANDS) ||
|
|
144
|
+
(utility.name === "bg" && value === "none") ||
|
|
145
|
+
(utility.name === "position" && value === "sticky")
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
128
149
|
/** Splits a `style` attribute into declarations with their spans. */
|
|
129
150
|
function declarations(text: string): Declaration[] {
|
|
130
151
|
const found: Declaration[] = [];
|
|
@@ -136,12 +157,11 @@ function declarations(text: string): Declaration[] {
|
|
|
136
157
|
if (colon === -1) continue;
|
|
137
158
|
const lead = part.length - part.trimStart().length;
|
|
138
159
|
const trail = part.length - part.trimEnd().length;
|
|
160
|
+
const raw = part.slice(colon + 1);
|
|
139
161
|
found.push({
|
|
140
162
|
name: part.slice(0, colon),
|
|
141
|
-
value:
|
|
142
|
-
|
|
143
|
-
.replace(/!\s*important\s*$/i, "")
|
|
144
|
-
.trim(),
|
|
163
|
+
value: raw.replace(/!\s*important\s*$/i, "").trim(),
|
|
164
|
+
raw,
|
|
145
165
|
span: [start + lead, start + part.length - trail],
|
|
146
166
|
});
|
|
147
167
|
}
|
|
@@ -227,6 +247,21 @@ export function auditNode(node: AuditNode, context: AuditContext): Finding[] {
|
|
|
227
247
|
const { value, span } = declaration;
|
|
228
248
|
const warn = (rule: RuleId, message: string, suggestion?: Suggestion) =>
|
|
229
249
|
found.push({ rule, message, span, ...(suggestion ? { suggestion } : {}) });
|
|
250
|
+
// the gated forms match the attribute text, so `--w:auto` and `--w: auto` miss
|
|
251
|
+
const spacing = () => {
|
|
252
|
+
const { raw } = declaration;
|
|
253
|
+
if (raw === ` ${value}` || /!\s*important/i.test(raw)) return;
|
|
254
|
+
const colon = span[0] + declaration.name.trimStart().length;
|
|
255
|
+
warn(
|
|
256
|
+
"whitespace-after-colon",
|
|
257
|
+
`\`${name}:${raw}\` is matched as text, so it needs exactly one space after the colon: \`${name}: ${value}\`.`,
|
|
258
|
+
{
|
|
259
|
+
description: `Write \`${name}: ${value}\`.`,
|
|
260
|
+
span: [colon + 1, span[1]],
|
|
261
|
+
text: ` ${value}`,
|
|
262
|
+
},
|
|
263
|
+
);
|
|
264
|
+
};
|
|
230
265
|
// --stuck-state names the side a sticky container reports as stuck
|
|
231
266
|
if (parsed.name === STUCK_STATE.modifier && !parsed.group && !parsed.side) {
|
|
232
267
|
if (parsed.tier) {
|
|
@@ -239,6 +274,8 @@ export function auditNode(node: AuditNode, context: AuditContext): Finding[] {
|
|
|
239
274
|
"scroll-state",
|
|
240
275
|
`\`${name}: ${value}\` is not a side the stuck state matches: ${STUCK_STATE.sides.join(", ")}.`,
|
|
241
276
|
);
|
|
277
|
+
} else {
|
|
278
|
+
spacing();
|
|
242
279
|
}
|
|
243
280
|
continue;
|
|
244
281
|
}
|
|
@@ -265,6 +302,7 @@ export function auditNode(node: AuditNode, context: AuditContext): Finding[] {
|
|
|
265
302
|
);
|
|
266
303
|
continue;
|
|
267
304
|
}
|
|
305
|
+
if (!parsed.side && gatedValue(utility, value)) spacing();
|
|
268
306
|
const baseName = (parsed.side ? `${parsed.side}-` : "") + utility.name;
|
|
269
307
|
if (parsed.group && parsed.tier === "stuck") {
|
|
270
308
|
warn(
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
loading="lazy"
|
|
66
66
|
width="800"
|
|
67
67
|
height="400"
|
|
68
|
-
src="https://
|
|
69
|
-
alt="
|
|
68
|
+
src="https://images.unsplash.com/photo-1564760055775-d63b17a55c44?auto=format&fit=crop&w=800&h=400&q=60"
|
|
69
|
+
alt="Elephants crossing a floodplain at dusk"
|
|
70
70
|
/>
|
|
71
|
-
<figcaption>Figure 1:
|
|
71
|
+
<figcaption>Figure 1: An image and its caption, styled by data-ui="prose"</figcaption>
|
|
72
72
|
</figure>
|
|
73
73
|
</article>
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
<table data-ui="table" data-table-size="sm">
|
|
2
2
|
<thead>
|
|
3
3
|
<tr>
|
|
4
|
-
<th>
|
|
5
|
-
<th>
|
|
6
|
-
<th>
|
|
4
|
+
<th>Attribute</th>
|
|
5
|
+
<th>Kind</th>
|
|
6
|
+
<th>Values</th>
|
|
7
7
|
</tr>
|
|
8
8
|
</thead>
|
|
9
9
|
<tbody>
|
|
10
10
|
<tr>
|
|
11
|
-
<td>data-variant</td>
|
|
12
|
-
<td>
|
|
13
|
-
<td
|
|
11
|
+
<td>data-table-variant</td>
|
|
12
|
+
<td>preset</td>
|
|
13
|
+
<td>alternating, grid</td>
|
|
14
14
|
</tr>
|
|
15
15
|
<tr>
|
|
16
|
-
<td>data-size</td>
|
|
17
|
-
<td>
|
|
18
|
-
<td
|
|
16
|
+
<td>data-table-size</td>
|
|
17
|
+
<td>preset</td>
|
|
18
|
+
<td>sm</td>
|
|
19
19
|
</tr>
|
|
20
20
|
<tr>
|
|
21
|
-
<td>data-state</td>
|
|
22
|
-
<td>
|
|
23
|
-
<td
|
|
21
|
+
<td>data-table-state</td>
|
|
22
|
+
<td>state</td>
|
|
23
|
+
<td>selected</td>
|
|
24
24
|
</tr>
|
|
25
25
|
</tbody>
|
|
26
26
|
</table>
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
--display: flex-col;
|
|
19
19
|
--p: 4;
|
|
20
20
|
--gap: 2;
|
|
21
|
-
--h:
|
|
21
|
+
--h: 24;
|
|
22
22
|
--bg: var(--color-muted);
|
|
23
23
|
--rounded: var(--radius-md);
|
|
24
24
|
--overflow-x: clip;
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
--text-align: center;
|
|
40
40
|
--text: var(--color-muted-foreground);
|
|
41
41
|
"
|
|
42
|
-
|
|
42
|
+
>--overflow-y: auto</span
|
|
43
43
|
>
|
|
44
44
|
</div>
|
|
45
45
|
<div
|
|
@@ -53,11 +53,10 @@
|
|
|
53
53
|
--display: flex-col;
|
|
54
54
|
--p: 4;
|
|
55
55
|
--gap: 2;
|
|
56
|
-
--h:
|
|
56
|
+
--h: 24;
|
|
57
57
|
--bg: var(--color-muted);
|
|
58
58
|
--rounded: var(--radius-md);
|
|
59
|
-
--overflow
|
|
60
|
-
--overflow-y: auto;
|
|
59
|
+
--overflow: hidden;
|
|
61
60
|
"
|
|
62
61
|
>
|
|
63
62
|
<p data-ui="text-sm">Scrollable region one</p>
|
|
@@ -74,7 +73,7 @@
|
|
|
74
73
|
--text-align: center;
|
|
75
74
|
--text: var(--color-muted-foreground);
|
|
76
75
|
"
|
|
77
|
-
|
|
76
|
+
>--overflow: hidden</span
|
|
78
77
|
>
|
|
79
78
|
</div>
|
|
80
79
|
</div>
|