forked from Dshield-xyz/Dshield
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelectButton.tsx
More file actions
56 lines (53 loc) · 1.39 KB
/
Copy pathSelectButton.tsx
File metadata and controls
56 lines (53 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/cn";
const selectButton = cva(
"focus-ring block rounded-xl border p-3 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50",
{
variants: {
selected: {
true: "",
false: "border-zinc-700 text-zinc-400 hover:border-brand-500/50",
},
tone: {
white: "",
accent: "",
},
},
compoundVariants: [
{
selected: true,
tone: "white",
class: "border-white bg-zinc-800 text-white",
},
{
selected: true,
tone: "accent",
class: "border-brand-500 bg-brand-950/30 text-brand-300",
},
],
defaultVariants: { selected: false, tone: "accent" },
},
);
export interface SelectButtonProps
extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "type">,
VariantProps<typeof selectButton> {}
/**
* A toggleable selection button used for denomination tiers, note pickers, and
* mode switches. `selected` drives the active styling; `tone` chooses the
* active accent (neutral white or brand).
*/
export function SelectButton({
className,
selected,
tone,
...props
}: SelectButtonProps) {
return (
<button
type="button"
aria-pressed={!!selected}
className={cn(selectButton({ selected, tone }), className)}
{...props}
/>
);
}