@nswds/ui 8.5.0 → 9.0.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/README.md +2 -2
- package/dist/components/badge.d.ts +16 -25
- package/dist/components/badge.js +50 -393
- package/dist/components/badge.js.map +1 -1
- package/dist/components/button.d.ts +3 -3
- package/dist/components/callout.d.ts +2 -2
- package/dist/components/header.d.ts +2 -0
- package/dist/components/input-group.d.ts +2 -2
- package/dist/components/link.d.ts +1 -1
- package/dist/components/link.js +1 -1
- package/dist/components/link.js.map +1 -1
- package/dist/components/tag.d.ts +47 -0
- package/dist/components/tag.js +196 -0
- package/dist/components/tag.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -0
- package/dist/lib/label-colors.d.ts +11 -0
- package/dist/lib/label-colors.js +10 -0
- package/dist/lib/label-colors.js.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -168,7 +168,7 @@ import {
|
|
|
168
168
|
|
|
169
169
|
## Components
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
68 components, plus 12 copy-and-adapt blocks on the registry channel. The complete catalogue —
|
|
172
172
|
with every export and a description per item — is in the
|
|
173
173
|
[component reference](https://github.com/digitalnsw/nswds-ui/blob/main/docs/reference-components.md).
|
|
174
174
|
|
|
@@ -181,7 +181,7 @@ StepIndicator, TabNav, ThemeSwitcher.
|
|
|
181
181
|
Accordion, AlertDialog, AspectRatio, Avatar, Badge, Breadcrumb, Button, ButtonGroup, Card, Carousel, Checkbox,
|
|
182
182
|
Collapsible, Combobox, Dialog, DirectionProvider, Drawer, DropdownMenu, Empty, Field, HoverCard, Input, InputGroup, InputOTP,
|
|
183
183
|
Kbd, Label, NativeSelect, Pagination, Popover, Progress, RadioGroup, ResizablePanelGroup, ScrollArea, Select,
|
|
184
|
-
Separator, Sheet, Skeleton, Slider, Spinner, Switch, Table, Tabs, Textarea, Toaster, Toggle, ToggleGroup,
|
|
184
|
+
Separator, Sheet, Skeleton, Slider, Spinner, Switch, Table, Tabs, Tag, Textarea, Toaster, Toggle, ToggleGroup,
|
|
185
185
|
Tooltip.
|
|
186
186
|
|
|
187
187
|
Plus the icon set under `@nswds/ui/icons` and the brand marks under `@nswds/ui/icons/brands`.
|
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
|
-
import { Button } from '@base-ui/react/button';
|
|
3
2
|
import { VariantProps } from 'class-variance-authority';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { LabelColor } from '../lib/label-colors.js';
|
|
5
|
+
import './button.js';
|
|
6
|
+
import '@base-ui/react/button';
|
|
7
|
+
import './link.js';
|
|
6
8
|
|
|
7
|
-
declare const
|
|
9
|
+
declare const badgeCva: (props?: ({
|
|
8
10
|
variant?: "solid" | "soft" | "surface" | "outline" | null | undefined;
|
|
9
|
-
color?: "tertiary" | "accent" | "white" | "grey" | "primary" | "secondary" | "primary/grey" | "light" | "primary/white" | null | undefined;
|
|
10
11
|
size?: "default" | "sm" | "lg" | null | undefined;
|
|
11
12
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
12
|
-
type
|
|
13
|
-
|
|
13
|
+
type BadgeVariantProps = NonNullable<Parameters<typeof badgeCva>[0]> & {
|
|
14
|
+
color?: LabelColor | 'light' | null;
|
|
14
15
|
};
|
|
15
|
-
declare function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
declare function badgeVariants({ color, variant, class: classValue, className, ...props }?: BadgeVariantProps): string;
|
|
17
|
+
type BadgeProps = VariantProps<typeof badgeVariants> & React.ComponentPropsWithoutRef<'span'> & {
|
|
18
|
+
ref?: React.Ref<HTMLSpanElement>;
|
|
19
|
+
/** Decorative status dot; always accompany it with a visible status label. */
|
|
20
|
+
dot?: boolean;
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
ref?: React__default.Ref<HTMLAnchorElement>;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Interactive badge on the Base UI button primitive. For badge-styled
|
|
27
|
-
* navigation, use `BadgeLink` — the `href` polymorphism that previously
|
|
28
|
-
* lived on this component was removed in v2.
|
|
29
|
-
*/
|
|
30
|
-
declare function BadgeButton({ variant, color, size, className, children, ref, ...props }: BadgeButtonProps): React__default.JSX.Element;
|
|
31
|
-
/** Badge-styled anchor; renders through `Link` (so `LinkProvider` applies). */
|
|
32
|
-
declare function BadgeLink({ variant, color, size, className, children, ref, ...props }: BadgeLinkProps): React__default.JSX.Element;
|
|
22
|
+
/** Static status or count. Categories and interactive labels belong to Tag. */
|
|
23
|
+
declare function Badge({ variant, color, size, dot, className, children, ...props }: BadgeProps): React.JSX.Element;
|
|
33
24
|
|
|
34
|
-
export { Badge,
|
|
25
|
+
export { Badge, type BadgeProps, badgeVariants };
|
package/dist/components/badge.js
CHANGED
|
@@ -1,416 +1,73 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { Button } from '@base-ui/react/button';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
3
|
import { cva } from 'class-variance-authority';
|
|
5
|
-
import
|
|
4
|
+
import { labelColorVariants } from '../lib/label-colors.js';
|
|
6
5
|
import { cn } from '../lib/utils.js';
|
|
7
|
-
import { TouchTarget } from './button.js';
|
|
8
|
-
import { Link } from './link.js';
|
|
9
6
|
|
|
10
|
-
const
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"dark:[--focus-outline:var(--color-grey-100)]",
|
|
26
|
-
// Soft dark mode
|
|
27
|
-
"dark:data-[variant=soft]:[--focus-outline:var(--color-grey-200)]/30",
|
|
28
|
-
// Surface
|
|
29
|
-
"data-[variant=surface]:[--focus-outline:var(--color-grey-600)]",
|
|
30
|
-
// Surface dark mode
|
|
31
|
-
"dark:data-[variant=surface]:[--focus-outline:var(--color-white)]/70"
|
|
32
|
-
],
|
|
33
|
-
"primary/white": [
|
|
34
|
-
// Base
|
|
35
|
-
"[--focus-outline:var(--color-primary-800)]",
|
|
36
|
-
// Base dark mode
|
|
37
|
-
"dark:[--focus-outline:var(--color-white)]",
|
|
38
|
-
// Soft
|
|
39
|
-
"data-[variant=soft]:[--focus-outline:var(--color-primary-800)]/20",
|
|
40
|
-
// Soft dark mode
|
|
41
|
-
"dark:data-[variant=soft]:[--focus-outline:var(--color-grey-200)]/30"
|
|
42
|
-
],
|
|
43
|
-
grey: [
|
|
44
|
-
// Base
|
|
45
|
-
"[--focus-outline:var(--color-grey-600)]",
|
|
46
|
-
// Base dark mode
|
|
47
|
-
"dark:[--focus-outline:var(--color-grey-500)]",
|
|
48
|
-
// Soft
|
|
49
|
-
"data-[variant=soft]:[--focus-outline:var(--color-grey-600)]/20",
|
|
50
|
-
// Soft dark mode
|
|
51
|
-
"dark:data-[variant=soft]:[--focus-outline:var(--color-grey-200)]/20",
|
|
52
|
-
// Outline dark mode
|
|
53
|
-
"dark:data-[variant=outline]:[--focus-outline:var(--color-grey-100)]/30",
|
|
54
|
-
// Surface dark mode
|
|
55
|
-
"dark:data-[variant=surface]:[--focus-outline:var(--color-grey-200)]/20"
|
|
56
|
-
],
|
|
57
|
-
white: [
|
|
58
|
-
// Base
|
|
59
|
-
"[--focus-outline:var(--color-white)]",
|
|
60
|
-
// Soft
|
|
61
|
-
"data-[variant=soft]:[--focus-outline:var(--color-white)]/20"
|
|
62
|
-
],
|
|
63
|
-
primary: [
|
|
64
|
-
// Base
|
|
65
|
-
"[--focus-outline:var(--color-primary-800)]",
|
|
66
|
-
// Soft
|
|
67
|
-
"data-[variant=soft]:[--focus-outline:var(--color-primary-800)]/20",
|
|
68
|
-
// Soft dark mode
|
|
69
|
-
"dark:data-[variant=soft]:[--focus-outline:var(--color-primary-800)]/60"
|
|
70
|
-
],
|
|
71
|
-
secondary: [
|
|
72
|
-
// Base
|
|
73
|
-
"[--focus-outline:var(--color-primary-200)]",
|
|
74
|
-
// Soft
|
|
75
|
-
"data-[variant=soft]:[--focus-outline:var(--color-primary-200)]/20",
|
|
76
|
-
// Soft dark mode
|
|
77
|
-
"dark:data-[variant=soft]:[--focus-outline:var(--color-primary-200)]/60"
|
|
78
|
-
],
|
|
79
|
-
tertiary: [
|
|
80
|
-
// Base
|
|
81
|
-
"[--focus-outline:var(--color-primary-600)]",
|
|
82
|
-
// Soft
|
|
83
|
-
"data-[variant=soft]:[--focus-outline:var(--color-primary-600)]/20",
|
|
84
|
-
// Soft dark mode
|
|
85
|
-
"dark:data-[variant=soft]:[--focus-outline:var(--color-primary-600)]/60"
|
|
86
|
-
],
|
|
87
|
-
accent: [
|
|
88
|
-
// Base
|
|
89
|
-
"[--focus-outline:var(--color-accent-600)]",
|
|
90
|
-
// Soft
|
|
91
|
-
"data-[variant=soft]:[--focus-outline:var(--color-accent-600)]/20",
|
|
92
|
-
// Soft dark mode
|
|
93
|
-
"dark:data-[variant=soft]:[--focus-outline:var(--color-accent-600)]/60"
|
|
94
|
-
]
|
|
95
|
-
};
|
|
96
|
-
const styles = {
|
|
97
|
-
base: [
|
|
98
|
-
// Base
|
|
99
|
-
"relative isolate inline-flex items-center rounded-sm font-normal border forced-colors:outline motion-safe:transition-all h-fit shrink-0",
|
|
100
|
-
// Icon — one flat size, for the same reason the type scale below is flat.
|
|
101
|
-
"*:data-[slot=icon]:size-4 *:data-[slot=icon]:shrink-0 *:data-[slot=icon]:self-center"
|
|
102
|
-
],
|
|
103
|
-
solid: [
|
|
104
|
-
// Text color
|
|
105
|
-
"text-(--badge-text)",
|
|
106
|
-
// Optical border, implemented as the button background to avoid corner artifacts
|
|
107
|
-
"border-transparent bg-(--badge-border)",
|
|
108
|
-
// Dark mode: border is rendered on `after` so background is set to button background
|
|
109
|
-
"dark:bg-(--badge-bg)",
|
|
110
|
-
// Button background, implemented as foreground layer to stack on top of pseudo-border layer
|
|
111
|
-
"before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--badge-bg)",
|
|
112
|
-
// Drop shadow, applied to the inset `before` layer so it blends with the border
|
|
113
|
-
"before:shadow-sm",
|
|
114
|
-
// Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo
|
|
115
|
-
"dark:before:hidden",
|
|
116
|
-
// Dark mode: Subtle white outline is applied using a border
|
|
117
|
-
"dark:border-white/5",
|
|
118
|
-
// Shim/overlay, inset to match button foreground and used for hover state + highlight shadow
|
|
119
|
-
"after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]",
|
|
120
|
-
// White overlay on hover
|
|
121
|
-
"group-active:after:bg-(--badge-hover-overlay) group-hover:after:bg-(--badge-hover-overlay)",
|
|
122
|
-
// Dark mode: `after` layer expands to cover entire button
|
|
123
|
-
"dark:after:-inset-px dark:after:rounded-sm",
|
|
124
|
-
// Disabled
|
|
125
|
-
"data-disabled:before:shadow-none data-disabled:after:shadow-none"
|
|
126
|
-
],
|
|
127
|
-
soft: [
|
|
128
|
-
// Text color
|
|
129
|
-
"text-(--badge-bg)",
|
|
130
|
-
// Optical border, implemented as the button background to avoid corner artifacts
|
|
131
|
-
"border-transparent bg-(--badge-bg)/5",
|
|
132
|
-
// Dark mode: border is rendered on `after` so background is set to button background
|
|
133
|
-
"dark:bg-(--badge-bg)/20",
|
|
134
|
-
// Button background, implemented as foreground layer to stack on top of pseudo-border layer
|
|
135
|
-
"before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--badge-bg)/5",
|
|
136
|
-
// Drop shadow, applied to the inset `before` layer so it blends with the border
|
|
137
|
-
"before:shadow-sm",
|
|
138
|
-
// Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo
|
|
139
|
-
"dark:before:bg-white/5",
|
|
140
|
-
// Dark mode: Subtle white outline is applied using a border
|
|
141
|
-
"dark:border-white/5",
|
|
142
|
-
// Shim/overlay, inset to match button foreground and used for hover state + highlight shadow
|
|
143
|
-
"after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]",
|
|
144
|
-
// White overlay on hover
|
|
145
|
-
"group-active:after:bg-(--badge-hover-overlay) group-hover:after:bg-(--badge-hover-overlay)",
|
|
146
|
-
// Dark mode: `after` layer expands to cover entire button
|
|
147
|
-
"dark:after:-inset-px dark:after:rounded-sm",
|
|
148
|
-
// Disabled
|
|
149
|
-
"data-disabled:before:shadow-none data-disabled:after:shadow-none"
|
|
150
|
-
],
|
|
151
|
-
surface: [
|
|
152
|
-
// Text color
|
|
153
|
-
"text-(--badge-bg)",
|
|
154
|
-
// Optical border, implemented as the button background to avoid corner artifacts
|
|
155
|
-
"border-(--badge-bg)/50 bg-(--badge-bg)/5",
|
|
156
|
-
// Dark mode: border is rendered on `after` so background is set to button background
|
|
157
|
-
"dark:bg-(--badge-bg)/30",
|
|
158
|
-
// Button background, implemented as foreground layer to stack on top of pseudo-border layer
|
|
159
|
-
"before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--badge-bg)/5",
|
|
160
|
-
// Drop shadow, applied to the inset `before` layer so it blends with the border
|
|
161
|
-
"before:shadow-sm",
|
|
162
|
-
// Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo
|
|
163
|
-
"dark:before:hidden",
|
|
164
|
-
// Dark mode: Subtle white outline is applied using a border
|
|
165
|
-
"dark:border-(--badge-bg)/50",
|
|
166
|
-
// Shim/overlay, inset to match button foreground and used for hover state + highlight shadow
|
|
167
|
-
"after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]",
|
|
168
|
-
// Border color on hover
|
|
169
|
-
"group-active:border-(--badge-bg) group-hover:border-(--badge-bg)",
|
|
170
|
-
// White overlay on hover
|
|
171
|
-
"group-active:after:bg-(--badge-hover-overlay) group-hover:after:bg-(--badge-hover-overlay)",
|
|
172
|
-
// Dark mode: `after` layer expands to cover entire button
|
|
173
|
-
"dark:after:-inset-px dark:after:rounded-sm",
|
|
174
|
-
// Disabled
|
|
175
|
-
"data-disabled:before:shadow-none data-disabled:after:shadow-none"
|
|
176
|
-
],
|
|
177
|
-
outline: [
|
|
178
|
-
// Text color
|
|
179
|
-
"border-(--badge-bg) text-(--badge-bg)",
|
|
180
|
-
// Optical border, implemented as the button background to avoid corner artifacts
|
|
181
|
-
"bg-transparent",
|
|
182
|
-
// Button background, implemented as foreground layer to stack on top of pseudo-border layer
|
|
183
|
-
"before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-transparent",
|
|
184
|
-
// Drop shadow, applied to the inset `before` layer so it blends with the border
|
|
185
|
-
"before:shadow-sm",
|
|
186
|
-
// Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo
|
|
187
|
-
"dark:before:hidden",
|
|
188
|
-
// Dark mode: Subtle white outline is applied using a border
|
|
189
|
-
"dark:border-(--badge-bg)",
|
|
190
|
-
// Shim/overlay, inset to match button foreground and used for hover state + highlight shadow
|
|
191
|
-
"after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]",
|
|
192
|
-
// White overlay on hover
|
|
193
|
-
"group-active:after:bg-(--badge-hover-overlay) group-hover:after:bg-(--badge-hover-overlay)",
|
|
194
|
-
// Dark mode: `after` layer expands to cover entire button
|
|
195
|
-
"dark:after:-inset-px dark:after:rounded-sm",
|
|
196
|
-
// Disabled
|
|
197
|
-
"data-disabled:before:shadow-none data-disabled:after:shadow-none"
|
|
198
|
-
],
|
|
199
|
-
colors: {
|
|
200
|
-
"primary/grey": [
|
|
201
|
-
// Base
|
|
202
|
-
"[--badge-bg:var(--color-primary-800)] [--badge-border:var(--color-primary-800)]/90 [--badge-text:var(--color-white)]",
|
|
203
|
-
// States
|
|
204
|
-
"[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10",
|
|
205
|
-
// Dark mode
|
|
206
|
-
"dark:[--badge-bg:var(--color-grey-600)] dark:[--badge-border:var(--color-grey-600)]/90 dark:[--badge-text:var(--color-white)] dark:text-white",
|
|
207
|
-
// Dark mode states
|
|
208
|
-
"dark:[--badge-hover-overlay:var(--color-grey-200)]/20"
|
|
209
|
-
],
|
|
210
|
-
light: [
|
|
211
|
-
// Base
|
|
212
|
-
"[--badge-bg:var(--color-grey-200)] [--badge-border:var(--color-grey-200)]/90 [--badge-text:var(--color-grey-800)]",
|
|
213
|
-
"text-grey-800",
|
|
214
|
-
// Soft
|
|
215
|
-
"data-[variant=soft]:[--badge-bg:var(--color-grey-500)]",
|
|
216
|
-
// Surface
|
|
217
|
-
"data-[variant=surface]:[--badge-bg:var(--color-grey-500)]",
|
|
218
|
-
// States
|
|
219
|
-
"[--badge-hover-overlay:var(--color-grey-200)]/10 data-[variant=outline]:[--badge-hover-overlay:var(--color-grey-200)]/20 data-[variant=solid]:[--badge-hover-overlay:var(--color-grey-400)]/50",
|
|
220
|
-
// Dark mode
|
|
221
|
-
"dark:text-grey-200 dark:data-[variant=solid]:text-grey-800",
|
|
222
|
-
// Dark mode states
|
|
223
|
-
""
|
|
224
|
-
],
|
|
225
|
-
"primary/white": [
|
|
226
|
-
// Base
|
|
227
|
-
"[--badge-bg:var(--color-primary-800)] [--badge-border:var(--color-primary-800)]/90 [--badge-text:var(--color-white)]",
|
|
228
|
-
// States
|
|
229
|
-
"[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10",
|
|
230
|
-
// Dark mode
|
|
231
|
-
"dark:[--badge-bg:var(--color-white)] dark:[--badge-border:var(--color-white)]/90 dark:[--badge-text:var(--color-grey-800)]",
|
|
232
|
-
// Dark mode states
|
|
233
|
-
""
|
|
234
|
-
],
|
|
235
|
-
grey: [
|
|
236
|
-
// Base
|
|
237
|
-
"[--badge-bg:var(--color-grey-600)] [--badge-border:var(--color-grey-600)]/90 [--badge-text:var(--color-white)]",
|
|
238
|
-
// States
|
|
239
|
-
"[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10",
|
|
240
|
-
// Dark mode
|
|
241
|
-
"dark:text-white",
|
|
242
|
-
// Dark mode states
|
|
243
|
-
""
|
|
244
|
-
],
|
|
245
|
-
white: [
|
|
246
|
-
// Base
|
|
247
|
-
"[--badge-bg:var(--color-white)] [--badge-border:var(--color-white)]/90 text-white data-[variant=solid]:text-grey-800",
|
|
248
|
-
// States
|
|
249
|
-
"[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10",
|
|
250
|
-
// Dark mode
|
|
251
|
-
"dark:text-grey-200 dark:data-[variant=solid]:text-grey-800",
|
|
252
|
-
// Dark mode states
|
|
253
|
-
""
|
|
254
|
-
],
|
|
255
|
-
primary: [
|
|
256
|
-
// Base
|
|
257
|
-
"[--badge-bg:var(--color-primary-800)] [--badge-border:var(--color-primary-800)]/90 [--badge-text:var(--color-white)]",
|
|
258
|
-
// States
|
|
259
|
-
"[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10",
|
|
260
|
-
// Dark mode
|
|
261
|
-
"dark:text-white dark:bg-(--badge-bg)/40 dark:data-[variant=solid]:bg-(--badge-bg)",
|
|
262
|
-
// Dark mode states
|
|
263
|
-
"dark:[--badge-hover-overlay:var(--color-primary-800)]/50 dark:data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/5",
|
|
264
|
-
// Dark border
|
|
265
|
-
"dark:data-[variant=surface]:border-(--badge-border)/60",
|
|
266
|
-
"dark:data-[variant=outline]:border-(--badge-border)",
|
|
267
|
-
// Dark border states
|
|
268
|
-
"dark:data-[variant=surface]:active:border-(--badge-border)",
|
|
269
|
-
"dark:data-[variant=surface]:hover:border-(--badge-border)"
|
|
270
|
-
],
|
|
271
|
-
secondary: [
|
|
272
|
-
// Base
|
|
273
|
-
"[--badge-bg:var(--color-primary-200)] [--badge-border:var(--color-primary-200)]/90 [--badge-text:var(--color-primary-800)]",
|
|
274
|
-
// States
|
|
275
|
-
"[--badge-hover-overlay:var(--color-primary-200)]/30 data-[variant=solid]:[--badge-hover-overlay:var(--color-primary-250)]",
|
|
276
|
-
// Dark mode
|
|
277
|
-
"dark:[--badge-bg:var(--color-primary-400)] dark:[--badge-border:var(--color-primary-400)]/90 dark:[--badge-text:white]",
|
|
278
|
-
// Dark mode states
|
|
279
|
-
"dark:[--badge-hover-overlay:var(--color-primary-400)]/30 dark:data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10"
|
|
280
|
-
],
|
|
281
|
-
tertiary: [
|
|
282
|
-
// Base
|
|
283
|
-
"[--badge-bg:var(--color-primary-600)] [--badge-border:var(--color-primary-600)]/90 [--badge-text:var(--color-white)]",
|
|
284
|
-
// States
|
|
285
|
-
"[--badge-hover-overlay:var(--color-primary-600)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10",
|
|
286
|
-
// Dark mode
|
|
287
|
-
"dark:[--badge-bg:var(--color-primary-500)] dark:[--badge-border:var(--color-primary-500)]/90 dark:[--badge-text:white]",
|
|
288
|
-
// Dark mode states
|
|
289
|
-
"dark:[--badge-hover-overlay:var(--color-primary-500)]/30 dark:data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10"
|
|
290
|
-
],
|
|
291
|
-
accent: [
|
|
292
|
-
// Base
|
|
293
|
-
"[--badge-bg:var(--color-accent-600)] [--badge-border:var(--color-accent-600)]/90 [--badge-text:var(--color-white)]",
|
|
294
|
-
// States
|
|
295
|
-
"[--badge-hover-overlay:var(--color-accent-600)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10",
|
|
296
|
-
// Dark mode
|
|
297
|
-
"dark:[--badge-bg:var(--color-accent-500)] dark:[--badge-border:var(--color-accent-500)]/90 dark:[--badge-text:white]",
|
|
298
|
-
// Dark mode states
|
|
299
|
-
"dark:[--badge-hover-overlay:var(--color-accent-500)]/30 dark:data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10"
|
|
300
|
-
]
|
|
301
|
-
},
|
|
302
|
-
// ───────────────────────────────────────────────────────────────────────────
|
|
303
|
-
// Type scale (flat — do not reintroduce a `sm:` shrink)
|
|
304
|
-
// ───────────────────────────────────────────────────────────────────────────
|
|
305
|
-
//
|
|
306
|
-
// Each size holds one font-size at every viewport. Sizes are chosen from the
|
|
307
|
-
// hierarchy field.tsx documents: 16px is the body-copy ideal, 14px reads as
|
|
308
|
-
// supporting information, and 12px is below the NSW Government digital
|
|
309
|
-
// service standards minimum body-text size.
|
|
310
|
-
//
|
|
311
|
-
// These variants used to shrink at `sm:` (640px) — `text-sm/5 sm:text-xs/5`
|
|
312
|
-
// and `text-base/5 sm:text-sm/5` — inherited from the Catalyst-derived
|
|
313
|
-
// scaffolding this component started life as (4889aba). That put `default`
|
|
314
|
-
// and `sm` badges at 12px from 640px up, i.e. under the floor precisely where
|
|
315
|
-
// there is the most room, and capped `lg` at 14px so no badge in the system
|
|
316
|
-
// could meet a 16px minimum on desktop. Buttons — which badges sit beside in
|
|
317
|
-
// the header — have always been a flat `text-base/7`, so the shrink was also
|
|
318
|
-
// out of step with its closest sibling.
|
|
319
|
-
//
|
|
320
|
-
// Below 640px nothing changed: every value here is the size that breakpoint
|
|
321
|
-
// already rendered.
|
|
322
|
-
size: {
|
|
323
|
-
default: "py-[calc(--spacing(1))] px-[calc(--spacing(2))] gap-[calc(--spacing(1)*1.5)] text-sm/5",
|
|
324
|
-
sm: "py-[calc(--spacing(1)*0.5)] px-[calc(--spacing(1)*1.5)] gap-[calc(--spacing(1)*1.5)] text-sm/5",
|
|
325
|
-
lg: "py-[calc(--spacing(1))] px-[calc(--spacing(2)*1.25)] gap-[calc(--spacing(2))] text-base/5"
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
const badgeVariants = cva(styles.base, {
|
|
329
|
-
variants: {
|
|
330
|
-
variant: {
|
|
331
|
-
solid: styles.solid,
|
|
332
|
-
soft: styles.soft,
|
|
333
|
-
surface: styles.surface,
|
|
334
|
-
outline: styles.outline
|
|
335
|
-
},
|
|
336
|
-
color: {
|
|
337
|
-
"primary/grey": styles.colors["primary/grey"],
|
|
338
|
-
light: styles.colors.light,
|
|
339
|
-
"primary/white": styles.colors["primary/white"],
|
|
340
|
-
white: styles.colors.white,
|
|
341
|
-
grey: styles.colors.grey,
|
|
342
|
-
primary: styles.colors.primary,
|
|
343
|
-
secondary: styles.colors.secondary,
|
|
344
|
-
tertiary: styles.colors.tertiary,
|
|
345
|
-
accent: styles.colors.accent
|
|
7
|
+
const badgeCva = cva(
|
|
8
|
+
"inline-flex max-w-full items-center justify-center gap-1.5 rounded-full border align-middle font-normal forced-colors:border-[CanvasText] [&_[data-slot=icon]]:inline-block [&_[data-slot=icon]]:size-4 [&_[data-slot=icon]]:shrink-0 [&_[data-slot=icon]]:align-middle",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
solid: "border-transparent bg-(--btn-fill) text-(--btn-text)",
|
|
13
|
+
soft: "border-transparent bg-(--btn-bg)/10 text-(--btn-bg) dark:bg-(--btn-bg)/20",
|
|
14
|
+
surface: "border-(--btn-bg)/50 bg-(--btn-bg)/5 text-(--btn-bg) dark:bg-(--btn-bg)/20",
|
|
15
|
+
outline: "border-(--btn-bg) bg-transparent text-(--btn-bg)"
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
sm: "px-2 py-0.5 text-base/6",
|
|
19
|
+
default: "px-3 py-1 text-base/6",
|
|
20
|
+
lg: "px-4 py-1.5 text-base/6"
|
|
21
|
+
}
|
|
346
22
|
},
|
|
347
|
-
size:
|
|
348
|
-
default: styles.size.default,
|
|
349
|
-
sm: styles.size.sm,
|
|
350
|
-
lg: styles.size.lg
|
|
351
|
-
}
|
|
352
|
-
},
|
|
353
|
-
defaultVariants: {
|
|
354
|
-
variant: "soft",
|
|
355
|
-
color: "primary",
|
|
356
|
-
size: "default"
|
|
23
|
+
defaultVariants: { variant: "soft", size: "default" }
|
|
357
24
|
}
|
|
358
|
-
|
|
359
|
-
function
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
25
|
+
);
|
|
26
|
+
function badgeVariants({
|
|
27
|
+
color = "primary",
|
|
28
|
+
variant = "soft",
|
|
29
|
+
class: classValue,
|
|
30
|
+
className,
|
|
31
|
+
...props
|
|
32
|
+
} = {}) {
|
|
33
|
+
return cn(
|
|
34
|
+
badgeCva({ ...props, variant }),
|
|
35
|
+
labelColorVariants(color, variant),
|
|
36
|
+
classValue,
|
|
37
|
+
className
|
|
368
38
|
);
|
|
369
39
|
}
|
|
370
|
-
function
|
|
371
|
-
|
|
372
|
-
// Base
|
|
373
|
-
"group relative inline-flex rounded-sm",
|
|
374
|
-
// Focus
|
|
375
|
-
"focus:outline-1 focus:outline-offset-1 focus:outline-(--focus-outline)",
|
|
376
|
-
// Disabled
|
|
377
|
-
"disabled:pointer-events-none disabled:opacity-50"
|
|
378
|
-
]);
|
|
379
|
-
}
|
|
380
|
-
function BadgeButton({
|
|
381
|
-
variant,
|
|
40
|
+
function Badge({
|
|
41
|
+
variant = "soft",
|
|
382
42
|
color,
|
|
383
43
|
size,
|
|
44
|
+
dot = false,
|
|
384
45
|
className,
|
|
385
46
|
children,
|
|
386
|
-
ref,
|
|
387
47
|
...props
|
|
388
48
|
}) {
|
|
389
|
-
return /* @__PURE__ */
|
|
390
|
-
|
|
49
|
+
return /* @__PURE__ */ jsxs(
|
|
50
|
+
"span",
|
|
391
51
|
{
|
|
392
|
-
"data-
|
|
52
|
+
"data-slot": "badge",
|
|
393
53
|
...props,
|
|
394
|
-
className: clsx(badgeWrapperClasses({ color, className }), "cursor-pointer"),
|
|
395
|
-
ref,
|
|
396
|
-
children: /* @__PURE__ */ jsx(TouchTarget, { children: /* @__PURE__ */ jsx(Badge, { variant, color: color ?? void 0, size, children }) })
|
|
397
|
-
}
|
|
398
|
-
);
|
|
399
|
-
}
|
|
400
|
-
function BadgeLink({ variant, color, size, className, children, ref, ...props }) {
|
|
401
|
-
return /* @__PURE__ */ jsx(
|
|
402
|
-
Link,
|
|
403
|
-
{
|
|
404
|
-
variant: "unstyled",
|
|
405
54
|
"data-variant": variant,
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
55
|
+
className: badgeVariants({ variant, color, size, className }),
|
|
56
|
+
children: [
|
|
57
|
+
dot && /* @__PURE__ */ jsx(
|
|
58
|
+
"span",
|
|
59
|
+
{
|
|
60
|
+
"aria-hidden": true,
|
|
61
|
+
"data-slot": "badge-dot",
|
|
62
|
+
className: "size-2 shrink-0 rounded-full not-forced-colors:bg-current forced-colors:bg-[CanvasText]"
|
|
63
|
+
}
|
|
64
|
+
),
|
|
65
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 [overflow-wrap:anywhere]", children })
|
|
66
|
+
]
|
|
410
67
|
}
|
|
411
68
|
);
|
|
412
69
|
}
|
|
413
70
|
|
|
414
|
-
export { Badge,
|
|
71
|
+
export { Badge, badgeVariants };
|
|
415
72
|
//# sourceMappingURL=badge.js.map
|
|
416
73
|
//# sourceMappingURL=badge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/badge.tsx"],"names":["ButtonPrimitive"],"mappings":";;;;;;;;AAWA,MAAM,YAAA,GAAe;AAAA,EACnB,cAAA,EAAgB;AAAA;AAAA,IAEd,4CAAA;AAAA;AAAA,IAEA,8CAAA;AAAA;AAAA,IAEA,mEAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA,EACA,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G,KAAA,EAAM,EAAmB;AAC/F,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MAIC,OAAA,EAAQ,UAAA;AAAA,MACR,cAAA,EAAc,OAAA;AAAA,MACb,GAAG,KAAA;AAAA,MACJ,SAAA,EAAW,mBAAA,CAAoB,EAAE,KAAA,EAAO,WAAW,CAAA;AAAA,MACnD,GAAA;AAAA,MAEA,QAAA,kBAAA,GAAA,CAAC,WAAA,EAAA,EACC,QAAA,kBAAA,GAAA,CAAC,KAAA,EAAA,EAAM,OAAA,EAAkB,OAAO,KAAA,IAAS,MAAA,EAAW,IAAA,EACjD,QAAA,EACH,CAAA,EACF;AAAA;AAAA,GACF;AAEJ","file":"badge.js","sourcesContent":["'use client'\n\nimport { Button as ButtonPrimitive } from '@base-ui/react/button'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport clsx from 'clsx'\nimport React from 'react'\n\nimport { cn } from '../lib/utils.js'\nimport { TouchTarget } from './button.js'\nimport { Link } from './link.js'\n\nconst focusOutline = {\n 'primary/grey': [\n // Base\n '[--focus-outline:var(--color-primary-800)]',\n // Base dark mode\n 'dark:[--focus-outline:var(--color-grey-600)]',\n // Soft, Surface and outline\n 'data-[variant=soft]:[--focus-outline:var(--color-primary-800)]/20',\n // Soft, Surface and outline dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-grey-200)]/30',\n ],\n light: [\n // Base\n '[--focus-outline:var(--color-grey-300)]',\n // Base dark mode\n 'dark:[--focus-outline:var(--color-grey-100)]',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-grey-200)]/30',\n // Surface\n 'data-[variant=surface]:[--focus-outline:var(--color-grey-600)]',\n // Surface dark mode\n 'dark:data-[variant=surface]:[--focus-outline:var(--color-white)]/70',\n ],\n 'primary/white': [\n // Base\n '[--focus-outline:var(--color-primary-800)]',\n // Base dark mode\n 'dark:[--focus-outline:var(--color-white)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-primary-800)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-grey-200)]/30',\n ],\n grey: [\n // Base\n '[--focus-outline:var(--color-grey-600)]',\n // Base dark mode\n 'dark:[--focus-outline:var(--color-grey-500)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-grey-600)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-grey-200)]/20',\n // Outline dark mode\n 'dark:data-[variant=outline]:[--focus-outline:var(--color-grey-100)]/30',\n // Surface dark mode\n 'dark:data-[variant=surface]:[--focus-outline:var(--color-grey-200)]/20',\n ],\n white: [\n // Base\n '[--focus-outline:var(--color-white)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-white)]/20',\n ],\n primary: [\n // Base\n '[--focus-outline:var(--color-primary-800)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-primary-800)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-primary-800)]/60',\n ],\n secondary: [\n // Base\n '[--focus-outline:var(--color-primary-200)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-primary-200)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-primary-200)]/60',\n ],\n tertiary: [\n // Base\n '[--focus-outline:var(--color-primary-600)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-primary-600)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-primary-600)]/60',\n ],\n accent: [\n // Base\n '[--focus-outline:var(--color-accent-600)]',\n // Soft\n 'data-[variant=soft]:[--focus-outline:var(--color-accent-600)]/20',\n // Soft dark mode\n 'dark:data-[variant=soft]:[--focus-outline:var(--color-accent-600)]/60',\n ],\n}\n\nconst styles = {\n base: [\n // Base\n 'relative isolate inline-flex items-center rounded-sm font-normal border forced-colors:outline motion-safe:transition-all h-fit shrink-0',\n // Icon — one flat size, for the same reason the type scale below is flat.\n '*:data-[slot=icon]:size-4 *:data-[slot=icon]:shrink-0 *:data-[slot=icon]:self-center',\n ],\n solid: [\n // Text color\n 'text-(--badge-text)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--badge-border)',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--badge-bg)',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--badge-bg)',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-white/5',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // White overlay on hover\n 'group-active:after:bg-(--badge-hover-overlay) group-hover:after:bg-(--badge-hover-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n soft: [\n // Text color\n 'text-(--badge-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-transparent bg-(--badge-bg)/5',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--badge-bg)/20',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--badge-bg)/5',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:bg-white/5',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-white/5',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // White overlay on hover\n 'group-active:after:bg-(--badge-hover-overlay) group-hover:after:bg-(--badge-hover-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n surface: [\n // Text color\n 'text-(--badge-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'border-(--badge-bg)/50 bg-(--badge-bg)/5',\n // Dark mode: border is rendered on `after` so background is set to button background\n 'dark:bg-(--badge-bg)/30',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-(--badge-bg)/5',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-(--badge-bg)/50',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // Border color on hover\n 'group-active:border-(--badge-bg) group-hover:border-(--badge-bg)',\n // White overlay on hover\n 'group-active:after:bg-(--badge-hover-overlay) group-hover:after:bg-(--badge-hover-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n outline: [\n // Text color\n 'border-(--badge-bg) text-(--badge-bg)',\n // Optical border, implemented as the button background to avoid corner artifacts\n 'bg-transparent',\n // Button background, implemented as foreground layer to stack on top of pseudo-border layer\n 'before:absolute before:inset-0 before:-z-10 before:rounded-[calc(var(--radius-sm)-1px)] before:bg-transparent',\n // Drop shadow, applied to the inset `before` layer so it blends with the border\n 'before:shadow-sm',\n // Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo\n 'dark:before:hidden',\n // Dark mode: Subtle white outline is applied using a border\n 'dark:border-(--badge-bg)',\n // Shim/overlay, inset to match button foreground and used for hover state + highlight shadow\n 'after:absolute after:inset-0 after:-z-10 after:rounded-[calc(var(--radius-sm)-1px)]',\n // White overlay on hover\n 'group-active:after:bg-(--badge-hover-overlay) group-hover:after:bg-(--badge-hover-overlay)',\n // Dark mode: `after` layer expands to cover entire button\n 'dark:after:-inset-px dark:after:rounded-sm',\n // Disabled\n 'data-disabled:before:shadow-none data-disabled:after:shadow-none',\n ],\n colors: {\n 'primary/grey': [\n // Base\n '[--badge-bg:var(--color-primary-800)] [--badge-border:var(--color-primary-800)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:[--badge-bg:var(--color-grey-600)] dark:[--badge-border:var(--color-grey-600)]/90 dark:[--badge-text:var(--color-white)] dark:text-white',\n // Dark mode states\n 'dark:[--badge-hover-overlay:var(--color-grey-200)]/20',\n ],\n light: [\n // Base\n '[--badge-bg:var(--color-grey-200)] [--badge-border:var(--color-grey-200)]/90 [--badge-text:var(--color-grey-800)]',\n 'text-grey-800',\n // Soft\n 'data-[variant=soft]:[--badge-bg:var(--color-grey-500)]',\n // Surface\n 'data-[variant=surface]:[--badge-bg:var(--color-grey-500)]',\n // States\n '[--badge-hover-overlay:var(--color-grey-200)]/10 data-[variant=outline]:[--badge-hover-overlay:var(--color-grey-200)]/20 data-[variant=solid]:[--badge-hover-overlay:var(--color-grey-400)]/50',\n // Dark mode\n 'dark:text-grey-200 dark:data-[variant=solid]:text-grey-800',\n // Dark mode states\n '',\n ],\n 'primary/white': [\n // Base\n '[--badge-bg:var(--color-primary-800)] [--badge-border:var(--color-primary-800)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:[--badge-bg:var(--color-white)] dark:[--badge-border:var(--color-white)]/90 dark:[--badge-text:var(--color-grey-800)]',\n // Dark mode states\n '',\n ],\n grey: [\n // Base\n '[--badge-bg:var(--color-grey-600)] [--badge-border:var(--color-grey-600)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:text-white',\n // Dark mode states\n '',\n ],\n white: [\n // Base\n '[--badge-bg:var(--color-white)] [--badge-border:var(--color-white)]/90 text-white data-[variant=solid]:text-grey-800',\n // States\n '[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:text-grey-200 dark:data-[variant=solid]:text-grey-800',\n // Dark mode states\n '',\n ],\n primary: [\n // Base\n '[--badge-bg:var(--color-primary-800)] [--badge-border:var(--color-primary-800)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-800)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:text-white dark:bg-(--badge-bg)/40 dark:data-[variant=solid]:bg-(--badge-bg)',\n // Dark mode states\n 'dark:[--badge-hover-overlay:var(--color-primary-800)]/50 dark:data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/5',\n // Dark border\n 'dark:data-[variant=surface]:border-(--badge-border)/60',\n 'dark:data-[variant=outline]:border-(--badge-border)',\n // Dark border states\n 'dark:data-[variant=surface]:active:border-(--badge-border)',\n 'dark:data-[variant=surface]:hover:border-(--badge-border)',\n ],\n secondary: [\n // Base\n '[--badge-bg:var(--color-primary-200)] [--badge-border:var(--color-primary-200)]/90 [--badge-text:var(--color-primary-800)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-200)]/30 data-[variant=solid]:[--badge-hover-overlay:var(--color-primary-250)]',\n // Dark mode\n 'dark:[--badge-bg:var(--color-primary-400)] dark:[--badge-border:var(--color-primary-400)]/90 dark:[--badge-text:white]',\n // Dark mode states\n 'dark:[--badge-hover-overlay:var(--color-primary-400)]/30 dark:data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n ],\n tertiary: [\n // Base\n '[--badge-bg:var(--color-primary-600)] [--badge-border:var(--color-primary-600)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-primary-600)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:[--badge-bg:var(--color-primary-500)] dark:[--badge-border:var(--color-primary-500)]/90 dark:[--badge-text:white]',\n // Dark mode states\n 'dark:[--badge-hover-overlay:var(--color-primary-500)]/30 dark:data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n ],\n accent: [\n // Base\n '[--badge-bg:var(--color-accent-600)] [--badge-border:var(--color-accent-600)]/90 [--badge-text:var(--color-white)]',\n // States\n '[--badge-hover-overlay:var(--color-accent-600)]/10 data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n // Dark mode\n 'dark:[--badge-bg:var(--color-accent-500)] dark:[--badge-border:var(--color-accent-500)]/90 dark:[--badge-text:white]',\n // Dark mode states\n 'dark:[--badge-hover-overlay:var(--color-accent-500)]/30 dark:data-[variant=solid]:[--badge-hover-overlay:var(--color-white)]/10',\n ],\n },\n // ───────────────────────────────────────────────────────────────────────────\n // Type scale (flat — do not reintroduce a `sm:` shrink)\n // ───────────────────────────────────────────────────────────────────────────\n //\n // Each size holds one font-size at every viewport. Sizes are chosen from the\n // hierarchy field.tsx documents: 16px is the body-copy ideal, 14px reads as\n // supporting information, and 12px is below the NSW Government digital\n // service standards minimum body-text size.\n //\n // These variants used to shrink at `sm:` (640px) — `text-sm/5 sm:text-xs/5`\n // and `text-base/5 sm:text-sm/5` — inherited from the Catalyst-derived\n // scaffolding this component started life as (4889aba). That put `default`\n // and `sm` badges at 12px from 640px up, i.e. under the floor precisely where\n // there is the most room, and capped `lg` at 14px so no badge in the system\n // could meet a 16px minimum on desktop. Buttons — which badges sit beside in\n // the header — have always been a flat `text-base/7`, so the shrink was also\n // out of step with its closest sibling.\n //\n // Below 640px nothing changed: every value here is the size that breakpoint\n // already rendered.\n size: {\n default:\n 'py-[calc(--spacing(1))] px-[calc(--spacing(2))] gap-[calc(--spacing(1)*1.5)] text-sm/5',\n sm: 'py-[calc(--spacing(1)*0.5)] px-[calc(--spacing(1)*1.5)] gap-[calc(--spacing(1)*1.5)] text-sm/5',\n lg: 'py-[calc(--spacing(1))] px-[calc(--spacing(2)*1.25)] gap-[calc(--spacing(2))] text-base/5',\n },\n}\n\nconst badgeVariants = cva(styles.base, {\n variants: {\n variant: {\n solid: styles.solid,\n soft: styles.soft,\n surface: styles.surface,\n outline: styles.outline,\n },\n color: {\n 'primary/grey': styles.colors['primary/grey'],\n light: styles.colors.light,\n 'primary/white': styles.colors['primary/white'],\n white: styles.colors.white,\n grey: styles.colors.grey,\n primary: styles.colors.primary,\n secondary: styles.colors.secondary,\n tertiary: styles.colors.tertiary,\n accent: styles.colors.accent,\n },\n size: {\n default: styles.size.default,\n sm: styles.size.sm,\n lg: styles.size.lg,\n },\n },\n defaultVariants: {\n variant: 'soft',\n color: 'primary',\n size: 'default',\n },\n})\n\ntype BadgeProps = VariantProps<typeof badgeVariants> &\n React.ComponentPropsWithoutRef<'span'> & { ref?: React.Ref<HTMLSpanElement> }\n\nfunction Badge({ variant, color, size, className, ref, ...props }: BadgeProps) {\n return (\n <span\n {...props}\n data-variant={variant}\n className={cn(badgeVariants({ variant, color, size }), className)}\n ref={ref}\n />\n )\n}\n\n/** Visual/content props shared by `BadgeButton` and `BadgeLink`. */\ntype BadgeOwnProps = VariantProps<typeof badgeVariants> & {\n className?: string\n children: React.ReactNode\n}\n\ntype BadgeButtonProps = BadgeOwnProps & Omit<ButtonPrimitive.Props, 'className'>\n\ntype BadgeLinkProps = BadgeOwnProps &\n Omit<React.ComponentPropsWithoutRef<typeof Link>, 'className' | 'variant'> & {\n ref?: React.Ref<HTMLAnchorElement>\n }\n\nfunction badgeWrapperClasses({ color, className }: Pick<BadgeOwnProps, 'color' | 'className'>) {\n return clsx(className, focusOutline[(color ?? undefined) as keyof typeof focusOutline], [\n // Base\n 'group relative inline-flex rounded-sm',\n // Focus\n 'focus:outline-1 focus:outline-offset-1 focus:outline-(--focus-outline)',\n // Disabled\n 'disabled:pointer-events-none disabled:opacity-50',\n ])\n}\n\n/**\n * Interactive badge on the Base UI button primitive. For badge-styled\n * navigation, use `BadgeLink` — the `href` polymorphism that previously\n * lived on this component was removed in v2.\n */\nfunction BadgeButton({\n variant,\n color,\n size,\n className,\n children,\n ref,\n ...props\n}: BadgeButtonProps) {\n return (\n <ButtonPrimitive\n data-variant={variant}\n {...props}\n className={clsx(badgeWrapperClasses({ color, className }), 'cursor-pointer')}\n ref={ref}\n >\n <TouchTarget>\n <Badge variant={variant} color={color ?? undefined} size={size}>\n {children}\n </Badge>\n </TouchTarget>\n </ButtonPrimitive>\n )\n}\n\n/** Badge-styled anchor; renders through `Link` (so `LinkProvider` applies). */\nfunction BadgeLink({ variant, color, size, className, children, ref, ...props }: BadgeLinkProps) {\n return (\n <Link\n // Opt out of Link's built-in styling — BadgeLink wraps the inner\n // Badge with its own focus ring / hit target and doesn't want Link's\n // underline, halo, or icon defaults composing on top.\n variant='unstyled'\n data-variant={variant}\n {...props}\n className={badgeWrapperClasses({ color, className })}\n ref={ref}\n >\n <TouchTarget>\n <Badge variant={variant} color={color ?? undefined} size={size}>\n {children}\n </Badge>\n </TouchTarget>\n </Link>\n )\n}\n\nexport { Badge, BadgeButton, BadgeLink, badgeVariants }\nexport type { BadgeButtonProps, BadgeLinkProps, BadgeProps }\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/badge.tsx"],"names":[],"mappings":";;;;;AAQA,MAAM,QAAA,GAAW,GAAA;AAAA,EACf,yQAAA;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,M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AAA;AAAA,YACV,SAAA,EAAU;AAAA;AAAA,SACZ;AAAA,wBAEF,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,kCAAA,EAAoC,QAAA,EAAS;AAAA;AAAA;AAAA,GAC/D;AAEJ","file":"badge.js","sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport type * as React from 'react'\n\nimport { labelColorVariants, type LabelColor } from '../lib/label-colors.js'\nimport { cn } from '../lib/utils.js'\n\nconst badgeCva = cva(\n 'inline-flex max-w-full items-center justify-center gap-1.5 rounded-full border align-middle font-normal forced-colors:border-[CanvasText] [&_[data-slot=icon]]:inline-block [&_[data-slot=icon]]:size-4 [&_[data-slot=icon]]:shrink-0 [&_[data-slot=icon]]:align-middle',\n {\n variants: {\n variant: {\n solid: 'border-transparent bg-(--btn-fill) text-(--btn-text)',\n soft: 'border-transparent bg-(--btn-bg)/10 text-(--btn-bg) dark:bg-(--btn-bg)/20',\n surface: 'border-(--btn-bg)/50 bg-(--btn-bg)/5 text-(--btn-bg) dark:bg-(--btn-bg)/20',\n outline: 'border-(--btn-bg) bg-transparent text-(--btn-bg)',\n },\n size: {\n sm: 'px-2 py-0.5 text-base/6',\n default: 'px-3 py-1 text-base/6',\n lg: 'px-4 py-1.5 text-base/6',\n },\n },\n defaultVariants: { variant: 'soft', size: 'default' },\n },\n)\n\ntype BadgeVariantProps = NonNullable<Parameters<typeof badgeCva>[0]> & {\n color?: LabelColor | 'light' | null\n}\n\nfunction badgeVariants({\n color = 'primary',\n variant = 'soft',\n class: classValue,\n className,\n ...props\n}: BadgeVariantProps = {}) {\n return cn(\n badgeCva({ ...props, variant }),\n labelColorVariants(color, variant),\n classValue,\n className,\n )\n}\n\ntype BadgeProps = VariantProps<typeof badgeVariants> &\n React.ComponentPropsWithoutRef<'span'> & {\n ref?: React.Ref<HTMLSpanElement>\n /** Decorative status dot; always accompany it with a visible status label. */\n dot?: boolean\n }\n\n/** Static status or count. Categories and interactive labels belong to Tag. */\nfunction Badge({\n variant = 'soft',\n color,\n size,\n dot = false,\n className,\n children,\n ...props\n}: BadgeProps) {\n return (\n <span\n data-slot='badge'\n {...props}\n data-variant={variant}\n className={badgeVariants({ variant, color, size, className })}\n >\n {dot && (\n <span\n aria-hidden\n data-slot='badge-dot'\n className='size-2 shrink-0 rounded-full not-forced-colors:bg-current forced-colors:bg-[CanvasText]'\n />\n )}\n <span className='min-w-0 [overflow-wrap:anywhere]'>{children}</span>\n </span>\n )\n}\n\nexport { Badge, badgeVariants }\nexport type { BadgeProps }\n"]}
|
|
@@ -6,8 +6,8 @@ import { Link } from './link.js';
|
|
|
6
6
|
|
|
7
7
|
declare const buttonCva: (props?: ({
|
|
8
8
|
variant?: "link" | "solid" | "soft" | "surface" | "outline" | "ghost" | null | undefined;
|
|
9
|
-
color?: "
|
|
10
|
-
size?: "default" | "
|
|
9
|
+
color?: "primary" | "secondary" | "white" | "accent" | "tertiary" | "success" | "warning" | "grey" | "danger" | null | undefined;
|
|
10
|
+
size?: "default" | "icon" | "sm" | "lg" | null | undefined;
|
|
11
11
|
iconOnly?: boolean | null | undefined;
|
|
12
12
|
onTint?: boolean | null | undefined;
|
|
13
13
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
@@ -27,7 +27,7 @@ type ButtonVariantProps = NonNullable<Parameters<typeof buttonCva>[0]>;
|
|
|
27
27
|
*/
|
|
28
28
|
declare function buttonVariants({ onTint, ...props }?: ButtonVariantProps): string;
|
|
29
29
|
declare const buttonColorCva: (props?: ({
|
|
30
|
-
color?: "
|
|
30
|
+
color?: "primary" | "secondary" | "white" | "accent" | "tertiary" | "success" | "warning" | "grey" | "danger" | null | undefined;
|
|
31
31
|
onTint?: boolean | null | undefined;
|
|
32
32
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
33
33
|
/**
|