@rak200/ui 0.2.2 → 0.2.4
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 +11 -1
- package/dist/button.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/tokens.d.ts +27 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +54 -3
- package/dist/tokens.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -48,9 +48,19 @@ Every visual decision is a CSS custom property, so a host restyles the kit witho
|
|
|
48
48
|
}
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
## Playground
|
|
52
|
+
|
|
53
|
+
**[rak200.github.io/ui](https://rak200.github.io/ui/)** — every component, rendered, with its
|
|
54
|
+
variants and states side by side and an accessibility panel over each one.
|
|
55
|
+
|
|
56
|
+
It follows `master` rather than the latest release, so it can show a component a published version
|
|
57
|
+
does not contain. The commit it was built from is stamped in the sidebar, so you can always tell
|
|
58
|
+
which one you are looking at.
|
|
59
|
+
|
|
51
60
|
## Documentation
|
|
52
61
|
|
|
53
|
-
The reference lives in [docs/](docs/README.md) — one page per unit.
|
|
62
|
+
The reference lives in [docs/](docs/README.md) — one page per unit. The playground shows the
|
|
63
|
+
components; `docs/` is what describes them.
|
|
54
64
|
|
|
55
65
|
## Status
|
|
56
66
|
|
package/dist/button.js
CHANGED
|
@@ -51,7 +51,7 @@ export class UiButton extends LitElement {
|
|
|
51
51
|
/* A visible focus ring is not decoration: removing it is the single most common
|
|
52
52
|
way a component stops being usable by keyboard. */
|
|
53
53
|
button:focus-visible {
|
|
54
|
-
outline: 2px solid var(--ui-color-focus, #
|
|
54
|
+
outline: 2px solid var(--ui-color-focus, #b45309);
|
|
55
55
|
outline-offset: 2px;
|
|
56
56
|
}
|
|
57
57
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { UiButton, type ButtonVariant } from './button.js';
|
|
2
2
|
export { UiField } from './field.js';
|
|
3
|
-
export { tokens, defaults, tokenStyleSheet, type Token } from './tokens.js';
|
|
3
|
+
export { tokens, defaults, darkScheme, tokenStyleSheet, type Token } from './tokens.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAsB,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAc,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAsB,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAc,MAAM,aAAa,CAAC"}
|
package/dist/tokens.d.ts
CHANGED
|
@@ -20,9 +20,36 @@ export type Token = (typeof tokens)[number];
|
|
|
20
20
|
* system's defaults are what a host sees before it has decided anything.
|
|
21
21
|
*/
|
|
22
22
|
export declare const defaults: Readonly<Record<Token, string>>;
|
|
23
|
+
/**
|
|
24
|
+
* The grounds whose value differs when the page is rendered dark.
|
|
25
|
+
*
|
|
26
|
+
* **A scheme is not a theme, and conflating them is the mistake this shape exists to
|
|
27
|
+
* avoid.** A theme is a named set of decisions, selected with `data-ui-theme`; a scheme is
|
|
28
|
+
* the light or dark rendering of whichever theme is in force, selected with
|
|
29
|
+
* `color-scheme`. The two axes are independent, and a token carries both of its schemes in
|
|
30
|
+
* one value through `light-dark()`, so a theme is a handful of grounds rather than a
|
|
31
|
+
* parallel block per scheme plus a media query nobody writes correctly the first time.
|
|
32
|
+
*
|
|
33
|
+
* `Partial` is the type doing the work: it answers *which grounds vary by scheme* in the
|
|
34
|
+
* type system. `--ui-radius` does not vary and `--ui-color-surface` does, and folding both
|
|
35
|
+
* schemes into {@link defaults} as a single expression would make those two
|
|
36
|
+
* indistinguishable — and would hand a native emitter a CSS function to parse instead of a
|
|
37
|
+
* value to read.
|
|
38
|
+
*
|
|
39
|
+
* Only colours appear here, and that is a rule rather than a coincidence: `light-dark()`
|
|
40
|
+
* takes colours, so a dark value for `--ui-radius` would emit CSS the browser discards.
|
|
41
|
+
*/
|
|
42
|
+
export declare const darkScheme: Readonly<Partial<Record<Token, string>>>;
|
|
23
43
|
/**
|
|
24
44
|
* The token defaults as a CSS rule, for a host that wants them without importing a
|
|
25
45
|
* component. Returns the text of a `:root` block; a host inserts it however it prefers.
|
|
46
|
+
*
|
|
47
|
+
* **It declares `color-scheme` as well as the tokens, and that is deliberate.**
|
|
48
|
+
* `color-scheme` is a real property rather than a custom one, so it can never be a token —
|
|
49
|
+
* and leaving it to the host is a silent failure at the highest possible frequency: every
|
|
50
|
+
* host would have to remember, and forgetting means dark mode simply never happens, with
|
|
51
|
+
* no error anywhere to read. A host who wants something else — `only light`, say — governs
|
|
52
|
+
* the order this sheet is inserted in, which is a knob they already hold.
|
|
26
53
|
*/
|
|
27
54
|
export declare function tokenStyleSheet(): string;
|
|
28
55
|
//# sourceMappingURL=tokens.d.ts.map
|
package/dist/tokens.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,mEAAmE;AACnE,eAAO,MAAM,MAAM,0LAUT,CAAC;AAEX,kDAAkD;AAClD,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,mEAAmE;AACnE,eAAO,MAAM,MAAM,0LAUT,CAAC;AAEX,kDAAkD;AAClD,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAkBpD,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAW/D,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAUxC"}
|
package/dist/tokens.js
CHANGED
|
@@ -32,18 +32,69 @@ export const defaults = {
|
|
|
32
32
|
'--ui-color-accent-contrast': '#ffffff',
|
|
33
33
|
'--ui-color-surface': '#ffffff',
|
|
34
34
|
'--ui-color-text': '#1f2937',
|
|
35
|
-
|
|
35
|
+
// Amber-700 rather than the amber-500 this shipped with, and the change is a floor
|
|
36
|
+
// rather than a preference: a focus ring is the visual information that identifies a
|
|
37
|
+
// component's state, so WCAG 1.4.11 asks 3:1 against what it sits on. `#f59e0b`
|
|
38
|
+
// against the default surface is 2.15:1 — and `outline-offset` puts the surface on
|
|
39
|
+
// both sides of the ring, so the surface is what it is measured against, not the
|
|
40
|
+
// button underneath. This value is 5.02:1 there and 3.53:1 on a dark surface, so it
|
|
41
|
+
// clears the floor in either scheme. `tests/tokens.test.ts` holds the assertion,
|
|
42
|
+
// because no axe rule does.
|
|
43
|
+
'--ui-color-focus': '#b45309',
|
|
36
44
|
'--ui-color-danger': '#b91c1c',
|
|
37
45
|
'--ui-radius': '0.375rem',
|
|
38
46
|
'--ui-space': '0.5rem',
|
|
39
47
|
'--ui-font': 'system-ui, sans-serif',
|
|
40
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* The grounds whose value differs when the page is rendered dark.
|
|
51
|
+
*
|
|
52
|
+
* **A scheme is not a theme, and conflating them is the mistake this shape exists to
|
|
53
|
+
* avoid.** A theme is a named set of decisions, selected with `data-ui-theme`; a scheme is
|
|
54
|
+
* the light or dark rendering of whichever theme is in force, selected with
|
|
55
|
+
* `color-scheme`. The two axes are independent, and a token carries both of its schemes in
|
|
56
|
+
* one value through `light-dark()`, so a theme is a handful of grounds rather than a
|
|
57
|
+
* parallel block per scheme plus a media query nobody writes correctly the first time.
|
|
58
|
+
*
|
|
59
|
+
* `Partial` is the type doing the work: it answers *which grounds vary by scheme* in the
|
|
60
|
+
* type system. `--ui-radius` does not vary and `--ui-color-surface` does, and folding both
|
|
61
|
+
* schemes into {@link defaults} as a single expression would make those two
|
|
62
|
+
* indistinguishable — and would hand a native emitter a CSS function to parse instead of a
|
|
63
|
+
* value to read.
|
|
64
|
+
*
|
|
65
|
+
* Only colours appear here, and that is a rule rather than a coincidence: `light-dark()`
|
|
66
|
+
* takes colours, so a dark value for `--ui-radius` would emit CSS the browser discards.
|
|
67
|
+
*/
|
|
68
|
+
export const darkScheme = {
|
|
69
|
+
// Blue-400 over the dark surface rather than blue-600, which is legible on white and
|
|
70
|
+
// muddy on charcoal. Its contrast pair is inverted with it: dark text on a light
|
|
71
|
+
// accent is what reads at this end.
|
|
72
|
+
'--ui-color-accent': '#60a5fa',
|
|
73
|
+
'--ui-color-accent-contrast': '#111827',
|
|
74
|
+
'--ui-color-surface': '#111827',
|
|
75
|
+
'--ui-color-text': '#e5e7eb',
|
|
76
|
+
// Red-700 is 2.74:1 on the dark surface — under the 4.5:1 floor for text, and error
|
|
77
|
+
// text is the one thing in this set that must never be hard to read. Red-400 is 6.41.
|
|
78
|
+
'--ui-color-danger': '#f87171',
|
|
79
|
+
};
|
|
41
80
|
/**
|
|
42
81
|
* The token defaults as a CSS rule, for a host that wants them without importing a
|
|
43
82
|
* component. Returns the text of a `:root` block; a host inserts it however it prefers.
|
|
83
|
+
*
|
|
84
|
+
* **It declares `color-scheme` as well as the tokens, and that is deliberate.**
|
|
85
|
+
* `color-scheme` is a real property rather than a custom one, so it can never be a token —
|
|
86
|
+
* and leaving it to the host is a silent failure at the highest possible frequency: every
|
|
87
|
+
* host would have to remember, and forgetting means dark mode simply never happens, with
|
|
88
|
+
* no error anywhere to read. A host who wants something else — `only light`, say — governs
|
|
89
|
+
* the order this sheet is inserted in, which is a knob they already hold.
|
|
44
90
|
*/
|
|
45
91
|
export function tokenStyleSheet() {
|
|
46
|
-
const body = tokens
|
|
47
|
-
|
|
92
|
+
const body = tokens
|
|
93
|
+
.map((token) => {
|
|
94
|
+
const dark = darkScheme[token];
|
|
95
|
+
return ` ${token}: ${dark === undefined ? defaults[token] : `light-dark(${defaults[token]}, ${dark})`};`;
|
|
96
|
+
})
|
|
97
|
+
.join('\n');
|
|
98
|
+
return `:root {\n color-scheme: light dark;\n${body}\n}`;
|
|
48
99
|
}
|
|
49
100
|
//# sourceMappingURL=tokens.js.map
|
package/dist/tokens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,mEAAmE;AACnE,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB,mBAAmB;IACnB,4BAA4B;IAC5B,oBAAoB;IACpB,iBAAiB;IACjB,kBAAkB;IAClB,mBAAmB;IACnB,aAAa;IACb,YAAY;IACZ,WAAW;CACL,CAAC;AAKX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAoC;IACrD,mBAAmB,EAAE,SAAS;IAC9B,4BAA4B,EAAE,SAAS;IACvC,oBAAoB,EAAE,SAAS;IAC/B,iBAAiB,EAAE,SAAS;IAC5B,kBAAkB,EAAE,SAAS;IAC7B,mBAAmB,EAAE,SAAS;IAC9B,aAAa,EAAE,UAAU;IACzB,YAAY,EAAE,QAAQ;IACtB,WAAW,EAAE,uBAAuB;CACvC,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,mEAAmE;AACnE,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB,mBAAmB;IACnB,4BAA4B;IAC5B,oBAAoB;IACpB,iBAAiB;IACjB,kBAAkB;IAClB,mBAAmB;IACnB,aAAa;IACb,YAAY;IACZ,WAAW;CACL,CAAC;AAKX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAoC;IACrD,mBAAmB,EAAE,SAAS;IAC9B,4BAA4B,EAAE,SAAS;IACvC,oBAAoB,EAAE,SAAS;IAC/B,iBAAiB,EAAE,SAAS;IAC5B,mFAAmF;IACnF,qFAAqF;IACrF,gFAAgF;IAChF,mFAAmF;IACnF,iFAAiF;IACjF,oFAAoF;IACpF,iFAAiF;IACjF,4BAA4B;IAC5B,kBAAkB,EAAE,SAAS;IAC7B,mBAAmB,EAAE,SAAS;IAC9B,aAAa,EAAE,UAAU;IACzB,YAAY,EAAE,QAAQ;IACtB,WAAW,EAAE,uBAAuB;CACvC,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,UAAU,GAA6C;IAChE,qFAAqF;IACrF,iFAAiF;IACjF,oCAAoC;IACpC,mBAAmB,EAAE,SAAS;IAC9B,4BAA4B,EAAE,SAAS;IACvC,oBAAoB,EAAE,SAAS;IAC/B,iBAAiB,EAAE,SAAS;IAC5B,oFAAoF;IACpF,sFAAsF;IACtF,mBAAmB,EAAE,SAAS;CACjC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe;IAC3B,MAAM,IAAI,GAAG,MAAM;SACd,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACX,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QAE/B,OAAO,KAAK,KAAK,KAAK,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,GAAG,GAAG,CAAC;IAC9G,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;IAEhB,OAAO,yCAAyC,IAAI,KAAK,CAAC;AAC9D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rak200/ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Host-agnostic custom-element UI components for the rak200 ecosystem",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "rak200 <rak.ricardo@windowslive.com>",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"analyse": "tsc --noEmit && eslint .",
|
|
39
39
|
"test": "vitest run",
|
|
40
40
|
"coverage": "coverage-floor",
|
|
41
|
-
"scan": "
|
|
41
|
+
"scan": "rak200-scan",
|
|
42
42
|
"mutation": "stryker run",
|
|
43
43
|
"build": "tsc -p tsconfig.build.json",
|
|
44
44
|
"storybook": "storybook dev -p 6006",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"lit": "^3.3.3"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@rak200/coding-standard-ts": "github:rak200/coding-standard-ts#0.4.
|
|
51
|
+
"@rak200/coding-standard-ts": "github:rak200/coding-standard-ts#0.4.7",
|
|
52
52
|
"@storybook/addon-a11y": "^10.5.8",
|
|
53
53
|
"@storybook/web-components-vite": "^10.5.8",
|
|
54
54
|
"@types/node": "^26.1.2",
|