@wzrhine/tokens 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/LICENSE +21 -0
- package/README.md +28 -3
- package/dist/contract.d.ts +56 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +165 -0
- package/dist/contract.js.map +1 -0
- package/dist/contrast.d.ts +10 -0
- package/dist/contrast.d.ts.map +1 -0
- package/dist/contrast.js +39 -0
- package/dist/contrast.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +406 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +246 -0
- package/dist/manifest.js.map +1 -0
- package/dist/tokens.css +316 -0
- package/package.json +42 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Changelog · @wzrhine/tokens
|
|
2
|
+
|
|
3
|
+
格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循 [SemVer](https://semver.org/lang/zh-CN/)。token **重命名或删除**视为破坏性变更;**色值调整**会注明对比度验证结果。
|
|
4
|
+
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
## [0.2.0] - 2026-10-14
|
|
8
|
+
|
|
9
|
+
与四个组件 / 契约包保持同一版本线。本包没有删除或重命名 token,既有 token 的取值未变。
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- 分类色 `--rl-category-1` … `--rl-category-8`:展示性分类(工具类别、材料分类等)的色调,随 `publicTokens` 纳入冻结合约(ADR-0013:展示性分类只驱动标签、图标与色调,不驱动行为)。
|
|
13
|
+
- `--rl-danger-hover`:危险操作悬停背景。浅色 `#bf3a34`(5.01:1)、深色 `#ffaba3`(9.92:1),system 主题同名重定义并登记对比度配对。
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
- 危险按钮悬停背景此前透明,因为对应的悬停 token 缺失;补齐后由 `@wzrhine/react` 的 Button `tone="danger"` 使用,组件侧修复见该包 changelog。
|
|
17
|
+
|
|
18
|
+
## [0.1.0] - 2026-10-12
|
|
19
|
+
|
|
20
|
+
首次发布。
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
- `.rl-theme` 作用域下的语义 CSS 变量:背景、前景、边框、研究橙信号、状态色、焦点、字体角色、4px 间距、圆角、边框宽度、密度、动效时长与缓动。不修改 `:root`。
|
|
24
|
+
- 明 / 暗 / system 三套主题(`data-rl-theme`),以及 compact 密度(`data-rl-density`)和强制减动(`data-rl-motion="reduce"`)。
|
|
25
|
+
- 类型化的 manifest(`colorGroups`、`typeRoles`、`spaceScale`、`motionDurations`、`contrastPairs` 等)和 `contrastRatio()` 工具。
|
|
26
|
+
- 随组件逐步新增的 token:字段(`--rl-bg-readonly`、`--rl-field-label-width`)、浮层宽度与层级、`--rl-fg-on-danger`、`--rl-orbit-size`。
|
|
27
|
+
- **M5**:通过 `dist/` 发布 ESM 与 `.d.ts`;`./styles.css` 导出。
|
|
28
|
+
- **M6 · 稳定主题契约**:`publicTokens`(按用途分组)、`allPublicTokens`、`themedPublicTokens`、`themeAttributes`、类型 `PublicToken` / `TokenCategory`,以及 `tokenVar(name, fallback?)`。测试保证 `tokens.css` 定义的变量与契约完全一致(114 个),且 dark / system 主题恰好重定义全部颜色与阴影 token。此后删除或重命名契约内的 token 视为破坏性变更。
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
- **M1-A(ADR-0003)**:浅色 `--rl-fg-muted`、`--rl-fg-subtle`、`--rl-accent-text` 与各状态色较 STYLE.md Draft 0.1 有所加深,以满足 WCAG 2.2 AA。`--rl-focus` 改为独立的蓝墨色。所有组合由测试在三种主题下验证。
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
- **M6**:system 主题块中 `--rl-bg-readonly` 重复声明(值相同,无视觉变化);新增测试禁止任何块内重复声明。
|
|
35
|
+
|
|
36
|
+
升级步骤见 [UPGRADING.md](https://github.com/BaiZhi967/WzRhineLab-UI/blob/main/docs/development/UPGRADING.md)。
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 WhiteZhi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# @wzrhine/tokens
|
|
2
|
+
|
|
3
|
+
WzRhineLab UI 的语义设计变量:`--rl-*` CSS 自定义属性(作用域为 `.rl-theme`,不修改 `:root`),以及一份类型化的 token 清单和对比度工具。
|
|
4
|
+
|
|
5
|
+
> 原创配色,不是任何游戏的官方色板。MIT 许可证。
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add @wzrhine/tokens
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import '@wzrhine/tokens/styles.css';
|
|
13
|
+
import { contrastRatio, motionDurations } from '@wzrhine/tokens';
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<div class="rl-theme" data-rl-theme="dark" data-rl-density="compact">…</div>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
- 主题:`data-rl-theme="light" | "dark" | "system"`
|
|
21
|
+
- 密度:`data-rl-density="comfortable" | "compact"`
|
|
22
|
+
- 强制减动:`data-rl-motion="reduce"`
|
|
23
|
+
|
|
24
|
+
所有组件实际用到的前景/背景组合,都由测试在三种主题下验证 WCAG 2.2 AA。
|
|
25
|
+
|
|
26
|
+
- API 参考(自动生成):[docs/api/tokens.md](https://github.com/BaiZhi967/WzRhineLab-UI/blob/main/docs/api/tokens.md)
|
|
27
|
+
- 变更记录:[CHANGELOG.md](./CHANGELOG.md)
|
|
28
|
+
- 许可证:[MIT](./LICENSE)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable theme contract (M6).
|
|
3
|
+
*
|
|
4
|
+
* The complete list of public `--rl-*` custom properties defined by `tokens.css`, grouped by
|
|
5
|
+
* purpose, plus the data attributes that switch theme, density and motion. Tests assert that
|
|
6
|
+
* `tokens.css` defines exactly this set, so the list cannot drift silently:
|
|
7
|
+
*
|
|
8
|
+
* - Removing or renaming a token, or an attribute value, is a breaking change (CHANGELOG + migration).
|
|
9
|
+
* - Adding a token is a minor change and must be added here in the same commit.
|
|
10
|
+
* - Changing a colour value is allowed in a patch release if every `contrastPairs` entry still passes.
|
|
11
|
+
*
|
|
12
|
+
* Variables named after a component (`--rl-button-*`, `--rl-toast-*` set inside component CSS)
|
|
13
|
+
* are internal to `@wzrhine/react` and are not part of this contract.
|
|
14
|
+
*/
|
|
15
|
+
export declare const themeAttributes: {
|
|
16
|
+
readonly theme: {
|
|
17
|
+
readonly attribute: "data-rl-theme";
|
|
18
|
+
readonly values: readonly ["light", "dark", "system"];
|
|
19
|
+
};
|
|
20
|
+
readonly density: {
|
|
21
|
+
readonly attribute: "data-rl-density";
|
|
22
|
+
readonly values: readonly ["comfortable", "compact"];
|
|
23
|
+
};
|
|
24
|
+
readonly motion: {
|
|
25
|
+
readonly attribute: "data-rl-motion";
|
|
26
|
+
readonly values: readonly ["reduce"];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export declare const publicTokens: {
|
|
30
|
+
/** Redefined by every theme. */
|
|
31
|
+
readonly color: readonly ["--rl-bg-canvas", "--rl-bg-surface", "--rl-bg-subtle", "--rl-bg-raised", "--rl-bg-hover", "--rl-bg-pressed", "--rl-bg-inverse", "--rl-bg-disabled", "--rl-bg-readonly", "--rl-fg-primary", "--rl-fg-muted", "--rl-fg-subtle", "--rl-fg-inverse", "--rl-fg-on-accent", "--rl-fg-on-danger", "--rl-fg-disabled", "--rl-border-subtle", "--rl-border-default", "--rl-border-strong", "--rl-accent", "--rl-accent-hover", "--rl-accent-subtle", "--rl-accent-text", "--rl-accent-amber", "--rl-info", "--rl-info-subtle", "--rl-success", "--rl-success-subtle", "--rl-warning", "--rl-warning-subtle", "--rl-danger", "--rl-danger-hover", "--rl-danger-subtle", "--rl-category-1", "--rl-category-2", "--rl-category-3", "--rl-category-4", "--rl-category-5", "--rl-category-6", "--rl-category-7", "--rl-category-8", "--rl-focus", "--rl-inverse-hover"];
|
|
32
|
+
/** Redefined by every theme. */
|
|
33
|
+
readonly elevation: readonly ["--rl-shadow-raised", "--rl-shadow-floating"];
|
|
34
|
+
readonly typography: readonly ["--rl-font-body", "--rl-font-mono", "--rl-type-display", "--rl-type-heading-1", "--rl-type-heading-2", "--rl-type-heading-3", "--rl-type-body", "--rl-type-body-sm", "--rl-type-label", "--rl-type-label-sm", "--rl-type-meta", "--rl-type-mono", "--rl-tracking-display", "--rl-tracking-caps", "--rl-tracking-mono"];
|
|
35
|
+
readonly space: readonly ["--rl-space-0", "--rl-space-1", "--rl-space-2", "--rl-space-3", "--rl-space-4", "--rl-space-6", "--rl-space-8", "--rl-space-12", "--rl-space-16"];
|
|
36
|
+
readonly shape: readonly ["--rl-radius-none", "--rl-radius-xs", "--rl-radius-sm", "--rl-radius-md", "--rl-radius-lg", "--rl-radius-round", "--rl-border-width", "--rl-border-width-strong"];
|
|
37
|
+
readonly focus: readonly ["--rl-focus-width", "--rl-focus-offset", "--rl-focus-ring"];
|
|
38
|
+
/** Redefined by `data-rl-density="compact"` (only the control and surface entries). */
|
|
39
|
+
readonly size: readonly ["--rl-control-height-sm", "--rl-control-height-md", "--rl-control-height-lg", "--rl-control-padding-x-sm", "--rl-control-padding-x-md", "--rl-control-padding-x-lg", "--rl-control-gap", "--rl-surface-padding", "--rl-icon-size-sm", "--rl-icon-size-md", "--rl-icon-size-lg", "--rl-badge-height-sm", "--rl-badge-height-md", "--rl-indicator-size", "--rl-field-label-width", "--rl-dialog-width-sm", "--rl-dialog-width-md", "--rl-dialog-width-lg", "--rl-tooltip-max-width", "--rl-popup-max-height", "--rl-popup-offset", "--rl-popover-width-sm", "--rl-popover-width-md", "--rl-popover-width-lg", "--rl-menu-min-width", "--rl-toast-width", "--rl-orbit-size"];
|
|
40
|
+
readonly layer: readonly ["--rl-z-overlay", "--rl-z-dialog", "--rl-z-popover", "--rl-z-tooltip", "--rl-z-toast"];
|
|
41
|
+
/** Durations collapse to 0ms under reduced motion (except `--rl-motion-loop`, whose users stop looping). */
|
|
42
|
+
readonly motion: readonly ["--rl-motion-instant", "--rl-motion-press", "--rl-motion-fast", "--rl-motion-base", "--rl-motion-panel", "--rl-motion-scene", "--rl-motion-showcase", "--rl-motion-loop", "--rl-ease-out", "--rl-ease-in-out", "--rl-ease-linear"];
|
|
43
|
+
};
|
|
44
|
+
export type TokenCategory = keyof typeof publicTokens;
|
|
45
|
+
export type PublicToken = (typeof publicTokens)[TokenCategory][number];
|
|
46
|
+
/** Every public token, in contract order. */
|
|
47
|
+
export declare const allPublicTokens: readonly PublicToken[];
|
|
48
|
+
export type ThemedToken = (typeof publicTokens)['color' | 'elevation'][number];
|
|
49
|
+
/** Tokens each theme block (`dark`, `system`) must redefine. */
|
|
50
|
+
export declare const themedPublicTokens: readonly ThemedToken[];
|
|
51
|
+
/**
|
|
52
|
+
* `var(--rl-…)` for a contract token. Typed, so a renamed or misspelled token fails to compile
|
|
53
|
+
* in CSS-in-JS or inline styles instead of silently resolving to nothing.
|
|
54
|
+
*/
|
|
55
|
+
export declare function tokenVar(name: PublicToken, fallback?: string): string;
|
|
56
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;CAIlB,CAAC;AAEX,eAAO,MAAM,YAAY;IACvB,gCAAgC;;IA8ChC,gCAAgC;;;;;;IAyChC,uFAAuF;;;IA+BvF,4GAA4G;;CAcpG,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,YAAY,CAAC;AACtD,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvE,6CAA6C;AAC7C,eAAO,MAAM,eAAe,EAAE,SAAS,WAAW,EAAuC,CAAC;AAE1F,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/E,gEAAgE;AAChE,eAAO,MAAM,kBAAkB,EAAE,SAAS,WAAW,EAAuD,CAAC;AAE7G;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAErE"}
|
package/dist/contract.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable theme contract (M6).
|
|
3
|
+
*
|
|
4
|
+
* The complete list of public `--rl-*` custom properties defined by `tokens.css`, grouped by
|
|
5
|
+
* purpose, plus the data attributes that switch theme, density and motion. Tests assert that
|
|
6
|
+
* `tokens.css` defines exactly this set, so the list cannot drift silently:
|
|
7
|
+
*
|
|
8
|
+
* - Removing or renaming a token, or an attribute value, is a breaking change (CHANGELOG + migration).
|
|
9
|
+
* - Adding a token is a minor change and must be added here in the same commit.
|
|
10
|
+
* - Changing a colour value is allowed in a patch release if every `contrastPairs` entry still passes.
|
|
11
|
+
*
|
|
12
|
+
* Variables named after a component (`--rl-button-*`, `--rl-toast-*` set inside component CSS)
|
|
13
|
+
* are internal to `@wzrhine/react` and are not part of this contract.
|
|
14
|
+
*/
|
|
15
|
+
export const themeAttributes = {
|
|
16
|
+
theme: { attribute: 'data-rl-theme', values: ['light', 'dark', 'system'] },
|
|
17
|
+
density: { attribute: 'data-rl-density', values: ['comfortable', 'compact'] },
|
|
18
|
+
motion: { attribute: 'data-rl-motion', values: ['reduce'] },
|
|
19
|
+
};
|
|
20
|
+
export const publicTokens = {
|
|
21
|
+
/** Redefined by every theme. */
|
|
22
|
+
color: [
|
|
23
|
+
'--rl-bg-canvas',
|
|
24
|
+
'--rl-bg-surface',
|
|
25
|
+
'--rl-bg-subtle',
|
|
26
|
+
'--rl-bg-raised',
|
|
27
|
+
'--rl-bg-hover',
|
|
28
|
+
'--rl-bg-pressed',
|
|
29
|
+
'--rl-bg-inverse',
|
|
30
|
+
'--rl-bg-disabled',
|
|
31
|
+
'--rl-bg-readonly',
|
|
32
|
+
'--rl-fg-primary',
|
|
33
|
+
'--rl-fg-muted',
|
|
34
|
+
'--rl-fg-subtle',
|
|
35
|
+
'--rl-fg-inverse',
|
|
36
|
+
'--rl-fg-on-accent',
|
|
37
|
+
'--rl-fg-on-danger',
|
|
38
|
+
'--rl-fg-disabled',
|
|
39
|
+
'--rl-border-subtle',
|
|
40
|
+
'--rl-border-default',
|
|
41
|
+
'--rl-border-strong',
|
|
42
|
+
'--rl-accent',
|
|
43
|
+
'--rl-accent-hover',
|
|
44
|
+
'--rl-accent-subtle',
|
|
45
|
+
'--rl-accent-text',
|
|
46
|
+
'--rl-accent-amber',
|
|
47
|
+
'--rl-info',
|
|
48
|
+
'--rl-info-subtle',
|
|
49
|
+
'--rl-success',
|
|
50
|
+
'--rl-success-subtle',
|
|
51
|
+
'--rl-warning',
|
|
52
|
+
'--rl-warning-subtle',
|
|
53
|
+
'--rl-danger',
|
|
54
|
+
'--rl-danger-hover',
|
|
55
|
+
'--rl-danger-subtle',
|
|
56
|
+
'--rl-category-1',
|
|
57
|
+
'--rl-category-2',
|
|
58
|
+
'--rl-category-3',
|
|
59
|
+
'--rl-category-4',
|
|
60
|
+
'--rl-category-5',
|
|
61
|
+
'--rl-category-6',
|
|
62
|
+
'--rl-category-7',
|
|
63
|
+
'--rl-category-8',
|
|
64
|
+
'--rl-focus',
|
|
65
|
+
'--rl-inverse-hover',
|
|
66
|
+
],
|
|
67
|
+
/** Redefined by every theme. */
|
|
68
|
+
elevation: ['--rl-shadow-raised', '--rl-shadow-floating'],
|
|
69
|
+
typography: [
|
|
70
|
+
'--rl-font-body',
|
|
71
|
+
'--rl-font-mono',
|
|
72
|
+
'--rl-type-display',
|
|
73
|
+
'--rl-type-heading-1',
|
|
74
|
+
'--rl-type-heading-2',
|
|
75
|
+
'--rl-type-heading-3',
|
|
76
|
+
'--rl-type-body',
|
|
77
|
+
'--rl-type-body-sm',
|
|
78
|
+
'--rl-type-label',
|
|
79
|
+
'--rl-type-label-sm',
|
|
80
|
+
'--rl-type-meta',
|
|
81
|
+
'--rl-type-mono',
|
|
82
|
+
'--rl-tracking-display',
|
|
83
|
+
'--rl-tracking-caps',
|
|
84
|
+
'--rl-tracking-mono',
|
|
85
|
+
],
|
|
86
|
+
space: [
|
|
87
|
+
'--rl-space-0',
|
|
88
|
+
'--rl-space-1',
|
|
89
|
+
'--rl-space-2',
|
|
90
|
+
'--rl-space-3',
|
|
91
|
+
'--rl-space-4',
|
|
92
|
+
'--rl-space-6',
|
|
93
|
+
'--rl-space-8',
|
|
94
|
+
'--rl-space-12',
|
|
95
|
+
'--rl-space-16',
|
|
96
|
+
],
|
|
97
|
+
shape: [
|
|
98
|
+
'--rl-radius-none',
|
|
99
|
+
'--rl-radius-xs',
|
|
100
|
+
'--rl-radius-sm',
|
|
101
|
+
'--rl-radius-md',
|
|
102
|
+
'--rl-radius-lg',
|
|
103
|
+
'--rl-radius-round',
|
|
104
|
+
'--rl-border-width',
|
|
105
|
+
'--rl-border-width-strong',
|
|
106
|
+
],
|
|
107
|
+
focus: ['--rl-focus-width', '--rl-focus-offset', '--rl-focus-ring'],
|
|
108
|
+
/** Redefined by `data-rl-density="compact"` (only the control and surface entries). */
|
|
109
|
+
size: [
|
|
110
|
+
'--rl-control-height-sm',
|
|
111
|
+
'--rl-control-height-md',
|
|
112
|
+
'--rl-control-height-lg',
|
|
113
|
+
'--rl-control-padding-x-sm',
|
|
114
|
+
'--rl-control-padding-x-md',
|
|
115
|
+
'--rl-control-padding-x-lg',
|
|
116
|
+
'--rl-control-gap',
|
|
117
|
+
'--rl-surface-padding',
|
|
118
|
+
'--rl-icon-size-sm',
|
|
119
|
+
'--rl-icon-size-md',
|
|
120
|
+
'--rl-icon-size-lg',
|
|
121
|
+
'--rl-badge-height-sm',
|
|
122
|
+
'--rl-badge-height-md',
|
|
123
|
+
'--rl-indicator-size',
|
|
124
|
+
'--rl-field-label-width',
|
|
125
|
+
'--rl-dialog-width-sm',
|
|
126
|
+
'--rl-dialog-width-md',
|
|
127
|
+
'--rl-dialog-width-lg',
|
|
128
|
+
'--rl-tooltip-max-width',
|
|
129
|
+
'--rl-popup-max-height',
|
|
130
|
+
'--rl-popup-offset',
|
|
131
|
+
'--rl-popover-width-sm',
|
|
132
|
+
'--rl-popover-width-md',
|
|
133
|
+
'--rl-popover-width-lg',
|
|
134
|
+
'--rl-menu-min-width',
|
|
135
|
+
'--rl-toast-width',
|
|
136
|
+
'--rl-orbit-size',
|
|
137
|
+
],
|
|
138
|
+
layer: ['--rl-z-overlay', '--rl-z-dialog', '--rl-z-popover', '--rl-z-tooltip', '--rl-z-toast'],
|
|
139
|
+
/** Durations collapse to 0ms under reduced motion (except `--rl-motion-loop`, whose users stop looping). */
|
|
140
|
+
motion: [
|
|
141
|
+
'--rl-motion-instant',
|
|
142
|
+
'--rl-motion-press',
|
|
143
|
+
'--rl-motion-fast',
|
|
144
|
+
'--rl-motion-base',
|
|
145
|
+
'--rl-motion-panel',
|
|
146
|
+
'--rl-motion-scene',
|
|
147
|
+
'--rl-motion-showcase',
|
|
148
|
+
'--rl-motion-loop',
|
|
149
|
+
'--rl-ease-out',
|
|
150
|
+
'--rl-ease-in-out',
|
|
151
|
+
'--rl-ease-linear',
|
|
152
|
+
],
|
|
153
|
+
};
|
|
154
|
+
/** Every public token, in contract order. */
|
|
155
|
+
export const allPublicTokens = Object.values(publicTokens).flat();
|
|
156
|
+
/** Tokens each theme block (`dark`, `system`) must redefine. */
|
|
157
|
+
export const themedPublicTokens = [...publicTokens.color, ...publicTokens.elevation];
|
|
158
|
+
/**
|
|
159
|
+
* `var(--rl-…)` for a contract token. Typed, so a renamed or misspelled token fails to compile
|
|
160
|
+
* in CSS-in-JS or inline styles instead of silently resolving to nothing.
|
|
161
|
+
*/
|
|
162
|
+
export function tokenVar(name, fallback) {
|
|
163
|
+
return fallback === undefined ? `var(${name})` : `var(${name}, ${fallback})`;
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../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eAAe,GAA2B,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,CAAC;AAI1F,gEAAgE;AAChE,MAAM,CAAC,MAAM,kBAAkB,GAA2B,CAAC,GAAG,YAAY,CAAC,KAAK,EAAE,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;AAE7G;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAiB,EAAE,QAAiB;IAC3D,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ,GAAG,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** WCAG 2.x relative luminance and contrast ratio for opaque sRGB colours. */
|
|
2
|
+
export interface Rgb {
|
|
3
|
+
r: number;
|
|
4
|
+
g: number;
|
|
5
|
+
b: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function parseColor(input: string): Rgb | null;
|
|
8
|
+
export declare function relativeLuminance({ r, g, b }: Rgb): number;
|
|
9
|
+
export declare function contrastRatio(a: string, b: string): number;
|
|
10
|
+
//# sourceMappingURL=contrast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contrast.d.ts","sourceRoot":"","sources":["../src/contrast.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAE9E,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI,CAkBpD;AAOD,wBAAgB,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,GAAG,MAAM,CAE1D;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ1D"}
|
package/dist/contrast.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** WCAG 2.x relative luminance and contrast ratio for opaque sRGB colours. */
|
|
2
|
+
export function parseColor(input) {
|
|
3
|
+
const value = input.trim().toLowerCase();
|
|
4
|
+
const hex = /^#([0-9a-f]{3}|[0-9a-f]{6})$/.exec(value);
|
|
5
|
+
if (hex) {
|
|
6
|
+
const digits = hex[1];
|
|
7
|
+
const full = digits.length === 3 ? [...digits].map((d) => d + d).join('') : digits;
|
|
8
|
+
return {
|
|
9
|
+
r: Number.parseInt(full.slice(0, 2), 16),
|
|
10
|
+
g: Number.parseInt(full.slice(2, 4), 16),
|
|
11
|
+
b: Number.parseInt(full.slice(4, 6), 16),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const rgb = /^rgba?\(\s*(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)(?:[\s,/]+(\d*\.?\d+))?\s*\)$/.exec(value);
|
|
15
|
+
if (rgb) {
|
|
16
|
+
if (rgb[4] !== undefined && Number(rgb[4]) < 1)
|
|
17
|
+
return null;
|
|
18
|
+
return { r: Number(rgb[1]), g: Number(rgb[2]), b: Number(rgb[3]) };
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
function channel(value) {
|
|
23
|
+
const c = value / 255;
|
|
24
|
+
return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
25
|
+
}
|
|
26
|
+
export function relativeLuminance({ r, g, b }) {
|
|
27
|
+
return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
|
|
28
|
+
}
|
|
29
|
+
export function contrastRatio(a, b) {
|
|
30
|
+
const ca = parseColor(a);
|
|
31
|
+
const cb = parseColor(b);
|
|
32
|
+
if (!ca || !cb)
|
|
33
|
+
return Number.NaN;
|
|
34
|
+
const la = relativeLuminance(ca);
|
|
35
|
+
const lb = relativeLuminance(cb);
|
|
36
|
+
const [hi, lo] = la > lb ? [la, lb] : [lb, la];
|
|
37
|
+
return (hi + 0.05) / (lo + 0.05);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=contrast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contrast.js","sourceRoot":"","sources":["../src/contrast.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAQ9E,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACzC,MAAM,GAAG,GAAG,8BAA8B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvD,IAAI,GAAG,EAAE,CAAC;QACR,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,CAAE,CAAC;QACvB,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACnF,OAAO;YACL,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;YACxC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;YACxC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;SACzC,CAAC;IACJ,CAAC;IACD,MAAM,GAAG,GAAG,mGAAmG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5H,IAAI,GAAG,EAAE,CAAC;QACR,IAAI,GAAG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EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;AACnC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './manifest.js';
|
|
2
|
+
export { contrastRatio, parseColor, relativeLuminance } from './contrast.js';
|
|
3
|
+
export type { Rgb } from './contrast.js';
|
|
4
|
+
export { allPublicTokens, publicTokens, themeAttributes, themedPublicTokens, tokenVar } from './contract.js';
|
|
5
|
+
export type { PublicToken, ThemedToken, TokenCategory } from './contract.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC7E,YAAY,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC7G,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
|