@threadlabs/looma 0.7.3 → 0.7.4
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/components/ui-badge/ui-badge.html +20 -0
- package/components/ui-button/ui-button.html +36 -13
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/styles/ui-badge.css +22 -0
- package/styles/ui-button.css +18 -12
- package/vanilla/UiBadge.d.ts +1 -0
- package/vanilla/UiBadge.js +4 -2
- package/vanilla/UiButton.d.ts +5 -0
- package/vanilla/UiButton.js +8 -6
- package/vue/UiBadge.d.ts +2 -0
- package/vue/UiBadge.vue +29 -0
- package/vue/UiButton.d.ts +9 -2
- package/vue/UiButton.vue +46 -16
- package/vue/chunks/UiBadge.js +7 -2
- package/vue/chunks/UiButton.js +52 -10
- package/vue/components.css +76 -47
package/package.json
CHANGED
package/styles/ui-badge.css
CHANGED
|
@@ -95,6 +95,24 @@
|
|
|
95
95
|
--_badge-text: var(--ui-info-subtle-text, var(--ui-info-solid));
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
/* A tag is flat at the start and points at the end. The point is cut from the box, so it has no
|
|
99
|
+
outline to follow: the edge is the fill. The end padding grows by the point's depth so the
|
|
100
|
+
label never runs into it. */
|
|
101
|
+
:scope[data-ui-badge-state~="shape=tag"] {
|
|
102
|
+
--_badge-point: var(--ui-badge-point, var(--ui-space-2));
|
|
103
|
+
|
|
104
|
+
border-color: transparent;
|
|
105
|
+
border-radius: 0;
|
|
106
|
+
padding-inline-end: calc(var(--ui-badge-padding-inline, var(--ui-space-2)) + var(--_badge-point));
|
|
107
|
+
clip-path: polygon(0 0, calc(100% - var(--_badge-point)) 0, 100% 50%, calc(100% - var(--_badge-point)) 100%, 0 100%);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
:scope[data-ui-badge-state~="shape=tag"]:dir(rtl) {
|
|
111
|
+
padding-inline-end: var(--ui-badge-padding-inline, var(--ui-space-2));
|
|
112
|
+
padding-inline-start: calc(var(--ui-badge-padding-inline, var(--ui-space-2)) + var(--_badge-point));
|
|
113
|
+
clip-path: polygon(var(--_badge-point) 0, 100% 0, 100% 100%, var(--_badge-point) 100%, 0 50%);
|
|
114
|
+
}
|
|
115
|
+
|
|
98
116
|
/* A component that sets its display still honours the hidden attribute on its root. */
|
|
99
117
|
:scope[hidden] {
|
|
100
118
|
display: none;
|
|
@@ -107,5 +125,9 @@
|
|
|
107
125
|
@supports (text-box-trim: trim-both) {
|
|
108
126
|
}
|
|
109
127
|
|
|
128
|
+
/* A tag is flat at the start and points at the end. The point is cut from the box, so it has no
|
|
129
|
+
outline to follow: the edge is the fill. The end padding grows by the point's depth so the
|
|
130
|
+
label never runs into it. */
|
|
131
|
+
|
|
110
132
|
/* A component that sets its display still honours the hidden attribute on its root. */
|
|
111
133
|
}
|
package/styles/ui-button.css
CHANGED
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
color: var(--ui-button-text, var(--_tone-text));
|
|
42
42
|
font: inherit;
|
|
43
43
|
font-weight: var(--ui-font-medium);
|
|
44
|
+
text-decoration: none;
|
|
44
45
|
line-height: var(--ui-line-height-tight);
|
|
45
46
|
padding: var(--ui-space-2) var(--ui-space-3);
|
|
46
47
|
background-image: var(--ui-raised-highlight);
|
|
@@ -73,13 +74,15 @@
|
|
|
73
74
|
font-size: 1rem;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
:
|
|
77
|
+
/* A link is never :enabled, so interactive states test "not unavailable" instead: for a button that
|
|
78
|
+
is exactly :enabled, at the same specificity, and it also matches a link that can be followed. */
|
|
79
|
+
:scope:hover:not(:disabled, [aria-disabled="true"]) {
|
|
77
80
|
border-color: var(--ui-button-hover-border, var(--_tone-hover));
|
|
78
81
|
background-color: var(--ui-button-hover-surface, oklch(from var(--_tone) l c h / 12%));
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
/* Pressed reads as pressed in: the highlight goes, and the shadow moves inside. */
|
|
82
|
-
:scope:active:
|
|
85
|
+
:scope:active:not(:disabled, [aria-disabled="true"]) {
|
|
83
86
|
background-color: var(--ui-button-active-surface, oklch(from var(--_tone) l c h / 18%));
|
|
84
87
|
background-image: none;
|
|
85
88
|
box-shadow: var(--ui-pressed);
|
|
@@ -92,12 +95,12 @@
|
|
|
92
95
|
box-shadow: var(--ui-button-solid-shadow, var(--ui-raised));
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
:is(:scope[data-ui-button-state~="variant=solid"], :scope[data-ui-button-state~="variant=danger"]):hover:
|
|
98
|
+
:is(:scope[data-ui-button-state~="variant=solid"], :scope[data-ui-button-state~="variant=danger"]):hover:not(:disabled, [aria-disabled="true"]) {
|
|
96
99
|
background-color: var(--_tone-hover);
|
|
97
100
|
border-color: var(--_tone-hover);
|
|
98
101
|
}
|
|
99
102
|
|
|
100
|
-
:is(:scope[data-ui-button-state~="variant=solid"], :scope[data-ui-button-state~="variant=danger"]):active:
|
|
103
|
+
:is(:scope[data-ui-button-state~="variant=solid"], :scope[data-ui-button-state~="variant=danger"]):active:not(:disabled, [aria-disabled="true"]) {
|
|
101
104
|
background-color: var(--_tone-active);
|
|
102
105
|
border-color: var(--_tone-active);
|
|
103
106
|
background-image: none;
|
|
@@ -154,12 +157,12 @@
|
|
|
154
157
|
}
|
|
155
158
|
|
|
156
159
|
/* Tints derive from the text colour, not a surface token, so hover and press show on any background. */
|
|
157
|
-
:scope[data-ui-button-state~="variant=ghost"]:hover:
|
|
160
|
+
:scope[data-ui-button-state~="variant=ghost"]:hover:not(:disabled, [aria-disabled="true"]) {
|
|
158
161
|
background-color: var(--ui-button-ghost-hover-surface, oklch(from var(--_tone) l c h / 10%));
|
|
159
162
|
border-color: transparent;
|
|
160
163
|
}
|
|
161
164
|
|
|
162
|
-
:scope[data-ui-button-state~="variant=ghost"]:active:
|
|
165
|
+
:scope[data-ui-button-state~="variant=ghost"]:active:not(:disabled, [aria-disabled="true"]) {
|
|
163
166
|
background-color: var(--ui-button-ghost-active-surface, oklch(from var(--_tone) l c h / 16%));
|
|
164
167
|
border-color: transparent;
|
|
165
168
|
box-shadow: var(--ui-pressed);
|
|
@@ -183,7 +186,7 @@
|
|
|
183
186
|
disabled outline is still an outline and a disabled ghost still has no edge. Intent goes — an
|
|
184
187
|
unavailable action says "unavailable", not "unavailable, and destructive" — and so do the
|
|
185
188
|
highlight and shadow, because nothing that cannot be pressed should look raised. */
|
|
186
|
-
:scope:disabled {
|
|
189
|
+
:scope:is(:disabled, [aria-disabled="true"]) {
|
|
187
190
|
/* Derived from the tone itself, not from a separate disabled palette: faded toward the
|
|
188
191
|
page, which desaturates it at the same time. Toward the page rather than toward white,
|
|
189
192
|
so a dark theme dims where a light one lightens — the same rule, both schemes. */
|
|
@@ -200,7 +203,7 @@
|
|
|
200
203
|
}
|
|
201
204
|
|
|
202
205
|
/* A filled button keeps its fill, faded further so its text stays legible on it. */
|
|
203
|
-
:is(:scope[data-ui-button-state~="variant=solid"], :scope[data-ui-button-state~="variant=danger"]):disabled {
|
|
206
|
+
:is(:scope[data-ui-button-state~="variant=solid"], :scope[data-ui-button-state~="variant=danger"]):is(:disabled, [aria-disabled="true"]) {
|
|
204
207
|
--_tone: color-mix(in oklab, var(--_hue) 34%, var(--ui-surface));
|
|
205
208
|
}
|
|
206
209
|
|
|
@@ -208,7 +211,7 @@
|
|
|
208
211
|
it takes a surface rather than reading as plain text. The surface is a wash of the faded tone,
|
|
209
212
|
the way hover washes the live one, so it stays light in every tone. An opaque mix toward the
|
|
210
213
|
hue came out a mid-grey slab for neutral, whose hue is the ink: louder than the enabled button. */
|
|
211
|
-
:scope[data-ui-button-state~="variant=ghost"]:disabled {
|
|
214
|
+
:scope[data-ui-button-state~="variant=ghost"]:is(:disabled, [aria-disabled="true"]) {
|
|
212
215
|
background-color: oklch(from var(--_tone) l c h / 14%);
|
|
213
216
|
border-color: transparent;
|
|
214
217
|
}
|
|
@@ -238,19 +241,19 @@
|
|
|
238
241
|
transition: color var(--ui-motion-fast) var(--ui-motion-ease), text-decoration-color var(--ui-motion-fast) var(--ui-motion-ease);
|
|
239
242
|
}
|
|
240
243
|
|
|
241
|
-
:scope[data-ui-button-state~="variant=link"]:hover:
|
|
244
|
+
:scope[data-ui-button-state~="variant=link"]:hover:not(:disabled, [aria-disabled="true"]) {
|
|
242
245
|
color: var(--ui-button-link-hover-text, var(--ui-text-primary));
|
|
243
246
|
text-decoration-color: currentColor;
|
|
244
247
|
background: none;
|
|
245
248
|
transform: none;
|
|
246
249
|
}
|
|
247
250
|
|
|
248
|
-
:scope[data-ui-button-state~="variant=link"]:active:
|
|
251
|
+
:scope[data-ui-button-state~="variant=link"]:active:not(:disabled, [aria-disabled="true"]) {
|
|
249
252
|
background: none;
|
|
250
253
|
transform: none;
|
|
251
254
|
}
|
|
252
255
|
|
|
253
|
-
:scope[data-ui-button-state~="variant=link"]:disabled {
|
|
256
|
+
:scope[data-ui-button-state~="variant=link"]:is(:disabled, [aria-disabled="true"]) {
|
|
254
257
|
background: none;
|
|
255
258
|
border-color: transparent;
|
|
256
259
|
color: var(--ui-button-disabled-text, var(--ui-disabled-text));
|
|
@@ -272,6 +275,9 @@
|
|
|
272
275
|
@supports (text-box-trim: trim-both) {
|
|
273
276
|
}
|
|
274
277
|
|
|
278
|
+
/* A link is never :enabled, so interactive states test "not unavailable" instead: for a button that
|
|
279
|
+
is exactly :enabled, at the same specificity, and it also matches a link that can be followed. */
|
|
280
|
+
|
|
275
281
|
/* Pressed reads as pressed in: the highlight goes, and the shadow moves inside. */
|
|
276
282
|
|
|
277
283
|
/* Tone is the colour, variant is the volume. Every pairing works: a danger outline is a
|
package/vanilla/UiBadge.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface UiBadgeElement extends HTMLSpanElement {
|
|
|
6
6
|
removeEventListener<K extends keyof UiBadgeEventMap>(type: K, listener: (this: UiBadgeElement, event: UiBadgeEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
|
|
7
7
|
}
|
|
8
8
|
export interface UiBadgeProps {
|
|
9
|
+
shape?: "pill" | "tag" | null;
|
|
9
10
|
tone?: "neutral" | "accent" | "info" | "success" | "warning" | "danger" | null;
|
|
10
11
|
variant?: "solid" | "subtle" | null;
|
|
11
12
|
attributes?: Readonly<Record<string, string | number | boolean | null | undefined>>;
|
package/vanilla/UiBadge.js
CHANGED
|
@@ -5,8 +5,9 @@ import "../styles/ui-badge.css";
|
|
|
5
5
|
export function createUiBadge(options = {}) {
|
|
6
6
|
const { attributes = {}, children = [], slots = {}, as, ...componentProps } = options;
|
|
7
7
|
const projected = [];
|
|
8
|
-
const prop0 = componentProps["
|
|
9
|
-
const prop1 = componentProps["
|
|
8
|
+
const prop0 = componentProps["shape"] === undefined ? "pill" : componentProps["shape"];
|
|
9
|
+
const prop1 = componentProps["tone"] === undefined ? "neutral" : componentProps["tone"];
|
|
10
|
+
const prop2 = componentProps["variant"] === undefined ? "subtle" : componentProps["variant"];
|
|
10
11
|
const element = document.createElement("span");
|
|
11
12
|
for (const [name, value] of Object.entries(attributes)) {
|
|
12
13
|
if (value === null || value === undefined || value === false) continue;
|
|
@@ -22,6 +23,7 @@ export function createUiBadge(options = {}) {
|
|
|
22
23
|
} else {
|
|
23
24
|
}
|
|
24
25
|
manageGeneratedProps(element, [
|
|
26
|
+
{ name: "shape", attribute: "data-shape", value: componentProps["shape"], default: "pill", type: ["pill","tag"], required: false },
|
|
25
27
|
{ name: "tone", attribute: "data-tone", value: componentProps["tone"], default: "neutral", type: ["neutral","accent","info","success","warning","danger"], required: false },
|
|
26
28
|
{ name: "variant", attribute: "data-variant", value: componentProps["variant"], default: "subtle", type: ["solid","subtle"], required: false },
|
|
27
29
|
]);
|
package/vanilla/UiButton.d.ts
CHANGED
|
@@ -8,12 +8,17 @@ export interface UiButtonElement extends HTMLButtonElement {
|
|
|
8
8
|
export interface UiButtonProps {
|
|
9
9
|
align?: "center" | "start" | null;
|
|
10
10
|
disabled?: boolean | null;
|
|
11
|
+
href?: string | null;
|
|
12
|
+
rel?: string | null;
|
|
11
13
|
size?: "sm" | "md" | "lg" | null;
|
|
12
14
|
stretch?: boolean | null;
|
|
15
|
+
target?: string | null;
|
|
13
16
|
tone?: "accent" | "neutral" | "danger" | "success" | "warning" | "info" | null;
|
|
17
|
+
type?: "button" | "submit" | "reset" | null;
|
|
14
18
|
variant?: "outline" | "solid" | "danger" | "ghost" | "link" | null;
|
|
15
19
|
attributes?: Readonly<Record<string, string | number | boolean | null | undefined>>;
|
|
16
20
|
children?: readonly (string | Node)[];
|
|
17
21
|
slots?: Readonly<Record<string, readonly (string | Node)[]>>;
|
|
22
|
+
as?: "button" | "a";
|
|
18
23
|
}
|
|
19
24
|
export declare function createUiButton(props?: UiButtonProps): UiButtonElement;
|
package/vanilla/UiButton.js
CHANGED
|
@@ -2,20 +2,22 @@
|
|
|
2
2
|
import { manageComponentLifecycle } from "@nextwebwg/html-next/runtime";
|
|
3
3
|
import "../styles/ui-button.css";
|
|
4
4
|
|
|
5
|
-
const definition = {...{"contract":{"tag":"ui-button","props":{"align":{"type":{"enum":["center","start"]},"required":false,"target":{"attribute":"align"},"default":"center"},"disabled":{"type":"boolean","required":false,"target":{"attribute":"disabled"},"default":false},"size":{"type":{"enum":["sm","md","lg"]},"required":false,"target":{"attribute":"size"},"default":"md"},"stretch":{"type":"boolean","required":false,"target":{"attribute":"stretch"},"default":false},"tone":{"type":{"enum":["accent","neutral","danger","success","warning","info"]},"required":false,"target":{"attribute":"tone"},"default":"accent"},"variant":{"type":{"enum":["outline","solid","danger","ghost","link"]},"required":false,"target":{"attribute":"variant"},"default":"outline"}}},"template":{"kind":"element","name":"button","attributes":[{"kind":"literal","name":"type","value":"
|
|
5
|
+
const definition = {...{"contract":{"tag":"ui-button","props":{"align":{"type":{"enum":["center","start"]},"required":false,"target":{"attribute":"align"},"default":"center"},"disabled":{"type":"boolean","required":false,"target":{"attribute":"disabled"},"default":false},"href":{"type":"string","required":false,"target":{"attribute":"href"}},"rel":{"type":"string","required":false,"target":{"attribute":"rel"}},"size":{"type":{"enum":["sm","md","lg"]},"required":false,"target":{"attribute":"size"},"default":"md"},"stretch":{"type":"boolean","required":false,"target":{"attribute":"stretch"},"default":false},"target":{"type":"string","required":false,"target":{"attribute":"target"}},"tone":{"type":{"enum":["accent","neutral","danger","success","warning","info"]},"required":false,"target":{"attribute":"tone"},"default":"accent"},"type":{"type":{"enum":["button","submit","reset"]},"required":false,"target":{"attribute":"type"},"default":"button"},"variant":{"type":{"enum":["outline","solid","danger","ghost","link"]},"required":false,"target":{"attribute":"variant"},"default":"outline"}}},"template":{"kind":"element","name":"button","attributes":[{"kind":"attribute","name":"type","expression":"{ true: type, false: null }[format('%s', not href)]","expressionPlan":{"source":"{ true: type, false: null }[format('%s', not href)]","ast":{"kind":"index","object":{"kind":"object","pairs":[{"key":"true","value":{"kind":"id","name":"type"}},{"key":"false","value":{"kind":"literal","value":null}}]},"index":{"kind":"call","fn":"format","args":[{"kind":"literal","value":"%s"},{"kind":"unary","op":"not","operand":{"kind":"id","name":"href"}}]}},"dependencies":["href","type"]}},{"kind":"attribute","name":"disabled","expression":"{ true: true, false: null }[format('%s', disabled and not href)]","expressionPlan":{"source":"{ true: true, false: null }[format('%s', disabled and not href)]","ast":{"kind":"index","object":{"kind":"object","pairs":[{"key":"true","value":{"kind":"literal","value":true}},{"key":"false","value":{"kind":"literal","value":null}}]},"index":{"kind":"call","fn":"format","args":[{"kind":"literal","value":"%s"},{"kind":"binary","op":"and","left":{"kind":"id","name":"disabled"},"right":{"kind":"unary","op":"not","operand":{"kind":"id","name":"href"}}}]}},"dependencies":["disabled","href"]}},{"kind":"attribute","name":"href","expression":"{ true: null, false: href }[format('%s', disabled)]","expressionPlan":{"source":"{ true: null, false: href }[format('%s', disabled)]","ast":{"kind":"index","object":{"kind":"object","pairs":[{"key":"true","value":{"kind":"literal","value":null}},{"key":"false","value":{"kind":"id","name":"href"}}]},"index":{"kind":"call","fn":"format","args":[{"kind":"literal","value":"%s"},{"kind":"id","name":"disabled"}]}},"dependencies":["disabled","href"]}},{"kind":"attribute","name":"target","expression":"target","expressionPlan":{"source":"target","ast":{"kind":"id","name":"target"},"dependencies":["target"]}},{"kind":"attribute","name":"rel","expression":"rel","expressionPlan":{"source":"rel","ast":{"kind":"id","name":"rel"},"dependencies":["rel"]}},{"kind":"attribute","name":"aria-disabled","expression":"{ true: 'true', false: null }[format('%s', disabled and href)]","expressionPlan":{"source":"{ true: 'true', false: null }[format('%s', disabled and href)]","ast":{"kind":"index","object":{"kind":"object","pairs":[{"key":"true","value":{"kind":"literal","value":"true"}},{"key":"false","value":{"kind":"literal","value":null}}]},"index":{"kind":"call","fn":"format","args":[{"kind":"literal","value":"%s"},{"kind":"binary","op":"and","left":{"kind":"id","name":"disabled"},"right":{"kind":"id","name":"href"}}]}},"dependencies":["disabled","href"]}}],"children":[{"kind":"slot"}]},"declarations":[],"root":{"kind":"native","element":"button","choices":["button","a"]}},source:{file:import.meta.url},css:""};
|
|
6
6
|
|
|
7
7
|
export function createUiButton(options = {}) {
|
|
8
8
|
const { attributes = {}, children = [], slots = {}, as, ...componentProps } = options;
|
|
9
9
|
const projected = [];
|
|
10
|
-
const element = document.createElement("button");
|
|
10
|
+
const element = document.createElement(as ?? "button");
|
|
11
11
|
for (const [name, value] of Object.entries(attributes)) {
|
|
12
12
|
if (value === null || value === undefined || value === false) continue;
|
|
13
13
|
element.setAttribute(name, value === true ? "" : String(value));
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const value0 = componentProps["target"] === undefined ? undefined : componentProps["target"];
|
|
16
|
+
if (value0 === null || value0 === undefined) element.removeAttribute("target");
|
|
17
|
+
else element.setAttribute("target", String(value0));
|
|
18
|
+
const value1 = componentProps["rel"] === undefined ? undefined : componentProps["rel"];
|
|
19
|
+
if (value1 === null || value1 === undefined) element.removeAttribute("rel");
|
|
20
|
+
else element.setAttribute("rel", String(value1));
|
|
19
21
|
element.setAttribute("data-component", "ui-button");
|
|
20
22
|
if (children.length > 0) {
|
|
21
23
|
for (const child of children) {
|
package/vue/UiBadge.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
|
+
shape?: 'pill' | 'tag';
|
|
2
3
|
tone?: 'neutral' | 'accent' | 'info' | 'success' | 'warning' | 'danger';
|
|
3
4
|
variant?: 'solid' | 'subtle';
|
|
4
5
|
};
|
|
@@ -7,6 +8,7 @@ type __VLS_Slots = {} & {
|
|
|
7
8
|
default?: (props: typeof __VLS_1) => any;
|
|
8
9
|
};
|
|
9
10
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
11
|
+
shape: "pill" | "tag";
|
|
10
12
|
tone: "neutral" | "accent" | "info" | "success" | "warning" | "danger";
|
|
11
13
|
variant: "solid" | "subtle";
|
|
12
14
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
package/vue/UiBadge.vue
CHANGED
|
@@ -6,10 +6,12 @@ defineOptions({ inheritAttrs: false })
|
|
|
6
6
|
|
|
7
7
|
const props = withDefaults(
|
|
8
8
|
defineProps<{
|
|
9
|
+
shape?: 'pill' | 'tag'
|
|
9
10
|
tone?: 'neutral' | 'accent' | 'info' | 'success' | 'warning' | 'danger'
|
|
10
11
|
variant?: 'solid' | 'subtle'
|
|
11
12
|
}>(),
|
|
12
13
|
{
|
|
14
|
+
shape: 'pill',
|
|
13
15
|
tone: 'neutral',
|
|
14
16
|
variant: 'subtle',
|
|
15
17
|
},
|
|
@@ -20,6 +22,7 @@ const hostState = computed(() =>
|
|
|
20
22
|
[
|
|
21
23
|
props.tone && `tone tone=${props.tone}`,
|
|
22
24
|
props.variant && `variant variant=${props.variant}`,
|
|
25
|
+
props.shape && `shape shape=${props.shape}`,
|
|
23
26
|
].filter(Boolean).join(' ')
|
|
24
27
|
)
|
|
25
28
|
</script>
|
|
@@ -129,6 +132,32 @@ const hostState = computed(() =>
|
|
|
129
132
|
--_badge-text: var(--ui-info-subtle-text, var(--ui-info-solid));
|
|
130
133
|
}
|
|
131
134
|
|
|
135
|
+
/* A tag is flat at the start and points at the end. The point is cut from the box, so it has no
|
|
136
|
+
outline to follow: the edge is the fill. The end padding grows by the point's depth so the
|
|
137
|
+
label never runs into it. */
|
|
138
|
+
[data-component~="ui-badge"][data-ui-badge-state~="shape=tag"] {
|
|
139
|
+
--_badge-point: var(--ui-badge-point, var(--ui-space-2));
|
|
140
|
+
|
|
141
|
+
border-color: transparent;
|
|
142
|
+
border-radius: 0;
|
|
143
|
+
padding-inline-end: calc(var(--ui-badge-padding-inline, var(--ui-space-2)) + var(--_badge-point));
|
|
144
|
+
clip-path: polygon(
|
|
145
|
+
0 0,
|
|
146
|
+
calc(100% - var(--_badge-point)) 0,
|
|
147
|
+
100% 50%,
|
|
148
|
+
calc(100% - var(--_badge-point)) 100%,
|
|
149
|
+
0 100%
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
[data-component~="ui-badge"][data-ui-badge-state~="shape=tag"]:dir(rtl) {
|
|
154
|
+
padding-inline-end: var(--ui-badge-padding-inline, var(--ui-space-2));
|
|
155
|
+
padding-inline-start: calc(
|
|
156
|
+
var(--ui-badge-padding-inline, var(--ui-space-2)) + var(--_badge-point)
|
|
157
|
+
);
|
|
158
|
+
clip-path: polygon(var(--_badge-point) 0, 100% 0, 100% 100%, var(--_badge-point) 100%, 0 50%);
|
|
159
|
+
}
|
|
160
|
+
|
|
132
161
|
/* A component that sets its display still honours the hidden attribute on its root. */
|
|
133
162
|
[data-component~="ui-badge"][hidden] {
|
|
134
163
|
display: none;
|
package/vue/UiButton.d.ts
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
|
+
as?: 'button' | 'a';
|
|
2
3
|
align?: 'center' | 'start';
|
|
3
4
|
disabled?: boolean;
|
|
5
|
+
href?: string;
|
|
6
|
+
rel?: string;
|
|
4
7
|
size?: 'sm' | 'md' | 'lg';
|
|
5
8
|
stretch?: boolean;
|
|
9
|
+
target?: string;
|
|
6
10
|
tone?: 'accent' | 'neutral' | 'danger' | 'success' | 'warning' | 'info';
|
|
11
|
+
type?: 'button' | 'submit' | 'reset';
|
|
7
12
|
variant?: 'outline' | 'solid' | 'danger' | 'ghost' | 'link';
|
|
8
13
|
};
|
|
9
|
-
declare var
|
|
14
|
+
declare var __VLS_8: {};
|
|
10
15
|
type __VLS_Slots = {} & {
|
|
11
|
-
default?: (props: typeof
|
|
16
|
+
default?: (props: typeof __VLS_8) => any;
|
|
12
17
|
};
|
|
13
18
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
19
|
+
type: "button" | "submit" | "reset";
|
|
14
20
|
tone: "accent" | "neutral" | "danger" | "success" | "warning" | "info";
|
|
15
21
|
variant: "outline" | "solid" | "danger" | "ghost" | "link";
|
|
22
|
+
as: "button" | "a";
|
|
16
23
|
align: "center" | "start";
|
|
17
24
|
disabled: boolean;
|
|
18
25
|
size: "sm" | "md" | "lg";
|
package/vue/UiButton.vue
CHANGED
|
@@ -6,19 +6,26 @@ defineOptions({ inheritAttrs: false })
|
|
|
6
6
|
|
|
7
7
|
const props = withDefaults(
|
|
8
8
|
defineProps<{
|
|
9
|
+
as?: 'button' | 'a'
|
|
9
10
|
align?: 'center' | 'start'
|
|
10
11
|
disabled?: boolean
|
|
12
|
+
href?: string
|
|
13
|
+
rel?: string
|
|
11
14
|
size?: 'sm' | 'md' | 'lg'
|
|
12
15
|
stretch?: boolean
|
|
16
|
+
target?: string
|
|
13
17
|
tone?: 'accent' | 'neutral' | 'danger' | 'success' | 'warning' | 'info'
|
|
18
|
+
type?: 'button' | 'submit' | 'reset'
|
|
14
19
|
variant?: 'outline' | 'solid' | 'danger' | 'ghost' | 'link'
|
|
15
20
|
}>(),
|
|
16
21
|
{
|
|
22
|
+
as: 'button',
|
|
17
23
|
align: 'center',
|
|
18
24
|
disabled: false,
|
|
19
25
|
size: 'md',
|
|
20
26
|
stretch: false,
|
|
21
27
|
tone: 'accent',
|
|
28
|
+
type: 'button',
|
|
22
29
|
variant: 'outline',
|
|
23
30
|
},
|
|
24
31
|
)
|
|
@@ -33,18 +40,38 @@ const hostState = computed(() =>
|
|
|
33
40
|
props.tone && `tone tone=${props.tone}`,
|
|
34
41
|
].filter(Boolean).join(' ')
|
|
35
42
|
)
|
|
43
|
+
|
|
44
|
+
function text(value: unknown): string {
|
|
45
|
+
if (Array.isArray(value)) return value.map(text).join(' ')
|
|
46
|
+
return value === null || value === undefined || typeof value === 'object' ? '' : String(value)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function attribute(value: unknown): any {
|
|
50
|
+
if (
|
|
51
|
+
value === null || value === undefined || value === false
|
|
52
|
+
|| (typeof value === 'object' && !Array.isArray(value))
|
|
53
|
+
) return undefined
|
|
54
|
+
return value === true ? '' : text(value)
|
|
55
|
+
}
|
|
36
56
|
</script>
|
|
37
57
|
|
|
38
58
|
<template>
|
|
39
|
-
<
|
|
59
|
+
<component
|
|
60
|
+
:is="as"
|
|
40
61
|
data-component="ui-button"
|
|
41
|
-
type="button"
|
|
42
62
|
v-bind="$attrs"
|
|
43
|
-
:
|
|
63
|
+
:type="attribute(({ true: type, false: null })[`${!href}`])"
|
|
64
|
+
:disabled="attribute(({ true: true, false: null })[`${disabled && !href}`])"
|
|
65
|
+
:href="attribute(({ true: null, false: href })[`${disabled}`])"
|
|
66
|
+
:target="target"
|
|
67
|
+
:rel="rel"
|
|
68
|
+
:aria-disabled="typeof (({ true: 'true', false: null })[`${Boolean(disabled && href)}`]) === 'boolean'
|
|
69
|
+
? String(({ true: 'true', false: null })[`${Boolean(disabled && href)}`])
|
|
70
|
+
: attribute(({ true: 'true', false: null })[`${Boolean(disabled && href)}`])"
|
|
44
71
|
:data-ui-button-state="hostState || undefined"
|
|
45
72
|
>
|
|
46
73
|
<slot />
|
|
47
|
-
</
|
|
74
|
+
</component>
|
|
48
75
|
</template>
|
|
49
76
|
|
|
50
77
|
<style scoped>
|
|
@@ -89,6 +116,7 @@ const hostState = computed(() =>
|
|
|
89
116
|
color: var(--ui-button-text, var(--_tone-text));
|
|
90
117
|
font: inherit;
|
|
91
118
|
font-weight: var(--ui-font-medium);
|
|
119
|
+
text-decoration: none;
|
|
92
120
|
line-height: var(--ui-line-height-tight);
|
|
93
121
|
padding: var(--ui-space-2) var(--ui-space-3);
|
|
94
122
|
background-image: var(--ui-raised-highlight);
|
|
@@ -121,13 +149,15 @@ const hostState = computed(() =>
|
|
|
121
149
|
font-size: 1rem;
|
|
122
150
|
}
|
|
123
151
|
|
|
124
|
-
|
|
152
|
+
/* A link is never :enabled, so interactive states test "not unavailable" instead: for a button that
|
|
153
|
+
is exactly :enabled, at the same specificity, and it also matches a link that can be followed. */
|
|
154
|
+
[data-component~="ui-button"]:hover:not(:disabled, [aria-disabled="true"]) {
|
|
125
155
|
border-color: var(--ui-button-hover-border, var(--_tone-hover));
|
|
126
156
|
background-color: var(--ui-button-hover-surface, oklch(from var(--_tone) l c h / 12%));
|
|
127
157
|
}
|
|
128
158
|
|
|
129
159
|
/* Pressed reads as pressed in: the highlight goes, and the shadow moves inside. */
|
|
130
|
-
[data-component~="ui-button"]:active:
|
|
160
|
+
[data-component~="ui-button"]:active:not(:disabled, [aria-disabled="true"]) {
|
|
131
161
|
background-color: var(--ui-button-active-surface, oklch(from var(--_tone) l c h / 18%));
|
|
132
162
|
background-image: none;
|
|
133
163
|
box-shadow: var(--ui-pressed);
|
|
@@ -141,12 +171,12 @@ const hostState = computed(() =>
|
|
|
141
171
|
box-shadow: var(--ui-button-solid-shadow, var(--ui-raised));
|
|
142
172
|
}
|
|
143
173
|
|
|
144
|
-
:is([data-component~="ui-button"][data-ui-button-state~="variant=solid"], [data-component~="ui-button"][data-ui-button-state~="variant=danger"]):hover:
|
|
174
|
+
:is([data-component~="ui-button"][data-ui-button-state~="variant=solid"], [data-component~="ui-button"][data-ui-button-state~="variant=danger"]):hover:not(:disabled, [aria-disabled="true"]) {
|
|
145
175
|
background-color: var(--_tone-hover);
|
|
146
176
|
border-color: var(--_tone-hover);
|
|
147
177
|
}
|
|
148
178
|
|
|
149
|
-
:is([data-component~="ui-button"][data-ui-button-state~="variant=solid"], [data-component~="ui-button"][data-ui-button-state~="variant=danger"]):active:
|
|
179
|
+
:is([data-component~="ui-button"][data-ui-button-state~="variant=solid"], [data-component~="ui-button"][data-ui-button-state~="variant=danger"]):active:not(:disabled, [aria-disabled="true"]) {
|
|
150
180
|
background-color: var(--_tone-active);
|
|
151
181
|
border-color: var(--_tone-active);
|
|
152
182
|
background-image: none;
|
|
@@ -204,12 +234,12 @@ const hostState = computed(() =>
|
|
|
204
234
|
}
|
|
205
235
|
|
|
206
236
|
/* Tints derive from the text colour, not a surface token, so hover and press show on any background. */
|
|
207
|
-
[data-component~="ui-button"][data-ui-button-state~="variant=ghost"]:hover:
|
|
237
|
+
[data-component~="ui-button"][data-ui-button-state~="variant=ghost"]:hover:not(:disabled, [aria-disabled="true"]) {
|
|
208
238
|
background-color: var(--ui-button-ghost-hover-surface, oklch(from var(--_tone) l c h / 10%));
|
|
209
239
|
border-color: transparent;
|
|
210
240
|
}
|
|
211
241
|
|
|
212
|
-
[data-component~="ui-button"][data-ui-button-state~="variant=ghost"]:active:
|
|
242
|
+
[data-component~="ui-button"][data-ui-button-state~="variant=ghost"]:active:not(:disabled, [aria-disabled="true"]) {
|
|
213
243
|
background-color: var(--ui-button-ghost-active-surface, oklch(from var(--_tone) l c h / 16%));
|
|
214
244
|
border-color: transparent;
|
|
215
245
|
box-shadow: var(--ui-pressed);
|
|
@@ -233,7 +263,7 @@ const hostState = computed(() =>
|
|
|
233
263
|
disabled outline is still an outline and a disabled ghost still has no edge. Intent goes — an
|
|
234
264
|
unavailable action says "unavailable", not "unavailable, and destructive" — and so do the
|
|
235
265
|
highlight and shadow, because nothing that cannot be pressed should look raised. */
|
|
236
|
-
[data-component~="ui-button"]:disabled {
|
|
266
|
+
[data-component~="ui-button"]:is(:disabled, [aria-disabled="true"]) {
|
|
237
267
|
/* Derived from the tone itself, not from a separate disabled palette: faded toward the
|
|
238
268
|
page, which desaturates it at the same time. Toward the page rather than toward white,
|
|
239
269
|
so a dark theme dims where a light one lightens — the same rule, both schemes. */
|
|
@@ -250,7 +280,7 @@ const hostState = computed(() =>
|
|
|
250
280
|
}
|
|
251
281
|
|
|
252
282
|
/* A filled button keeps its fill, faded further so its text stays legible on it. */
|
|
253
|
-
:is([data-component~="ui-button"][data-ui-button-state~="variant=solid"], [data-component~="ui-button"][data-ui-button-state~="variant=danger"]):disabled {
|
|
283
|
+
:is([data-component~="ui-button"][data-ui-button-state~="variant=solid"], [data-component~="ui-button"][data-ui-button-state~="variant=danger"]):is(:disabled, [aria-disabled="true"]) {
|
|
254
284
|
--_tone: color-mix(in oklab, var(--_hue) 34%, var(--ui-surface));
|
|
255
285
|
}
|
|
256
286
|
|
|
@@ -258,7 +288,7 @@ const hostState = computed(() =>
|
|
|
258
288
|
it takes a surface rather than reading as plain text. The surface is a wash of the faded tone,
|
|
259
289
|
the way hover washes the live one, so it stays light in every tone. An opaque mix toward the
|
|
260
290
|
hue came out a mid-grey slab for neutral, whose hue is the ink: louder than the enabled button. */
|
|
261
|
-
[data-component~="ui-button"][data-ui-button-state~="variant=ghost"]:disabled {
|
|
291
|
+
[data-component~="ui-button"][data-ui-button-state~="variant=ghost"]:is(:disabled, [aria-disabled="true"]) {
|
|
262
292
|
background-color: oklch(from var(--_tone) l c h / 14%);
|
|
263
293
|
border-color: transparent;
|
|
264
294
|
}
|
|
@@ -290,19 +320,19 @@ const hostState = computed(() =>
|
|
|
290
320
|
text-decoration-color var(--ui-motion-fast) var(--ui-motion-ease);
|
|
291
321
|
}
|
|
292
322
|
|
|
293
|
-
[data-component~="ui-button"][data-ui-button-state~="variant=link"]:hover:
|
|
323
|
+
[data-component~="ui-button"][data-ui-button-state~="variant=link"]:hover:not(:disabled, [aria-disabled="true"]) {
|
|
294
324
|
color: var(--ui-button-link-hover-text, var(--ui-text-primary));
|
|
295
325
|
text-decoration-color: currentColor;
|
|
296
326
|
background: none;
|
|
297
327
|
transform: none;
|
|
298
328
|
}
|
|
299
329
|
|
|
300
|
-
[data-component~="ui-button"][data-ui-button-state~="variant=link"]:active:
|
|
330
|
+
[data-component~="ui-button"][data-ui-button-state~="variant=link"]:active:not(:disabled, [aria-disabled="true"]) {
|
|
301
331
|
background: none;
|
|
302
332
|
transform: none;
|
|
303
333
|
}
|
|
304
334
|
|
|
305
|
-
[data-component~="ui-button"][data-ui-button-state~="variant=link"]:disabled {
|
|
335
|
+
[data-component~="ui-button"][data-ui-button-state~="variant=link"]:is(:disabled, [aria-disabled="true"]) {
|
|
306
336
|
background: none;
|
|
307
337
|
border-color: transparent;
|
|
308
338
|
color: var(--ui-button-disabled-text, var(--ui-disabled-text));
|
package/vue/chunks/UiBadge.js
CHANGED
|
@@ -8,17 +8,22 @@ var UiBadge_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE
|
|
|
8
8
|
inheritAttrs: false,
|
|
9
9
|
__name: "UiBadge",
|
|
10
10
|
props: {
|
|
11
|
+
shape: { default: "pill" },
|
|
11
12
|
tone: { default: "neutral" },
|
|
12
13
|
variant: { default: "subtle" }
|
|
13
14
|
},
|
|
14
15
|
setup(__props) {
|
|
15
16
|
const props = __props;
|
|
16
17
|
/** The values the styles' :host-state() rules test. */
|
|
17
|
-
const hostState = computed(() => [
|
|
18
|
+
const hostState = computed(() => [
|
|
19
|
+
props.tone && `tone tone=${props.tone}`,
|
|
20
|
+
props.variant && `variant variant=${props.variant}`,
|
|
21
|
+
props.shape && `shape shape=${props.shape}`
|
|
22
|
+
].filter(Boolean).join(" "));
|
|
18
23
|
return (_ctx, _cache) => {
|
|
19
24
|
return openBlock(), createElementBlock("span", mergeProps({ "data-component": "ui-badge" }, _ctx.$attrs, { "data-ui-badge-state": hostState.value || void 0 }), [renderSlot(_ctx.$slots, "default", {}, void 0, true)], 16, _hoisted_1);
|
|
20
25
|
};
|
|
21
26
|
}
|
|
22
|
-
}), [["__scopeId", "data-v-
|
|
27
|
+
}), [["__scopeId", "data-v-c0ffc4d8"]]);
|
|
23
28
|
//#endregion
|
|
24
29
|
export { UiBadge_default as t };
|
package/vue/chunks/UiButton.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
|
|
2
|
-
import { computed,
|
|
3
|
-
//#region .build/vue/UiButton.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
-
var _hoisted_1 = ["disabled", "data-ui-button-state"];
|
|
2
|
+
import { computed, createBlock, defineComponent, mergeProps, openBlock, renderSlot, resolveDynamicComponent, withCtx } from "vue";
|
|
5
3
|
//#endregion
|
|
6
4
|
//#region .build/vue/UiButton.vue
|
|
7
5
|
var UiButton_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
|
|
8
6
|
inheritAttrs: false,
|
|
9
7
|
__name: "UiButton",
|
|
10
8
|
props: {
|
|
9
|
+
as: { default: "button" },
|
|
11
10
|
align: { default: "center" },
|
|
12
11
|
disabled: {
|
|
13
12
|
type: Boolean,
|
|
14
13
|
default: false
|
|
15
14
|
},
|
|
15
|
+
href: {},
|
|
16
|
+
rel: {},
|
|
16
17
|
size: { default: "md" },
|
|
17
18
|
stretch: {
|
|
18
19
|
type: Boolean,
|
|
19
20
|
default: false
|
|
20
21
|
},
|
|
22
|
+
target: {},
|
|
21
23
|
tone: { default: "accent" },
|
|
24
|
+
type: { default: "button" },
|
|
22
25
|
variant: { default: "outline" }
|
|
23
26
|
},
|
|
24
27
|
setup(__props) {
|
|
@@ -31,16 +34,55 @@ var UiButton_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PUR
|
|
|
31
34
|
props.variant && `variant variant=${props.variant}`,
|
|
32
35
|
props.tone && `tone tone=${props.tone}`
|
|
33
36
|
].filter(Boolean).join(" "));
|
|
37
|
+
function text(value) {
|
|
38
|
+
if (Array.isArray(value)) return value.map(text).join(" ");
|
|
39
|
+
return value === null || value === void 0 || typeof value === "object" ? "" : String(value);
|
|
40
|
+
}
|
|
41
|
+
function attribute(value) {
|
|
42
|
+
if (value === null || value === void 0 || value === false || typeof value === "object" && !Array.isArray(value)) return void 0;
|
|
43
|
+
return value === true ? "" : text(value);
|
|
44
|
+
}
|
|
34
45
|
return (_ctx, _cache) => {
|
|
35
|
-
return openBlock(),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
return openBlock(), createBlock(resolveDynamicComponent(__props.as), mergeProps({ "data-component": "ui-button" }, _ctx.$attrs, {
|
|
47
|
+
type: attribute({
|
|
48
|
+
true: __props.type,
|
|
49
|
+
false: null
|
|
50
|
+
}[`${!__props.href}`]),
|
|
51
|
+
disabled: attribute({
|
|
52
|
+
true: true,
|
|
53
|
+
false: null
|
|
54
|
+
}[`${__props.disabled && !__props.href}`]),
|
|
55
|
+
href: attribute({
|
|
56
|
+
true: null,
|
|
57
|
+
false: __props.href
|
|
58
|
+
}[`${__props.disabled}`]),
|
|
59
|
+
target: __props.target,
|
|
60
|
+
rel: __props.rel,
|
|
61
|
+
"aria-disabled": typeof {
|
|
62
|
+
true: "true",
|
|
63
|
+
false: null
|
|
64
|
+
}[`${Boolean(__props.disabled && __props.href)}`] === "boolean" ? String({
|
|
65
|
+
true: "true",
|
|
66
|
+
false: null
|
|
67
|
+
}[`${Boolean(__props.disabled && __props.href)}`]) : attribute({
|
|
68
|
+
true: "true",
|
|
69
|
+
false: null
|
|
70
|
+
}[`${Boolean(__props.disabled && __props.href)}`]),
|
|
40
71
|
"data-ui-button-state": hostState.value || void 0
|
|
41
|
-
}),
|
|
72
|
+
}), {
|
|
73
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", {}, void 0, true)]),
|
|
74
|
+
_: 3
|
|
75
|
+
}, 16, [
|
|
76
|
+
"type",
|
|
77
|
+
"disabled",
|
|
78
|
+
"href",
|
|
79
|
+
"target",
|
|
80
|
+
"rel",
|
|
81
|
+
"aria-disabled",
|
|
82
|
+
"data-ui-button-state"
|
|
83
|
+
]);
|
|
42
84
|
};
|
|
43
85
|
}
|
|
44
|
-
}), [["__scopeId", "data-v-
|
|
86
|
+
}), [["__scopeId", "data-v-852dd10e"]]);
|
|
45
87
|
//#endregion
|
|
46
88
|
export { UiButton_default as t };
|