@spaethtech/svelte-ui 0.20.1-dev.103.a762c22 → 0.20.1-dev.107.910f0d7
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.
|
@@ -35,6 +35,14 @@
|
|
|
35
35
|
text?: string;
|
|
36
36
|
variant?: BadgeVariant;
|
|
37
37
|
size?: Responsive<Size>;
|
|
38
|
+
/** Arbitrary fill colour — any CSS colour (e.g. a DB-stored `#rrggbb` for data-driven statuses).
|
|
39
|
+
* Overrides `variant` for colour: when set, `variant` is ignored for the fill/border/text
|
|
40
|
+
* (size/radius/`borderless` still apply). Pair with `textColor` for contrast. This is the
|
|
41
|
+
* supported alternative to a `style` override (which the chip owns). */
|
|
42
|
+
color?: string;
|
|
43
|
+
/** Text (and icon) colour paired with `color`. Only used when `color` is set; default
|
|
44
|
+
* `var(--ui-color-text)`. */
|
|
45
|
+
textColor?: string;
|
|
38
46
|
dismissible?: boolean;
|
|
39
47
|
rounded?: boolean;
|
|
40
48
|
/** Hide the border WITHOUT changing the box: the border stays 1px (so height/width are
|
|
@@ -53,6 +61,8 @@
|
|
|
53
61
|
text = "",
|
|
54
62
|
variant = "default",
|
|
55
63
|
size = "md",
|
|
64
|
+
color,
|
|
65
|
+
textColor,
|
|
56
66
|
dismissible = false,
|
|
57
67
|
rounded = true,
|
|
58
68
|
borderless = true,
|
|
@@ -107,16 +117,26 @@
|
|
|
107
117
|
? "color-mix(in srgb, var(--ui-color-text) 20%, transparent)"
|
|
108
118
|
: `color-mix(in srgb, var(${token}) var(--ui-tint-border), transparent)`,
|
|
109
119
|
);
|
|
110
|
-
const
|
|
120
|
+
const variantText = $derived(
|
|
111
121
|
variant === "ghost"
|
|
112
122
|
? "color-mix(in srgb, var(--ui-color-text) 65%, transparent)"
|
|
113
123
|
: `color-mix(in srgb, var(${token}) var(--ui-tint-strong), var(--ui-color-text))`,
|
|
114
124
|
);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
125
|
+
// An explicit `color` overrides the variant entirely: fill = color; ring = color (borderless) or
|
|
126
|
+
// color mixed toward the text at the shared hover-border strength (keeps the ring on the tint
|
|
127
|
+
// scale); text = `textColor` or the theme text colour. Otherwise the variant tokens drive it.
|
|
128
|
+
const fill = $derived(color ?? bgColor);
|
|
129
|
+
const ring = $derived(
|
|
130
|
+
color
|
|
131
|
+
? borderless
|
|
132
|
+
? color
|
|
133
|
+
: `color-mix(in srgb, ${color} var(--ui-tint-border-hover), var(--ui-color-text))`
|
|
134
|
+
: borderless
|
|
135
|
+
? bgColor
|
|
136
|
+
: standardBorder,
|
|
119
137
|
);
|
|
138
|
+
const fg = $derived(color ? (textColor ?? "var(--ui-color-text)") : variantText);
|
|
139
|
+
const style = $derived(`background-color: ${fill}; border-color: ${ring}; color: ${fg};`);
|
|
120
140
|
|
|
121
141
|
function handleDismiss() {
|
|
122
142
|
ondismiss?.();
|
|
@@ -17,6 +17,14 @@ interface Props extends Omit<HTMLAttributes<HTMLElement>, "style"> {
|
|
|
17
17
|
text?: string;
|
|
18
18
|
variant?: BadgeVariant;
|
|
19
19
|
size?: Responsive<Size>;
|
|
20
|
+
/** Arbitrary fill colour — any CSS colour (e.g. a DB-stored `#rrggbb` for data-driven statuses).
|
|
21
|
+
* Overrides `variant` for colour: when set, `variant` is ignored for the fill/border/text
|
|
22
|
+
* (size/radius/`borderless` still apply). Pair with `textColor` for contrast. This is the
|
|
23
|
+
* supported alternative to a `style` override (which the chip owns). */
|
|
24
|
+
color?: string;
|
|
25
|
+
/** Text (and icon) colour paired with `color`. Only used when `color` is set; default
|
|
26
|
+
* `var(--ui-color-text)`. */
|
|
27
|
+
textColor?: string;
|
|
20
28
|
dismissible?: boolean;
|
|
21
29
|
rounded?: boolean;
|
|
22
30
|
/** Hide the border WITHOUT changing the box: the border stays 1px (so height/width are
|
package/docs/components.md
CHANGED
|
@@ -17,6 +17,18 @@ Most sizeable/themeable components share two props (defined in `types/variants.t
|
|
|
17
17
|
- **`size`** — `sm` (24px), `md` (32px, **default**), `lg` (40px). Tied to the theme's
|
|
18
18
|
`--ui-height-sm` / `--ui-height` / `--ui-height-lg`.
|
|
19
19
|
|
|
20
|
+
## HTML attribute passthrough
|
|
21
|
+
|
|
22
|
+
Components forward the standard HTML attributes you pass — **`class`** (merged onto the root, appended
|
|
23
|
+
last so your classes win), **`data-*`** (e.g. a stable `data-testid` for e2e), **`aria-*`**, **`id`**,
|
|
24
|
+
**`title`**, and event handlers — onto their root element, typed against the matching `HTML*Attributes`.
|
|
25
|
+
So `<Badge data-testid="status" class="ml-2">` or `<Card onmouseenter={…}>` just work and type-check.
|
|
26
|
+
|
|
27
|
+
Exceptions: components that compute their own root **`style`** (themed `color-mix`, dimensions, drag
|
|
28
|
+
transforms — e.g. `Badge`, `Alert`, `Skeleton`, `DataTable`) do **not** accept a `style` override —
|
|
29
|
+
use `class`. Field-shaped components (`Input`, the specialized inputs, `Slider`, `TokenInput`,
|
|
30
|
+
`FileUpload`) route `class` to their outer field wrapper and land other attributes on the control.
|
|
31
|
+
|
|
20
32
|
## Field chrome (shared)
|
|
21
33
|
|
|
22
34
|
Every field-shaped component — `Input`, `Select`, `TextArea`, `Checkbox`, `Toggle` (and the
|
|
@@ -590,11 +602,21 @@ Status indicator / label.
|
|
|
590
602
|
- **Location**: `src/lib/components/Badge/Badge.svelte`
|
|
591
603
|
- **Axes**: `size`
|
|
592
604
|
- **Variants**: `default`, `primary`, `success`, `warning`, `danger`, `info`
|
|
593
|
-
- **Props**: `text`, `variant`, `size`, `dismissible`, `rounded`, `href`, `children`; dispatches `dismiss`
|
|
605
|
+
- **Props**: `text`, `variant`, `size`, `color`, `textColor`, `dismissible`, `rounded`, `href`, `children`; dispatches `dismiss`
|
|
606
|
+
- **Arbitrary colour (data-driven)**: `color` takes any CSS colour (e.g. a DB-stored `#rrggbb` for
|
|
607
|
+
operator-defined statuses) and overrides `variant` for the fill/border/text — `variant` is ignored
|
|
608
|
+
for colour when `color` is set (size/radius/`borderless` still apply). Pair with `textColor` (the
|
|
609
|
+
paired text/icon colour; default `var(--ui-color-text)`). The border stays on the shared tint scale
|
|
610
|
+
(`color` mixed toward the text at `--ui-tint-border-hover`, or just `color` when `borderless`). This
|
|
611
|
+
is the supported alternative to a `style` override, which the chip owns.
|
|
612
|
+
```svelte
|
|
613
|
+
<!-- operator-defined ticket status: {label, color: "#rrggbb", fg} from the DB -->
|
|
614
|
+
<Badge {size} borderless text={status.label} color={status.color} textColor={status.fg} />
|
|
615
|
+
```
|
|
594
616
|
- **Attribute passthrough**: leftover HTML attributes — `class` (merged, appended last), `data-*`
|
|
595
617
|
(e.g. a `data-testid` e2e hook), `aria-*`, `id`, `title`, event handlers — spread onto the chip's
|
|
596
618
|
root element. **`style` is not** passed through (the chip computes its own themed `style`); use
|
|
597
|
-
`class` for
|
|
619
|
+
`class` for extra styling and **`color`/`textColor`** for an arbitrary chip colour.
|
|
598
620
|
|
|
599
621
|
### NotesEditor
|
|
600
622
|
|