@luxalgo/vela-ui 0.3.0 → 0.4.1
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 +165 -132
- package/LICENSE +201 -201
- package/NOTICE +28 -28
- package/README.md +86 -86
- package/cli/engine.mjs +282 -282
- package/cli/index.mjs +154 -154
- package/dist/button.js +2 -2
- package/dist/callout-bubble.js +3 -3
- package/dist/checkbox.js +3 -3
- package/dist/{chunk-OJ2SEMN6.js → chunk-5A54GODF.js} +2 -2
- package/dist/{chunk-UEO6W37Z.js → chunk-7LYWI32I.js} +2 -2
- package/dist/{chunk-IOOYDSSK.js → chunk-BIU66EHS.js} +2 -2
- package/dist/{chunk-KKS6NEGI.js → chunk-BWSOMG3G.js} +1 -1
- package/dist/{chunk-DXDCKZ2M.js → chunk-CZRHHVSB.js} +1 -1
- package/dist/{chunk-C3PXY2SW.js → chunk-EDYD5XKJ.js} +9 -0
- package/dist/chunk-GUIYFQ27.js +30 -0
- package/dist/{chunk-WWHNUKSZ.js → chunk-JEGB72M4.js} +8 -8
- package/dist/{chunk-B2EZB5ZG.js → chunk-ODPGOUQT.js} +4 -3
- package/dist/{chunk-TBXUF5YX.js → chunk-RH53NQGE.js} +18 -4
- package/dist/{chunk-OQXFQMZM.js → chunk-TGJNHUYV.js} +2 -2
- package/dist/collapsible.js +2 -2
- package/dist/color-picker.js +4 -4
- package/dist/context-menu.js +4 -4
- package/dist/date-picker.js +1 -1
- package/dist/dialog.js +4 -4
- package/dist/donut.d.ts +1 -1
- package/dist/drawer.js +1 -1
- package/dist/dropdown-menu.d.ts +2 -0
- package/dist/dropdown-menu.js +4 -4
- package/dist/empty.js +1 -1
- package/dist/field.js +9 -9
- package/dist/{stat.d.ts → figure.d.ts} +9 -9
- package/dist/figure.js +41 -0
- package/dist/glyph-select.js +4 -4
- package/dist/hover-card.js +1 -1
- package/dist/icons.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/input-group.js +2 -2
- package/dist/item.js +1 -1
- package/dist/manifest.json +75 -74
- package/dist/number-input.js +3 -3
- package/dist/popover.js +2 -2
- package/dist/select.d.ts +5 -1
- package/dist/select.js +5 -5
- package/dist/slider.js +1 -1
- package/dist/sort-button.js +2 -2
- package/dist/switch.js +1 -1
- package/dist/tabs.js +2 -2
- package/dist/{theme-Ct-q58xz.d.ts → theme-TefB8vtl.d.ts} +2 -2
- package/dist/theme.d.ts +2 -2
- package/dist/theme.js +1 -1
- package/dist/theme.schema.json +30 -30
- package/dist/toast.d.ts +2 -2
- package/dist/toast.js +2 -2
- package/dist/toggle-group.js +2 -2
- package/dist/tooltip.js +1 -1
- package/dist/zag.d.ts +11 -2
- package/dist/zag.js +1 -1
- package/docs/theming.md +217 -217
- package/docs/what-to-change.md +20 -20
- package/docs/writing-a-component.md +250 -250
- package/llms.txt +3 -3
- package/package.json +90 -90
- package/registry/badge.ts +119 -119
- package/registry/bar-chart.ts +215 -215
- package/registry/button.ts +387 -387
- package/registry/callout-bubble.ts +347 -347
- package/registry/card.ts +379 -379
- package/registry/checkbox.ts +234 -234
- package/registry/collapsible.ts +271 -271
- package/registry/color-picker.ts +582 -582
- package/registry/context-menu.ts +208 -208
- package/registry/data-table.ts +215 -215
- package/registry/date-picker.ts +483 -483
- package/registry/dialog.ts +551 -551
- package/registry/donut.ts +145 -145
- package/registry/drawer.ts +636 -636
- package/registry/dropdown-menu.ts +765 -762
- package/registry/empty.ts +91 -91
- package/registry/field.ts +584 -584
- package/registry/{stat.ts → figure.ts} +96 -96
- package/registry/glyph-select.ts +268 -268
- package/registry/hover-card.ts +222 -222
- package/registry/input-group.ts +229 -229
- package/registry/input.ts +181 -181
- package/registry/item.ts +376 -376
- package/registry/kbd.ts +64 -64
- package/registry/line-chart.ts +218 -218
- package/registry/month-grid.ts +328 -328
- package/registry/number-input.ts +443 -443
- package/registry/popover.ts +368 -368
- package/registry/scatter-chart.ts +221 -221
- package/registry/select.ts +629 -620
- package/registry/slider.ts +259 -259
- package/registry/sort-button.ts +189 -189
- package/registry/sparkline.ts +114 -114
- package/registry/switch.ts +205 -205
- package/registry/tabs.ts +426 -426
- package/registry/text-area.ts +186 -186
- package/registry/toast.ts +965 -965
- package/registry/toggle-group.ts +295 -295
- package/registry/tooltip.ts +156 -156
- package/registry/treemap.ts +847 -847
- package/skills/theming-vela-ui/SKILL.md +137 -137
- package/skills/using-vela-ui-components/SKILL.md +141 -139
- package/skills/writing-vela-ui-components/SKILL.md +163 -163
- package/src/components/badge.ts +119 -119
- package/src/components/bar-chart.ts +215 -215
- package/src/components/button.ts +387 -387
- package/src/components/callout-bubble.ts +347 -347
- package/src/components/card.ts +379 -379
- package/src/components/checkbox.ts +234 -234
- package/src/components/collapsible.ts +271 -271
- package/src/components/color-picker.ts +582 -582
- package/src/components/context-menu.ts +208 -208
- package/src/components/data-table.ts +215 -215
- package/src/components/date-picker.ts +483 -483
- package/src/components/dialog.ts +551 -551
- package/src/components/donut.ts +145 -145
- package/src/components/drawer.ts +636 -636
- package/src/components/dropdown-menu.ts +765 -762
- package/src/components/empty.ts +91 -91
- package/src/components/field.ts +584 -584
- package/src/components/{stat.ts → figure.ts} +96 -96
- package/src/components/glyph-select.ts +268 -268
- package/src/components/hover-card.ts +222 -222
- package/src/components/input-group.ts +229 -229
- package/src/components/input.ts +181 -181
- package/src/components/item.ts +376 -376
- package/src/components/kbd.ts +64 -64
- package/src/components/line-chart.ts +218 -218
- package/src/components/month-grid.ts +328 -328
- package/src/components/number-input.ts +443 -443
- package/src/components/popover.ts +368 -368
- package/src/components/scatter-chart.ts +221 -221
- package/src/components/select.ts +629 -620
- package/src/components/slider.ts +259 -259
- package/src/components/sort-button.ts +189 -189
- package/src/components/sparkline.ts +114 -114
- package/src/components/switch.ts +205 -205
- package/src/components/tabs.ts +426 -426
- package/src/components/text-area.ts +186 -186
- package/src/components/toast.ts +965 -965
- package/src/components/toggle-group.ts +295 -295
- package/src/components/tooltip.ts +156 -156
- package/src/components/treemap.ts +847 -847
- package/src/index.ts +24 -24
- package/src/lib/calendar.ts +117 -117
- package/src/lib/chart.ts +72 -72
- package/src/lib/color.ts +89 -89
- package/src/lib/component-index.ts +163 -163
- package/src/lib/css.ts +48 -48
- package/src/lib/define.ts +45 -45
- package/src/lib/dispose.ts +36 -36
- package/src/lib/h.ts +55 -55
- package/src/lib/headless.ts +16 -16
- package/src/lib/i18n.ts +30 -30
- package/src/lib/icons.ts +253 -244
- package/src/lib/kit-text.ts +26 -26
- package/src/lib/page.ts +24 -24
- package/src/lib/palette.ts +81 -81
- package/src/lib/placement.ts +188 -188
- package/src/lib/scope.ts +135 -135
- package/src/lib/styles.ts +53 -53
- package/src/lib/surface-events.ts +31 -31
- package/src/lib/surface-exit.ts +87 -87
- package/src/lib/t.ts +68 -68
- package/src/lib/theme.ts +684 -670
- package/src/lib/tokens.ts +110 -110
- package/src/lib/variants.ts +32 -32
- package/src/lib/zag.ts +61 -46
- package/stylelint/index.mjs +60 -60
- package/stylelint/lint.mjs +81 -81
- package/stylelint/plugin.mjs +115 -115
- package/dist/chunk-P4MTEMT7.js +0 -23
- package/dist/stat.js +0 -41
|
@@ -1,250 +1,250 @@
|
|
|
1
|
-
# Writing a component
|
|
2
|
-
|
|
3
|
-
Each component is **one file**, `src/components/<name>.ts`, published at
|
|
4
|
-
`@luxalgo/vela-ui/<name>`, holding its declaration, its variants, its CSS and its
|
|
5
|
-
`create<Name>` function. Overlays (menu, dialog, drawer, tooltip) and composite controls (tabs,
|
|
6
|
-
toggle group) run a [Zag.js](https://zagjs.com) state machine, which owns their keyboard
|
|
7
|
-
behavior and accessibility; form controls keep small vanilla state objects.
|
|
8
|
-
|
|
9
|
-
## One file per component
|
|
10
|
-
|
|
11
|
-
Start one with `npm run new-component -- gauge` at the repo root: it writes the file in the
|
|
12
|
-
shape below, adds its declaration to the theme, and writes its test. A component file reads
|
|
13
|
-
top to bottom:
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
// Gauge: … what it is and how it behaves, for the reader of the file.
|
|
17
|
-
import { css, defineStyles } from '../lib/css';
|
|
18
|
-
import { defineComponent } from '../lib/define';
|
|
19
|
-
import { h } from '../lib/h';
|
|
20
|
-
import { t } from '../lib/t';
|
|
21
|
-
import { variants, type VariantProps } from '../lib/variants';
|
|
22
|
-
|
|
23
|
-
// Its name, its parts (each part's data-slot) and its settings (custom properties a theme
|
|
24
|
-
// or a host's CSS can set, with their defaults).
|
|
25
|
-
export const gaugeDef = defineComponent({ name: 'gauge', parts: ['root', 'needle'], settings: { radius: t.radius.lg } });
|
|
26
|
-
|
|
27
|
-
// Its variants: the names type the props, the first value is the default.
|
|
28
|
-
export const gaugeVariants = variants({ size: ['md', 'sm'] });
|
|
29
|
-
|
|
30
|
-
export interface GaugeProps extends VariantProps<typeof gaugeVariants> {
|
|
31
|
-
value: number;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface GaugeHandle {
|
|
35
|
-
readonly el: HTMLElement;
|
|
36
|
-
setValue(value: number): void;
|
|
37
|
-
destroy(): void;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const injectStyles = defineStyles(
|
|
41
|
-
'vela-ui-gauge',
|
|
42
|
-
css`
|
|
43
|
-
@layer vela.ui {
|
|
44
|
-
[data-slot='gauge'] {
|
|
45
|
-
border-radius: ${gaugeDef.vars.radius};
|
|
46
|
-
background: ${t.surface.sunken};
|
|
47
|
-
|
|
48
|
-
&[data-size='sm'] { … }
|
|
49
|
-
& > [data-slot='gauge-needle'] { color: ${t.accent}; }
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
`,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
class GaugeImpl implements GaugeHandle { … } // methods shared across instances
|
|
56
|
-
|
|
57
|
-
export function createGauge(props: GaugeProps): GaugeHandle {
|
|
58
|
-
return new GaugeImpl(props);
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Then add the declaration to `ComponentDefs` in `src/lib/theme.ts`
|
|
63
|
-
(`gauge: typeof gaugeDef;`), which types the component's settings and parts in a theme. The
|
|
64
|
-
build fails while one is missing. The manifest (`dist/manifest.json`), the theme's JSON
|
|
65
|
-
Schema and `llms.txt` are generated from the file at build time, so there is nothing else to
|
|
66
|
-
list.
|
|
67
|
-
|
|
68
|
-
Released components keep their class (`new Checkbox(…)`, `new Tooltip(trigger, …)`) and their
|
|
69
|
-
controller (`checkboxController`, `tooltipController`) next to the `create…` function; the
|
|
70
|
-
class is the instance the function returns. New components start from the shape above.
|
|
71
|
-
|
|
72
|
-
## A component of your own
|
|
73
|
-
|
|
74
|
-
The same shape works outside the kit, for a component a project writes: import the helpers
|
|
75
|
-
from the package root (`import { css, defineComponent, defineStyles, h, t, variants } from
|
|
76
|
-
'@luxalgo/vela-ui'`) and keep the rules below. Three things make it a full citizen:
|
|
77
|
-
|
|
78
|
-
- **Its CSS goes in `@layer vela.ui`**, like the kit's, not in `vela.custom`: a theme's part
|
|
79
|
-
CSS sits in `vela.custom`, and only from a later layer does it restyle the component.
|
|
80
|
-
- **Declare it before creating a theme that names it.** `defineComponent` records the
|
|
81
|
-
component for the page, and `checkTheme` (and `createTheme`'s warnings) then check the
|
|
82
|
-
theme's settings and parts for it, as they do the kit's.
|
|
83
|
-
- **Type it in themes** by merging its declaration into `ComponentDefs`, so a wrong setting
|
|
84
|
-
or part fails the typecheck:
|
|
85
|
-
|
|
86
|
-
```ts
|
|
87
|
-
export const gaugeDef = defineComponent({ name: 'gauge', parts: ['root', 'needle'], settings: { radius: t.radius.lg } });
|
|
88
|
-
|
|
89
|
-
declare module '@luxalgo/vela-ui/theme' {
|
|
90
|
-
interface ComponentDefs {
|
|
91
|
-
gauge: typeof gaugeDef;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
createTheme({ components: { gauge: { radius: '2px', css: { needle: css`color: ${t.accent};` } } } });
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## Changing a component
|
|
99
|
-
|
|
100
|
-
A component's public contract is what hosts and themes build on: its props and its handle's
|
|
101
|
-
methods, its part names (the `data-slot` values), its variant and size values, the state
|
|
102
|
-
attributes its CSS keys on, and its settings. Inside the file, everything else is free to
|
|
103
|
-
change.
|
|
104
|
-
|
|
105
|
-
- **Keep the contract.** A change to how a component looks or behaves keeps those names. Add
|
|
106
|
-
a prop, a variant or a setting freely; give a new setting a default that keeps today's look,
|
|
107
|
-
so a theme that sets nothing renders as before.
|
|
108
|
-
- **Rename in two steps.** A renamed prop, part, variant or component keeps its old name
|
|
109
|
-
working for one release: the component accepts both (and says which is deprecated in the
|
|
110
|
-
prop's comment), and Vela's `src/ui/renamed.ts` keeps the old export names on
|
|
111
|
-
`@luxalgo/vela/ui`. The changelog names the old and the new, and the release after removes
|
|
112
|
-
the old one.
|
|
113
|
-
- **Prove it.** The component's test covers the change; `npm run lint` checks its CSS; the
|
|
114
|
-
gallery (`npm run playground`, then `/primitives.html`) shows every component in every
|
|
115
|
-
variant, beside the theme editor, so compare it before and after. The build regenerates the
|
|
116
|
-
manifest, the theme's JSON Schema and `llms.txt` from the file, so they follow on their
|
|
117
|
-
own.
|
|
118
|
-
- **Write it down.** A change users notice gets an entry in Vela's `CHANGELOG.md`, and a
|
|
119
|
-
breaking one says what to do instead.
|
|
120
|
-
|
|
121
|
-
## The helpers (`src/lib/`)
|
|
122
|
-
|
|
123
|
-
- **`h(tag, props, ...children)`** builds an element, typed by its tag. `slot` writes the
|
|
124
|
-
`data-slot`, `data` the `data-*` attributes (`true` writes an empty value, `false` and
|
|
125
|
-
`null` nothing), `attrs`, `on` and `text` the rest. Class names are layout hooks, never the
|
|
126
|
-
styling contract.
|
|
127
|
-
- **`css`** marks a template as CSS (editors highlight it, stylelint checks it) and
|
|
128
|
-
**`defineStyles(id, text)`** returns the injector a component calls at creation, never at
|
|
129
|
-
import: it declares the layer order once per document or shadow root, then injects the
|
|
130
|
-
sheet, id-guarded. The sheet applies inside kit hosts, their floating layers and themed
|
|
131
|
-
hosts only: a `:where()` joins the first compound of each top-level selector, adding no
|
|
132
|
-
weight, so a page's own elements that carry the same `data-slot` names are never restyled.
|
|
133
|
-
Inject a component's CSS through it, never by hand.
|
|
134
|
-
- **`t`** reads the design tokens: `${t.radius.md}` prints `var(--vela-radius-md)`, and a
|
|
135
|
-
name that does not exist fails the typecheck. A test checks that `t` and the tokens the
|
|
136
|
-
theme writes match in both directions.
|
|
137
|
-
- **`variants(spec)`** turns `{ variant: [...], size: [...] }` into the `data-*` attributes
|
|
138
|
-
the CSS keys on, and types the props through `VariantProps`.
|
|
139
|
-
- **`defineComponent({ name, parts, settings })`** links a name to its CSS: `slot(part)` is
|
|
140
|
-
the part's `data-slot` (`name` for `root`, `name-part` otherwise), and `vars.<setting>`
|
|
141
|
-
prints `var(--vela-<name>-<setting>, <default>)`.
|
|
142
|
-
- **`addSlot(el, part)`** adds a part to an element's slot. A shell one component owns and
|
|
143
|
-
another builds on carries both, `data-slot="popover-content select-content"`, and CSS
|
|
144
|
-
matches either with `[data-slot~='…']`.
|
|
145
|
-
|
|
146
|
-
## CSS rules
|
|
147
|
-
|
|
148
|
-
- Everything sits in **`@layer vela.ui`**, below unlayered CSS, so a page's own rule wins
|
|
149
|
-
without `!important` or a more specific selector. Selectors start with one of the
|
|
150
|
-
component's own parts (`[data-slot='gauge-needle']`), nest with `&`, and key on state
|
|
151
|
-
attributes (`data-state`, `data-selected`, `aria-expanded`), never on classes.
|
|
152
|
-
- A root that can be `hidden` takes its `display` under `:where(:not([hidden]))`: any
|
|
153
|
-
authored `display` beats the browser's `[hidden]` rule. A rule that depends on an ancestor
|
|
154
|
-
(the mobile layout) reads `&:is([data-layout='mobile'] *)`, which keeps the selector's
|
|
155
|
-
weight.
|
|
156
|
-
- Values come from `t` or the component's settings; durations from `t.dur`; directions are
|
|
157
|
-
logical (`padding-inline`, `inset-inline-end`, `text-align: start`).
|
|
158
|
-
- `npm run lint` (at the repo root) checks every template with stylelint and the postcss-lit
|
|
159
|
-
syntax, through the package's shared config (`@luxalgo/vela-ui/stylelint`, which Vela's
|
|
160
|
-
chrome, Pro and a host's own components extend with their own layer): the `vela/layer`,
|
|
161
|
-
`vela/slot-scope`, `vela/token-values` and `vela/no-raw-token-var` rules, no hex or named
|
|
162
|
-
colors, no class or id selectors, no `!important`, no
|
|
163
|
-
`box-sizing: content-box` (the kit's border-box reset is unlayered: size the full box
|
|
164
|
-
instead). A template the parser cannot read fails the run instead of going unchecked.
|
|
165
|
-
- The kit supports the browsers that brought `color-mix()`, which its tints use: Chrome and
|
|
166
|
-
Edge 111, Firefox 113, Safari 16.2. The build flattens the nesting for them (Lightning CSS),
|
|
167
|
-
as nesting came later; the tests and the playground run the nested source.
|
|
168
|
-
- Three rules stay outside the layer on purpose, each next to a comment saying why: the
|
|
169
|
-
kit's border-box reset, the field rows' dimmed state, and the reset of a dragged dialog's
|
|
170
|
-
offset in the mobile layout.
|
|
171
|
-
|
|
172
|
-
## Zag machines
|
|
173
|
-
|
|
174
|
-
Wrap the machine in a controller function that maps the component's options to machine
|
|
175
|
-
props, with an explicit return interface (TypeScript cannot name Zag's inferred types
|
|
176
|
-
portably), then start it with `runMachine` and re-project the api's props on every
|
|
177
|
-
notification with `spreadProps`:
|
|
178
|
-
|
|
179
|
-
```ts
|
|
180
|
-
export function tooltipController(opts: TooltipControllerOptions = {}): TooltipController {
|
|
181
|
-
return {
|
|
182
|
-
machine: tooltip.machine,
|
|
183
|
-
props: { id: nextUid('vela-tooltip'), /* map opts */ },
|
|
184
|
-
connect: (service) => tooltip.connect(service, normalizeProps),
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// in the component class:
|
|
189
|
-
this.handle = runMachine(ctrl.machine, ctrl.props, (service) => {
|
|
190
|
-
const api = ctrl.connect(service);
|
|
191
|
-
spreadProps(trigger, api.getTriggerProps(), mid);
|
|
192
|
-
// …spread the other parts onto their elements
|
|
193
|
-
});
|
|
194
|
-
this.release = ownTeardown(trigger, () => this.handle.stop());
|
|
195
|
-
|
|
196
|
-
destroy(): void {
|
|
197
|
-
this.release();
|
|
198
|
-
}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
Tie the machine's teardown to the element with `ownTeardown`, and have `destroy()` call the
|
|
202
|
-
release: a host that discards a subtree with `disposeWithin` reaches controls whose handles it
|
|
203
|
-
never kept, and the release runs once whichever comes first. A component whose content holds
|
|
204
|
-
other controls (a dialog's panel, a popover's content) calls `disposeWithin` on it when it is
|
|
205
|
-
destroyed.
|
|
206
|
-
|
|
207
|
-
Form controls keep the value they show in a small state of their own (getters, `set*` /
|
|
208
|
-
`sync` that do not emit, and the one method that does), so a host refresh rewrites the
|
|
209
|
-
displayed value without firing `onChange`. The text fields are plain inputs; the checkbox, the
|
|
210
|
-
switch, the number field and the select's list run Zag machines underneath, which that state
|
|
211
|
-
drives (`setChecked`, `setValue`) without reporting.
|
|
212
|
-
|
|
213
|
-
## Rules (learned the hard way)
|
|
214
|
-
|
|
215
|
-
- **Always pass a `machineId` to `spreadProps`** (the `mid` above). Two machines sharing one
|
|
216
|
-
element under the default scope wipe each other's listeners.
|
|
217
|
-
- **Zag trigger props overwrite the element's DOM `id`.** To compose several machines on one
|
|
218
|
-
trigger, share the id through the machines' `ids` prop (see the `triggerId` option on
|
|
219
|
-
Tooltip and DropdownMenu).
|
|
220
|
-
- **Dialog-like machines expect conditional rendering**: their props carry no `hidden`;
|
|
221
|
-
toggle visibility from `api.open` in your render (tooltip and menu props do carry it).
|
|
222
|
-
- **Never hard-code colors.** The tokens derive from the theme (`src/lib/tokens.ts`), and the
|
|
223
|
-
fixed brand and meaning colors live in `src/lib/palette.ts`. A test fails on a stray hex
|
|
224
|
-
literal.
|
|
225
|
-
- **Take icons from the registry** (`src/lib/icons.ts`) rather than inlining SVG: 16×16 at
|
|
226
|
-
stroke 1.2 for UI chrome, 24×24 at stroke 1.8 for drawing tools, always `currentColor`.
|
|
227
|
-
- **No imports from Vela.** The kit is used without the chart; what it needs lives in
|
|
228
|
-
`src/lib/`.
|
|
229
|
-
- **A machine must be stopped, not only removed.** Some machines register page-wide
|
|
230
|
-
listeners (the switch's focus-visible tracking is one) that keep running, and keep their
|
|
231
|
-
memory, after the element is gone. See `ownTeardown` above.
|
|
232
|
-
- **State other copies of the kit must see goes through `pageState`** (`src/lib/page.ts`),
|
|
233
|
-
not a module variable: a page can load the kit twice, and a registry, an id counter or an
|
|
234
|
-
"open popover" kept per copy splits in two. Caches each copy can rebuild stay local.
|
|
235
|
-
- Floating layers mount into the nearest `.vela-ui` host, which carries the theme; use the
|
|
236
|
-
`vela-ui-layer` class on portaled positioners. Popovers call `ensureUIHost` on show, so a
|
|
237
|
-
list portaled to the body still has the theme. A component built before its trigger is in
|
|
238
|
-
the DOM needs an explicit `host`: the `closest()` fallback portals to the body, outside the
|
|
239
|
-
theme.
|
|
240
|
-
- Keyboard-facing components report open and close through an `onOpenChange` option, so a
|
|
241
|
-
host can scope its keyboard shortcuts while they are open.
|
|
242
|
-
- A component that opens and closes a surface **announces it** with `announceSurface`
|
|
243
|
-
(`@luxalgo/vela-ui/surface-events`): open once the surface shows, close while it still
|
|
244
|
-
shows (before a fade-out, `hidden`, or removal), so the event bubbles to the host.
|
|
245
|
-
- After announcing the close, run the hide or removal through `holdForExit`
|
|
246
|
-
(`@luxalgo/vela-ui/surface-exit`), so hosts can animate it out by styling `data-closing`. It
|
|
247
|
-
completes synchronously when no exit animation starts; keep the returned handle to
|
|
248
|
-
`cancel()` it on a reopen and `finish()` it on teardown.
|
|
249
|
-
- The primitive's **root is one element**. Settings rows use `display: contents`, so a
|
|
250
|
-
fragment of sibling nodes would fall onto the pane grid as extra tracks.
|
|
1
|
+
# Writing a component
|
|
2
|
+
|
|
3
|
+
Each component is **one file**, `src/components/<name>.ts`, published at
|
|
4
|
+
`@luxalgo/vela-ui/<name>`, holding its declaration, its variants, its CSS and its
|
|
5
|
+
`create<Name>` function. Overlays (menu, dialog, drawer, tooltip) and composite controls (tabs,
|
|
6
|
+
toggle group) run a [Zag.js](https://zagjs.com) state machine, which owns their keyboard
|
|
7
|
+
behavior and accessibility; form controls keep small vanilla state objects.
|
|
8
|
+
|
|
9
|
+
## One file per component
|
|
10
|
+
|
|
11
|
+
Start one with `npm run new-component -- gauge` at the repo root: it writes the file in the
|
|
12
|
+
shape below, adds its declaration to the theme, and writes its test. A component file reads
|
|
13
|
+
top to bottom:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// Gauge: … what it is and how it behaves, for the reader of the file.
|
|
17
|
+
import { css, defineStyles } from '../lib/css';
|
|
18
|
+
import { defineComponent } from '../lib/define';
|
|
19
|
+
import { h } from '../lib/h';
|
|
20
|
+
import { t } from '../lib/t';
|
|
21
|
+
import { variants, type VariantProps } from '../lib/variants';
|
|
22
|
+
|
|
23
|
+
// Its name, its parts (each part's data-slot) and its settings (custom properties a theme
|
|
24
|
+
// or a host's CSS can set, with their defaults).
|
|
25
|
+
export const gaugeDef = defineComponent({ name: 'gauge', parts: ['root', 'needle'], settings: { radius: t.radius.lg } });
|
|
26
|
+
|
|
27
|
+
// Its variants: the names type the props, the first value is the default.
|
|
28
|
+
export const gaugeVariants = variants({ size: ['md', 'sm'] });
|
|
29
|
+
|
|
30
|
+
export interface GaugeProps extends VariantProps<typeof gaugeVariants> {
|
|
31
|
+
value: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface GaugeHandle {
|
|
35
|
+
readonly el: HTMLElement;
|
|
36
|
+
setValue(value: number): void;
|
|
37
|
+
destroy(): void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const injectStyles = defineStyles(
|
|
41
|
+
'vela-ui-gauge',
|
|
42
|
+
css`
|
|
43
|
+
@layer vela.ui {
|
|
44
|
+
[data-slot='gauge'] {
|
|
45
|
+
border-radius: ${gaugeDef.vars.radius};
|
|
46
|
+
background: ${t.surface.sunken};
|
|
47
|
+
|
|
48
|
+
&[data-size='sm'] { … }
|
|
49
|
+
& > [data-slot='gauge-needle'] { color: ${t.accent}; }
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
`,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
class GaugeImpl implements GaugeHandle { … } // methods shared across instances
|
|
56
|
+
|
|
57
|
+
export function createGauge(props: GaugeProps): GaugeHandle {
|
|
58
|
+
return new GaugeImpl(props);
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Then add the declaration to `ComponentDefs` in `src/lib/theme.ts`
|
|
63
|
+
(`gauge: typeof gaugeDef;`), which types the component's settings and parts in a theme. The
|
|
64
|
+
build fails while one is missing. The manifest (`dist/manifest.json`), the theme's JSON
|
|
65
|
+
Schema and `llms.txt` are generated from the file at build time, so there is nothing else to
|
|
66
|
+
list.
|
|
67
|
+
|
|
68
|
+
Released components keep their class (`new Checkbox(…)`, `new Tooltip(trigger, …)`) and their
|
|
69
|
+
controller (`checkboxController`, `tooltipController`) next to the `create…` function; the
|
|
70
|
+
class is the instance the function returns. New components start from the shape above.
|
|
71
|
+
|
|
72
|
+
## A component of your own
|
|
73
|
+
|
|
74
|
+
The same shape works outside the kit, for a component a project writes: import the helpers
|
|
75
|
+
from the package root (`import { css, defineComponent, defineStyles, h, t, variants } from
|
|
76
|
+
'@luxalgo/vela-ui'`) and keep the rules below. Three things make it a full citizen:
|
|
77
|
+
|
|
78
|
+
- **Its CSS goes in `@layer vela.ui`**, like the kit's, not in `vela.custom`: a theme's part
|
|
79
|
+
CSS sits in `vela.custom`, and only from a later layer does it restyle the component.
|
|
80
|
+
- **Declare it before creating a theme that names it.** `defineComponent` records the
|
|
81
|
+
component for the page, and `checkTheme` (and `createTheme`'s warnings) then check the
|
|
82
|
+
theme's settings and parts for it, as they do the kit's.
|
|
83
|
+
- **Type it in themes** by merging its declaration into `ComponentDefs`, so a wrong setting
|
|
84
|
+
or part fails the typecheck:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
export const gaugeDef = defineComponent({ name: 'gauge', parts: ['root', 'needle'], settings: { radius: t.radius.lg } });
|
|
88
|
+
|
|
89
|
+
declare module '@luxalgo/vela-ui/theme' {
|
|
90
|
+
interface ComponentDefs {
|
|
91
|
+
gauge: typeof gaugeDef;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
createTheme({ components: { gauge: { radius: '2px', css: { needle: css`color: ${t.accent};` } } } });
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Changing a component
|
|
99
|
+
|
|
100
|
+
A component's public contract is what hosts and themes build on: its props and its handle's
|
|
101
|
+
methods, its part names (the `data-slot` values), its variant and size values, the state
|
|
102
|
+
attributes its CSS keys on, and its settings. Inside the file, everything else is free to
|
|
103
|
+
change.
|
|
104
|
+
|
|
105
|
+
- **Keep the contract.** A change to how a component looks or behaves keeps those names. Add
|
|
106
|
+
a prop, a variant or a setting freely; give a new setting a default that keeps today's look,
|
|
107
|
+
so a theme that sets nothing renders as before.
|
|
108
|
+
- **Rename in two steps.** A renamed prop, part, variant or component keeps its old name
|
|
109
|
+
working for one release: the component accepts both (and says which is deprecated in the
|
|
110
|
+
prop's comment), and Vela's `src/ui/renamed.ts` keeps the old export names on
|
|
111
|
+
`@luxalgo/vela/ui`. The changelog names the old and the new, and the release after removes
|
|
112
|
+
the old one.
|
|
113
|
+
- **Prove it.** The component's test covers the change; `npm run lint` checks its CSS; the
|
|
114
|
+
gallery (`npm run playground`, then `/primitives.html`) shows every component in every
|
|
115
|
+
variant, beside the theme editor, so compare it before and after. The build regenerates the
|
|
116
|
+
manifest, the theme's JSON Schema and `llms.txt` from the file, so they follow on their
|
|
117
|
+
own.
|
|
118
|
+
- **Write it down.** A change users notice gets an entry in Vela's `CHANGELOG.md`, and a
|
|
119
|
+
breaking one says what to do instead.
|
|
120
|
+
|
|
121
|
+
## The helpers (`src/lib/`)
|
|
122
|
+
|
|
123
|
+
- **`h(tag, props, ...children)`** builds an element, typed by its tag. `slot` writes the
|
|
124
|
+
`data-slot`, `data` the `data-*` attributes (`true` writes an empty value, `false` and
|
|
125
|
+
`null` nothing), `attrs`, `on` and `text` the rest. Class names are layout hooks, never the
|
|
126
|
+
styling contract.
|
|
127
|
+
- **`css`** marks a template as CSS (editors highlight it, stylelint checks it) and
|
|
128
|
+
**`defineStyles(id, text)`** returns the injector a component calls at creation, never at
|
|
129
|
+
import: it declares the layer order once per document or shadow root, then injects the
|
|
130
|
+
sheet, id-guarded. The sheet applies inside kit hosts, their floating layers and themed
|
|
131
|
+
hosts only: a `:where()` joins the first compound of each top-level selector, adding no
|
|
132
|
+
weight, so a page's own elements that carry the same `data-slot` names are never restyled.
|
|
133
|
+
Inject a component's CSS through it, never by hand.
|
|
134
|
+
- **`t`** reads the design tokens: `${t.radius.md}` prints `var(--vela-radius-md)`, and a
|
|
135
|
+
name that does not exist fails the typecheck. A test checks that `t` and the tokens the
|
|
136
|
+
theme writes match in both directions.
|
|
137
|
+
- **`variants(spec)`** turns `{ variant: [...], size: [...] }` into the `data-*` attributes
|
|
138
|
+
the CSS keys on, and types the props through `VariantProps`.
|
|
139
|
+
- **`defineComponent({ name, parts, settings })`** links a name to its CSS: `slot(part)` is
|
|
140
|
+
the part's `data-slot` (`name` for `root`, `name-part` otherwise), and `vars.<setting>`
|
|
141
|
+
prints `var(--vela-<name>-<setting>, <default>)`.
|
|
142
|
+
- **`addSlot(el, part)`** adds a part to an element's slot. A shell one component owns and
|
|
143
|
+
another builds on carries both, `data-slot="popover-content select-content"`, and CSS
|
|
144
|
+
matches either with `[data-slot~='…']`.
|
|
145
|
+
|
|
146
|
+
## CSS rules
|
|
147
|
+
|
|
148
|
+
- Everything sits in **`@layer vela.ui`**, below unlayered CSS, so a page's own rule wins
|
|
149
|
+
without `!important` or a more specific selector. Selectors start with one of the
|
|
150
|
+
component's own parts (`[data-slot='gauge-needle']`), nest with `&`, and key on state
|
|
151
|
+
attributes (`data-state`, `data-selected`, `aria-expanded`), never on classes.
|
|
152
|
+
- A root that can be `hidden` takes its `display` under `:where(:not([hidden]))`: any
|
|
153
|
+
authored `display` beats the browser's `[hidden]` rule. A rule that depends on an ancestor
|
|
154
|
+
(the mobile layout) reads `&:is([data-layout='mobile'] *)`, which keeps the selector's
|
|
155
|
+
weight.
|
|
156
|
+
- Values come from `t` or the component's settings; durations from `t.dur`; directions are
|
|
157
|
+
logical (`padding-inline`, `inset-inline-end`, `text-align: start`).
|
|
158
|
+
- `npm run lint` (at the repo root) checks every template with stylelint and the postcss-lit
|
|
159
|
+
syntax, through the package's shared config (`@luxalgo/vela-ui/stylelint`, which Vela's
|
|
160
|
+
chrome, Pro and a host's own components extend with their own layer): the `vela/layer`,
|
|
161
|
+
`vela/slot-scope`, `vela/token-values` and `vela/no-raw-token-var` rules, no hex or named
|
|
162
|
+
colors, no class or id selectors, no `!important`, no
|
|
163
|
+
`box-sizing: content-box` (the kit's border-box reset is unlayered: size the full box
|
|
164
|
+
instead). A template the parser cannot read fails the run instead of going unchecked.
|
|
165
|
+
- The kit supports the browsers that brought `color-mix()`, which its tints use: Chrome and
|
|
166
|
+
Edge 111, Firefox 113, Safari 16.2. The build flattens the nesting for them (Lightning CSS),
|
|
167
|
+
as nesting came later; the tests and the playground run the nested source.
|
|
168
|
+
- Three rules stay outside the layer on purpose, each next to a comment saying why: the
|
|
169
|
+
kit's border-box reset, the field rows' dimmed state, and the reset of a dragged dialog's
|
|
170
|
+
offset in the mobile layout.
|
|
171
|
+
|
|
172
|
+
## Zag machines
|
|
173
|
+
|
|
174
|
+
Wrap the machine in a controller function that maps the component's options to machine
|
|
175
|
+
props, with an explicit return interface (TypeScript cannot name Zag's inferred types
|
|
176
|
+
portably), then start it with `runMachine` and re-project the api's props on every
|
|
177
|
+
notification with `spreadProps`:
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
export function tooltipController(opts: TooltipControllerOptions = {}): TooltipController {
|
|
181
|
+
return {
|
|
182
|
+
machine: tooltip.machine,
|
|
183
|
+
props: { id: nextUid('vela-tooltip'), /* map opts */ },
|
|
184
|
+
connect: (service) => tooltip.connect(service, normalizeProps),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// in the component class:
|
|
189
|
+
this.handle = runMachine(ctrl.machine, ctrl.props, (service) => {
|
|
190
|
+
const api = ctrl.connect(service);
|
|
191
|
+
spreadProps(trigger, api.getTriggerProps(), mid);
|
|
192
|
+
// …spread the other parts onto their elements
|
|
193
|
+
});
|
|
194
|
+
this.release = ownTeardown(trigger, () => this.handle.stop());
|
|
195
|
+
|
|
196
|
+
destroy(): void {
|
|
197
|
+
this.release();
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Tie the machine's teardown to the element with `ownTeardown`, and have `destroy()` call the
|
|
202
|
+
release: a host that discards a subtree with `disposeWithin` reaches controls whose handles it
|
|
203
|
+
never kept, and the release runs once whichever comes first. A component whose content holds
|
|
204
|
+
other controls (a dialog's panel, a popover's content) calls `disposeWithin` on it when it is
|
|
205
|
+
destroyed.
|
|
206
|
+
|
|
207
|
+
Form controls keep the value they show in a small state of their own (getters, `set*` /
|
|
208
|
+
`sync` that do not emit, and the one method that does), so a host refresh rewrites the
|
|
209
|
+
displayed value without firing `onChange`. The text fields are plain inputs; the checkbox, the
|
|
210
|
+
switch, the number field and the select's list run Zag machines underneath, which that state
|
|
211
|
+
drives (`setChecked`, `setValue`) without reporting.
|
|
212
|
+
|
|
213
|
+
## Rules (learned the hard way)
|
|
214
|
+
|
|
215
|
+
- **Always pass a `machineId` to `spreadProps`** (the `mid` above). Two machines sharing one
|
|
216
|
+
element under the default scope wipe each other's listeners.
|
|
217
|
+
- **Zag trigger props overwrite the element's DOM `id`.** To compose several machines on one
|
|
218
|
+
trigger, share the id through the machines' `ids` prop (see the `triggerId` option on
|
|
219
|
+
Tooltip and DropdownMenu).
|
|
220
|
+
- **Dialog-like machines expect conditional rendering**: their props carry no `hidden`;
|
|
221
|
+
toggle visibility from `api.open` in your render (tooltip and menu props do carry it).
|
|
222
|
+
- **Never hard-code colors.** The tokens derive from the theme (`src/lib/tokens.ts`), and the
|
|
223
|
+
fixed brand and meaning colors live in `src/lib/palette.ts`. A test fails on a stray hex
|
|
224
|
+
literal.
|
|
225
|
+
- **Take icons from the registry** (`src/lib/icons.ts`) rather than inlining SVG: 16×16 at
|
|
226
|
+
stroke 1.2 for UI chrome, 24×24 at stroke 1.8 for drawing tools, always `currentColor`.
|
|
227
|
+
- **No imports from Vela.** The kit is used without the chart; what it needs lives in
|
|
228
|
+
`src/lib/`.
|
|
229
|
+
- **A machine must be stopped, not only removed.** Some machines register page-wide
|
|
230
|
+
listeners (the switch's focus-visible tracking is one) that keep running, and keep their
|
|
231
|
+
memory, after the element is gone. See `ownTeardown` above.
|
|
232
|
+
- **State other copies of the kit must see goes through `pageState`** (`src/lib/page.ts`),
|
|
233
|
+
not a module variable: a page can load the kit twice, and a registry, an id counter or an
|
|
234
|
+
"open popover" kept per copy splits in two. Caches each copy can rebuild stay local.
|
|
235
|
+
- Floating layers mount into the nearest `.vela-ui` host, which carries the theme; use the
|
|
236
|
+
`vela-ui-layer` class on portaled positioners. Popovers call `ensureUIHost` on show, so a
|
|
237
|
+
list portaled to the body still has the theme. A component built before its trigger is in
|
|
238
|
+
the DOM needs an explicit `host`: the `closest()` fallback portals to the body, outside the
|
|
239
|
+
theme.
|
|
240
|
+
- Keyboard-facing components report open and close through an `onOpenChange` option, so a
|
|
241
|
+
host can scope its keyboard shortcuts while they are open.
|
|
242
|
+
- A component that opens and closes a surface **announces it** with `announceSurface`
|
|
243
|
+
(`@luxalgo/vela-ui/surface-events`): open once the surface shows, close while it still
|
|
244
|
+
shows (before a fade-out, `hidden`, or removal), so the event bubbles to the host.
|
|
245
|
+
- After announcing the close, run the hide or removal through `holdForExit`
|
|
246
|
+
(`@luxalgo/vela-ui/surface-exit`), so hosts can animate it out by styling `data-closing`. It
|
|
247
|
+
completes synchronously when no exit animation starts; keep the returned handle to
|
|
248
|
+
`cancel()` it on a reopen and `finish()` it on teardown.
|
|
249
|
+
- The primitive's **root is one element**. Settings rows use `display: contents`, so a
|
|
250
|
+
fragment of sibling nodes would fall onto the pane grid as extra tracks.
|
package/llms.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @luxalgo/vela-ui 0.
|
|
1
|
+
# @luxalgo/vela-ui 0.4.1
|
|
2
2
|
|
|
3
3
|
> The component kit of Vela: one file per component, Zag state machines for behavior, CSS in
|
|
4
4
|
> cascade layers over design tokens, and one typed theme config.
|
|
@@ -11,7 +11,7 @@ kit host: `ensureUIHost(el, createTheme())` (`@luxalgo/vela-ui/theme`), or insid
|
|
|
11
11
|
## Skills (agent instructions in this package)
|
|
12
12
|
|
|
13
13
|
- [theming-vela-ui](skills/theming-vela-ui/SKILL.md): Themes and restyles Vela charts and @luxalgo/vela-ui components with createTheme - brand colors, light, dark and custom themes, design tokens, component settings, part-by-part CSS restyles, scrollbars, cascade layers and theme JSON files checked with checkTheme.
|
|
14
|
-
- [using-vela-ui-components](skills/using-vela-ui-components/SKILL.md): Builds interface pieces with @luxalgo/vela-ui, the component kit behind Vela charts - buttons, tabs, toggle groups, badges, dialogs, drawers, dropdown and context menus, tooltips, hover cards, popovers, toasts, collapsible sections, cards, list rows, form controls (checkbox, switch, slider, input, select, number input, date and color pickers) and data components (data table, sort buttons, month grid,
|
|
14
|
+
- [using-vela-ui-components](skills/using-vela-ui-components/SKILL.md): Builds interface pieces with @luxalgo/vela-ui, the component kit behind Vela charts - buttons, tabs, toggle groups, badges, dialogs, drawers, dropdown and context menus, tooltips, hover cards, popovers, toasts, collapsible sections, cards, list rows, form controls (checkbox, switch, slider, input, select, number input, date and color pickers) and data components (data table, sort buttons, month grid, figure, sparkline, bar, line and scatter charts, treemap).
|
|
15
15
|
- [writing-vela-ui-components](skills/writing-vela-ui-components/SKILL.md): Writes new UI components with the @luxalgo/vela-ui authoring helpers (defineComponent, h, css, defineStyles, variants, t), customizes a kit component's markup or behavior by copying its source with "vela-ui add --source", and adds components to the kit itself.
|
|
16
16
|
|
|
17
17
|
Link them into a project's coding agent with `npx skills experimental_sync` once the package is
|
|
@@ -49,6 +49,7 @@ installed, or install them from the repository with `npx skills add LuxAlgo/Vela
|
|
|
49
49
|
- createDropdownMenu (`@luxalgo/vela-ui/dropdown-menu`): DropdownMenu: MenuItemDescriptor[] projected into a floating list over Zag's menu machine (keyboard navigation, typeahead and dismissal belong to the machine).
|
|
50
50
|
- createEmpty (`@luxalgo/vela-ui/empty`): Empty: what a panel shows when it has nothing to list: an icon in a tile, a title, a line saying why or what to do, and an optional action (a button that fills it).
|
|
51
51
|
- FieldGridVariant (`@luxalgo/vela-ui/field`): Field: the label-and-control grid the settings dialogs lay their inputs out on: rows (a label and its control, an optional master toggle that dims the control, an optional info mark), full-width toggles, stacked and inline rows, section headings and separators, and a factory that builds a row's control from a descriptor.
|
|
52
|
+
- createFigure (`@luxalgo/vela-ui/figure`): Figure: a value under its label (Net P&L, Win rate), with an optional line under it.
|
|
52
53
|
- createGlyphSelect (`@luxalgo/vela-ui/glyph-select`): GlyphSelect: a trigger showing the current option's glyph, and a list of glyph options on a popover.
|
|
53
54
|
- createHoverCard (`@luxalgo/vela-ui/hover-card`): HoverCard: a card beside a control while the pointer rests on it, richer than a tooltip: a title with an icon tile and a shortcut drawn as keycaps, a description, rich content (figures, a sparkline) and a hint line.
|
|
54
55
|
- createInputGroup (`@luxalgo/vela-ui/input-group`): InputGroup: an input with addons inside its border: an icon, a short text or a button, at its start or end, or in a row above or below it (a search field with its magnifier, an amount with its unit).
|
|
@@ -64,7 +65,6 @@ installed, or install them from the repository with `npx skills add LuxAlgo/Vela
|
|
|
64
65
|
- createSlider (`@luxalgo/vela-ui/slider`): Slider: a value on a track, dragged by its thumb or moved with the arrow keys, Page Up/Down and Home/End, over Zag's slider machine.
|
|
65
66
|
- createSortButton (`@luxalgo/vela-ui/sort-button`): SortButton: the header of a column that sorts a list which is not a table (a watchlist's Last and Day %).
|
|
66
67
|
- createSparkline (`@luxalgo/vela-ui/sparkline`): Sparkline: a tiny line of values (a watchlist row's day, an equity curve in a card), in the profit tone when it ends at or above where it started (or its baseline) and the loss tone below, with an optional soft area under it and a dotted baseline (the previous close).
|
|
67
|
-
- createStat (`@luxalgo/vela-ui/stat`): Stat: a figure under its label (Net P&L, Win rate), with an optional line under it.
|
|
68
68
|
- createSwitch (`@luxalgo/vela-ui/switch`): Switch: a sliding on/off toggle, a track with a round thumb, for a setting that applies at once.
|
|
69
69
|
- createTabs (`@luxalgo/vela-ui/tabs`): Tabs: a tab list over Zag's tabs machine (WAI-ARIA tabs: roving focus, the arrow keys along the orientation, Home/End, automatic or manual activation).
|
|
70
70
|
- createTextArea (`@luxalgo/vela-ui/text-area`): TextArea: a multi-line text input that commits on blur, and can grow with its content up to a number of lines before it scrolls.
|