@spaethtech/svelte-ui 0.20.1-dev.105.894ecae → 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
|
@@ -602,11 +602,21 @@ Status indicator / label.
|
|
|
602
602
|
- **Location**: `src/lib/components/Badge/Badge.svelte`
|
|
603
603
|
- **Axes**: `size`
|
|
604
604
|
- **Variants**: `default`, `primary`, `success`, `warning`, `danger`, `info`
|
|
605
|
-
- **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
|
+
```
|
|
606
616
|
- **Attribute passthrough**: leftover HTML attributes — `class` (merged, appended last), `data-*`
|
|
607
617
|
(e.g. a `data-testid` e2e hook), `aria-*`, `id`, `title`, event handlers — spread onto the chip's
|
|
608
618
|
root element. **`style` is not** passed through (the chip computes its own themed `style`); use
|
|
609
|
-
`class` for
|
|
619
|
+
`class` for extra styling and **`color`/`textColor`** for an arbitrary chip colour.
|
|
610
620
|
|
|
611
621
|
### NotesEditor
|
|
612
622
|
|