@lofid/web 0.0.0-stage → 1.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/README.md +104 -2
- package/custom-elements.json +12890 -0
- package/dist/index.d.ts +3192 -0
- package/dist/index.js +20807 -0
- package/dist/index.js.map +1 -0
- package/dist/styles/ag-grid.css +145 -0
- package/dist/styles/motion.css +32 -0
- package/dist/styles/motion.tokens.json +38 -0
- package/dist/styles/typography.css +41 -0
- package/dist/styles/typography.json +858 -0
- package/dist/styles/vars.css +1225 -0
- package/package.json +46 -4
- package/readmes/lof-accordion/README.md +140 -0
- package/readmes/lof-alert/README.md +142 -0
- package/readmes/lof-autocomplete/README.md +209 -0
- package/readmes/lof-avatar/README.md +228 -0
- package/readmes/lof-badge/README.md +102 -0
- package/readmes/lof-breadcrumb/README.md +97 -0
- package/readmes/lof-button/README.md +189 -0
- package/readmes/lof-calendar/README.md +111 -0
- package/readmes/lof-card/README.md +105 -0
- package/readmes/lof-cardmedia/README.md +100 -0
- package/readmes/lof-carousel/README.md +187 -0
- package/readmes/lof-checkbox/README.md +159 -0
- package/readmes/lof-chip/README.md +153 -0
- package/readmes/lof-container/README.md +107 -0
- package/readmes/lof-date-picker/README.md +221 -0
- package/readmes/lof-divider/README.md +88 -0
- package/readmes/lof-drawer/README.md +188 -0
- package/readmes/lof-empty-state/README.md +78 -0
- package/readmes/lof-image-input/README.md +75 -0
- package/readmes/lof-kbd/README.md +188 -0
- package/readmes/lof-layout/README.md +122 -0
- package/readmes/lof-link/README.md +67 -0
- package/readmes/lof-menu/README.md +187 -0
- package/readmes/lof-menubar/README.md +218 -0
- package/readmes/lof-nav/README.md +90 -0
- package/readmes/lof-otp/README.md +167 -0
- package/readmes/lof-page-header/README.md +71 -0
- package/readmes/lof-pagination/README.md +141 -0
- package/readmes/lof-popover/README.md +220 -0
- package/readmes/lof-progress/README.md +88 -0
- package/readmes/lof-radio/README.md +142 -0
- package/readmes/lof-range-picker/README.md +194 -0
- package/readmes/lof-rating/README.md +90 -0
- package/readmes/lof-resizable/README.md +220 -0
- package/readmes/lof-segmented-button/README.md +158 -0
- package/readmes/lof-select/README.md +193 -0
- package/readmes/lof-sheet/README.md +170 -0
- package/readmes/lof-signature-pad/README.md +161 -0
- package/readmes/lof-skeleton/README.md +104 -0
- package/readmes/lof-slider/README.md +140 -0
- package/readmes/lof-snackbar/README.md +170 -0
- package/readmes/lof-split-button/README.md +129 -0
- package/readmes/lof-stat/README.md +73 -0
- package/readmes/lof-stepper/README.md +171 -0
- package/readmes/lof-switch/README.md +122 -0
- package/readmes/lof-tab/README.md +188 -0
- package/readmes/lof-table/README.md +114 -0
- package/readmes/lof-textfield/README.md +206 -0
- package/readmes/lof-time-picker/README.md +188 -0
- package/readmes/lof-toast/README.md +174 -0
- package/readmes/lof-tooltip/README.md +120 -0
- package/readmes/lof-tree/README.md +157 -0
- package/readmes/lof-upload/README.md +223 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# lof-split-button
|
|
2
|
+
|
|
3
|
+
<!-- @unreleased-component 1.5.0 -->
|
|
4
|
+
|
|
5
|
+
A button with a main action and a menu of related actions, also called a combo button. It is one pill in two segments with a 1px divider between them: the main action on the left, and a chevron on the right that opens a `lof-menu` of `items`, anchored below and end-aligned. Use it when one action is the usual choice and a few close variants should stay one click away, such as "New order" with "Duplicate" and "Save as template". Use `lof-button` for a single action, and a `lof-popover` with a `lof-menu` when no action is the default.
|
|
6
|
+
|
|
7
|
+
Each segment is a native `<button>` drawn with lof-button's own styles for the chosen `variant`, `tone` and `size`. The heights (28 / 34 / 40px), padding, type, hover, pressed, focus ring and disabled look are therefore lof-button's. The outer corners keep the pill radius and the seam between the segments is square. While the menu is open, the chevron keeps its pressed look and its arrow turns up.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<!-- Items are set as a property; the host's click is the main action -->
|
|
13
|
+
<lof-split-button id="order" label="New order"></lof-split-button>
|
|
14
|
+
<script>
|
|
15
|
+
const order = document.getElementById('order');
|
|
16
|
+
order.items = [
|
|
17
|
+
{ value: 'duplicate', label: 'Duplicate', icon: 'copy' },
|
|
18
|
+
{ value: 'template', label: 'Save as template' },
|
|
19
|
+
{ value: 'archive', label: 'Archive', disabled: true }
|
|
20
|
+
];
|
|
21
|
+
order.addEventListener('click', () => createOrder());
|
|
22
|
+
order.addEventListener('lof-select', (e) => {
|
|
23
|
+
console.log('chose', e.detail.value);
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<!-- Filled, in the brand colour, with a leading icon -->
|
|
28
|
+
<lof-split-button variant="primary" tone="brand" icon="plus" label="New order"></lof-split-button>
|
|
29
|
+
|
|
30
|
+
<!-- Small, and a custom name for the chevron -->
|
|
31
|
+
<lof-split-button size="small" menu-label="More export formats" label="Export CSV"></lof-split-button>
|
|
32
|
+
|
|
33
|
+
<!-- The main action is busy: a spinner only, and the chevron is disabled -->
|
|
34
|
+
<lof-split-button loading label="Saving"></lof-split-button>
|
|
35
|
+
|
|
36
|
+
<!-- Icon-only: the main action is a square; aria-label names it -->
|
|
37
|
+
<lof-split-button icon-only icon="plus" aria-label="New order"></lof-split-button>
|
|
38
|
+
|
|
39
|
+
<!-- On a dark or coloured surface -->
|
|
40
|
+
<lof-split-button variant="static" label="Accept job"></lof-split-button>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`items` is an array, so set it as a property, or as a JSON array attribute in static HTML. In React 19 and Next.js, pass it as a prop on the client: server rendering drops arrays on custom elements.
|
|
44
|
+
|
|
45
|
+
The divider between the segments follows the variant:
|
|
46
|
+
|
|
47
|
+
- `secondary` draws the tone's outline border (`--lof-action-neutral-border-outline`, or the danger outline), which takes the outline's hover colour while the main action is hovered or pressed. The segments drop their inner borders.
|
|
48
|
+
- `primary` draws the segment's label colour.
|
|
49
|
+
- `static` draws the static label colour (white).
|
|
50
|
+
- `ghost` draws `--lof-border-subtle`.
|
|
51
|
+
|
|
52
|
+
The divider is its own 1px column, so the pill is the main action, plus 1px, plus the chevron. A disabled split button dims each segment and keeps the divider's colour.
|
|
53
|
+
|
|
54
|
+
<!-- readme-gen:start -->
|
|
55
|
+
|
|
56
|
+
<!-- Generated from lof-split-button.ts — do not edit; run readme-generate.mjs -->
|
|
57
|
+
|
|
58
|
+
## API
|
|
59
|
+
|
|
60
|
+
### Attributes / Properties
|
|
61
|
+
|
|
62
|
+
| Property | Attribute | Type | Default | Description |
|
|
63
|
+
| --- | --- | --- | --- | --- |
|
|
64
|
+
| `label` | `label` | `string` | `""` | Text of the main action. Slotted content replaces it. |
|
|
65
|
+
| `variant` | `variant` | `"primary" \| "secondary" \| "ghost" \| "static"` | `"secondary"` | Style of both segments, as lof-button's `variant`: `primary` (filled), `secondary` (outlined, the default), `ghost` (no fill or border) or `static` (transparent with a white label and divider, for dark or coloured surfaces; neutral only, as on lof-button). Reflected. |
|
|
66
|
+
| `tone` | `tone` | `"neutral" \| "brand" \| "destructive"` | `"neutral"` | Colour of both segments, as lof-button's `tone`: `neutral` (default), `brand` or `destructive`. As on lof-button, `brand` changes only the `primary` style. Reflected. |
|
|
67
|
+
| `size` | `size` | `"small" \| "medium" \| "large"` | `"medium"` | Height of the pill and size of its text and icons, as lof-button's `size`: `small` = 32px, `medium` = 40px (default), `large` = 48px. The menu rows take the same size. Reflected. |
|
|
68
|
+
| `disabled` | `disabled` | `boolean` | `false` | Dims both segments to lof-button's disabled look (the divider keeps its colour), removes them from the Tab order and keeps the menu closed. Reflected. |
|
|
69
|
+
| `loading` | `loading` | `boolean` | `false` | The main action shows only lof-button's spinner, at its minimum width; its text stays its accessible name (visually hidden) and it is `aria-busy`. Its clicks are blocked and the chevron is disabled, so nothing else starts mid-request; an open menu closes. Reflected. |
|
|
70
|
+
| `iconOnly` | `icon-only` | `boolean` | `false` | The main action is a square of the button's height (28 / 34 / 40), as lof-button's `icon-only`: give it a single icon (`icon`, or a slotted `lof-icon`) and set `aria-label`. Reflected. |
|
|
71
|
+
| `ariaLabel` | `aria-label` | `string \| null` | `null` | Accessible name of the main action, forwarded to its native `<button>`. Required with `icon-only`, where the main action has no visible text (a console warning names split buttons without one). |
|
|
72
|
+
| `menuLabel` | `menu-label` | `string` | `"More options"` | Accessible name of the chevron button (attribute `menu-label`); it has no visible text. |
|
|
73
|
+
| `icon` | `icon` | `string` | `""` | `lof-icon` name drawn before the main action's text (16 / 18 / 20px by size). |
|
|
74
|
+
| `items` | `items` | `SplitButtonItem[]` | `[]` | The menu entries, each `{ value, label, icon?, disabled? }`. Set as a property (or a JSON array attribute). |
|
|
75
|
+
| `open` | `open` | `boolean` | `false` | Whether the menu is open. Updated by the component (and announced with `lof-open-change`); set it to open or close the menu from code. Reflected. |
|
|
76
|
+
|
|
77
|
+
## Events
|
|
78
|
+
|
|
79
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
80
|
+
| --- | --- | --- | --- |
|
|
81
|
+
| `lof-open-change` | `{ open }` | bubbles / composed | The menu opened or closed (chevron, keyboard, Escape, an outside click, Tab away, or a choice). Detail: `{ open: boolean }`. |
|
|
82
|
+
| `lof-select` | `{ value, item }` | bubbles / composed | A menu entry was chosen with a click, Enter or Space; the menu has closed and focus is back on the chevron. Detail: `{ value: string, item: SplitButtonItem }`. |
|
|
83
|
+
|
|
84
|
+
## Slots
|
|
85
|
+
|
|
86
|
+
| Slot | Description |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| (default) | The main action's content (text, or a `lof-icon` and text). Falls back to `label`. |
|
|
89
|
+
|
|
90
|
+
## CSS Parts
|
|
91
|
+
|
|
92
|
+
| Part | Description |
|
|
93
|
+
| --- | --- |
|
|
94
|
+
| `main` | The main action's native `<button>`. |
|
|
95
|
+
| `indicator` | The loading spinner on the main action, rendered only while `loading` is set. |
|
|
96
|
+
| `toggle` | The chevron's native `<button>` (`aria-haspopup="menu"`, `aria-expanded`, named by `menu-label`). |
|
|
97
|
+
|
|
98
|
+
## Tokens / CSS Variables
|
|
99
|
+
|
|
100
|
+
### Component hooks
|
|
101
|
+
|
|
102
|
+
Set these on the host (or an ancestor) to customise the element without touching design tokens.
|
|
103
|
+
|
|
104
|
+
| Custom property | Default | Description |
|
|
105
|
+
| --- | --- | --- |
|
|
106
|
+
| `--lof-split-button-menu-width` | `max-content` | Width of the menu (default `max-content`). The menu is never narrower than the split button. |
|
|
107
|
+
|
|
108
|
+
<!-- readme-gen:end -->
|
|
109
|
+
|
|
110
|
+
## Accessibility
|
|
111
|
+
|
|
112
|
+
- The main action is a native `<button>` named by its content. The chevron is a native `<button>` with `aria-haspopup="menu"`, `aria-expanded` and the accessible name from `menu-label` (default "More options").
|
|
113
|
+
- The menu is a `lof-menu` (`role="menu"`); its rows are `role="menuitem"`, and a disabled entry has `aria-disabled="true"`. Item icons are hidden from assistive technology.
|
|
114
|
+
- `loading` shows only the spinner, sets `aria-busy="true"` on the main action and keeps its text as its accessible name (visually hidden). The chevron is disabled while it loads, so it leaves the Tab order.
|
|
115
|
+
- With `icon-only`, the main action has no visible text: set `aria-label`, which is forwarded to its `<button>`. The element logs a console warning without one (a `label` is not drawn and does not name it).
|
|
116
|
+
- Each segment shows lof-button's focus ring. A mouse open shows no ring in the menu, and none on the chevron when the menu closes; the first arrow key brings the row ring back.
|
|
117
|
+
|
|
118
|
+
### Keyboard
|
|
119
|
+
|
|
120
|
+
| Key | Action |
|
|
121
|
+
| --- | --- |
|
|
122
|
+
| Tab / Shift+Tab | Two Tab stops: the main action, then the chevron |
|
|
123
|
+
| Enter / Space (main action) | Runs the main action (`click`) |
|
|
124
|
+
| Enter / Space / Down (chevron) | Opens the menu on its first entry |
|
|
125
|
+
| Up (chevron) | Opens the menu on its last entry |
|
|
126
|
+
| Down / Up, Home / End (menu) | Moves through the entries |
|
|
127
|
+
| Enter / Space (menu) | Chooses the entry: fires `lof-select`, closes the menu and returns focus to the chevron |
|
|
128
|
+
| Escape (menu) | Closes the menu and returns focus to the chevron |
|
|
129
|
+
| Tab (menu) | Closes the menu and moves focus on |
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# lof-stat
|
|
2
|
+
|
|
3
|
+
`<lof-stat>` is a KPI tile: an optional icon (the `icon` slot), the figure, what it counts and an optional trend chip ("+2.7%") that is green going up and red going down. `appearance="card"` (default) draws the hairline card surface; `plain` sits inside another card, as the headline figure of a panel. Format the number yourself ("9.3k", "$295.7k"). New in the 2026-11 admin refresh, after admin dashboard KPI rows.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<div style="display:grid;grid-template-columns:repeat(4,1fr);gap:16px">
|
|
9
|
+
<lof-stat value="9.3k" label="Amazing mates"><lof-icon slot="icon" name="person"></lof-icon></lof-stat>
|
|
10
|
+
<lof-stat value="24k" label="Lesson views" change="+12%"><lof-icon slot="icon" name="visibility"></lof-icon></lof-stat>
|
|
11
|
+
<lof-stat value="608" label="New subscribers" change="-0.7%"><lof-icon slot="icon" name="email"></lof-icon></lof-stat>
|
|
12
|
+
<lof-stat value="2.5k" label="Stream audience" change="0%" trend="neutral"></lof-stat>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<!-- Headline figure inside a card -->
|
|
16
|
+
<lof-card heading="Highlights">
|
|
17
|
+
<lof-stat appearance="plain" size="large" value="$295.7k" label="All time sales" change="+2.7%" change-label="up 2.7% from last month"></lof-stat>
|
|
18
|
+
</lof-card>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
<!-- readme-gen:start -->
|
|
22
|
+
|
|
23
|
+
## API
|
|
24
|
+
|
|
25
|
+
### Attributes / Properties
|
|
26
|
+
|
|
27
|
+
| Property | Attribute | Type | Default | Description |
|
|
28
|
+
| --- | --- | --- | --- | --- |
|
|
29
|
+
| `value` | `value` | `string` | `""` | The figure, already formatted ("9.3k", "$295.7k"). |
|
|
30
|
+
| `label` | `label` | `string` | `""` | What the figure counts ("Amazing mates"). |
|
|
31
|
+
| `change` | `change` | `string` | `""` | Trend text ("+2.7%"); renders the trend chip. |
|
|
32
|
+
| `trend` | `trend` | `"up" \| "down" \| "neutral"` | `—` | Direction of the change. Default: from the sign of `change` (`+` up, `-` down, otherwise neutral). |
|
|
33
|
+
| `changeLabel` | `change-label` | `string` | `""` | Spoken direction words, e.g. "up 2.7% from last month". Default: "increase" / "decrease". |
|
|
34
|
+
| `size` | `size` | `"medium" \| "large"` | `"medium"` | |
|
|
35
|
+
| `appearance` | `appearance` | `"card" \| "plain"` | `"card"` | |
|
|
36
|
+
|
|
37
|
+
## Events
|
|
38
|
+
|
|
39
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
40
|
+
| --- | --- | --- | --- |
|
|
41
|
+
| — | — | — | This element emits no custom events. |
|
|
42
|
+
|
|
43
|
+
## Slots
|
|
44
|
+
|
|
45
|
+
| Slot | Description |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| `icon` | A lof-icon (drawn on a 36px muted tile), a logo or an image. |
|
|
48
|
+
| (default) | Extra content under the label. |
|
|
49
|
+
| `value` | Rich figure content after `value`. |
|
|
50
|
+
| `footer` | A sparkline, a progress bar or a link. |
|
|
51
|
+
|
|
52
|
+
## CSS Parts
|
|
53
|
+
|
|
54
|
+
| Part | Description |
|
|
55
|
+
| --- | --- |
|
|
56
|
+
| `base` | The tile |
|
|
57
|
+
| `icon` | The icon tile |
|
|
58
|
+
| `value` | The figure |
|
|
59
|
+
| `trend` | The trend chip |
|
|
60
|
+
| `label` | The label |
|
|
61
|
+
| `footer` | The footer region |
|
|
62
|
+
|
|
63
|
+
<!-- readme-gen:end -->
|
|
64
|
+
|
|
65
|
+
## Accessibility
|
|
66
|
+
|
|
67
|
+
- The figure and label are plain text in reading order. The trend chip starts with a visually hidden direction word ("increase:", "decrease:"), so colour and the arrow are not the only cue; set `change-label` for a fuller phrase.
|
|
68
|
+
- The tile is not interactive. Wrap it in a link, or put a lof-link in the footer, to make it go somewhere.
|
|
69
|
+
|
|
70
|
+
## Notes / Edge Cases
|
|
71
|
+
|
|
72
|
+
- Figures use tabular numerals so a row of tiles lines up.
|
|
73
|
+
- `size="large"` uses the display heading size for headline totals.
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# lof-stepper
|
|
2
|
+
|
|
3
|
+
A multi-step progress indicator implementing the Figma "Stepper" component: its `Type` axis (default, dot, number, icon indicators), its `Typel` label-placement axis (top, centered, inverted), two sizes and both orientations. Each entry in `steps` renders as a focusable step with a circular indicator, a label and a connector to the next step, styled by its status (`done`, `progress`, `disabled`). Use it to show where the user is in a linear flow (checkout, onboarding, a wizard) and to let them jump back to completed steps; the component is presentation only — it never changes a step's status itself, so drive `steps` from your own state.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!-- Horizontal (default), labels under the indicators -->
|
|
9
|
+
<lof-stepper id="checkout"></lof-stepper>
|
|
10
|
+
<script>
|
|
11
|
+
document.getElementById('checkout').steps = [
|
|
12
|
+
{ title: 'Cart', status: 'done' },
|
|
13
|
+
{ title: 'Work', status: 'progress' },
|
|
14
|
+
{ title: 'Payment', status: 'disabled' },
|
|
15
|
+
{ title: 'Confirmation', status: 'disabled' }
|
|
16
|
+
];
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<!-- Vertical, label beside the indicator (Figma Type = Centered).
|
|
20
|
+
`size` is DEPRECATED and deliberately omitted: Figma has no Size axis on the
|
|
21
|
+
Stepper — the connector geometry is fixed — so it was a code-only scale. It is
|
|
22
|
+
still accepted so existing markup keeps working, but it now resolves to the one
|
|
23
|
+
Figma geometry and logs a one-time notice. Retune with
|
|
24
|
+
`--lof-stepper-connector-length` instead. -->
|
|
25
|
+
<lof-stepper id="onboarding" orientation="vertical" label-placement="centered"></lof-stepper>
|
|
26
|
+
<script>
|
|
27
|
+
document.getElementById('onboarding').steps = [
|
|
28
|
+
{ title: 'Create account', status: 'done' },
|
|
29
|
+
{ title: 'Verify email', status: 'done' },
|
|
30
|
+
{ title: 'Set up profile', status: 'progress' },
|
|
31
|
+
{ title: 'Done', status: 'disabled' }
|
|
32
|
+
];
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<!-- Figma Type axis: dot / number / icon indicators -->
|
|
36
|
+
<lof-stepper type="dot" steps='[{"title":"Plan","status":"done"},{"title":"Build","status":"progress"},{"title":"Ship","status":"disabled"}]'></lof-stepper>
|
|
37
|
+
<lof-stepper type="number" steps='[{"title":"Plan","status":"done"},{"title":"Build","status":"progress"},{"title":"Ship","status":"disabled"}]'></lof-stepper>
|
|
38
|
+
<lof-stepper type="icon" steps='[{"title":"Plan","status":"done"},{"title":"Build","status":"progress"},{"title":"Ship","status":"disabled"}]'></lof-stepper>
|
|
39
|
+
|
|
40
|
+
<!-- Figma .Line Types axis: the CONNECTOR between steps, dashed 2px on / 2px off.
|
|
41
|
+
Distinct from type="dot" above, which is the indicator disc — combine freely. -->
|
|
42
|
+
<lof-stepper connector="dot" steps='[{"title":"Plan","status":"done"},{"title":"Build","status":"progress"},{"title":"Ship","status":"disabled"}]'></lof-stepper>
|
|
43
|
+
<lof-stepper connector="dot" type="dot" steps='[{"title":"Plan","status":"done"},{"title":"Build","status":"progress"},{"title":"Ship","status":"disabled"}]'></lof-stepper>
|
|
44
|
+
|
|
45
|
+
<!-- Label placement (Figma Typel): top-aligned beside the indicator, or indicator above the label -->
|
|
46
|
+
<lof-stepper orientation="vertical" label-placement="top" steps='[{"title":"Review","status":"done"},{"title":"Approve","status":"progress"}]'></lof-stepper>
|
|
47
|
+
<lof-stepper label-placement="inverted" steps='[{"title":"Review","status":"done"},{"title":"Approve","status":"progress"}]'></lof-stepper>
|
|
48
|
+
|
|
49
|
+
<!-- Let users jump back to a completed step -->
|
|
50
|
+
<lof-stepper id="wizard"></lof-stepper>
|
|
51
|
+
<script>
|
|
52
|
+
const wizard = document.getElementById('wizard');
|
|
53
|
+
wizard.steps = [
|
|
54
|
+
{ title: 'Select', status: 'done' },
|
|
55
|
+
{ title: 'Configure', status: 'progress' },
|
|
56
|
+
{ title: 'Review', status: 'disabled' }
|
|
57
|
+
];
|
|
58
|
+
wizard.addEventListener('lof-step-change', (e) => {
|
|
59
|
+
console.log('Activated step', e.detail.index, e.detail.step.title);
|
|
60
|
+
// Recompute statuses and assign a new array so the stepper re-renders
|
|
61
|
+
wizard.steps = wizard.steps.map((s, i) => ({
|
|
62
|
+
...s,
|
|
63
|
+
status: i < e.detail.index ? 'done' : i === e.detail.index ? 'progress' : 'disabled'
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
66
|
+
</script>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Deprecated aliases
|
|
70
|
+
|
|
71
|
+
```html
|
|
72
|
+
<!-- textalign="right" → label-placement="centered"; textalign="below" → label-placement="inverted".
|
|
73
|
+
Still supported and still the fallback when label-placement is unset. Since 1.4.9 a
|
|
74
|
+
non-default value logs a one-time console notice; it had been marked deprecated since the
|
|
75
|
+
rename but never said so at runtime. Setting label-placement supersedes it and stays silent. -->
|
|
76
|
+
<lof-stepper textalign="right" steps='[{"title":"Review","status":"done"},{"title":"Approve","status":"progress"}]'></lof-stepper>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The `Step` type and the `StepStatus`, `StepperType`, `StepperConnector` and `LabelPlacement` unions are exported from the package:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import type { Step } from '@lofid/web';
|
|
83
|
+
|
|
84
|
+
const steps: Step[] = [
|
|
85
|
+
{ title: 'Cart', status: 'done' }, // filled indicator with a check mark
|
|
86
|
+
{ title: 'Work', status: 'progress' }, // current step (aria-current="step")
|
|
87
|
+
{ title: 'Payment', status: 'disabled' } // not yet reachable; rendered at 40% opacity, not focusable
|
|
88
|
+
];
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
<!-- readme-gen:start -->
|
|
92
|
+
|
|
93
|
+
<!-- Generated from lof-stepper.ts — do not edit; run readme-generate.mjs -->
|
|
94
|
+
|
|
95
|
+
## API
|
|
96
|
+
|
|
97
|
+
### Attributes / Properties
|
|
98
|
+
|
|
99
|
+
| Property | Attribute | Type | Default | Description |
|
|
100
|
+
| --- | --- | --- | --- | --- |
|
|
101
|
+
| `steps` | `steps` | `Step[]` | `[]` | The steps in order, each `{ title: string; subtitle?: string; status: "done" \| "progress" \| "disabled" }`. Set as a property (or a JSON array attribute); the component never mutates it — update it from the `lof-step-change` handler. |
|
|
102
|
+
| `orientation` | `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | Layout axis: `horizontal` (default) lays the steps out in a centred row; `vertical` stacks them. |
|
|
103
|
+
| `type` | `type` | `"default" \| "dot" \| "number" \| "icon"` | `"default"` | Figma "Type" axis — what the INDICATOR shows: `default` (step number, check mark once done), `dot` (8px dot, no glyph), `number` (always the number) or `icon` (always the check mark). Not the same axis as `connector="dot"`, which dashes the line between steps. Reflected. |
|
|
104
|
+
| `connector` | `connector` | `"solid" \| "dot"` | `"solid"` | Figma ".Line Types" axis — how the line BETWEEN steps is drawn: `solid` (an unbroken 1px rule) or `dot` (a 1px rule dashed 2px on, 2px off). Applies to both orientations. Not the same axis as `type="dot"`, which is the indicator disc; the two are independent and can be combined. Reflected. |
|
|
105
|
+
| `labelPlacement` | `label-placement` | `"top" \| "centered" \| "inverted"` | `undefined` | Figma "Typel" axis — where the label sits: `top` (top-aligned beside the indicator), `centered` (vertically centred beside it) or `inverted` (indicator above the label). When unset, the deprecated `textAlign` prop drives the layout (`below` ≈ `inverted`, `right` ≈ `centered`). Figma marks Top + Horizontal as an unsupported combination. Reflected. |
|
|
106
|
+
|
|
107
|
+
#### Deprecated (still supported — removal targeted for 3.0)
|
|
108
|
+
|
|
109
|
+
| Property | Attribute | Type | Use instead |
|
|
110
|
+
| --- | --- | --- | --- |
|
|
111
|
+
| `textAlign` | `textalign` | `"right" \| "below"` | Deprecated alias of `label-placement`; use `label-placement="inverted"` instead of `textalign="below"` and `label-placement="centered"` instead of `textalign="right"`. |
|
|
112
|
+
| `size` | `size` | `"small" \| "large"` | Figma has no Size axis on the Stepper — the connector geometry is fixed — so this was a code-only scale. It stays accepted so existing markup keeps working, and now resolves to the one Figma geometry. Retune it with `--lof-stepper-connector-length` instead. Logs a one-time notice. |
|
|
113
|
+
|
|
114
|
+
## Events
|
|
115
|
+
|
|
116
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
117
|
+
| --- | --- | --- | --- |
|
|
118
|
+
| `lof-step-change` | `{ index, step, }` | bubbles / composed | Fired when a step whose status is not `disabled` is clicked or activated with Enter / Space. Detail: `{ index: number, step: Step }`. Statuses are not changed by the component — update `steps` in the handler. |
|
|
119
|
+
|
|
120
|
+
## Slots
|
|
121
|
+
|
|
122
|
+
| Slot | Description |
|
|
123
|
+
| --- | --- |
|
|
124
|
+
| — | This element has no slots. |
|
|
125
|
+
|
|
126
|
+
## CSS Parts
|
|
127
|
+
|
|
128
|
+
| Part | Description |
|
|
129
|
+
| --- | --- |
|
|
130
|
+
| `indicator` | The 24px circle (8px for `type="dot"`) that holds the step number, check mark or icon. |
|
|
131
|
+
| `track` | The 1px connector line from a step to the next one (not rendered on the last step). |
|
|
132
|
+
| `label` | The step title text. |
|
|
133
|
+
| `subtitle` | The optional second line under the title; rendered only when a step sets `subtitle`. |
|
|
134
|
+
|
|
135
|
+
## Tokens / CSS Variables
|
|
136
|
+
|
|
137
|
+
### Component hooks
|
|
138
|
+
|
|
139
|
+
Set these on the host (or an ancestor) to customise the element without touching design tokens.
|
|
140
|
+
|
|
141
|
+
| Custom property | Default | Description |
|
|
142
|
+
| --- | --- | --- |
|
|
143
|
+
| `--lof-stepper-connector-length` | `var(--lof-stepper-connector-length-lg, 96px)` | Length of the connector line; the step gap is derived from it by adding Figma's clear space at both ends. Defaults to Figma's fixed geometry: 96px horizontally, 34px vertically with `label-placement="centered"`, 51px with `inverted`. |
|
|
144
|
+
| `--lof-stepper-indicator-size` | `24px` | Indicator diameter (default 24px; `type="dot"` is fixed at 8px). |
|
|
145
|
+
|
|
146
|
+
<!-- readme-gen:end -->
|
|
147
|
+
|
|
148
|
+
## Accessibility
|
|
149
|
+
|
|
150
|
+
- The list renders as a `role="group"` with the fixed name "Progress steps" (not configurable).
|
|
151
|
+
- Every step is a `role="button"` element with `aria-label="<title>, step n of N"`, plus ", completed" for `done` steps. The `progress` step carries `aria-current="step"`; `disabled` steps carry `aria-disabled="true"` and `tabindex="-1"` so they are skipped in the Tab order and by the arrow keys.
|
|
152
|
+
- Enabled steps are individual Tab stops (`tabindex="0"`) with a 2px focus ring; the indicators and connectors are purely visual (the check mark SVG is `aria-hidden`).
|
|
153
|
+
- Activating a step only emits `lof-step-change`; nothing is announced and no status changes until you update `steps`.
|
|
154
|
+
|
|
155
|
+
| Key | Action |
|
|
156
|
+
| --- | --- |
|
|
157
|
+
| `Enter` / `Space` | Activate the focused step (emits `lof-step-change`; ignored on `disabled` steps) |
|
|
158
|
+
| `ArrowRight` / `ArrowDown` | Move focus to the next enabled step (wraps to the first) |
|
|
159
|
+
| `ArrowLeft` / `ArrowUp` | Move focus to the previous enabled step (wraps to the last) |
|
|
160
|
+
| `Home` / `End` | Move focus to the first / last enabled step |
|
|
161
|
+
|
|
162
|
+
## Notes / Edge Cases
|
|
163
|
+
|
|
164
|
+
- `label-placement` is the canonical layout switch (Figma `Typel`). When it is unset the deprecated `textalign` prop decides: `below` renders like `inverted` (indicator above the label), `right` renders like `centered` (label beside the indicator). `top` differs from `centered` only in aligning the label to the top of the indicator. Figma marks Top + Horizontal as an unsupported combination.
|
|
165
|
+
- Statuses map to the Figma `.Artwork` states: `done` = inverse fill with a check mark (or the number when `type="number"`, nothing when `type="dot"`), `progress` = neutral fill with a strong 1px border, `disabled` = the same drawn at 40% opacity. Connectors are `border-strong` after a `done` / `progress` step and `border-default` otherwise.
|
|
166
|
+
- `type="icon"` shows the check mark on every step regardless of status; `type="dot"` shrinks the indicator to 8px and fills it for `done` and `progress`.
|
|
167
|
+
- Two axes spell one value "dot" and they are independent: `type="dot"` is the INDICATOR (a 10px disc replacing the number), `connector="dot"` is the LINE between steps. `connector="dot"` draws a 1px rule dashed 2px on / 2px off, matching Figma `.Line Types` `Type=Dot` (`strokeWeight=1`, `strokeDashes=[2,2]`). It is a repeating gradient rather than a dashed border because no engine lets you state a 2/2 dash period. The dash takes the connector's own state colour, so it goes `border-strong` after a `done` / `progress` step like the solid line does.
|
|
168
|
+
- Connector length doubles as the gap between steps and depends on `size` and `orientation`: large = `--lof-stepper-connector-length-lg` (86px) in both orientations; small horizontal = `--lof-stepper-connector-length-md` (60px); small vertical = `--lof-stepper-connector-length-sm` (42px). Note the `md` / `sm` suffixes refer to those defaults, not to a size value.
|
|
169
|
+
- Labels never wrap (`white-space: nowrap`); keep titles short or widen the connector hooks.
|
|
170
|
+
- `steps` is compared by reference: mutate-in-place changes are not picked up — assign a new array.
|
|
171
|
+
- Steps are `<div role="button">` elements, not native buttons, so they do not submit forms and do not get native disabled styling.
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# lof-switch
|
|
2
|
+
|
|
3
|
+
`<lof-switch>` implements the Figma **Switch** component set (9059:11244): Type Line (default; at medium a 44×20 toggle with a thin 10px track and a 20px handle that slides 20px) or Pill (a 44×24 filled track), three sizes, an optional label at either end, and the hover, pressed, focused and disabled states from the Figma State axis. It wraps a native checkbox with `role="switch"`, so keyboard and screen-reader behaviour are native. Use it for settings that take effect immediately (notifications on/off, dark mode); for choices that are collected and submitted with a form use `<lof-checkbox>`.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!-- Basic -->
|
|
9
|
+
<lof-switch field-aria-label="Email notifications"></lof-switch>
|
|
10
|
+
|
|
11
|
+
<!-- On by default -->
|
|
12
|
+
<lof-switch checked field-aria-label="Dark mode"></lof-switch>
|
|
13
|
+
|
|
14
|
+
<!-- Disabled, off and on -->
|
|
15
|
+
<lof-switch disabled field-aria-label="Locked setting"></lof-switch>
|
|
16
|
+
<lof-switch checked disabled field-aria-label="Locked setting"></lof-switch>
|
|
17
|
+
|
|
18
|
+
<!-- One handler for several switches: `value` is echoed in the event detail -->
|
|
19
|
+
<lof-switch value="marketing" field-aria-label="Marketing emails"></lof-switch>
|
|
20
|
+
<lof-switch value="product" field-aria-label="Product updates"></lof-switch>
|
|
21
|
+
<script>
|
|
22
|
+
document.addEventListener('lof-change', (e) => {
|
|
23
|
+
if (e.target.tagName !== 'LOF-SWITCH') return;
|
|
24
|
+
console.log(e.detail.value, e.detail.checked); // "marketing", true
|
|
25
|
+
});
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<!-- Programmatic control (no event is fired) -->
|
|
29
|
+
<lof-switch id="wifi" field-aria-label="Wi-Fi"></lof-switch>
|
|
30
|
+
<script>
|
|
31
|
+
const wifi = document.getElementById('wifi');
|
|
32
|
+
wifi.checked = true;
|
|
33
|
+
</script>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
<!-- readme-gen:start -->
|
|
37
|
+
|
|
38
|
+
<!-- Generated from lof-switch.ts — do not edit; run readme-generate.mjs -->
|
|
39
|
+
|
|
40
|
+
## API
|
|
41
|
+
|
|
42
|
+
### Attributes / Properties
|
|
43
|
+
|
|
44
|
+
| Property | Attribute | Type | Default | Description |
|
|
45
|
+
| --- | --- | --- | --- | --- |
|
|
46
|
+
| `checked` | `checked` | `boolean` | `false` | Whether the switch is on. Set it to control the state programmatically; user toggles update it and fire `lof-change`. |
|
|
47
|
+
| `type` | `type` | `"line" \| "pill"` | `"pill"` | Shape. `"pill"` (default since the 2026-11 refresh) is a filled track with the knob inside it: 26×18 / 30×20 / 34×22 with a 10 / 12 / 14px knob, the accent when on. `"line"` is the earlier 44×20 control with a thin rail and the knob riding on it, accent knob when on. Pressing squashes the knob; only `line` also shows a pressed disc behind it. Reflected. |
|
|
48
|
+
| `disabled` | `disabled` | `boolean` | `false` | Disables interaction and swaps in the dulled rail / handle fills (for both types, checked or not) and the disabled label colour; the handle shadow is removed. An ancestor `<fieldset disabled>` disables it the same way, without changing this property. |
|
|
49
|
+
| `value` | `value` | `string` | `""` | Arbitrary string echoed in the `lof-change` event detail — useful when one handler serves several switches. |
|
|
50
|
+
| `fieldAriaLabel` | `field-aria-label` | `string` | `undefined` | Accessible name for the native input when the switch has no visible text. Prefer `label`, slotted text or an outer `<label>` (wrapping the switch, or `for=`), which are visible and clickable. |
|
|
51
|
+
| `label` | `label` | `string` | `undefined` | Visible text beside the control. Clicking it toggles the switch, and it becomes the accessible name — use `fieldAriaLabel` instead when the switch has no visible text. For rich content (a bold word, an icon) slot it in the default slot rather than setting this. |
|
|
52
|
+
| `labelPlacement` | `label-placement` | `"end" \| "start"` | `"end"` | Which side the label sits on: `end` (default) puts it after the control, `start` before it. Note this is a PHYSICAL side, not a writing-direction one, matching every other placement prop in the library. Reflected. |
|
|
53
|
+
| `size` | `size` | `"small" \| "medium" \| "large" \| "sm" \| "md" \| "lg"` | `"medium"` | Control scale: `small`, `medium` (default) or `large`. `sm` / `md` / `lg` are alternative spellings and stay supported — normalised to the full words, not deprecated. Matches Figma's Size axis: controls 36 / 44 / 52px wide, labels body-sm / body-md / body-lg (12 / 14 / 16px). The default stays `medium` (Figma's own default is Large). It does NOT respond to viewport width. Picking a size per breakpoint is the consuming application's decision — a control that silently resized itself at some width would be undocumentable behaviour, and the breakpoint that matters belongs to the layout around it, not to the switch. Reflected. |
|
|
54
|
+
|
|
55
|
+
## Events
|
|
56
|
+
|
|
57
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
58
|
+
| --- | --- | --- | --- |
|
|
59
|
+
| `lof-change` | `{ checked: this.checked, value: this.value, }` | bubbles / composed | Fired when the user toggles the switch (not on programmatic `checked` changes). Detail: `{ checked: boolean, value: string }`. |
|
|
60
|
+
|
|
61
|
+
## Slots
|
|
62
|
+
|
|
63
|
+
| Slot | Description |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| (default) | Rich label content beside the control, as an alternative to the `label` property. Clicking it toggles the switch. |
|
|
66
|
+
|
|
67
|
+
## CSS Parts
|
|
68
|
+
|
|
69
|
+
| Part | Description |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `root` | The `<label>` holding the control and its optional text; carries the `label-placement` order and the keyboard focus ring |
|
|
72
|
+
| `base` | The control box around the hidden input and the track |
|
|
73
|
+
| `track` | The thin rail; the handle is its `::before` pseudo-element |
|
|
74
|
+
| `label` | The text beside the control (body-sm / body-md / body-lg by `size`; `--lof-text-disabled` while disabled); not rendered when there is neither a `label` nor slotted content |
|
|
75
|
+
|
|
76
|
+
## Tokens / CSS Variables
|
|
77
|
+
|
|
78
|
+
### Component hooks
|
|
79
|
+
|
|
80
|
+
Set these on the host (or an ancestor) to customise the element without touching design tokens.
|
|
81
|
+
|
|
82
|
+
| Custom property | Default | Description |
|
|
83
|
+
| --- | --- | --- |
|
|
84
|
+
| `--lof-switch-disabled` | `var(--switch-disabled)` | Handle colour while disabled; default `var(--lof-bg-neutral-elevated-1)` |
|
|
85
|
+
| `--lof-switch-knob-off` | `var(--switch-knob-off)` | Handle colour when unchecked; default `var(--lof-text-static-light)` |
|
|
86
|
+
| `--lof-switch-knob-on` | `var(--switch-knob-on)` | Handle colour when checked; default `var(--lof-bg-neutral-inverse-2)` |
|
|
87
|
+
| `--lof-switch-thumb-size` | `var(--_lof-sw-thumb)` | Handle diameter; defaults to the `size` ramp (16 / 20 / 24px), and the handle always travels its own width minus the 2px inset on each side |
|
|
88
|
+
| `--lof-switch-track` | `var(--switch-track)` | Rail colour; default `var(--lof-bg-neutral-elevated-2)` |
|
|
89
|
+
| `--lof-switch-track-height` | `var(--_lof-sw-h)` | Overall control height; defaults to the `size` ramp — 16 / 20 / 24px for `type="line"`, 20 / 24 / 28px for `type="pill"` |
|
|
90
|
+
| `--lof-switch-track-width` | `var(--_lof-sw-w)` | Overall control width; defaults to the `size` ramp (36 / 44 / 52px) |
|
|
91
|
+
| `--switch-halo` | `var(--lof-action-overlay-hover-strong)` | — |
|
|
92
|
+
|
|
93
|
+
<!-- readme-gen:end -->
|
|
94
|
+
|
|
95
|
+
## Accessibility
|
|
96
|
+
|
|
97
|
+
- Renders a native `<input type="checkbox" role="switch">` with `aria-checked` mirroring `checked`; the input is visually hidden (opacity 0, zero size) inside the `<label part="root">` that also holds the label text, so clicking anywhere on the control or its text toggles it.
|
|
98
|
+
- `field-aria-label` becomes the input's `aria-label`. Use it only when there is no visible text; visible text in `label` or the default slot is clickable and becomes the accessible name.
|
|
99
|
+
- An outer `<label>` works too, wrapped around the switch (`<label><lof-switch></lof-switch> Wi-Fi</label>`) or pointing at it (`<label for="wifi">Wi-Fi</label><lof-switch id="wifi">`). The element is form-associated, so clicking the label's text toggles the switch (once, with one `lof-change`); a disabled switch ignores it. The input lives in the shadow root, where `aria-labelledby` cannot reach the label, so the label's text is copied into the input's `aria-label`. That happens only when the switch has no name of its own: `label`, `field-aria-label` and slotted text each win over an outer label. The copy follows edits to the label's text.
|
|
100
|
+
- Focus: keyboard focus (`:focus-visible`) draws one square 2px `--lof-border-focus` outline around the whole component, control and label together (the same treatment as `lof-checkbox` and `lof-radio`). A pointer click shows no ring.
|
|
101
|
+
- `disabled` disables the native input (removed from the tab order), swaps in the dulled rail and handle fills, drops the handle shadow and colours the label `--lof-text-disabled`.
|
|
102
|
+
- Forced colors (Windows High Contrast): the rail and handle are redrawn from system colours (a CanvasText outline, the handle filled Highlight when on, GrayText while disabled), and the focus ring stays an outline.
|
|
103
|
+
- `prefers-reduced-motion: reduce` removes the track and handle transitions.
|
|
104
|
+
|
|
105
|
+
| Key | Action |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| `Space` | Toggles the switch (native checkbox behaviour). |
|
|
108
|
+
| `Tab` / `Shift+Tab` | Moves focus to / from the switch. |
|
|
109
|
+
|
|
110
|
+
## Notes / Edge Cases
|
|
111
|
+
|
|
112
|
+
- `lof-change` fires for user toggles only; setting `checked` from JavaScript updates the visuals but emits nothing.
|
|
113
|
+
- Geometry: the default `pill` switch is 26×18 / 30×20 / 34×22 (small / medium / large) with a 10 / 12 / 14px knob inset 4px; on, the track takes the accent (`--lof-accent`) and the knob travels the track width minus its height. `type="line"` keeps the earlier geometry: 44×20 control, 40×10 rail, 20px knob (36×16 and 52×24 at small and large). Changing `--lof-switch-track-width` widens the control without moving the "on" position.
|
|
114
|
+
- The label type follows the size: body-sm / body-md / body-lg (12 / 14 / 16px) for small / medium / large.
|
|
115
|
+
- **`size` does not respond to viewport width.** It follows Figma's Size axis, and choosing a size per breakpoint is the application's decision — set it from your own media queries or container queries. A control that resized itself at some width would be behaviour a design system cannot document, and the breakpoint that matters belongs to the layout around the switch, not to the switch.
|
|
116
|
+
- A `label` (or slotted content) becomes the switch's accessible name and is clickable, because the root element is the `<label>` that owns the input. Use `field-aria-label` instead when there is no visible text; when both are set, `label` wins.
|
|
117
|
+
- Hover and pressed cover the whole component, label included. Hover tints the track with the action overlay and raises the handle shadow. Pressed (pointer down, or Space held) squashes the handle by 4px on Line (16×12 / 20×16 / 24×20) over an overlay disc 8px wider than the handle, and to (handle + 1) × (handle − 2) on Pill, with no disc; an unchecked rail turns `--lof-bg-neutral-elevated-1` while pressed.
|
|
118
|
+
- Legacy hook aliases still honoured: `--switch-track`, `--switch-knob-on`, `--switch-knob-off` and `--switch-disabled` are read as fallbacks of the `--lof-switch-*` hooks. The old `--switch-halo` name was never read by any rule and is not a hook.
|
|
119
|
+
- `registerOnChange`, `registerOnTouched` and `writeValue` exist for the Angular `ControlValueAccessor` wrapper and are not public API.
|
|
120
|
+
- The element is form-associated (so an outer `<label>` can find it) but sets no form value: it is still NOT submitted with a surrounding `<form>`, and form reset does not touch it. It does now appear in `form.elements`. Read `checked` or listen to `lof-change`.
|
|
121
|
+
- Inside a `<fieldset disabled>` the switch behaves disabled (input disabled, dulled fills, no toggling) without its `disabled` property changing.
|
|
122
|
+
- `el.click()` from script now toggles the switch, like a native checkbox; it used to do nothing.
|