@fluixi-ui/tokens 0.3.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/LICENSE +21 -0
- package/README.md +106 -0
- package/dist/css/accordion.css +7 -0
- package/dist/css/alert.css +42 -0
- package/dist/css/avatar.css +36 -0
- package/dist/css/badge.css +12 -0
- package/dist/css/base.css +10 -0
- package/dist/css/bulk-editor.css +478 -0
- package/dist/css/button.css +92 -0
- package/dist/css/calendar.css +140 -0
- package/dist/css/checkbox-radio.css +66 -0
- package/dist/css/command.css +90 -0
- package/dist/css/date-field.css +58 -0
- package/dist/css/date-picker.css +81 -0
- package/dist/css/field.css +19 -0
- package/dist/css/hover-card.css +16 -0
- package/dist/css/input.css +85 -0
- package/dist/css/kbd.css +20 -0
- package/dist/css/menubar.css +27 -0
- package/dist/css/navigation-menu.css +144 -0
- package/dist/css/number-field.css +83 -0
- package/dist/css/parts/listbox.css +111 -0
- package/dist/css/parts/menu.css +69 -0
- package/dist/css/parts/motion.css +34 -0
- package/dist/css/parts/overlays.css +36 -0
- package/dist/css/progress.css +40 -0
- package/dist/css/select-combobox.css +76 -0
- package/dist/css/separator.css +15 -0
- package/dist/css/skeleton.css +22 -0
- package/dist/css/slider.css +71 -0
- package/dist/css/spinner.css +17 -0
- package/dist/css/switch.css +33 -0
- package/dist/css/table.css +173 -0
- package/dist/css/tabs.css +32 -0
- package/dist/css/toast.css +154 -0
- package/dist/css/toggle.css +74 -0
- package/dist/css/toolbar.css +48 -0
- package/dist/css/tooltip.css +13 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/lib/css/index.d.ts +20 -0
- package/dist/lib/css/index.d.ts.map +1 -0
- package/dist/lib/css/index.js +135 -0
- package/dist/lib/reference/colors.d.ts +24 -0
- package/dist/lib/reference/colors.d.ts.map +1 -0
- package/dist/lib/reference/colors.js +150 -0
- package/dist/lib/reference/index.d.ts +302 -0
- package/dist/lib/reference/index.d.ts.map +1 -0
- package/dist/lib/reference/index.js +147 -0
- package/dist/lib/theme/index.d.ts +32 -0
- package/dist/lib/theme/index.d.ts.map +1 -0
- package/dist/lib/theme/index.js +87 -0
- package/dist/lib/vars/index.d.ts +131 -0
- package/dist/lib/vars/index.d.ts.map +1 -0
- package/dist/lib/vars/index.js +40 -0
- package/dist/preset.css +47 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +79 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fluixi
|
|
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
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/fluixi/assets/main/logos/128x128.png" alt="Fluixi" width="120" height="120" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# @fluixi-ui/tokens
|
|
6
|
+
|
|
7
|
+
**Two-tier design tokens and `preset.css` default skin for Fluixi UI.**
|
|
8
|
+
|
|
9
|
+
[](../../LICENSE)
|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
Layer 3 of the Fluixi UI ecosystem: the design token and theming system. Every
|
|
17
|
+
visual value a component uses comes from here as a CSS variable, so components
|
|
18
|
+
never hardcode design values.
|
|
19
|
+
|
|
20
|
+
## Architecture
|
|
21
|
+
|
|
22
|
+
Two tiers:
|
|
23
|
+
|
|
24
|
+
- **Reference tokens** — the raw scales. Non-color tokens (spacing, sizing,
|
|
25
|
+
typography, radius, borders, shadows, motion, opacity, blur, elevation,
|
|
26
|
+
z-index, breakpoints) are static. Color scales (`gray`, `accent`, status) are
|
|
27
|
+
authored per theme; their `--flx-ui-*` values change between themes.
|
|
28
|
+
- **Semantic tokens** — meaning-based aliases (`color-bg`, `color-fg`,
|
|
29
|
+
`color-primary`, `color-border`, …) defined once, referencing the scale
|
|
30
|
+
variables. Because the scales flip per theme, the semantics follow
|
|
31
|
+
automatically.
|
|
32
|
+
|
|
33
|
+
Components consume **semantic** tokens only.
|
|
34
|
+
|
|
35
|
+
All variables are prefixed `--flx-ui-`. Themes are selected with `data-theme` and
|
|
36
|
+
fall back to `prefers-color-scheme` when unset.
|
|
37
|
+
|
|
38
|
+
```css
|
|
39
|
+
:root, [data-theme='light'] { /* static + light scales + semantics */ }
|
|
40
|
+
[data-theme='dark'] { /* dark scales only */ }
|
|
41
|
+
[data-theme='high-contrast'] { /* high-contrast scales + semantics */ }
|
|
42
|
+
@media (prefers-color-scheme: dark) {
|
|
43
|
+
:root:not([data-theme]) { /* automatic dark */ }
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Using tokens in components
|
|
48
|
+
|
|
49
|
+
Import the `vars` reference — typed `var(--flx-ui-*)` strings — and never write raw
|
|
50
|
+
values:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { vars } from '@fluixi-ui/tokens/vars';
|
|
54
|
+
|
|
55
|
+
const styles = {
|
|
56
|
+
background: vars.color.bg,
|
|
57
|
+
color: vars.color.fg,
|
|
58
|
+
padding: vars.space[4],
|
|
59
|
+
borderRadius: vars.radius.md,
|
|
60
|
+
boxShadow: vars.shadow.md,
|
|
61
|
+
transition: `background ${vars.duration.fast} ${vars.easing.standard}`,
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Theming at runtime
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import { injectTokens, createThemeController } from '@fluixi-ui/tokens/theme';
|
|
69
|
+
|
|
70
|
+
injectTokens(); // add the stylesheet to <head>
|
|
71
|
+
|
|
72
|
+
const theme = createThemeController({ defaultPreference: 'system' });
|
|
73
|
+
theme.setPreference('dark'); // light | dark | high-contrast | system
|
|
74
|
+
theme.toggle();
|
|
75
|
+
theme.theme(); // resolved ThemeName (reactive)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`createThemeController` resolves the preference (honoring `prefers-color-scheme`
|
|
79
|
+
and `prefers-contrast` for `system`), applies it via `data-theme`, persists it,
|
|
80
|
+
and follows system changes while the preference is `system`.
|
|
81
|
+
|
|
82
|
+
Static helpers are also available: `setTheme`, `getTheme`, `clearTheme`,
|
|
83
|
+
`getSystemTheme`, `prefersHighContrast`, `prefersReducedMotion`, `resolveTheme`.
|
|
84
|
+
|
|
85
|
+
## Token categories
|
|
86
|
+
|
|
87
|
+
Colors, typography (family, size, weight, line-height, letter-spacing), spacing,
|
|
88
|
+
sizes, radius, border widths, shadows, motion (duration, easing), opacity, blur,
|
|
89
|
+
elevation, z-index, breakpoints — with light, dark and high-contrast themes.
|
|
90
|
+
|
|
91
|
+
## Performance
|
|
92
|
+
|
|
93
|
+
- Side-effect free; the stylesheet is a plain string (`tokensCss`) that can be
|
|
94
|
+
injected at runtime or extracted at build time.
|
|
95
|
+
- Theme switching only toggles one attribute; no per-component recomputation.
|
|
96
|
+
- SSR-safe: DOM and `matchMedia` access no-op on the server.
|
|
97
|
+
|
|
98
|
+
## Extension points
|
|
99
|
+
|
|
100
|
+
`generateTokensCss()` rebuilds the stylesheet from the token definitions, and the
|
|
101
|
+
reference scales (`colorScales`, `semanticColors`, `staticTokens`) are exported
|
|
102
|
+
for custom builds, additional palettes, or brand overrides.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
Part of the [Fluixi UI](../../README.md) component library. Made with ☕ by the Fluixi team.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@layer flx.components {
|
|
2
|
+
/* ----------------------------------------------------------------------------
|
|
3
|
+
* Alert
|
|
4
|
+
* ------------------------------------------------------------------------- */
|
|
5
|
+
:where([data-alert]) {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
align-items: flex-start;
|
|
9
|
+
gap: var(--flx-ui-space-1);
|
|
10
|
+
text-align: left;
|
|
11
|
+
padding-block: var(--flx-ui-space-4);
|
|
12
|
+
padding-inline: var(--flx-ui-space-4);
|
|
13
|
+
border: var(--flx-ui-border-width-thin) solid var(--flx-ui-color-border);
|
|
14
|
+
border-left-width: 3px;
|
|
15
|
+
border-radius: var(--flx-ui-radius-md);
|
|
16
|
+
background: var(--flx-ui-color-bg-subtle);
|
|
17
|
+
color: var(--flx-ui-color-fg);
|
|
18
|
+
}
|
|
19
|
+
:where([data-alert][data-variant='info']) {
|
|
20
|
+
border-color: var(--flx-ui-color-primary);
|
|
21
|
+
background: var(--flx-ui-color-primary-subtle);
|
|
22
|
+
}
|
|
23
|
+
:where([data-alert][data-variant='success']) {
|
|
24
|
+
border-color: var(--flx-ui-color-success);
|
|
25
|
+
background: var(--flx-ui-color-success-subtle);
|
|
26
|
+
}
|
|
27
|
+
:where([data-alert][data-variant='warning']) {
|
|
28
|
+
border-color: var(--flx-ui-color-warning);
|
|
29
|
+
background: var(--flx-ui-color-warning-subtle);
|
|
30
|
+
}
|
|
31
|
+
:where([data-alert][data-variant='danger']) {
|
|
32
|
+
border-color: var(--flx-ui-color-danger);
|
|
33
|
+
background: var(--flx-ui-color-danger-subtle);
|
|
34
|
+
}
|
|
35
|
+
:where([data-alert-title]) {
|
|
36
|
+
font-weight: var(--flx-ui-font-weight-semibold);
|
|
37
|
+
}
|
|
38
|
+
:where([data-alert-description]) {
|
|
39
|
+
font-size: var(--flx-ui-font-size-sm);
|
|
40
|
+
opacity: 0.9;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
@layer flx.components {
|
|
2
|
+
/* ----------------------------------------------------------------------------
|
|
3
|
+
* Avatar
|
|
4
|
+
* ------------------------------------------------------------------------- */
|
|
5
|
+
:where([data-avatar]) {
|
|
6
|
+
position: relative;
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
width: 40px;
|
|
11
|
+
height: 40px;
|
|
12
|
+
flex: none;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
border-radius: var(--flx-ui-radius-full);
|
|
15
|
+
background: var(--flx-ui-color-bg-muted);
|
|
16
|
+
color: var(--flx-ui-color-fg-muted);
|
|
17
|
+
font-weight: var(--flx-ui-font-weight-semibold);
|
|
18
|
+
font-size: var(--flx-ui-font-size-sm);
|
|
19
|
+
letter-spacing: var(--flx-ui-letter-spacing-wide);
|
|
20
|
+
user-select: none;
|
|
21
|
+
vertical-align: middle;
|
|
22
|
+
}
|
|
23
|
+
:where([data-avatar-image]) {
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: 100%;
|
|
26
|
+
object-fit: cover;
|
|
27
|
+
border-radius: inherit;
|
|
28
|
+
}
|
|
29
|
+
:where([data-avatar-fallback]) {
|
|
30
|
+
display: inline-flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
width: 100%;
|
|
34
|
+
height: 100%;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
@layer flx.components {
|
|
2
|
+
/* Badge */
|
|
3
|
+
:where([data-variant].flx-ui-badge, .flx-ui-badge[data-variant]) {
|
|
4
|
+
height: auto;
|
|
5
|
+
padding: 2px var(--flx-ui-space-2);
|
|
6
|
+
border-radius: var(--flx-ui-radius-full);
|
|
7
|
+
font-size: var(--flx-ui-font-size-xs);
|
|
8
|
+
font-weight: var(--flx-ui-font-weight-semibold);
|
|
9
|
+
letter-spacing: var(--flx-ui-letter-spacing-wide);
|
|
10
|
+
box-shadow: none;
|
|
11
|
+
}
|
|
12
|
+
}
|