@lofid/web 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +3 -3
- package/dist/index.d.ts +18 -1
- package/dist/index.js +155 -29
- package/dist/index.js.map +1 -1
- package/dist/styles/motion.css +1 -1
- package/dist/styles/typography.css +1 -1
- package/dist/styles/typography.json +1 -1
- package/dist/styles/vars.css +16 -16
- package/package.json +2 -2
- package/readmes/lof-avatar/README.md +2 -1
- package/readmes/lof-button/README.md +2 -2
- package/readmes/lof-chip/README.md +142 -142
- package/readmes/lof-pagination/README.md +141 -141
- package/readmes/lof-select/README.md +2 -2
- package/readmes/lof-stat/README.md +1 -1
- package/readmes/lof-textfield/README.md +2 -2
package/dist/styles/motion.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Lofid Design System 1.1.
|
|
1
|
+
/* Lofid Design System 1.1.1 — typography utility classes. Generated from scripts/typography-spec.mjs. Do not edit.
|
|
2
2
|
Needs vars.css. Pick the class by what the text is for, and the HTML tag for document structure. */
|
|
3
3
|
.lof-heading-hero { font: var(--lof-heading-hero); letter-spacing: var(--lof-heading-hero-letter-spacing); }
|
|
4
4
|
.lof-heading-display { font: var(--lof-heading-display); letter-spacing: var(--lof-heading-display-letter-spacing); }
|
package/dist/styles/vars.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Lofid Design System 1.1.
|
|
1
|
+
/* Lofid Design System 1.1.1 — generated from tokens/tokens.json. Do not edit. */
|
|
2
2
|
|
|
3
3
|
:root {
|
|
4
4
|
/* --- PRIMITIVES — COLOR --- */
|
|
@@ -18,17 +18,17 @@
|
|
|
18
18
|
--lof-colors-brand-400: #28F6AB;
|
|
19
19
|
--lof-colors-brand-500: #00F49C;
|
|
20
20
|
--lof-colors-brand-600: #00DB8B;
|
|
21
|
-
--lof-colors-accent-50: #
|
|
22
|
-
--lof-colors-accent-100: #
|
|
23
|
-
--lof-colors-accent-200: #
|
|
24
|
-
--lof-colors-accent-300: #
|
|
25
|
-
--lof-colors-accent-400: #
|
|
26
|
-
--lof-colors-accent-500: #
|
|
27
|
-
--lof-colors-accent-600: #
|
|
28
|
-
--lof-colors-accent-700: #
|
|
29
|
-
--lof-colors-accent-800: #
|
|
30
|
-
--lof-colors-accent-900: #
|
|
31
|
-
--lof-colors-accent-950: #
|
|
21
|
+
--lof-colors-accent-50: #EDF8F4;
|
|
22
|
+
--lof-colors-accent-100: #D5F1E7;
|
|
23
|
+
--lof-colors-accent-200: #A9E3CD;
|
|
24
|
+
--lof-colors-accent-300: #60C9A3;
|
|
25
|
+
--lof-colors-accent-400: #30B887;
|
|
26
|
+
--lof-colors-accent-500: #00A86B;
|
|
27
|
+
--lof-colors-accent-600: #008655;
|
|
28
|
+
--lof-colors-accent-700: #00744A;
|
|
29
|
+
--lof-colors-accent-800: #006440;
|
|
30
|
+
--lof-colors-accent-900: #004D31;
|
|
31
|
+
--lof-colors-accent-950: #003823;
|
|
32
32
|
--lof-colors-green-50: #EDF8F4;
|
|
33
33
|
--lof-colors-green-100: #D5F1E7;
|
|
34
34
|
--lof-colors-green-200: #91D9BF;
|
|
@@ -582,7 +582,7 @@
|
|
|
582
582
|
--lof-radius-surface: 12px;
|
|
583
583
|
--lof-radius-overlay: 8px;
|
|
584
584
|
--lof-border-hover: var(--lof-colors-gray-300);
|
|
585
|
-
--lof-focus-halo: rgba(
|
|
585
|
+
--lof-focus-halo: rgba(0, 134, 85, 0.20);
|
|
586
586
|
--lof-focus-halo-danger: rgba(206, 49, 49, 0.18);
|
|
587
587
|
--lof-bg-hover-row: var(--lof-colors-dark-alpha-1);
|
|
588
588
|
--lof-bg-selected-row: var(--lof-colors-dark-alpha-2);
|
|
@@ -764,7 +764,7 @@
|
|
|
764
764
|
|
|
765
765
|
/* --- roles --- */
|
|
766
766
|
--lof-border-hover: var(--lof-colors-gray-600);
|
|
767
|
-
--lof-focus-halo: rgba(
|
|
767
|
+
--lof-focus-halo: rgba(48, 184, 135, 0.30);
|
|
768
768
|
--lof-focus-halo-danger: rgba(255, 114, 114, 0.3);
|
|
769
769
|
--lof-bg-hover-row: var(--lof-colors-light-alpha-2);
|
|
770
770
|
--lof-bg-selected-row: var(--lof-colors-light-alpha-3);
|
|
@@ -780,8 +780,8 @@
|
|
|
780
780
|
--lof-accent-foreground: var(--lof-colors-gray-0);
|
|
781
781
|
--lof-accent-text: var(--lof-colors-accent-400);
|
|
782
782
|
--lof-accent-text-hover: var(--lof-colors-accent-300);
|
|
783
|
-
--lof-accent-subtle: rgba(
|
|
784
|
-
--lof-accent-subtle-hover: rgba(
|
|
783
|
+
--lof-accent-subtle: rgba(0, 168, 107, 0.16);
|
|
784
|
+
--lof-accent-subtle-hover: rgba(0, 168, 107, 0.24);
|
|
785
785
|
--lof-accent-subtle-text: var(--lof-colors-accent-300);
|
|
786
786
|
--lof-accent-border-subtle: var(--lof-colors-accent-900);
|
|
787
787
|
--lof-border-control: var(--lof-colors-gray-500);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lofid/web",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Lofid Design System web components (Lit) — rebuilt, API-compatible with 1.5.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"cem": "node scripts/cem.mjs"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@lofid/icons": "1.1.
|
|
37
|
+
"@lofid/icons": "1.1.1",
|
|
38
38
|
"lit": "^3.3.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
@@ -144,6 +144,7 @@ Set these on the host (or an ancestor) to customise the element without touching
|
|
|
144
144
|
| `--lof-avatar-color-outline` | `var(--lof-text-default)` | Text / icon colour of the `outline` variant |
|
|
145
145
|
| `--lof-avatar-color-subtle` | `var(--lof-text-default)` | Text / icon colour of the `subtle` variant |
|
|
146
146
|
| `--lof-avatar-font-size` | `var(--_lof-avatar-font-size)` | Overrides the initials' font-size, for use alongside `--lof-avatar-size`; defaults to the preset's text role |
|
|
147
|
+
| `--lof-avatar-label-inset-end` | `0px` | Moves the initials off the end edge by half this length, to centre them in what stays visible when something covers that edge; an avatar group sets it to its overlap |
|
|
147
148
|
| `--lof-avatar-icon-size` | `var(--_lof-avatar-icon-size)` | Overrides the slotted icon's size; defaults to the preset ramp (20 / 18 / 16 / 12px) |
|
|
148
149
|
| `--lof-avatar-ring-color` | `var(--lof-border-inverse)` | Colour of the `ring`; defaults to `--lof-border-inverse` (new in 1.5.0) |
|
|
149
150
|
| `--lof-avatar-size` | `var(--_lof-avatar-size)` | Overrides the circle's width/height for sizes between (or below) the `size` presets; defaults to the preset's diameter |
|
|
@@ -224,5 +225,5 @@ Set these on the host (or an ancestor) to customise the element without touching
|
|
|
224
225
|
- **Badge** (new in 1.5.0): 12 / 10 / 8 / 6px by size, flush with the bottom-right of the avatar's box, with a 1px outside edge. `dot` fills with `--lof-bg-success` (Figma has only the green dot); `icon` fills with `--lof-bg-neutral-elevated-2` and draws `badge-icon` at two thirds of the disc. Recolour either with `--lof-avatar-badge-bg`. At the two smallest sizes an icon badge is too small to read; prefer `dot` there.
|
|
225
226
|
- **`icon` vs the slot:** when `icon` is set it replaces the slot; leave it empty to slot your own SVG.
|
|
226
227
|
<!-- @unreleased-begin 1.5.0 -->
|
|
227
|
-
- **Avatar group.** The group writes `size` and `ring` on its avatars, so a size set on an avatar inside a group is replaced by the group's. It hides avatars beyond `max` with a `data-lof-group-hidden` attribute it manages itself; your own `hidden` attributes are left alone. The "+N" text steps down to 36% of the diameter from two digits ("+10"), and counts above 99 show "99+". Change the overlap with `--lof-avatar-group-overlap`.
|
|
228
|
+
- **Avatar group.** The group writes `size` and `ring` on its avatars, so a size set on an avatar inside a group is replaced by the group's. It hides avatars beyond `max` with a `data-lof-group-hidden` attribute it manages itself; your own `hidden` attributes are left alone. The "+N" text steps down to 36% of the diameter from two digits ("+10"), and counts above 99 show "99+". Change the overlap with `--lof-avatar-group-overlap`. Initials inside a group step down to 38% of the diameter (at least 10px) and centre in the part the next avatar leaves visible, so two letters stay readable; set `--lof-avatar-font-size` or `--lof-avatar-label-inset-end` on an avatar to override.
|
|
228
229
|
<!-- @unreleased-end -->
|
|
@@ -94,7 +94,7 @@ Action button implementing the Figma "Button" component: a native `<button>` wit
|
|
|
94
94
|
| Property | Attribute | Type | Default | Description |
|
|
95
95
|
| --- | --- | --- | --- | --- |
|
|
96
96
|
| `variant` | `variant` | `"default" \| "primary" \| "secondary" \| "text" \| "link" \| "icon" \| "static" \| "outline" \| "ghost"` | `"default"` | Style axis (Figma "Style"). Canonical: `default` (legacy neutral fill), `primary`, `secondary` (outlined), `ghost` (text-only), `link` (underlined inline text), `static` (transparent, static-light label for dark/colored surfaces). Deprecated aliases still accepted: `outline` = secondary, `text` = ghost, and `icon` (pre-2.0 40px circular icon button — use `icon-only` with a style instead). |
|
|
97
|
-
| `tone` | `tone` | `"accent" \| "primary" \| "neutral" \| "mono" \| "default" \| "brand" \| "destructive" \| "success" \| "secondary" \| "critical" \| "danger"` | `undefined` | Tone axis. Canonical: `accent` (= `primary`, the
|
|
97
|
+
| `tone` | `tone` | `"accent" \| "primary" \| "neutral" \| "mono" \| "default" \| "brand" \| "destructive" \| "success" \| "secondary" \| "critical" \| "danger"` | `undefined` | Tone axis. Canonical: `accent` (= `primary`, the green accent), `neutral` (= `mono` = `default`, the black fill), `brand` (mint), `destructive`. Unset: `accent` on fill and link styles, `neutral` on outline and ghost. `critical` / `danger` are deprecated spellings of `destructive`; `secondary` only applies to the legacy `icon` variant. |
|
|
98
98
|
| `iconOnly` | `icon-only` | `boolean` | `false` | Figma "Type=Icon Only": renders a square button (28/34/40px per `size`) of the current style and tone with no padding or min-width. Composes with every `variant`; slot a single `lof-icon` and set `aria-label`. Reflected. |
|
|
99
99
|
| `loading` | `loading` | `boolean` | `false` | Figma "State=Loading": replaces the label with a spinner (`indicator` part), sets `aria-busy`, and blocks pointer and programmatic clicks. The button keeps its width. Reflected. |
|
|
100
100
|
| `size` | `size` | `"small" \| "medium" \| "large"` | `"medium"` | Figma "Size": `small` = 32px, `medium` = 40px, `large` = 48px height, with matching padding, typography and minimum width. |
|
|
@@ -153,7 +153,7 @@ Focus: `:focus-visible` shows the shared 2px focus outline plus inner/outer halo
|
|
|
153
153
|
|
|
154
154
|
### Tone defaults (2026-11 admin refresh)
|
|
155
155
|
|
|
156
|
-
The accent (
|
|
156
|
+
The accent (Lofid green) is the primary-action colour; black is the "mono" companion; the light mint (`brand`) stays available for brand moments.
|
|
157
157
|
|
|
158
158
|
| Markup | Renders |
|
|
159
159
|
| --- | --- |
|
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
# lof-chip
|
|
2
|
-
|
|
3
|
-
`<lof-chip>` is the compact chip from the Figma "Chip" component: a short label with tone × variant colouring, an optional leading icon or initials avatar, an optional trailing icon, a remove control and opt-in drag-and-drop. Use it for tags, active filters, selected values in a multi-select and small status labels. Do not use it as a general button (use `lof-button`) or for status counts (use `lof-badge`); for long-lived toggles use `lof-switch` or `lof-checkbox`.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```html
|
|
8
|
-
<!-- Basic chip (tone="neutral" variant="fill" size="medium" border="default") -->
|
|
9
|
-
<lof-chip label="Active"></lof-chip>
|
|
10
|
-
|
|
11
|
-
<!-- Tones -->
|
|
12
|
-
<lof-chip label="Info" tone="info"></lof-chip>
|
|
13
|
-
<lof-chip label="Warning" tone="warning"></lof-chip>
|
|
14
|
-
<lof-chip label="Error" tone="destructive"></lof-chip>
|
|
15
|
-
<lof-chip label="Success" tone="success"></lof-chip>
|
|
16
|
-
|
|
17
|
-
<!-- Subtle variant: tinted background, tone-coloured text -->
|
|
18
|
-
<lof-chip label="Subtle" tone="info" variant="subtle"></lof-chip>
|
|
19
|
-
|
|
20
|
-
<!-- Sizes -->
|
|
21
|
-
<lof-chip label="Small" size="small"></lof-chip>
|
|
22
|
-
<lof-chip label="Medium" size="medium"></lof-chip>
|
|
23
|
-
<lof-chip label="Large" size="large"></lof-chip>
|
|
24
|
-
|
|
25
|
-
<!-- Deprecated aliases — these still render, but prefer the canonical spellings above.
|
|
26
|
-
tone="danger" is an alias of tone="destructive" and logs a one-time console notice.
|
|
27
|
-
size="sm" / "md" / "lg" are alternative spellings (NOT deprecated, no notice). -->
|
|
28
|
-
<lof-chip label="Error" tone="danger"></lof-chip>
|
|
29
|
-
<lof-chip label="Small" size="sm"></lof-chip>
|
|
30
|
-
|
|
31
|
-
<!-- Fully rounded corners -->
|
|
32
|
-
<lof-chip label="Rounded" border="rounded"></lof-chip>
|
|
33
|
-
|
|
34
|
-
<!-- Leading / trailing icons (icon dictionary names, rendered via <lof-icon>) -->
|
|
35
|
-
<lof-chip label="Settings" leading-icon="settings"></lof-chip>
|
|
36
|
-
<lof-chip label="Next" trailing-icon="chevron-right"></lof-chip>
|
|
37
|
-
|
|
38
|
-
<!-- Initials avatar (takes precedence over leading-icon) -->
|
|
39
|
-
<lof-chip label="John Doe" avatar="JD"></lof-chip>
|
|
40
|
-
|
|
41
|
-
<!-- Removable chip -->
|
|
42
|
-
<lof-chip id="removableChip" label="Removable" removable></lof-chip>
|
|
43
|
-
<script>
|
|
44
|
-
document.getElementById("removableChip").addEventListener("removed", () => {
|
|
45
|
-
console.log("Chip was removed");
|
|
46
|
-
});
|
|
47
|
-
</script>
|
|
48
|
-
|
|
49
|
-
<!-- Draggable chip: native drag-and-drop plus Left/Right arrow reordering -->
|
|
50
|
-
<lof-chip id="dragChip" label="Reorder me" draggable-chip></lof-chip>
|
|
51
|
-
<script>
|
|
52
|
-
document.getElementById("dragChip").addEventListener("chip-move", (e) => {
|
|
53
|
-
console.log("move", e.detail.direction); // -1 = left, 1 = right
|
|
54
|
-
});
|
|
55
|
-
</script>
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
<!-- readme-gen:start -->
|
|
59
|
-
|
|
60
|
-
<!-- Generated from lof-chip.ts — do not edit; run readme-generate.mjs -->
|
|
61
|
-
|
|
62
|
-
## API
|
|
63
|
-
|
|
64
|
-
### Attributes / Properties
|
|
65
|
-
|
|
66
|
-
| Property | Attribute | Type | Default | Description |
|
|
67
|
-
| --- | --- | --- | --- | --- |
|
|
68
|
-
| `label` | `label` | `string` | `"Label"` | Text shown in the chip; also its accessible name and the drag payload. |
|
|
69
|
-
| `fieldAriaLabel` | `field-aria-label` | `string` | `undefined` | Accessible name for an icon-only or intentionally unlabelled chip; overrides `label` for the chip and its remove button. |
|
|
70
|
-
| `tone` | `tone` | `"neutral" \| "accent" \| "destructive" \| "warning" \| "success" \| "info" \| "danger"` | `"neutral"` | Colour tone (Figma Tone): `neutral`, `destructive`, `warning`, `success` or `info`. Combined with `variant`. `"danger"` is a deprecated alias of `"destructive"`: it keeps working, logs a one-time console notice, and is normalised to `"destructive"` on the property and the reflected attribute. Reflected. |
|
|
71
|
-
| `variant` | `variant` | `"fill" \| "subtle" \| "outline" \| "primary" \| "secondary"` | `"fill"` | Emphasis (Figma Style): `fill` = solid tone background, `subtle` = tinted background with tone-coloured text. Figma's own spellings `primary` and `secondary` are accepted and normalised to `fill` / `subtle`. Reflected. |
|
|
72
|
-
| `size` | `size` | `"small" \| "medium" \| "large" \| "sm" \| "md" \| "lg"` | `"medium"` | Height scale (Figma Size): `small` 24px / body-sm, `medium` 28px / body-md, `large` 32px / body-lg. Icon size follows (12 / 14 / 16px). `sm` / `md` / `lg` are accepted and normalised to the full words. Reflected. |
|
|
73
|
-
| `border` | `border` | `"default" \| "rounded"` | `"default"` | Corner shape (Figma Border): `default` = 6px radius, `rounded` = fully rounded with 12px horizontal padding. Reflected. |
|
|
74
|
-
| `leadingIcon` | `leading-icon` | `string` | `undefined` | Icon name from the generated icon dictionary (e.g. "settings") — rendered via <lof-icon> before the label. Ignored when `avatar` is set. |
|
|
75
|
-
| `trailingIcon` | `trailing-icon` | `string` | `undefined` | Icon name from the generated icon dictionary, rendered after the label. |
|
|
76
|
-
| `avatar` | `avatar` | `string` | `undefined` | Initials text for the avatar (e.g. "JD"), rendered as a `<lof-avatar type="text">` before the label. Mutually exclusive with leadingIcon (avatar wins). |
|
|
77
|
-
| `removable` | `removable` | `boolean` | `false` | Shows a remove (close) button after the label; clicking it sets `removed` and fires `removed`. |
|
|
78
|
-
| `presentational` | `presentational` | `boolean` | `false` | New in 1.5.0. Makes the chip body plain text: no `button` role, no Tab stop, no Enter / Space / Delete handling and no host click re-dispatch. The remove button (when `removable`) stays a real button. For chips that only display a value inside another control, e.g. lof-select's multi-select chips. Reflected. |
|
|
79
|
-
| `removed` | `removed` | `boolean` | `false` | `true` once the chip has been removed — the host is hidden via `:host([removed])`. Reflected so CSS and Angular can see it; reset to `false` to show the chip again. Reflected. |
|
|
80
|
-
| `draggableChip` | `draggable-chip` | `boolean` | `false` | Opt-in native drag-and-drop: sets `draggable="true"` on the host, shows the Figma "Dragged" state during a real drag gesture, and makes Left/Right arrow keys fire `chip-move`. |
|
|
81
|
-
|
|
82
|
-
## Events
|
|
83
|
-
|
|
84
|
-
| Event | Detail | Bubbles / composed | Description |
|
|
85
|
-
| --- | --- | --- | --- |
|
|
86
|
-
| `chip-move` | `{ direction: e.key === "ArrowLeft" ? -1 : 1 }` | bubbles / composed | Fired on Left/Right arrow keys when `draggable-chip` is set — the keyboard alternative to drag-and-drop; the container should reorder the chip. Detail: `{ direction: -1 \| 1 }` (-1 = left, 1 = right). |
|
|
87
|
-
| `removed` | — | bubbles / composed | Fired when the chip is removed via its remove button or Delete/Backspace (after `removed` is set to `true`). No detail. |
|
|
88
|
-
|
|
89
|
-
## Slots
|
|
90
|
-
|
|
91
|
-
| Slot | Description |
|
|
92
|
-
| --- | --- |
|
|
93
|
-
| — | This element has no slots. |
|
|
94
|
-
|
|
95
|
-
## CSS Parts
|
|
96
|
-
|
|
97
|
-
| Part | Description |
|
|
98
|
-
| --- | --- |
|
|
99
|
-
| `base` | The chip body (`.chip`) that carries size, tone, variant and border styling |
|
|
100
|
-
| `icon` | The leading `<lof-icon>` (rendered only when `leading-icon` is set and no avatar) |
|
|
101
|
-
| `label` | The label text |
|
|
102
|
-
| `remove` | The remove `<button>` (rendered only when `removable`) |
|
|
103
|
-
|
|
104
|
-
## Tokens / CSS Variables
|
|
105
|
-
|
|
106
|
-
### Component hooks
|
|
107
|
-
|
|
108
|
-
Set these on the host (or an ancestor) to customise the element without touching design tokens.
|
|
109
|
-
|
|
110
|
-
| Custom property | Default | Description |
|
|
111
|
-
| --- | --- | --- |
|
|
112
|
-
| `--lof-chip-focus-ring` | `var(--lof-border-focus)` | Colour of the keyboard focus outline; default `var(--lof-border-focus)` |
|
|
113
|
-
|
|
114
|
-
<!-- readme-gen:end -->
|
|
115
|
-
|
|
1
|
+
# lof-chip
|
|
2
|
+
|
|
3
|
+
`<lof-chip>` is the compact chip from the Figma "Chip" component: a short label with tone × variant colouring, an optional leading icon or initials avatar, an optional trailing icon, a remove control and opt-in drag-and-drop. Use it for tags, active filters, selected values in a multi-select and small status labels. Do not use it as a general button (use `lof-button`) or for status counts (use `lof-badge`); for long-lived toggles use `lof-switch` or `lof-checkbox`.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!-- Basic chip (tone="neutral" variant="fill" size="medium" border="default") -->
|
|
9
|
+
<lof-chip label="Active"></lof-chip>
|
|
10
|
+
|
|
11
|
+
<!-- Tones -->
|
|
12
|
+
<lof-chip label="Info" tone="info"></lof-chip>
|
|
13
|
+
<lof-chip label="Warning" tone="warning"></lof-chip>
|
|
14
|
+
<lof-chip label="Error" tone="destructive"></lof-chip>
|
|
15
|
+
<lof-chip label="Success" tone="success"></lof-chip>
|
|
16
|
+
|
|
17
|
+
<!-- Subtle variant: tinted background, tone-coloured text -->
|
|
18
|
+
<lof-chip label="Subtle" tone="info" variant="subtle"></lof-chip>
|
|
19
|
+
|
|
20
|
+
<!-- Sizes -->
|
|
21
|
+
<lof-chip label="Small" size="small"></lof-chip>
|
|
22
|
+
<lof-chip label="Medium" size="medium"></lof-chip>
|
|
23
|
+
<lof-chip label="Large" size="large"></lof-chip>
|
|
24
|
+
|
|
25
|
+
<!-- Deprecated aliases — these still render, but prefer the canonical spellings above.
|
|
26
|
+
tone="danger" is an alias of tone="destructive" and logs a one-time console notice.
|
|
27
|
+
size="sm" / "md" / "lg" are alternative spellings (NOT deprecated, no notice). -->
|
|
28
|
+
<lof-chip label="Error" tone="danger"></lof-chip>
|
|
29
|
+
<lof-chip label="Small" size="sm"></lof-chip>
|
|
30
|
+
|
|
31
|
+
<!-- Fully rounded corners -->
|
|
32
|
+
<lof-chip label="Rounded" border="rounded"></lof-chip>
|
|
33
|
+
|
|
34
|
+
<!-- Leading / trailing icons (icon dictionary names, rendered via <lof-icon>) -->
|
|
35
|
+
<lof-chip label="Settings" leading-icon="settings"></lof-chip>
|
|
36
|
+
<lof-chip label="Next" trailing-icon="chevron-right"></lof-chip>
|
|
37
|
+
|
|
38
|
+
<!-- Initials avatar (takes precedence over leading-icon) -->
|
|
39
|
+
<lof-chip label="John Doe" avatar="JD"></lof-chip>
|
|
40
|
+
|
|
41
|
+
<!-- Removable chip -->
|
|
42
|
+
<lof-chip id="removableChip" label="Removable" removable></lof-chip>
|
|
43
|
+
<script>
|
|
44
|
+
document.getElementById("removableChip").addEventListener("removed", () => {
|
|
45
|
+
console.log("Chip was removed");
|
|
46
|
+
});
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<!-- Draggable chip: native drag-and-drop plus Left/Right arrow reordering -->
|
|
50
|
+
<lof-chip id="dragChip" label="Reorder me" draggable-chip></lof-chip>
|
|
51
|
+
<script>
|
|
52
|
+
document.getElementById("dragChip").addEventListener("chip-move", (e) => {
|
|
53
|
+
console.log("move", e.detail.direction); // -1 = left, 1 = right
|
|
54
|
+
});
|
|
55
|
+
</script>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
<!-- readme-gen:start -->
|
|
59
|
+
|
|
60
|
+
<!-- Generated from lof-chip.ts — do not edit; run readme-generate.mjs -->
|
|
61
|
+
|
|
62
|
+
## API
|
|
63
|
+
|
|
64
|
+
### Attributes / Properties
|
|
65
|
+
|
|
66
|
+
| Property | Attribute | Type | Default | Description |
|
|
67
|
+
| --- | --- | --- | --- | --- |
|
|
68
|
+
| `label` | `label` | `string` | `"Label"` | Text shown in the chip; also its accessible name and the drag payload. |
|
|
69
|
+
| `fieldAriaLabel` | `field-aria-label` | `string` | `undefined` | Accessible name for an icon-only or intentionally unlabelled chip; overrides `label` for the chip and its remove button. |
|
|
70
|
+
| `tone` | `tone` | `"neutral" \| "accent" \| "destructive" \| "warning" \| "success" \| "info" \| "danger"` | `"neutral"` | Colour tone (Figma Tone): `neutral`, `destructive`, `warning`, `success` or `info`. Combined with `variant`. `"danger"` is a deprecated alias of `"destructive"`: it keeps working, logs a one-time console notice, and is normalised to `"destructive"` on the property and the reflected attribute. Reflected. |
|
|
71
|
+
| `variant` | `variant` | `"fill" \| "subtle" \| "outline" \| "primary" \| "secondary"` | `"fill"` | Emphasis (Figma Style): `fill` = solid tone background, `subtle` = tinted background with tone-coloured text. Figma's own spellings `primary` and `secondary` are accepted and normalised to `fill` / `subtle`. Reflected. |
|
|
72
|
+
| `size` | `size` | `"small" \| "medium" \| "large" \| "sm" \| "md" \| "lg"` | `"medium"` | Height scale (Figma Size): `small` 24px / body-sm, `medium` 28px / body-md, `large` 32px / body-lg. Icon size follows (12 / 14 / 16px). `sm` / `md` / `lg` are accepted and normalised to the full words. Reflected. |
|
|
73
|
+
| `border` | `border` | `"default" \| "rounded"` | `"default"` | Corner shape (Figma Border): `default` = 6px radius, `rounded` = fully rounded with 12px horizontal padding. Reflected. |
|
|
74
|
+
| `leadingIcon` | `leading-icon` | `string` | `undefined` | Icon name from the generated icon dictionary (e.g. "settings") — rendered via <lof-icon> before the label. Ignored when `avatar` is set. |
|
|
75
|
+
| `trailingIcon` | `trailing-icon` | `string` | `undefined` | Icon name from the generated icon dictionary, rendered after the label. |
|
|
76
|
+
| `avatar` | `avatar` | `string` | `undefined` | Initials text for the avatar (e.g. "JD"), rendered as a `<lof-avatar type="text">` before the label. Mutually exclusive with leadingIcon (avatar wins). |
|
|
77
|
+
| `removable` | `removable` | `boolean` | `false` | Shows a remove (close) button after the label; clicking it sets `removed` and fires `removed`. |
|
|
78
|
+
| `presentational` | `presentational` | `boolean` | `false` | New in 1.5.0. Makes the chip body plain text: no `button` role, no Tab stop, no Enter / Space / Delete handling and no host click re-dispatch. The remove button (when `removable`) stays a real button. For chips that only display a value inside another control, e.g. lof-select's multi-select chips. Reflected. |
|
|
79
|
+
| `removed` | `removed` | `boolean` | `false` | `true` once the chip has been removed — the host is hidden via `:host([removed])`. Reflected so CSS and Angular can see it; reset to `false` to show the chip again. Reflected. |
|
|
80
|
+
| `draggableChip` | `draggable-chip` | `boolean` | `false` | Opt-in native drag-and-drop: sets `draggable="true"` on the host, shows the Figma "Dragged" state during a real drag gesture, and makes Left/Right arrow keys fire `chip-move`. |
|
|
81
|
+
|
|
82
|
+
## Events
|
|
83
|
+
|
|
84
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
85
|
+
| --- | --- | --- | --- |
|
|
86
|
+
| `chip-move` | `{ direction: e.key === "ArrowLeft" ? -1 : 1 }` | bubbles / composed | Fired on Left/Right arrow keys when `draggable-chip` is set — the keyboard alternative to drag-and-drop; the container should reorder the chip. Detail: `{ direction: -1 \| 1 }` (-1 = left, 1 = right). |
|
|
87
|
+
| `removed` | — | bubbles / composed | Fired when the chip is removed via its remove button or Delete/Backspace (after `removed` is set to `true`). No detail. |
|
|
88
|
+
|
|
89
|
+
## Slots
|
|
90
|
+
|
|
91
|
+
| Slot | Description |
|
|
92
|
+
| --- | --- |
|
|
93
|
+
| — | This element has no slots. |
|
|
94
|
+
|
|
95
|
+
## CSS Parts
|
|
96
|
+
|
|
97
|
+
| Part | Description |
|
|
98
|
+
| --- | --- |
|
|
99
|
+
| `base` | The chip body (`.chip`) that carries size, tone, variant and border styling |
|
|
100
|
+
| `icon` | The leading `<lof-icon>` (rendered only when `leading-icon` is set and no avatar) |
|
|
101
|
+
| `label` | The label text |
|
|
102
|
+
| `remove` | The remove `<button>` (rendered only when `removable`) |
|
|
103
|
+
|
|
104
|
+
## Tokens / CSS Variables
|
|
105
|
+
|
|
106
|
+
### Component hooks
|
|
107
|
+
|
|
108
|
+
Set these on the host (or an ancestor) to customise the element without touching design tokens.
|
|
109
|
+
|
|
110
|
+
| Custom property | Default | Description |
|
|
111
|
+
| --- | --- | --- |
|
|
112
|
+
| `--lof-chip-focus-ring` | `var(--lof-border-focus)` | Colour of the keyboard focus outline; default `var(--lof-border-focus)` |
|
|
113
|
+
|
|
114
|
+
<!-- readme-gen:end -->
|
|
115
|
+
|
|
116
116
|
## 2026-11 admin refresh
|
|
117
117
|
|
|
118
118
|
- Chips are status labels: 20 / 24 / 28px tall (small / medium / large), 4px corners at small and 6px above, 12px Medium text (10px at small).
|
|
119
119
|
- `variant="subtle"` is a light tint with a 1px edge in the same hue; `variant="outline"` (new) is the surface colour with a hairline, the tone tinting only the text.
|
|
120
|
-
- `tone="accent"` (new) uses the
|
|
120
|
+
- `tone="accent"` (new) uses the green accent: a solid accent fill, or the accent tint when subtle.
|
|
121
121
|
|
|
122
122
|
```html
|
|
123
123
|
<lof-chip label="Public" tone="success" variant="subtle" size="small"></lof-chip>
|
|
@@ -125,29 +125,29 @@ Set these on the host (or an ancestor) to customise the element without touching
|
|
|
125
125
|
<lof-chip label="New" tone="accent" variant="subtle"></lof-chip>
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
-
## Accessibility
|
|
129
|
-
|
|
130
|
-
- The chip body is a `<span role="button" tabindex="0">` whose `aria-label` is the `label` text. The shadow root uses `delegatesFocus`, so calling `focus()` on the host focuses that inner span.
|
|
131
|
-
- The remove control is a real `<button>` labelled `Remove {label}`; it is a second Tab stop after the chip body.
|
|
132
|
-
- Removing a chip (button or keyboard) calls the shared `announce()` helper with `"{label} removed"`, so screen readers hear the removal even though the chip disappears.
|
|
133
|
-
- Icons and the avatar are decorative; the accessible name comes only from `label`.
|
|
134
|
-
|
|
135
|
-
| Key | Action |
|
|
136
|
-
|-----|--------|
|
|
137
|
-
| `Tab` | Focus the chip body, then the remove button (when `removable`) |
|
|
138
|
-
| `Enter` / `Space` | Re-dispatches a `click` on the host so consumer `click` handlers run |
|
|
139
|
-
| `Delete` / `Backspace` | Removes the chip when `removable` (sets `removed`, fires `removed`) |
|
|
140
|
-
| `ArrowLeft` / `ArrowRight` | Fires `chip-move` with `direction: -1` / `1` when `draggable-chip` is set |
|
|
141
|
-
|
|
142
|
-
Focus is shown as a 2px outline in `--lof-chip-focus-ring` (defaults to `--lof-border-focus`) around the whole chip, plus an inner `--lof-border-focus-inner` ring, only for keyboard focus (`:focus-visible`). The remove button gets its own `currentColor` outline.
|
|
143
|
-
|
|
144
|
-
## Notes / Edge Cases
|
|
145
|
-
|
|
146
|
-
- `avatar` and `leading-icon` are mutually exclusive: when both are set the avatar wins and a console warning is logged. The avatar is a `lof-avatar type="text"` sized to fill the chip's content box — 16 / 20 / 24px for `sm` / `md` / `lg`, driven through `--lof-avatar-size` rather than the avatar's own `size` presets (the small chip needs 16px, below the 20px `xs` floor).
|
|
147
|
-
- The trailing icon has no CSS part; only the leading icon is exposed as `icon`.
|
|
148
|
-
- The remove `✕` is drawn at the same size as the leading/trailing icons (12 / 14 / 16px) and in the same colour as the label — it carries no opacity dulling, so it keeps the label's contrast ratio on the `subtle` tones.
|
|
149
|
-
- `border="rounded"` also widens the horizontal padding to 12px at every size, per the Figma spec.
|
|
150
|
-
- `removed` is reflected: once `true` the host is `display: none` via `:host([removed])`. Set it back to `false` to show the chip again. Clicking the remove button stops propagation, so chip-level `click` handlers do not fire on removal.
|
|
151
|
-
- `draggable-chip` sets the native `draggable="true"` attribute on the host and puts the label in `dataTransfer` as `text/plain`. During a real drag the host carries a `dragging` attribute that maps to the Figma "Dragged" state; the same look is used for `:active`. The component does not reorder anything itself — the container must handle `drop` / `chip-move`.
|
|
152
|
-
- The remove button has no hover state of its own; the hover/pressed colours belong to the whole chip (per-tone action tokens).
|
|
153
|
-
- The host is `display: inline-flex` with `flex: 0 0 auto`, so chips flow inline and never stretch in a flex row.
|
|
128
|
+
## Accessibility
|
|
129
|
+
|
|
130
|
+
- The chip body is a `<span role="button" tabindex="0">` whose `aria-label` is the `label` text. The shadow root uses `delegatesFocus`, so calling `focus()` on the host focuses that inner span.
|
|
131
|
+
- The remove control is a real `<button>` labelled `Remove {label}`; it is a second Tab stop after the chip body.
|
|
132
|
+
- Removing a chip (button or keyboard) calls the shared `announce()` helper with `"{label} removed"`, so screen readers hear the removal even though the chip disappears.
|
|
133
|
+
- Icons and the avatar are decorative; the accessible name comes only from `label`.
|
|
134
|
+
|
|
135
|
+
| Key | Action |
|
|
136
|
+
|-----|--------|
|
|
137
|
+
| `Tab` | Focus the chip body, then the remove button (when `removable`) |
|
|
138
|
+
| `Enter` / `Space` | Re-dispatches a `click` on the host so consumer `click` handlers run |
|
|
139
|
+
| `Delete` / `Backspace` | Removes the chip when `removable` (sets `removed`, fires `removed`) |
|
|
140
|
+
| `ArrowLeft` / `ArrowRight` | Fires `chip-move` with `direction: -1` / `1` when `draggable-chip` is set |
|
|
141
|
+
|
|
142
|
+
Focus is shown as a 2px outline in `--lof-chip-focus-ring` (defaults to `--lof-border-focus`) around the whole chip, plus an inner `--lof-border-focus-inner` ring, only for keyboard focus (`:focus-visible`). The remove button gets its own `currentColor` outline.
|
|
143
|
+
|
|
144
|
+
## Notes / Edge Cases
|
|
145
|
+
|
|
146
|
+
- `avatar` and `leading-icon` are mutually exclusive: when both are set the avatar wins and a console warning is logged. The avatar is a `lof-avatar type="text"` sized to fill the chip's content box — 16 / 20 / 24px for `sm` / `md` / `lg`, driven through `--lof-avatar-size` rather than the avatar's own `size` presets (the small chip needs 16px, below the 20px `xs` floor).
|
|
147
|
+
- The trailing icon has no CSS part; only the leading icon is exposed as `icon`.
|
|
148
|
+
- The remove `✕` is drawn at the same size as the leading/trailing icons (12 / 14 / 16px) and in the same colour as the label — it carries no opacity dulling, so it keeps the label's contrast ratio on the `subtle` tones.
|
|
149
|
+
- `border="rounded"` also widens the horizontal padding to 12px at every size, per the Figma spec.
|
|
150
|
+
- `removed` is reflected: once `true` the host is `display: none` via `:host([removed])`. Set it back to `false` to show the chip again. Clicking the remove button stops propagation, so chip-level `click` handlers do not fire on removal.
|
|
151
|
+
- `draggable-chip` sets the native `draggable="true"` attribute on the host and puts the label in `dataTransfer` as `text/plain`. During a real drag the host carries a `dragging` attribute that maps to the Figma "Dragged" state; the same look is used for `:active`. The component does not reorder anything itself — the container must handle `drop` / `chip-move`.
|
|
152
|
+
- The remove button has no hover state of its own; the hover/pressed colours belong to the whole chip (per-tone action tokens).
|
|
153
|
+
- The host is `display: inline-flex` with `flex: 0 0 auto`, so chips flow inline and never stretch in a flex row.
|