@bevelo/styles 0.0.0-stage → 0.1.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 +243 -2
- package/package.json +24 -3
- package/src/base.css +5433 -0
- package/src/index.css +6 -0
- package/src/tokens.css +319 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bevelo contributors
|
|
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,244 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @bevelo/styles
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Design tokens for `@bevelo/core`, and an optional base layer. The components put their
|
|
4
|
+
state in attributes — `role`, `aria-*`, `data-*` — and the host's stylesheet is what
|
|
5
|
+
reads them; the kit ships no component look by default. It ships no build step and no
|
|
6
|
+
JavaScript: three CSS files.
|
|
7
|
+
|
|
8
|
+
Stability: `@stable`. Token names and the attribute selectors in `base.css` follow semver;
|
|
9
|
+
token values may be tuned in a minor release.
|
|
10
|
+
|
|
11
|
+
## Files
|
|
12
|
+
|
|
13
|
+
| file | what it is |
|
|
14
|
+
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
15
|
+
| `src/tokens.css` | Design tokens as CSS custom properties: colour, shadow, geometry, size, type, motion. One `light-dark()` pair per colour, one value per theme. |
|
|
16
|
+
| `src/base.css` | An optional look for every component the kit ships, written against the attributes the components emit. Tokens only — no colour or size of its own. Not part of the default import. |
|
|
17
|
+
| `src/index.css` | The entry point: the tokens, and nothing else. |
|
|
18
|
+
|
|
19
|
+
The package exposes exactly three subpaths, in that order of granularity:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"exports": {
|
|
24
|
+
"./tokens.css": "./src/tokens.css",
|
|
25
|
+
"./base.css": "./src/base.css",
|
|
26
|
+
"./index.css": "./src/index.css"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Installing
|
|
32
|
+
|
|
33
|
+
```css
|
|
34
|
+
/* the tokens: the values a host's own stylesheet reads */
|
|
35
|
+
@import "@bevelo/styles/index.css";
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```css
|
|
39
|
+
/* the optional neutral look on top of the tokens */
|
|
40
|
+
@import "@bevelo/styles/tokens.css";
|
|
41
|
+
@import "@bevelo/styles/base.css";
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
A host that writes its own component styles imports the tokens and stops there: the
|
|
45
|
+
attributes are the API, and `base.css` is a starting point it can keep, override or
|
|
46
|
+
ignore. Import tokens before base if you import them separately: `base.css` reads the
|
|
47
|
+
variables and does not declare them, so a base-first import paints one frame of browser
|
|
48
|
+
defaults.
|
|
49
|
+
|
|
50
|
+
## The token table
|
|
51
|
+
|
|
52
|
+
The design language: a warm near-black paper, light-dark pairs, a four-step shadow scale with line rings, four radii, three control sizes and a
|
|
53
|
+
20px leading.
|
|
54
|
+
|
|
55
|
+
| group | token | value |
|
|
56
|
+
| ------------ | -------------------------------------- | ---------------------------------------------------------------------------------------------- |
|
|
57
|
+
| ink / paper | `--ui-color-ink` | `light-dark(#171717, #dedcd7)` |
|
|
58
|
+
| | `--ui-color-paper` | `light-dark(#fff, #141413)` |
|
|
59
|
+
| surfaces | `--ui-color-surface-1` | `light-dark(#fff, #1a1a19)` |
|
|
60
|
+
| | `--ui-color-surface-2` | `light-dark(#fff, #212120)` |
|
|
61
|
+
| | `--ui-color-surface-3` | `light-dark(#fff, #282827)` |
|
|
62
|
+
| lines | `--ui-color-line` | `light-dark(#a2a2a0, #6f6e6b)` |
|
|
63
|
+
| | `--ui-color-line-faint` | `light-dark(#e2e2e0, #3a3937)` |
|
|
64
|
+
| | `--ui-color-line-disabled` | `light-dark(#a8a8a6, #5f5e5b)` |
|
|
65
|
+
| tint / muted | `--ui-color-tint` | `light-dark(#f4f4f3, #262625)` |
|
|
66
|
+
| | `--ui-color-muted` | `light-dark(#6f6f6c, #9a9893)` |
|
|
67
|
+
| accent | `--ui-color-accent` | `var(--ui-color-ink)` |
|
|
68
|
+
| | `--ui-color-halo` | `color-mix(in oklab, accent 22%, transparent)` |
|
|
69
|
+
| | `--ui-color-accent-text` | `var(--ui-color-paper)` |
|
|
70
|
+
| | `--ui-color-backdrop` | `light-dark(rgb(23 23 23 / 40%), rgb(0 0 0 / 60%))` |
|
|
71
|
+
| danger | `--ui-color-danger` | `light-dark(#d60020, #ec7a72)` |
|
|
72
|
+
| shadows | `--ui-shadow-drop` | `0 2px 3px -1px` (16% ink light / 60% black dark) |
|
|
73
|
+
| | `--ui-shadow-drop-pressed` | `0 1px 1px -1px` (same mix) |
|
|
74
|
+
| | `--ui-shadow-float` | `0 2px 4px -1px 6%, 0 9px 22px -6px 16%` |
|
|
75
|
+
| | `--ui-shadow-2` | `0 0 0 1px var(--ui-color-line), var(--ui-shadow-float)` |
|
|
76
|
+
| | `--ui-shadow-3` | ring + `0 4px 8px -2px 6% + 0 22px 46px -12px 26%` |
|
|
77
|
+
| radii | `--ui-radius-row` | `7px` |
|
|
78
|
+
| | `--ui-radius-control` | `8px` |
|
|
79
|
+
| | `--ui-radius-surface` | `10px` |
|
|
80
|
+
| | `--ui-radius-popup` | `12px` |
|
|
81
|
+
| space | `--ui-space-1` … `--ui-space-6` | `4 / 8 / 12 / 16 / 24 / 32px` (`7` = 40, `8` = 48, kept for layouts that need the wider steps) |
|
|
82
|
+
| sizes | `--ui-size-control-sm` | `28px` |
|
|
83
|
+
| | `--ui-size-control-md` | `34px` |
|
|
84
|
+
| | `--ui-size-control-lg` | `38px` |
|
|
85
|
+
| | `--ui-size-item` | `32px` |
|
|
86
|
+
| | `--ui-size-icon` | `16px` |
|
|
87
|
+
| type | `--ui-text-xs` … `--ui-text-2xl` | `12 / 13 / 14 / 16 / 20 / 24px` |
|
|
88
|
+
| | `--ui-leading` | `20px` |
|
|
89
|
+
| motion | `--ui-duration` | `0.15s`, `0s` under `prefers-reduced-motion: reduce` |
|
|
90
|
+
| | `--ui-ease-standard` / `--ui-ease-out` | `cubic-bezier(0.2, 0, 0, 1)` / `cubic-bezier(0, 0, 0.2, 1)` |
|
|
91
|
+
|
|
92
|
+
The full list is in `src/tokens.css`.
|
|
93
|
+
|
|
94
|
+
## Theming
|
|
95
|
+
|
|
96
|
+
A theme is a set of token values. Override them after the import, on `:root` or on any
|
|
97
|
+
subtree; a component never needs a second class name.
|
|
98
|
+
|
|
99
|
+
```css
|
|
100
|
+
:root {
|
|
101
|
+
--ui-color-accent: oklch(0.55 0.2 300);
|
|
102
|
+
--ui-color-surface-1: oklch(0.99 0.005 300);
|
|
103
|
+
--ui-space-3: 0.75rem; /* the whole 4px scale shifts with this one */
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Every colour is one `light-dark()` pair, and a theme is the `color-scheme` that pair
|
|
108
|
+
resolves against. That gives two triggers:
|
|
109
|
+
|
|
110
|
+
- **system preference** — `prefers-color-scheme` applies while no theme is forced;
|
|
111
|
+
- **explicit choice** — put `data-theme="dark"` (or `"light"`) on `<html>` or on any
|
|
112
|
+
subtree. `data-theme="light"` forces light even inside a dark subtree, which is what
|
|
113
|
+
makes a per-section override (a code sample that must stay dark, a preview pane) work:
|
|
114
|
+
`light-dark()` resolves against the element's own `color-scheme`, and the forced
|
|
115
|
+
blocks re-declare it.
|
|
116
|
+
|
|
117
|
+
The files also set `color-scheme`, so the browser's own scrollbars, form controls and
|
|
118
|
+
canvas follow the theme instead of staying white on a dark page.
|
|
119
|
+
|
|
120
|
+
The docs site's toggle is the intended consumer: it writes `system | light | dark` into
|
|
121
|
+
`data-theme` on `<html>` and persists the choice. The styles package only reads the
|
|
122
|
+
attribute; it has no opinion about where the preference comes from.
|
|
123
|
+
|
|
124
|
+
### Token groups
|
|
125
|
+
|
|
126
|
+
Colour: `--ui-color-ink`, `-paper`, `-surface-1|2|3`, `-line`, `-line-faint`,
|
|
127
|
+
`-line-disabled`, `-tint`, `-muted`, `-accent`, `-accent-text`, `-halo`,
|
|
128
|
+
`-backdrop`, `-danger`, `-success`, `-warning`. `-accent-text` is the ink on an accent
|
|
129
|
+
fill, not another accent; `-halo` is the focus ring.
|
|
130
|
+
|
|
131
|
+
Shadow: `--ui-shadow-drop`, `-drop-pressed`, `-float`, `-2`, `-3`. `2` and `3` are a
|
|
132
|
+
line ring plus a float, so a popup and a dialog get their edge from the shadow rather
|
|
133
|
+
than from a border.
|
|
134
|
+
|
|
135
|
+
Geometry: `--ui-space-1` … `--ui-space-8` (a 4px-based rem scale),
|
|
136
|
+
`--ui-radius-row|control|surface|popup|full`, `--ui-border-width`,
|
|
137
|
+
`--ui-z-layer|dropdown|overlay`.
|
|
138
|
+
|
|
139
|
+
Size: `--ui-size-control-sm|md|lg` (control heights), `--ui-size-item` (a row in a menu,
|
|
140
|
+
list or toolbar), `--ui-size-icon` (the box an icon or check mark fits in).
|
|
141
|
+
|
|
142
|
+
Type: `--ui-font-sans`, `--ui-font-mono`, `--ui-text-xs|sm|md|lg|xl|2xl`,
|
|
143
|
+
`--ui-leading`, `--ui-line-tight|base|loose`, `--ui-weight-normal|medium|semibold`.
|
|
144
|
+
|
|
145
|
+
Motion: `--ui-duration`, `--ui-ease-standard|out`.
|
|
146
|
+
|
|
147
|
+
## What base.css assumes about a host
|
|
148
|
+
|
|
149
|
+
- **The attributes are the API.** A variant is one selector on `aria-*` / `data-*`; the
|
|
150
|
+
file never asks a component for a class name, and a host's class names stay free.
|
|
151
|
+
- **One owner per value.** Geometry a component was given at runtime (a carousel's
|
|
152
|
+
transform, a drawer's size, a virtual list's row offset, a table column's width) arrives
|
|
153
|
+
as an inline style. `base.css` does not write those properties, so there is no tug of war.
|
|
154
|
+
- **Specificity is low on purpose.** Shared resets are wrapped in `:where()`; component
|
|
155
|
+
groups use plain attribute selectors. A host overrides with a class, an id, or its own
|
|
156
|
+
token values.
|
|
157
|
+
- **Reduced motion is honoured.** `--ui-duration` becomes `0s` under
|
|
158
|
+
`prefers-reduced-motion: reduce`, so every transition declared against it is already
|
|
159
|
+
off; the state changes remain, only the interpolation between them goes. The end of the
|
|
160
|
+
file also pins the few animations (the indeterminate progress bar becomes a static
|
|
161
|
+
half-full bar).
|
|
162
|
+
- **Shadow DOM cannot be crossed.** These are element selectors, so a host that renders a
|
|
163
|
+
component inside a shadow root must import the same CSS into that root (the tokens
|
|
164
|
+
inherit through the boundary; the selectors do not).
|
|
165
|
+
|
|
166
|
+
## Compatibility notes
|
|
167
|
+
|
|
168
|
+
- Colours use `light-dark()`, which needs Chrome 123+, Safari 17.5+ or Firefox 120+.
|
|
169
|
+
The file is one pair per colour rather than three blocks per theme; a browser without
|
|
170
|
+
`light-dark()` would paint the light value in both themes, which sets the kit's browser
|
|
171
|
+
floor.
|
|
172
|
+
- `base.css` reads two runtime values as numbers with typed `attr()`
|
|
173
|
+
(`attr(data-percent type(<number>), 0)`), for the progress/meter fill and the slider
|
|
174
|
+
thumb. Browsers without typed `attr()` paint an empty track at 0%; everything else on
|
|
175
|
+
the component (value text, ARIA, keyboard) still works.
|
|
176
|
+
- `:has()` selects the wrappers that have no marker attribute of their own (a field that
|
|
177
|
+
contains a textarea, a select root that contains its trigger). It is supported by every
|
|
178
|
+
browser the kit targets.
|
|
179
|
+
|
|
180
|
+
## Checking it
|
|
181
|
+
|
|
182
|
+
Two checks, because they fail differently.
|
|
183
|
+
|
|
184
|
+
**Does it parse and bundle?** `node scripts/check-css.mjs` at the repo root runs
|
|
185
|
+
lightningcss over `src/index.css` with `bundle` + `minify` and fails on a syntax error, an
|
|
186
|
+
unknown at-rule or an unbalanced block. `pnpm check:css` runs the same script. A file that
|
|
187
|
+
parses is not a file that paints, so there is a second check.
|
|
188
|
+
|
|
189
|
+
**Does it paint the components it claims to?** The rules here are written against the
|
|
190
|
+
attributes the components emit, and attribute names are easy to guess wrong — a rule keyed
|
|
191
|
+
on `data-menu-panel` matches nothing if the menu never writes it, and the panel silently
|
|
192
|
+
paints as text. So the check is a fixture built from the components' own markup:
|
|
193
|
+
|
|
194
|
+
1. **Render, do not hand-write.** A small Node script reuses the jsdom preamble from
|
|
195
|
+
`examples/scripts/prerender.mjs` (same globals, same stubs), mounts one example per
|
|
196
|
+
component, clicks the triggers that open panels, and serialises what the components
|
|
197
|
+
actually produced — including the markup they portal into `[data-ui-layer-root]`.
|
|
198
|
+
Every fragment is embedded in a fixture HTML with `tokens.css` and `base.css`
|
|
199
|
+
inlined, plus a thin fixture-only layer that puts anchored panels in flow (jsdom has no
|
|
200
|
+
layout, so a fixed panel would sit at 0,0) and caps scrolling regions to a visible
|
|
201
|
+
height. None of that fixture CSS ships.
|
|
202
|
+
2. **Screenshot 1280 wide, light and dark, at 2x DPR.** Headless Chrome, one capture of
|
|
203
|
+
the page and one per component section, plus a `data-theme="dark"` page.
|
|
204
|
+
3. **Measure, not only look.** The fixture then reads back `getComputedStyle` and
|
|
205
|
+
`getBoundingClientRect` for the kit's controls: a default button is 34px and a large
|
|
206
|
+
one 38px (`data-size`), a text field is 34px, a menu row is 32px, the focus ring is a
|
|
207
|
+
3px halo, the radii resolve to 7/8/10/12, and a popup and a dialog carry the two- and
|
|
208
|
+
three-step shadows. A rule that silently matches nothing shows up here as a default
|
|
209
|
+
(16px) font size and no border.
|
|
210
|
+
4. **Fix until both passes are clean**, then re-run `check-css` and `pnpm build`.
|
|
211
|
+
|
|
212
|
+
A stylesheet written from the components' names rather than their output keys on
|
|
213
|
+
attributes nothing emits, which is why the method starts from rendered markup and why the
|
|
214
|
+
look lives in one file.
|
|
215
|
+
|
|
216
|
+
The package still has no script and no build of its own: the two checks above run from the
|
|
217
|
+
repo root and from the apps that consume the file.
|
|
218
|
+
|
|
219
|
+
## Design notes
|
|
220
|
+
|
|
221
|
+
- **Control heights and the type scale are separate groups.** Control heights are
|
|
222
|
+
`--ui-size-control-sm|md|lg` (plus `--ui-size-item` and `--ui-size-icon`), and font
|
|
223
|
+
sizes are `--ui-text-*`, so a size token never means two things.
|
|
224
|
+
- **Motion is a token group.** `base.css` cannot honour reduced motion without durations
|
|
225
|
+
and easings to switch off, and keeping the values in `base.css` would break its
|
|
226
|
+
tokens-only rule.
|
|
227
|
+
- Token names are namespaced per group (`--ui-color-*`, `--ui-space-*`,
|
|
228
|
+
`--ui-size-*`) rather than bare member names. A group prefix keeps a host's own
|
|
229
|
+
`--ui-accent` or `--ui-radius` from being reinterpreted as a kit token by accident.
|
|
230
|
+
- The colour picker's field and hue ramp are drawn from token colours
|
|
231
|
+
(`--ui-color-paper` → `--ui-color-accent`, with `--ui-color-ink` for the shading), not
|
|
232
|
+
from a literal spectrum. A true hue ramp needs six or more colour literals, which the
|
|
233
|
+
tokens-only rule forbids; a host that wants one paints over `[data-square]` and
|
|
234
|
+
`[data-hue]`, and the component's own pointer position keeps working either way.
|
|
235
|
+
- `[data-preview]` in the colour picker paints the accent token. The component never
|
|
236
|
+
writes the picked colour to that element (it writes it to the trigger's swatch), so the
|
|
237
|
+
stylesheet has no value to read.
|
|
238
|
+
- The success and warning hues are OKLCH values, written as `light-dark()` pairs.
|
|
239
|
+
|
|
240
|
+
## Not in this package
|
|
241
|
+
|
|
242
|
+
Utilities, a reset for the host page, per-component CSS files and any runtime theme
|
|
243
|
+
management. The kit's components are styled by their attributes; anything beyond that is
|
|
244
|
+
a host design decision, and a host makes it by setting tokens.
|
package/package.json
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bevelo/styles",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Design tokens for the kit's attribute contract, plus an optional base layer.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./tokens.css": "./src/tokens.css",
|
|
8
|
+
"./base.css": "./src/base.css",
|
|
9
|
+
"./index.css": "./src/index.css"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"src"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"homepage": "https://github.com/bevelo/bevelo#readme",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/bevelo/bevelo/issues"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/bevelo/bevelo.git",
|
|
22
|
+
"directory": "packages/styles"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
}
|
|
6
27
|
}
|