@iyulab/components 1.22.0 → 1.24.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 +242 -0
- package/LICENSE +1 -1
- package/README.md +33 -1
- package/dist/components/UOverlayElement.d.ts +18 -0
- package/dist/components/UOverlayElement.js +24 -0
- package/dist/components/badge/UBadge.d.ts +5 -0
- package/dist/components/badge/UBadge.js +9 -0
- package/dist/components/badge/UBadge.styles.js +6 -0
- package/dist/components/dialog/UDialog.styles.js +1 -1
- package/dist/components/drawer/UDrawer.styles.js +1 -1
- package/dist/components/expander/UExpander.d.ts +38 -0
- package/dist/components/expander/UExpander.js +78 -0
- package/dist/components/expander/UExpander.styles.d.ts +1 -0
- package/dist/components/expander/UExpander.styles.js +95 -0
- package/dist/components/field/UField.styles.js +15 -0
- package/dist/components/icon/UIcon.d.ts +17 -4
- package/dist/components/icon/UIcon.js +9 -6
- package/dist/components/panel/UPanel.d.ts +0 -2
- package/dist/components/panel/UPanel.js +0 -5
- package/dist/components/skeleton/USkeleton.d.ts +7 -0
- package/dist/components/skeleton/USkeleton.js +7 -1
- package/dist/components/skeleton/USkeleton.styles.js +64 -0
- package/dist/components/tab-panel/UTabPanel.d.ts +4 -2
- package/dist/components/tab-panel/UTabPanel.js +0 -5
- package/dist/components/tag/UTag.d.ts +7 -0
- package/dist/components/tag/UTag.js +10 -1
- package/dist/components/tag/UTag.styles.js +4 -0
- package/dist/components/text/UText.d.ts +38 -0
- package/dist/components/text/UText.js +45 -0
- package/dist/components/text/UText.styles.d.ts +1 -0
- package/dist/components/text/UText.styles.js +91 -0
- package/dist/components/tree/UTree.d.ts +4 -2
- package/dist/components/tree/UTree.js +0 -5
- package/dist/components/tree-item/UTreeItem.d.ts +4 -1
- package/dist/components/tree-item/UTreeItem.js +0 -5
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/react/UExpander.d.ts +16 -0
- package/dist/react/UExpander.js +13 -0
- package/dist/react/UText.d.ts +12 -0
- package/dist/react/UText.js +10 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +2 -0
- package/dist/utilities/Dialog.js +1 -1
- package/dist/utilities/Locale.d.ts +34 -0
- package/dist/utilities/Locale.js +43 -6
- package/dist/utilities/Theme.d.ts +37 -0
- package/dist/utilities/Theme.js +65 -0
- package/dist/utilities/accent.d.ts +52 -0
- package/dist/utilities/accent.js +127 -0
- package/dist/utilities/icons.js +1 -1
- package/dist/utilities/statusIcon.d.ts +31 -0
- package/dist/utilities/statusIcon.js +34 -0
- package/package.json +5 -3
- package/skills/iyulab-components/SKILL.md +4 -1
- package/skills/iyulab-components/references/components/badge.md +2 -1
- package/skills/iyulab-components/references/components/button.md +3 -1
- package/skills/iyulab-components/references/components/copy-button.md +80 -0
- package/skills/iyulab-components/references/components/drawer.md +30 -0
- package/skills/iyulab-components/references/components/expander.md +70 -0
- package/skills/iyulab-components/references/components/icon.md +12 -0
- package/skills/iyulab-components/references/components/input.md +6 -0
- package/skills/iyulab-components/references/components/panel.md +6 -4
- package/skills/iyulab-components/references/components/skeleton.md +12 -0
- package/skills/iyulab-components/references/components/tab-panel.md +4 -5
- package/skills/iyulab-components/references/components/tag.md +18 -1
- package/skills/iyulab-components/references/components/text.md +79 -0
- package/skills/iyulab-components/references/components/textarea.md +5 -0
- package/skills/iyulab-components/references/components/tree.md +2 -4
- package/skills/iyulab-components/references/usage.md +73 -2
- package/skills/iyulab-components/references/utilities/theme.md +23 -4
|
@@ -64,13 +64,84 @@ const current = Theme.get(); // 'system' | 'light' | 'dark' | undefined
|
|
|
64
64
|
|
|
65
65
|
### Brand color customization
|
|
66
66
|
|
|
67
|
+
**Recommended — derive the whole ramp from one seed:**
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { Theme } from '@iyulab/components';
|
|
71
|
+
|
|
72
|
+
Theme.accent('#7c3aed'); // computes --u-primary-color-{weakest,weaker,weak,…,strong} + txt
|
|
73
|
+
Theme.accent(null); // back to the sheet defaults
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The computed ramp satisfies the contrast contract this library tests against — text on the
|
|
77
|
+
accent surface ≥ 4.5:1, accent text on the page background ≥ 4.5:1, `-strong` distinguishable
|
|
78
|
+
from `-color`, and `-weak` usable as a non-text graphic (≥ 3:1). It is **recalculated when the
|
|
79
|
+
theme changes**, because those targets are relative to the page background.
|
|
80
|
+
|
|
81
|
+
#### How many tokens does the `primary` role have? **Seven.**
|
|
82
|
+
|
|
83
|
+
`Theme.accent()` sets **six** of them:
|
|
84
|
+
|
|
85
|
+
| Token | `Theme.accent()` | What reads it |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| `--u-primary-color` | ✅ | accent surface — 21 source files |
|
|
88
|
+
| `--u-primary-color-strong` | ✅ | text/icons on the page background; hover · active · link · focus ring — 14 files |
|
|
89
|
+
| `--u-primary-color-weak` | ✅ | non-text graphics |
|
|
90
|
+
| `--u-primary-color-weaker` | ✅ | decorative |
|
|
91
|
+
| `--u-primary-color-weakest` | ✅ | decorative |
|
|
92
|
+
| `--u-primary-txt-color` | ✅ | text on the accent surface |
|
|
93
|
+
| **`--u-primary-bg-color`** | 🔴**no** | tinted **surface behind text** — `u-tag`'s `--tag-hue-surface` |
|
|
94
|
+
|
|
95
|
+
🔴 **`Theme.accent()` does not touch `--u-primary-bg-color`.** It stays on the sheet default
|
|
96
|
+
(a blue tint), so a seeded brand leaves tinted surfaces blue. Set it yourself alongside the seed:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
Theme.accent('#7c3aed');
|
|
100
|
+
document.documentElement.style.setProperty('--u-primary-bg-color', '#f3e8ff');
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Pick a tint that keeps your body text readable on it — the built-in sheet values sit at roughly
|
|
104
|
+
1.14:1 (light) and 1.03:1 (dark) against the page background. Deriving this step automatically is
|
|
105
|
+
tracked as open work, because the sheet pairs it by hand across five colour roles and two themes.
|
|
106
|
+
|
|
107
|
+
**Manual override** — you must set the steps you use, not just one:
|
|
108
|
+
|
|
67
109
|
```css
|
|
68
110
|
:root {
|
|
69
|
-
--u-primary-color: #
|
|
111
|
+
--u-primary-color-weak: #a78bfa; /* graphics on the page background */
|
|
112
|
+
--u-primary-color: #7c3aed; /* accent surface */
|
|
113
|
+
--u-primary-color-strong: #5b21b6; /* text/icons on the page background */
|
|
114
|
+
--u-primary-txt-color: #ffffff; /* text on the accent surface */
|
|
115
|
+
--u-primary-bg-color: #f3e8ff; /* tinted surface behind text */
|
|
70
116
|
}
|
|
71
117
|
```
|
|
72
118
|
|
|
73
|
-
|
|
119
|
+
⚠ Setting `--u-primary-color` alone is **not enough**: hover/focus/link colors resolve from
|
|
120
|
+
`--u-primary-color-strong`, so they stay on the default ramp and your brand looks half-applied.
|
|
121
|
+
The measured symptom is a *selected table row* or *tag* that stays blue while buttons turn brand —
|
|
122
|
+
that one is `--u-primary-bg-color`.
|
|
123
|
+
|
|
124
|
+
### Typography
|
|
125
|
+
|
|
126
|
+
The sheet defines seven semantic steps — `display`, `title`, `subtitle`, `body`, `label`,
|
|
127
|
+
`caption`, `overline` — each with `-size`, `-weight`, `-leading`, `-tracking`. Use them from
|
|
128
|
+
markup with [`u-text`](./components/text.md) instead of writing your own CSS:
|
|
129
|
+
|
|
130
|
+
```html
|
|
131
|
+
<u-text level="1" variant="display">Document title</u-text>
|
|
132
|
+
<u-text variant="subtitle" tone="weak">One-line description</u-text>
|
|
133
|
+
<u-text>Body copy</u-text>
|
|
134
|
+
<u-text variant="caption" tone="weak">Helper text</u-text>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
`variant` is the visual step and `level` is the document level — they are independent, and
|
|
138
|
+
`level` renders a real `<h1>`–`<h6>` so the heading is read as one.
|
|
139
|
+
|
|
140
|
+
To rebrand typography, override the tokens rather than the screens:
|
|
141
|
+
|
|
142
|
+
```css
|
|
143
|
+
:root { --u-text-title-size: 22px; --u-text-title-weight: 800; }
|
|
144
|
+
```
|
|
74
145
|
|
|
75
146
|
---
|
|
76
147
|
|
|
@@ -22,17 +22,34 @@ await Theme.init({
|
|
|
22
22
|
});
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
##
|
|
25
|
+
## Brand accent
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
**Recommended — derive the whole ramp from one seed:**
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
Theme.accent('#7c3aed'); // computes --u-primary-color-{weakest…strong} + --u-primary-txt-color
|
|
31
|
+
Theme.accent(null); // back to the sheet defaults
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The computed ramp satisfies the contrast contract this library tests against — text on the accent
|
|
35
|
+
surface ≥ 4.5:1, accent text on the page background ≥ 4.5:1, `-strong` distinguishable from
|
|
36
|
+
`-color`, and `-weak` usable as a non-text graphic (≥ 3:1). It is **recalculated when the theme
|
|
37
|
+
changes**, because those targets are relative to the page background.
|
|
38
|
+
|
|
39
|
+
**Manual override** — set the steps you use, not just one:
|
|
28
40
|
|
|
29
41
|
```css
|
|
30
42
|
:root {
|
|
31
|
-
--u-primary-color: #
|
|
43
|
+
--u-primary-color-weak: #a78bfa; /* graphics on the page background */
|
|
44
|
+
--u-primary-color: #7c3aed; /* accent surface */
|
|
45
|
+
--u-primary-color-strong: #5b21b6; /* text/icons on the page background */
|
|
46
|
+
--u-primary-txt-color: #ffffff; /* text on the accent surface */
|
|
32
47
|
}
|
|
33
48
|
```
|
|
34
49
|
|
|
35
|
-
|
|
50
|
+
> ⚠ Overriding `--u-primary-color` **alone is not enough**. Hover, focus and link colors resolve
|
|
51
|
+
> from `--u-primary-color-strong`, so they stay on the default ramp and the brand looks
|
|
52
|
+
> half-applied. (The sheet derives no step from `--u-primary-color` — measured: 0 references.)
|
|
36
53
|
|
|
37
54
|
## API
|
|
38
55
|
|
|
@@ -41,6 +58,8 @@ With this single token override, components such as buttons, checkbox/radio/swit
|
|
|
41
58
|
| `Theme.init(options?)` | `Promise<void>` | Initialize and apply theme |
|
|
42
59
|
| `Theme.get()` | `ThemeType \| undefined` | Get current theme |
|
|
43
60
|
| `Theme.set(theme)` | `void` | Set theme (`'light'`, `'dark'`, `'system'`) |
|
|
61
|
+
| `Theme.resolved()` | `'light' | 'dark'` | The theme actually applied — use this, not `get()`, for brightness branches |
|
|
62
|
+
| `Theme.accent(seed)` | `void` | Derive the `--u-primary-*` ramp from a brand color; `null` clears it |
|
|
44
63
|
| `Theme.isInitialized` | `boolean` | Whether `init()` has been called |
|
|
45
64
|
|
|
46
65
|
## Types
|