aboutsummaryrefslogtreecommitdiff
path: root/packages/memory-graph/src/ui/badge.css.ts
blob: 0f8cbc92c1f0b289de5a05bfbefe8aaae77bc2bb (plain) (blame)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import { recipe, type RecipeVariants } from "@vanilla-extract/recipes"
import { style, globalStyle } from "@vanilla-extract/css"
import { themeContract } from "../styles/theme.css"

/**
 * Base styles for SVG icons inside badges
 */
export const badgeIcon = style({
	width: "0.75rem",
	height: "0.75rem",
	pointerEvents: "none",
})

/**
 * Badge recipe with variants
 * Replaces CVA-based badge variants with vanilla-extract recipes
 */
const badgeBase = style({
	display: "inline-flex",
	alignItems: "center",
	justifyContent: "center",
	borderRadius: themeContract.radii.md,
	border: "1px solid",
	paddingLeft: themeContract.space[2],
	paddingRight: themeContract.space[2],
	paddingTop: "0.125rem",
	paddingBottom: "0.125rem",
	fontSize: themeContract.typography.fontSize.xs,
	fontWeight: themeContract.typography.fontWeight.medium,
	width: "fit-content",
	whiteSpace: "nowrap",
	flexShrink: 0,
	gap: themeContract.space[1],
	transition: "color 200ms ease-in-out, box-shadow 200ms ease-in-out",
	overflow: "hidden",

	selectors: {
		"&:focus-visible": {
			borderColor: themeContract.colors.accent.primary,
			boxShadow: `0 0 0 2px ${themeContract.colors.accent.primary}33`,
		},
		"&[aria-invalid='true']": {
			boxShadow: `0 0 0 2px ${themeContract.colors.status.forgotten}33`,
			borderColor: themeContract.colors.status.forgotten,
		},
	},
})

// Global style for SVG children
globalStyle(`${badgeBase} > svg`, {
	width: "0.75rem",
	height: "0.75rem",
	pointerEvents: "none",
})

export const badge = recipe({
	base: badgeBase,

	variants: {
		variant: {
			default: {
				borderColor: "transparent",
				backgroundColor: themeContract.colors.accent.primary,
				color: themeContract.colors.text.primary,

				selectors: {
					"a&:hover": {
						opacity: 0.9,
					},
				},
			},

			secondary: {
				borderColor: "transparent",
				backgroundColor: themeContract.colors.background.secondary,
				color: themeContract.colors.text.secondary,

				selectors: {
					"a&:hover": {
						backgroundColor: themeContract.colors.background.accent,
					},
				},
			},

			destructive: {
				borderColor: "transparent",
				backgroundColor: themeContract.colors.status.forgotten,
				color: themeContract.colors.text.primary,

				selectors: {
					"a&:hover": {
						opacity: 0.9,
					},
					"&:focus-visible": {
						boxShadow: `0 0 0 2px ${themeContract.colors.status.forgotten}33`,
					},
				},
			},

			outline: {
				borderColor: themeContract.colors.document.border,
				backgroundColor: "transparent",
				color: themeContract.colors.text.primary,

				selectors: {
					"a&:hover": {
						backgroundColor: themeContract.colors.document.primary,
					},
				},
			},
		},
	},

	defaultVariants: {
		variant: "default",
	},
})

export type BadgeVariants = RecipeVariants<typeof badge>