@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.
Files changed (65) hide show
  1. package/README.md +104 -2
  2. package/custom-elements.json +12890 -0
  3. package/dist/index.d.ts +3192 -0
  4. package/dist/index.js +20807 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/styles/ag-grid.css +145 -0
  7. package/dist/styles/motion.css +32 -0
  8. package/dist/styles/motion.tokens.json +38 -0
  9. package/dist/styles/typography.css +41 -0
  10. package/dist/styles/typography.json +858 -0
  11. package/dist/styles/vars.css +1225 -0
  12. package/package.json +46 -4
  13. package/readmes/lof-accordion/README.md +140 -0
  14. package/readmes/lof-alert/README.md +142 -0
  15. package/readmes/lof-autocomplete/README.md +209 -0
  16. package/readmes/lof-avatar/README.md +228 -0
  17. package/readmes/lof-badge/README.md +102 -0
  18. package/readmes/lof-breadcrumb/README.md +97 -0
  19. package/readmes/lof-button/README.md +189 -0
  20. package/readmes/lof-calendar/README.md +111 -0
  21. package/readmes/lof-card/README.md +105 -0
  22. package/readmes/lof-cardmedia/README.md +100 -0
  23. package/readmes/lof-carousel/README.md +187 -0
  24. package/readmes/lof-checkbox/README.md +159 -0
  25. package/readmes/lof-chip/README.md +153 -0
  26. package/readmes/lof-container/README.md +107 -0
  27. package/readmes/lof-date-picker/README.md +221 -0
  28. package/readmes/lof-divider/README.md +88 -0
  29. package/readmes/lof-drawer/README.md +188 -0
  30. package/readmes/lof-empty-state/README.md +78 -0
  31. package/readmes/lof-image-input/README.md +75 -0
  32. package/readmes/lof-kbd/README.md +188 -0
  33. package/readmes/lof-layout/README.md +122 -0
  34. package/readmes/lof-link/README.md +67 -0
  35. package/readmes/lof-menu/README.md +187 -0
  36. package/readmes/lof-menubar/README.md +218 -0
  37. package/readmes/lof-nav/README.md +90 -0
  38. package/readmes/lof-otp/README.md +167 -0
  39. package/readmes/lof-page-header/README.md +71 -0
  40. package/readmes/lof-pagination/README.md +141 -0
  41. package/readmes/lof-popover/README.md +220 -0
  42. package/readmes/lof-progress/README.md +88 -0
  43. package/readmes/lof-radio/README.md +142 -0
  44. package/readmes/lof-range-picker/README.md +194 -0
  45. package/readmes/lof-rating/README.md +90 -0
  46. package/readmes/lof-resizable/README.md +220 -0
  47. package/readmes/lof-segmented-button/README.md +158 -0
  48. package/readmes/lof-select/README.md +193 -0
  49. package/readmes/lof-sheet/README.md +170 -0
  50. package/readmes/lof-signature-pad/README.md +161 -0
  51. package/readmes/lof-skeleton/README.md +104 -0
  52. package/readmes/lof-slider/README.md +140 -0
  53. package/readmes/lof-snackbar/README.md +170 -0
  54. package/readmes/lof-split-button/README.md +129 -0
  55. package/readmes/lof-stat/README.md +73 -0
  56. package/readmes/lof-stepper/README.md +171 -0
  57. package/readmes/lof-switch/README.md +122 -0
  58. package/readmes/lof-tab/README.md +188 -0
  59. package/readmes/lof-table/README.md +114 -0
  60. package/readmes/lof-textfield/README.md +206 -0
  61. package/readmes/lof-time-picker/README.md +188 -0
  62. package/readmes/lof-toast/README.md +174 -0
  63. package/readmes/lof-tooltip/README.md +120 -0
  64. package/readmes/lof-tree/README.md +157 -0
  65. package/readmes/lof-upload/README.md +223 -0
@@ -0,0 +1,161 @@
1
+ # lof-signature-pad
2
+
3
+ <!-- @unreleased-component 1.5.0 -->
4
+
5
+ A field that captures a handwritten signature. The user signs with a mouse, pen or finger on a 160px pad that fills its container's width. Like `lof-textfield`, the field has a label, helper text, and error, disabled and read-only states. Undo and Clear sit in the helper row. Undo removes the last stroke, and it also brings back a signature that Clear removed, so Clear asks no confirmation. `value` is the signature as a trimmed PNG data URL; `strokes` keeps the vector record, and `toSVG()` exports it.
6
+
7
+ A "Type your name instead" link beside the label switches to type mode: the user types their name and it renders on the baseline in Poppins italic. The value is the same kind of PNG. Type mode is the keyboard and screen-reader alternative to drawing (WCAG 2.2 SC 2.5.7, Dragging Movements), and it is offered to everyone.
8
+
9
+ ## Usage
10
+
11
+ ```html
12
+ <lof-signature-pad id="sig" label="Customer signature" required></lof-signature-pad>
13
+ <script>
14
+ const sig = document.getElementById('sig');
15
+ sig.addEventListener('lof-change', (e) => {
16
+ console.log(e.detail.value); // "data:image/png;base64,…", or "" once cleared
17
+ console.log(e.detail.strokes); // [{ points: [[x, y, t, pressure], …], pointerType }, …]
18
+ console.log(e.detail.signedAt); // ISO 8601 time of the first stroke
19
+ });
20
+ </script>
21
+
22
+ <!-- An error message replaces the helper text -->
23
+ <lof-signature-pad label="Customer signature" required error
24
+ error-message="A signature is required to confirm handoff"></lof-signature-pad>
25
+
26
+ <!-- Show a stored signature without letting it change -->
27
+ <lof-signature-pad label="Customer signature" readonly value="data:image/png;base64,…"></lof-signature-pad>
28
+
29
+ <!-- Start in type mode, with a name filled in -->
30
+ <lof-signature-pad label="Signature" mode="type" typed-name="Ada Lovelace"></lof-signature-pad>
31
+
32
+ <!-- A taller pad -->
33
+ <lof-signature-pad label="Signature" style="--lof-signature-pad-height: 200px"></lof-signature-pad>
34
+ ```
35
+
36
+ Once there is ink, the helper row shows "Signed" with the date, time and a short time zone (for example "Signed 18/10/2026, 2:14 PM GMT+5"), formatted for the nearest `lang` attribute. `signedAt` holds the same moment as an ISO string. It is set by the first stroke and cleared by Clear.
37
+
38
+ The exported PNG and SVG always use black ink on a transparent background, so a signature captured in dark mode still prints. On screen the ink follows the theme (`--lof-text-default`), and a stored `value` is recoloured to match. The PNG is trimmed to the ink plus 8px and drawn at 2×.
39
+
40
+ `strokes` coordinates are CSS pixels of the pad at the moment the signature began. If the pad later gets narrower, the signature is drawn scaled down to fit and the coordinates do not change. Assigning `strokes` redraws a stored record that can still be added to; assigning `value` shows a stored image that Undo cannot take apart. Both start a new Undo history.
41
+
42
+ Each mode keeps its own content when the user switches, and only the active mode makes the `value`. In type mode, Clear empties the name and Undo brings it back; while focus is in the name input, Ctrl/Cmd+Z is the input's own undo. `signedAt` in type mode is when the name was first typed. The value updates as the user types, and `lof-change` fires when the name is committed (on blur or Enter) and when the mode switch changes the value.
43
+
44
+ `lof-change` reports what the user did: a stroke, Undo, Clear, a committed name or a mode switch. It does not fire when your code sets `value`, `strokes`, `typed-name` or `mode`, or calls `undo()` or `clear()`. Read the new state from the element after those calls.
45
+
46
+ ## Forms
47
+
48
+ The pad is a form control (decision 0006). Inside a `<form>` it submits its `value`, the PNG data URL, under its `name`; an empty pad submits `""`. The data URL is typically 5–30 KB, so post the form (`method="post"`) and check your server's request-size limit.
49
+
50
+ ```html
51
+ <form method="post" action="/handoffs/42/confirm">
52
+ <lof-signature-pad name="signature" label="Customer signature" required></lof-signature-pad>
53
+ <button>Confirm handoff</button>
54
+ </form>
55
+ ```
56
+
57
+ - **Validation:** a `required` pad is invalid while empty (`valueMissing`), so the form will not submit and the browser focuses the pad, or the name input in type mode. The field does not turn red by itself. Listen for `invalid` and set `error` and `error-message`, as with the other fields. A `readonly` pad is not validated.
58
+ - **Reset:** a form reset empties both modes and the Undo history, without firing `lof-change`.
59
+ - **Restore:** when the browser restores a form (back and forward navigation), the strokes, the stored image or the typed name come back.
60
+ - **Labels and fieldsets:** an outer `<label for>` (or a wrapping one) names the pad and focuses it when clicked. A `<fieldset disabled>` disables the pad, and a disabled pad is left out of the form data.
61
+
62
+ <!-- readme-gen:start -->
63
+
64
+ <!-- Generated from lof-signature-pad.ts — do not edit; run readme-generate.mjs -->
65
+
66
+ ## API
67
+
68
+ ### Attributes / Properties
69
+
70
+ | Property | Attribute | Type | Default | Description |
71
+ | --- | --- | --- | --- | --- |
72
+ | `label` | `label` | `string` | `undefined` | Visible label above the pad. A `required` asterisk is appended. |
73
+ | `required` | `required` | `boolean` | `false` | Marks the signature as required: the label gets an asterisk. Reflected. |
74
+ | `helperText` | `helper-text` | `string` | `undefined` | Helper line below the pad. Defaults to "Use a mouse, pen or finger to sign"; once signed, the line shows "Signed {date and time}" instead. |
75
+ | `disabledText` | `disabled-text` | `string` | `undefined` | Text in the helper line while disabled (default "Signing is unavailable"). |
76
+ | `error` | `error` | `boolean` | `false` | Puts the field in the error state: danger border, and `error-message` replacing the helper text. Reflected. |
77
+ | `errorMessage` | `error-message` | `string` | `undefined` | Text shown below the pad, with an alert icon, instead of the helper text while `error` is set. |
78
+ | `disabled` | `disabled` | `boolean` | `false` | Disables the field: no drawing, Undo and Clear disabled, the pad leaves the Tab order, and the helper line shows `disabled-text`. Reflected. |
79
+ | `readonly` | `readonly` | `boolean` | `false` | Shows the signature and its timestamp without letting it change: a subtle border, no Undo or Clear buttons, no drawing. Reflected. |
80
+ | `placeholder` | `placeholder` | `string` | `"Sign here"` | Text in the empty pad (default "Sign here"). It hides on the first ink; the baseline stays. |
81
+ | `name` | `name` | `string` | `undefined` | Name of the field in a form. Reflected. |
82
+ | `fieldAriaLabel` | `field-aria-label` | `string` | `undefined` | Accessible name of the pad when there is no visible `label`. |
83
+ | `value` | `value` | `string` | `""` | The signature as a PNG data URL, trimmed to the ink at 2×, with black ink on a transparent background in every theme; `""` when empty. Set it to show a stored signature: it is drawn in the theme's ink colour and replaces the strokes, so Undo cannot take it apart stroke by stroke (Clear removes it, and Undo brings it back). Setting `""` empties the pad. |
84
+ | `strokes` | — | `SignatureStroke[]` | `[]` | The vector record of the signature, one entry per stroke: `{ points: [x, y, t, pressure][], pointerType? }`. Coordinates are CSS pixels of the pad when the first stroke was drawn (a narrower pad later shows the signature scaled down to fit, and the coordinates do not change); `t` is epoch milliseconds. Set it to redraw a stored signature that can be added to; that starts a new Undo history. Property only. |
85
+ | `mode` | `mode` | `"draw" \| "type"` | `"draw"` | `draw` (default) captures the signature with a pointer; `type` takes a typed name and renders it in Poppins italic. The user switches with the link beside the label. Each mode keeps its own content; only the active mode makes the `value`. Reflected. |
86
+ | `typedName` | `typed-name` | `string` | `""` | The name typed in type mode. The `value` in type mode is this name rendered as a PNG, black, in Poppins italic. |
87
+
88
+ ### Public fields / accessors
89
+
90
+ | Name | Type | Description |
91
+ | --- | --- | --- |
92
+ | `signedAt` | `string` | When the signature was started, as an ISO 8601 string; `""` while empty. Set by the first stroke and cleared by Clear. Read-only. |
93
+
94
+ ### Methods
95
+
96
+ | Method | Signature | Description |
97
+ | --- | --- | --- |
98
+ | `isEmpty` | `isEmpty(): boolean` | True when the active mode has no signature: no strokes and no stored signature in draw mode, a blank name in type mode. |
99
+ | `undo` | `undo(): void` | Removes the last stroke, or restores what Clear removed (in type mode, the cleared name). Does not fire `lof-change`. |
100
+ | `clear` | `clear(): void` | Removes the whole signature of the active mode; Undo brings it back. Does not fire `lof-change`. |
101
+ | `toDataURL` | `toDataURL(type = "image/png"): string` | The signature as a data URL of the given type (default `"image/png"`), trimmed to the ink at 2× with black ink; `"image/svg+xml"` returns `toSVG()` as a data URL, and `"image/jpeg"` gets a white background. `""` when empty. |
102
+ | `toSVG` | `toSVG(): string` | The signature as an SVG document string, in black and trimmed. Draw mode gives smoothed paths in the `strokes` coordinate space (a stored signature from `value` is embedded as an image); type mode gives the name as `<text>` in Poppins italic. `""` when empty. |
103
+
104
+ ## Events
105
+
106
+ | Event | Detail | Bubbles / composed | Description |
107
+ | --- | --- | --- | --- |
108
+ | `lof-begin` | `{}` | bubbles / composed | The user put the pointer down to start a stroke. Detail: `{}`. |
109
+ | `lof-change` | `{ value, strokes, signedAt, mode }` | bubbles / composed | The signature changed through the user: a finished stroke, Undo, Clear, a committed typed name (on blur or Enter) or a switch of mode. Detail: `{ value, strokes, signedAt, mode }`. Not fired for property changes or the `undo()` / `clear()` methods. |
110
+ | `lof-end` | `{}` | bubbles / composed | The user finished a stroke. Detail: `{}`. |
111
+
112
+ ## Slots
113
+
114
+ | Slot | Description |
115
+ | --- | --- |
116
+ | — | This element has no slots. |
117
+
118
+ ## CSS Parts
119
+
120
+ | Part | Description |
121
+ | --- | --- |
122
+ | `label` | The label above the pad. |
123
+ | `mode-toggle` | The link-style `lof-button` beside the label that switches between drawing ("Type your name instead") and typing ("Draw instead"). Hidden while `readonly`. |
124
+ | `pad` | The bordered drawing area. In draw mode it is a focusable `role="img"` named by the label and the signature's state; in type mode it holds the name input. |
125
+ | `canvas` | The `<canvas>` the ink is drawn on. |
126
+ | `placeholder` | The "Sign here" text ("Type your full name" in type mode), shown while the pad is empty. |
127
+ | `baseline` | The line near the bottom of the pad. |
128
+ | `typed-input` | The text input of type mode, drawn on the baseline in Poppins italic. |
129
+ | `helper` | The helper, error or "Signed …" text below the pad. |
130
+ | `actions` | The row that holds the Undo and Clear buttons. |
131
+ | `undo` | The Undo `lof-button` (ghost, small). |
132
+ | `clear` | The Clear `lof-button` (secondary, small). |
133
+
134
+ ## Tokens / CSS Variables
135
+
136
+ ### Component hooks
137
+
138
+ Set these on the host (or an ancestor) to customise the element without touching design tokens.
139
+
140
+ | Custom property | Default | Description |
141
+ | --- | --- | --- |
142
+ | `--lof-signature-pad-height` | `160px` | Height of the pad, border included (default 160px). |
143
+
144
+ <!-- readme-gen:end -->
145
+
146
+ ## Accessibility
147
+
148
+ - The "Type your name instead" / "Draw instead" link comes before the pad in the Tab order, so keyboard users reach the typed alternative first. Switching moves focus to the name input or to the pad. The input is named "{label}, type your full name", carries `aria-required` and `aria-invalid`, and is described by the helper or error text.
149
+ - In draw mode the pad is a focusable `role="img"`. Its name is the label (or `field-aria-label`) plus its state: "Customer signature, required, signature pad, empty", or "Customer signature, required, signed 18/10/2026, 2:14 PM GMT+5". It is described by the helper or error text.
150
+ - Undo and Clear are real buttons, named "Undo last stroke" ("Undo clear" in type mode) and "Clear signature". When a button disables itself (Clear, or the last Undo), focus moves to the pad.
151
+ - Changes are announced politely: "Signature captured" on the first stroke, then "Last stroke removed", "Signature cleared" and "Signature restored".
152
+ - The pad has the field border (`--lof-border-default`, 3:1 or more). Focus, and drawing, draw a 2px `--lof-border-strong` border inside the pad edge; the error state draws it in `--lof-border-danger` at rest, and focus in error adds a 2px danger ring outside, so focus stays visible. Both stay visible in forced-colours mode, where the ink is drawn in `CanvasText`.
153
+ - Only the canvas sets `touch-action: none`. The page still scrolls from the label, the helper row and a read-only or disabled pad.
154
+
155
+ ### Keyboard
156
+
157
+ | Key | Action |
158
+ | --- | --- |
159
+ | Tab / Shift+Tab | Moves between the mode link, the pad (or the name input in type mode), Undo and Clear. The pad leaves the Tab order while disabled. |
160
+ | Ctrl+Z / Cmd+Z | Undoes the last stroke, or a Clear, while focus is in the field (in the name input it is the input's own undo) |
161
+ | Enter / Space | Activates the mode link, Undo or Clear |
@@ -0,0 +1,104 @@
1
+ # lof-skeleton
2
+
3
+ Loading placeholder that reserves the space of content still being fetched: a neutral `block`, a `circle` (avatars, icons) or a stack of text `line` bars, animated with a `pulse` or `shimmer` until you set `loaded`, at which point it hides itself. Use it when you know the shape of the incoming content (cards, list rows, avatars); use a spinner for indeterminate waits with no layout to preserve.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <!-- Block (default): fills its container, height set explicitly -->
9
+ <lof-skeleton height="160px"></lof-skeleton>
10
+
11
+ <!-- Circle: only a width is needed, the aspect ratio keeps it round -->
12
+ <lof-skeleton shape="circle" width="48px"></lof-skeleton>
13
+
14
+ <!-- Paragraph: three text bars, the last one shorter -->
15
+ <lof-skeleton shape="line" lines="3"></lof-skeleton>
16
+
17
+ <!-- Animation variants -->
18
+ <lof-skeleton shape="line" lines="2" animation="shimmer"></lof-skeleton>
19
+ <lof-skeleton shape="block" height="80px" animation="none"></lof-skeleton>
20
+
21
+ <!-- Custom colours -->
22
+ <lof-skeleton
23
+ shape="block"
24
+ height="120px"
25
+ animation="shimmer"
26
+ style="--lof-skeleton-color: #e5e7eb; --lof-skeleton-highlight: #f9fafb;"
27
+ ></lof-skeleton>
28
+
29
+ <!-- A list-row placeholder that swaps for real content -->
30
+ <div style="display: flex; gap: 12px; align-items: center;">
31
+ <lof-skeleton id="avatar" shape="circle" width="40px"></lof-skeleton>
32
+ <div style="flex: 1;">
33
+ <lof-skeleton id="text" shape="line" lines="2"></lof-skeleton>
34
+ </div>
35
+ </div>
36
+ <script>
37
+ fetchUser().then(() => {
38
+ document.getElementById('avatar').loaded = true;
39
+ document.getElementById('text').loaded = true;
40
+ });
41
+ </script>
42
+ ```
43
+
44
+ <!-- readme-gen:start -->
45
+
46
+ <!-- Generated from lof-skeleton.ts — do not edit; run readme-generate.mjs -->
47
+
48
+ ## API
49
+
50
+ ### Attributes / Properties
51
+
52
+ | Property | Attribute | Type | Default | Description |
53
+ | --- | --- | --- | --- | --- |
54
+ | `shape` | `shape` | `"line" \| "circle" \| "block"` | `"block"` | Placeholder shape: `block` fills the host (min 16px tall), `circle` is a square-aspect disc sized by the host width, `line` renders `lines` 16px text bars with the last one at 65% width. Reflected. |
55
+ | `lines` | `lines` | `number` | `1` | Number of text bars when `shape="line"` (minimum 1, --lof-spacing-xs apart); ignored by the other shapes. |
56
+ | `width` | `width` | `string` | `""` | Any CSS width (e.g. `"240px"`, `"50%"`) applied to the host's inline style. Empty leaves the host at its natural block width. |
57
+ | `height` | `height` | `string` | `""` | Any CSS height (e.g. `"120px"`) applied to the host's inline style. Not needed for `circle`, which derives its height from the width. |
58
+ | `animation` | `animation` | `"pulse" \| "shimmer" \| "none"` | `"pulse"` | Motion: `pulse` fades opacity between 20% and 40% (Figma's Start/End states), `shimmer` sweeps a highlight band left to right, `none` is static. Both animations are disabled under `prefers-reduced-motion: reduce`. Reflected. |
59
+ | `loaded` | `loaded` | `boolean` | `false` | Set once the real content is ready: hides the skeleton (`display: none`) and removes its `role="status"` / "Loading" label. Reflected. |
60
+
61
+ ## Events
62
+
63
+ | Event | Detail | Bubbles / composed | Description |
64
+ | --- | --- | --- | --- |
65
+ | — | — | — | This element emits no custom events. |
66
+
67
+ ## Slots
68
+
69
+ | Slot | Description |
70
+ | --- | --- |
71
+ | — | This element has no slots. |
72
+
73
+ ## CSS Parts
74
+
75
+ | Part | Description |
76
+ | --- | --- |
77
+ | `base` | Each placeholder surface: the single block/circle, or every bar when `shape="line"`. |
78
+
79
+ ## Tokens / CSS Variables
80
+
81
+ ### Component hooks
82
+
83
+ Set these on the host (or an ancestor) to customise the element without touching design tokens.
84
+
85
+ | Custom property | Default | Description |
86
+ | --- | --- | --- |
87
+ | `--lof-skeleton-color` | `var(--lof-bg-neutral-elevated-3)` | Fill colour of the placeholder (defaults to the elevated-3 neutral background token). |
88
+ | `--lof-skeleton-highlight` | `var(--lof-bg-neutral-elevated-2)` | Lighter band that sweeps across the placeholder when `animation="shimmer"` (defaults to the elevated-2 neutral background token). |
89
+ | `--lof-skeleton-line-height` | `16px` | Height of each text bar when `shape="line"`; default 16px (Figma's Line shape). |
90
+
91
+ <!-- readme-gen:end -->
92
+
93
+ ## Accessibility
94
+
95
+ - While not `loaded`, the host carries `role="status"` and `aria-label="Loading"`, so assistive technology announces that the region is loading; both are removed once `loaded` is set (the attributes are managed on each update, so they appear after the first render).
96
+ - The placeholder is not focusable and has no keyboard interaction.
97
+ - Under `prefers-reduced-motion: reduce` both `pulse` and `shimmer` are disabled and the placeholder renders static.
98
+
99
+ ## Notes / Edge Cases
100
+
101
+ - **Sizing.** `width` / `height` are written to the host's inline `style` and accept any CSS length. A `block` with no `height` is 16px tall (its `min-height`); a `circle` needs only a width (`aspect-ratio: 1 / 1`); `line` bars are 16px tall, `--lof-spacing-xs` apart, full width, with the last bar at 65% when there is more than one.
102
+ - **`loaded` hides, it does not remove.** The host switches to `display: none` and stays in the DOM; place the real content as a sibling rather than inside the skeleton (the element has no slot).
103
+ - **Multiple `base` parts.** With `shape="line"` every bar carries `part="base"`, so `::part(base)` styles all of them.
104
+ - **Shimmer overrides the fill.** In `shimmer` mode the background becomes a gradient built from `--lof-skeleton-color` and `--lof-skeleton-highlight`; set both when customising colours.
@@ -0,0 +1,140 @@
1
+ # lof-slider
2
+
3
+ `<lof-slider>` implements the Figma **Slider** component (6417:1340): a pill-shaped track with a stroked round thumb, an optional value tooltip, discrete tick marks with labels, a dotted track style and a dual-thumb `range` mode. It is built on native `<input type="range">` elements, so keyboard and assistive-technology behaviour come from the browser. Use it when a user picks a value or an interval from a bounded numeric range and the relative position matters more than exact digits (volume, opacity, price band); for precise numeric entry use `<lof-textfield>`, and for a handful of named options use `<lof-radio>` or `<lof-tab>`.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <!-- Continuous slider -->
9
+ <lof-slider value="40" min="0" max="100" field-aria-label="Volume"></lof-slider>
10
+
11
+ <!-- Discrete slider: snaps to step, shows tick marks and tick labels -->
12
+ <lof-slider type="discrete" value="3" min="1" max="5" step="1" show-tick-labels field-aria-label="Rating"></lof-slider>
13
+
14
+ <!-- Range slider: two thumbs bounding value…value-end -->
15
+ <lof-slider type="range" value="20" value-end="80" min="0" max="100" field-aria-label="Price"></lof-slider>
16
+
17
+ <!-- Sizes (Figma S / M / L) -->
18
+ <lof-slider size="sm" value="30"></lof-slider>
19
+ <lof-slider size="md" value="50"></lof-slider>
20
+ <lof-slider size="lg" value="70"></lof-slider>
21
+
22
+ <!-- Dotted fill, no tooltip -->
23
+ <lof-slider id="opacity" track="dotted" value="60"></lof-slider>
24
+ <script>
25
+ // showBubble defaults to true; an absent attribute keeps the default, so switch it off from JS.
26
+ document.getElementById('opacity').showBubble = false;
27
+ </script>
28
+
29
+ <!-- Disabled -->
30
+ <lof-slider value="30" disabled></lof-slider>
31
+
32
+ <!-- Listening for changes -->
33
+ <lof-slider id="budget" type="range" value="10" value-end="90"></lof-slider>
34
+ <script>
35
+ document.getElementById('budget').addEventListener('lof-change', (e) => {
36
+ console.log(e.detail.value, e.detail.valueEnd); // valueEnd only in range mode
37
+ });
38
+ </script>
39
+ ```
40
+
41
+ ### Deprecated aliases
42
+
43
+ ```html
44
+ <!-- showticklabels / showbubble → show-tick-labels / show-bubble (since 1.5.0; still work, log a one-time
45
+ console notice, removed in 3.0). showTickLabels still reflects as showticklabels in 1.x. -->
46
+ <lof-slider type="discrete" min="1" max="5" step="1" showticklabels showbubble="false"></lof-slider>
47
+ <lof-slider type="discrete" min="1" max="5" step="1" show-tick-labels show-bubble="false"></lof-slider>
48
+ ```
49
+
50
+ <!-- readme-gen:start -->
51
+
52
+ <!-- Generated from lof-slider.ts — do not edit; run readme-generate.mjs -->
53
+
54
+ ## API
55
+
56
+ ### Attributes / Properties
57
+
58
+ | Property | Attribute | Type | Default | Description |
59
+ | --- | --- | --- | --- | --- |
60
+ | `type` | `type` | `"continuous" \| "discrete" \| "default" \| "range"` | `"continuous"` | Slider mode: `continuous` (or its alias `default`) accepts any integer value, `discrete` snaps to `step` and draws tick marks, `range` shows two thumbs bounding `value`…`valueEnd`. Reflected. |
61
+ | `showTicks` | `show-ticks` | `boolean` | `undefined` | Draws the tick marks (Figma's separate `Is Determinated` boolean). Works with ANY `type` — Figma shows ticks on every variant, where the code used to gate them behind the code-only `type="discrete"`, so a `default` or `range` slider could never show them. Left unset it follows `type="discrete"`, so nothing changes for existing sliders; set it explicitly to override in either direction. Reflected. |
62
+ | `size` | `size` | `"small" \| "medium" \| "large" \| "sm" \| "md" \| "lg"` | `"medium"` | Figma Size axis: `small` (6px track / 16px thumb), `medium` (8 / 20, default) or `large` (10 / 24), which also scales the ticks and the value bubble. `sm` / `md` / `lg` are alternative spellings and stay supported — they are normalised to the full words, not deprecated. Reflected. |
63
+ | `min` | `min` | `number` | `0` | Lowest selectable value. |
64
+ | `max` | `max` | `number` | `100` | Highest selectable value. |
65
+ | `step` | `step` | `number` | `1` | Increment between values. In `discrete` mode it also spaces the tick marks; in `continuous` mode the native input always moves in steps of 1. |
66
+ | `disabled` | `disabled` | `boolean` | `false` | Disables interaction and dims the track, thumb and ticks; the tooltip is hidden. |
67
+ | `track` | `track` | `"solid" \| "dotted"` | `"solid"` | Style of the filled part of the track: `solid` or a `dotted` pattern. |
68
+ | `showTickLabels` | `show-tick-labels` | `boolean` | `false` | Print the numeric value under every tick mark. Only has an effect in `discrete` mode. Reflected (as `showticklabels` in 1.x). The `showticklabels` attribute spelling is deprecated (still works; removal targeted for 3.0). |
69
+ | `showBubble` | `show-bubble` | `boolean` | `true` | Show the value tooltip above the thumb(s). The `showbubble` attribute spelling is deprecated (still works; removal targeted for 3.0). |
70
+ | `value` | `value` | `number` | `0` | Current value (the lower value in `range` mode). |
71
+ | `valueEnd` | `value-end` | `number` | `100` | Upper value when type="range" (attribute value-end). |
72
+ | `fieldAriaLabel` | `field-aria-label` | `string` | `undefined` | Accessible name for the native range input. In `range` mode it is suffixed with " minimum" / " maximum" per thumb; without it the two thumbs read "Minimum value" / "Maximum value" and a single slider has no name. |
73
+
74
+ ## Events
75
+
76
+ | Event | Detail | Bubbles / composed | Description |
77
+ | --- | --- | --- | --- |
78
+ | `lof-change` | `{ value: this.value, valueEnd: this.valueEnd } / { value: this.value }` | bubbles / composed | Fired on every user change of the value. Detail: `{ value }` for single-thumb sliders, `{ value, valueEnd }` in `range` mode. |
79
+
80
+ ## Slots
81
+
82
+ | Slot | Description |
83
+ | --- | --- |
84
+ | — | This element has no slots. |
85
+
86
+ ## CSS Parts
87
+
88
+ | Part | Description |
89
+ | --- | --- |
90
+ | `tooltip` | The value bubble + chevron above each thumb (only while `showBubble` is on) |
91
+ | `thumb` | The round grab handle (one per thumb in range mode) |
92
+ | `track` | The rail behind the thumb (the filled portion has no part) |
93
+
94
+ ## Tokens / CSS Variables
95
+
96
+ ### Component hooks
97
+
98
+ Set these on the host (or an ancestor) to customise the element without touching design tokens.
99
+
100
+ | Custom property | Default | Description |
101
+ | --- | --- | --- |
102
+ | `--lof-slider-bubble-radius` | `var(--bubble-radius)` | Corner radius of the value bubble; 8px for size sm, otherwise 10px |
103
+ | `--lof-slider-thumb-halo-color` | `var(--thumb-halo-color)` | Colour of the keyboard-focus ring; default `var(--lof-border-default)` |
104
+ | `--lof-slider-thumb-size` | `var(--thumb-size)` | Thumb diameter; 16 / 20 / 24px for size sm / md / lg |
105
+ | `--lof-slider-thumb-stroke` | `var(--thumb-stroke)` | Width of the hover / pressed / focus ring around the thumb; default 6px |
106
+ | `--lof-slider-tick-size` | `var(--tick-size)` | Tick-mark diameter in discrete mode; 4 / 5 / 6px for size sm / md / lg |
107
+ | `--lof-slider-track-height` | `var(--track-height)` | Rail thickness; 6 / 8 / 10px for size sm / md / lg |
108
+
109
+ <!-- readme-gen:end -->
110
+
111
+ ## Accessibility
112
+
113
+ - Each thumb is a native `<input type="range">`; the custom track, thumb and tooltip are decorative (`pointer-events: none`) and the tooltip is `aria-hidden="true"`.
114
+ - `field-aria-label` becomes the input's `aria-label`. In `range` mode the two inputs are named `"<label> minimum"` / `"<label> maximum"`; without a label they fall back to `"Minimum value"` / `"Maximum value"`. A single-thumb slider without `field-aria-label` has no accessible name, so always set one (or label it from the surrounding form).
115
+ - `min`, `max` and `step` are forwarded to the native input, so screen readers announce the current value and the range. In `continuous` mode the native step is always 1 regardless of `step`.
116
+ - The keyboard-focus ring is drawn on the custom thumb via `:focus-visible` (`--lof-slider-thumb-halo-color`); mouse focus shows no ring.
117
+ - `disabled` disables the native inputs (removed from the tab order) and hides the tooltip.
118
+ - In `range` mode pointer input is handled by the container so either thumb can be grabbed (the nearer thumb wins); keyboard input still goes through the two native inputs.
119
+ - `prefers-reduced-motion: reduce` removes the thumb and tick transitions.
120
+
121
+ Keys come from the native range input:
122
+
123
+ | Key | Action |
124
+ | --- | --- |
125
+ | `ArrowRight` / `ArrowUp` | Increase by one step (`step` in `discrete` mode, 1 otherwise). |
126
+ | `ArrowLeft` / `ArrowDown` | Decrease by one step. |
127
+ | `Home` | Jump to `min`. |
128
+ | `End` | Jump to `max`. |
129
+ | `PageUp` / `PageDown` | Larger jump (browser-defined). |
130
+
131
+ ## Notes / Edge Cases
132
+
133
+ - `type="default"` is an alias of `continuous` (Figma's Type axis). Only `discrete` draws ticks and snaps to `step`; `continuous` sliders move in integer steps whatever `step` says.
134
+ - Ticks are generated from `min` to `max` in `step` increments; if the range does not divide evenly a final tick is added at `max`. `show-tick-labels` only has an effect in `discrete` mode.
135
+ - In `range` mode the thumbs cannot cross: `value` is clamped to `≤ value-end` and `value-end` to `≥ value`. The default `value-end` is 100.
136
+ - `lof-change` fires for user interaction only; setting `value` / `valueEnd` programmatically updates the visuals but emits nothing.
137
+ - The element is `display: block`. Its rail (the pointer target) is at least 24px tall at every size (since 1.5.0, so Small and Medium grow from 16 / 20px to 24px); the track and thumb keep their 6/16, 8/20 and 10/24px sizes. The value bubble overflows above the rail and is not reserved; tick labels reserve their own space below it.
138
+ - Size presets set the track/thumb/tick/bubble dimensions per `size`; a `--lof-slider-*` hook set on the host overrides the preset for every size.
139
+ - Legacy hook aliases still honoured: `--track-height`, `--thumb-size`, `--thumb-stroke`, `--thumb-halo-color`, `--tick-size` and `--bubble-radius` are read as fallbacks of the `--lof-slider-*` hooks.
140
+ - `registerOnChange`, `registerOnTouched` and `writeValue` exist for the Angular `ControlValueAccessor` wrapper and are not public API.
@@ -0,0 +1,170 @@
1
+ # lof-snackbar
2
+
3
+ `<lof-snackbar>` is the snackbar of the Lofid Design System (Figma "Snackbar"): a dark, elevated message bar with a 4px tone accent and leading status icon for the success / warning / destructive tones, an optional action button and a close icon, in single-line and double-line (Figma Type=Longer Action) layouts. It is shown by setting `show` and hides itself after `duration` milliseconds. Unlike `<lof-toast>` it is **not** positioned — it is a `display: block` element you place yourself (in-flow, or fixed via your own CSS). Use it for brief feedback with one follow-up action ("Undo", "Retry"); use `<lof-alert>` for messages that must stay on the page.
4
+
5
+ ## Usage
6
+
7
+ ```html
8
+ <!-- Hidden until `show` is set -->
9
+ <lof-snackbar id="uploaded" message="File uploaded"></lof-snackbar>
10
+
11
+ <!-- Initially visible; neutral tone (no accent, no icon), auto-hides after 4000 ms -->
12
+ <lof-snackbar show message="Settings saved"></lof-snackbar>
13
+
14
+ <!-- Status tones: left accent + leading icon -->
15
+ <lof-snackbar show tone="success" message="Invitation sent"></lof-snackbar>
16
+ <lof-snackbar show tone="warning" message="Connection is unstable"></lof-snackbar>
17
+ <lof-snackbar show tone="destructive" message="Payment failed"></lof-snackbar>
18
+
19
+ <!-- Action button -->
20
+ <lof-snackbar id="deleted" message="Item deleted" action="Undo"></lof-snackbar>
21
+
22
+ <!-- Double-line layout with a longer (2 × duration) dismiss delay -->
23
+ <lof-snackbar
24
+ id="archived"
25
+ message="12 conversations were archived and will be deleted in 30 days"
26
+ action="Undo"
27
+ variant="longer-action"
28
+ ></lof-snackbar>
29
+
30
+ <!-- Persistent, without the close icon ("false" switches a default-true boolean off, since 1.5.0) -->
31
+ <lof-snackbar id="busy" message="Processing…" duration="0" icon-close="false"></lof-snackbar>
32
+ ```
33
+
34
+ ```js
35
+ const uploaded = document.getElementById("uploaded");
36
+ uploaded.show = true; // starts the auto-dismiss timer and announces the message
37
+ uploaded.addEventListener("close", () => {
38
+ uploaded.show; // false — fired by the close icon, the action button and the timer
39
+ });
40
+
41
+ const deleted = document.getElementById("deleted");
42
+ deleted.addEventListener("actionClick", () => {
43
+ // undo the deletion… the snackbar dismisses itself right after (a `close` event follows)
44
+ });
45
+ deleted.show = true;
46
+
47
+ const busy = document.getElementById("busy");
48
+ busy.show = true;
49
+ busy.show = false; // hides silently — no `close` event when hidden from script
50
+ ```
51
+
52
+ ```css
53
+ /* The component is display: block; position it yourself */
54
+ lof-snackbar {
55
+ position: fixed;
56
+ bottom: 24px;
57
+ left: 50%;
58
+ transform: translateX(-50%);
59
+ }
60
+ ```
61
+
62
+ ### Deprecated aliases
63
+
64
+ ```html
65
+ <!-- type= is the deprecated alias of tone= (tone wins when both are set). Logs once per page:
66
+ [lof-snackbar] "type" is deprecated and will be removed in 3.0 — use "tone" instead. Note: tone="destructive" replaces type="error"; tone="neutral" replaces type="default". -->
67
+ <lof-snackbar type="error" message="Payment failed"></lof-snackbar>
68
+ <lof-snackbar type="default" message="Settings saved"></lof-snackbar>
69
+
70
+ <!-- tone="default" is the deprecated spelling of tone="neutral". Logs once:
71
+ [lof-snackbar] "tone="default"" is deprecated and will be removed in 3.0 — use "tone="neutral"" instead. -->
72
+ <lof-snackbar tone="default" message="Settings saved"></lof-snackbar>
73
+
74
+ <!-- tone="error" | "danger" | "critical" are deprecated spellings of tone="destructive". Logs once per spelling:
75
+ [lof-snackbar] "tone="error"" is deprecated and will be removed in 3.0 — use "tone="destructive"" instead. -->
76
+ <lof-snackbar tone="error" message="Payment failed"></lof-snackbar>
77
+ <lof-snackbar tone="critical" message="Payment failed"></lof-snackbar>
78
+
79
+ <!-- lines="double" and longeraction (lower-case attribute) are deprecated spellings of
80
+ variant="longer-action". Either one alone renders the full longer-action variant: stacked
81
+ layout and the doubled auto-dismiss delay. Ignored when variant is set; each logs once. -->
82
+ <lof-snackbar message="Older markup" action="Undo" lines="double"></lof-snackbar>
83
+ <lof-snackbar message="Older markup" action="Undo" longeraction></lof-snackbar>
84
+
85
+ <!-- iconclose → icon-close (since 1.5.0; still works, logs a one-time console notice, removed in 3.0) -->
86
+ <lof-snackbar message="Processing…" duration="0" iconclose="false"></lof-snackbar>
87
+ <lof-snackbar message="Processing…" duration="0" icon-close="false"></lof-snackbar>
88
+ ```
89
+
90
+ <!-- readme-gen:start -->
91
+
92
+ <!-- Generated from lof-snackbar.ts — do not edit; run readme-generate.mjs -->
93
+
94
+ ## API
95
+
96
+ ### Attributes / Properties
97
+
98
+ | Property | Attribute | Type | Default | Description |
99
+ | --- | --- | --- | --- | --- |
100
+ | `message` | `message` | `string` | `"This is a snackbar message"` | Message text. Announced to screen readers through the shared live-region announcer when the snackbar is shown and whenever it changes while shown. The default is a placeholder — always set it. |
101
+ | `action` | `action` | `string` | `undefined` | Label of the optional action button (Figma trailing button, Static / Small); omitted when unset. Clicking it fires `actionClick` and then dismisses the snackbar. |
102
+ | `variant` | `variant` | `"default" \| "longer-action"` | `undefined` | Layout and timing (Figma "Type"): `"default"` (the default: message and actions on one row) \| `"longer-action"` (message stacked above the actions, which align to the end, with the auto-dismiss delay doubled so there is time to use the action). Takes precedence over the deprecated `lines` and `longerAction` props. |
103
+ | `iconClose` | `icon-close` | `boolean` | `true` | Shows the trailing close icon button. Defaults to true; `icon-close="false"` (or the property set to `false`) hides the button. The `iconclose` attribute spelling is deprecated (still works; removal targeted for 3.0). |
104
+ | `duration` | `duration` | `number` | `4000` | Auto-dismiss delay in milliseconds (doubled by `variant="longer-action"`), started when `show` becomes true and restarted when `duration` or the layout changes while shown. `0` (or a negative value) disables auto-dismiss. |
105
+ | `tone` | `tone` | `"neutral" \| "success" \| "warning" \| "destructive" \| "default" \| "error" \| "danger" \| "critical"` | `undefined` | Semantic tone (Figma "Tone"): `"neutral"` (default: no accent, no icon) \| `"success"` \| `"warning"` \| `"destructive"` — the status tones add a 4px left accent and a leading icon (check-circle / warning / error) in the tone colour. `"default"` is a deprecated alias of `"neutral"`; `"error"`, `"danger"` and `"critical"` are deprecated aliases of `"destructive"`; each logs a one-time console notice. Takes precedence over the deprecated `type` prop. |
106
+ | `show` | `show` | `boolean` | `false` | Whether the snackbar is visible. Set it to true to show the snackbar and start the auto-dismiss timer; it is set back to false by the close icon, the action button and the timer. There is no open/close method — toggle this property. Reflected. |
107
+
108
+ #### Deprecated (still supported — removal targeted for 3.0)
109
+
110
+ | Property | Attribute | Type | Use instead |
111
+ | --- | --- | --- | --- |
112
+ | `longerAction` | `longeraction` | `boolean` | — use `variant="longer-action"`. On its own it renders the full longer-action variant (stacked layout and the doubled auto-dismiss delay, `duration * 2`). Ignored when `variant` is set. Logs a one-time console notice. |
113
+ | `lines` | `lines` | `"single" \| "double"` | — use `variant`; `lines="double"` maps to `variant="longer-action"` (stacked layout and the doubled auto-dismiss delay). Ignored when `variant` is set. Logs a one-time console notice. |
114
+ | `type` | `type` | `"neutral" \| "success" \| "warning" \| "destructive" \| "default" \| "error" \| "danger" \| "critical"` | Deprecated since 1.4.7 — alias of `tone`; use `tone`. Same values as `tone`; `type="error"` maps to `tone="destructive"` and `type="default"` to `tone="neutral"`. Ignored when `tone` is set. Logs a one-time console notice. |
115
+
116
+ ### Public fields / accessors
117
+
118
+ | Name | Type | Description |
119
+ | --- | --- | --- |
120
+ | `resolvedVariant` | `SnackbarVariant` | Read-only canonical layout actually rendered: explicit `variant` wins, else either deprecated prop (`lines="double"` or `longerAction`) promotes to `"longer-action"`, else `"default"`. |
121
+ | `resolvedTone` | `SnackbarTone` | Read-only canonical tone actually rendered: explicit `tone` wins, else `type`, else `"neutral"`; deprecated aliases are resolved to `"neutral"` / `"destructive"`. |
122
+
123
+ ## Events
124
+
125
+ | Event | Detail | Bubbles / composed | Description |
126
+ | --- | --- | --- | --- |
127
+ | `actionClick` | — | bubbles / composed | Fired when the action button is clicked, before the snackbar dismisses itself (a `close` event follows). No detail. |
128
+ | `close` | — | bubbles / composed | Fired whenever the snackbar dismisses itself — via the close icon, the action button or the auto-dismiss timer. Not fired when `show` is set to false from script. No detail. |
129
+
130
+ ## Slots
131
+
132
+ | Slot | Description |
133
+ | --- | --- |
134
+ | — | This element has no slots. |
135
+
136
+ ## CSS Parts
137
+
138
+ | Part | Description |
139
+ | --- | --- |
140
+ | `label` | The message text container |
141
+ | `action` | The action button; rendered only when `action` is set |
142
+ | `close-button` | The close icon button; rendered while `icon-close` is true |
143
+
144
+ <!-- readme-gen:end -->
145
+
146
+ ## Accessibility
147
+
148
+ - The bar is always in the shadow DOM and hidden with `display: none` while `show` is false. Its role follows the tone: `role="alert"` for `destructive` (implicitly assertive), `role="status"` for every other tone (implicitly polite); no explicit `aria-live` is set. Because toggling `display` is not reliably announced, the component also pushes `message` into the shared off-screen live-region announcer (`utils/announce`) when `show` becomes true and whenever `message` changes while shown — assertively for `destructive`, politely otherwise. Focus is never moved.
149
+ - The leading status icon and the close glyph are `<lof-icon>`s and render `aria-hidden="true"`; the close control is a native `<button>` with `aria-label="Close"`, the action button is labelled by `action`. Both are in the Tab order; the component registers no key handlers (there is no Escape-to-close):
150
+
151
+ | Key | Action |
152
+ | --- | --- |
153
+ | Tab / Shift + Tab | Move between the action button (if any) and the close button (if any) |
154
+ | Enter / Space | Activate the focused button: action fires `actionClick` then `close`; the close button fires `close` |
155
+
156
+ - Keyboard focus on either button is a 2px `--lof-text-static-light` outline with 2px offset (`:focus-visible` only); the close button adds `--lof-border-radius-xs` corners, the action button keeps its pill radius.
157
+ - The 0.3s slide-up animation is disabled under `prefers-reduced-motion: reduce`.
158
+ - A snackbar that auto-dismisses while one of its buttons has focus drops focus to `<body>`; use `duration="0"` (or `variant="longer-action"`, which doubles the delay) when the action matters.
159
+
160
+ ## Notes / Edge Cases
161
+
162
+ - Positioning is yours: the host is `display: block` and in flow. The bar itself is `min-width: 280px; max-width: 500px`.
163
+ - The auto-dismiss timer starts when `show` becomes true and restarts whenever `duration`, `variant` or a deprecated `lines` / `longerAction` changes while visible; `variant="longer-action"` doubles the delay (`duration * 2`). `duration="0"` disables it.
164
+ - Setting `show = false` from script hides the bar **without** firing `close`; `close` fires only for the close icon, the action button and the timer. Setting `show = true` on an already visible snackbar is a no-op (the value did not change).
165
+ - `variant="longer-action"` (Figma Longer Action) stacks the message over end-aligned actions with 16px top padding and doubles the auto-dismiss delay. The deprecated `lines="double"` and `longeraction` each produce the same full variant on their own (see "Deprecated aliases"); before 1.5.0 this README said each did only half of it.
166
+ - The status icon is fixed per tone (`check-circle`, `warning`, `error`) and neutral has none; there are no slots, so the icon cannot be replaced.
167
+ - `message` defaults to the placeholder "This is a snackbar message" — a snackbar that shows that text has simply not been given a message.
168
+ - `iconClose` is a boolean: presence or `""` means true, and since 1.5.0 `icon-close="false"` means false.
169
+ - Figma binds the success / destructive icon colours to dark-surface status text values that no light-mode semantic token resolves to; the component uses the status fill tokens (`--lof-bg-success` / `--lof-bg-danger` / `--lof-bg-warning`) for both the accent and the icon instead.
170
+ - `resolvedTone` is the tone actually rendered after alias resolution; use it (not `tone` / `type`) if you branch on tone in script.