torch-glare 1.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/LICENSE +21 -0
- package/README.md +207 -0
- package/cli/bin/addComponent.js +278 -0
- package/cli/bin/addHooks.js +75 -0
- package/cli/bin/addLayout.js +71 -0
- package/cli/bin/addProvider.js +71 -0
- package/cli/bin/addUtils.js +74 -0
- package/cli/bin/cli.js +73 -0
- package/cli/bin/init/init.js +15 -0
- package/cli/bin/init/tailwindInit.js +174 -0
- package/cli/bin/update.js +147 -0
- package/lib/components/ActionButton.tsx +63 -0
- package/lib/components/ActionsGroup.tsx +34 -0
- package/lib/components/AlertDialog.tsx +211 -0
- package/lib/components/Badge.tsx +116 -0
- package/lib/components/BadgeField.tsx +192 -0
- package/lib/components/Button.tsx +277 -0
- package/lib/components/Card.tsx +63 -0
- package/lib/components/Checkbox.tsx +104 -0
- package/lib/components/CountBadge.tsx +54 -0
- package/lib/components/DatePicker.tsx +464 -0
- package/lib/components/Drawer.tsx +118 -0
- package/lib/components/DropdownMenu.tsx +399 -0
- package/lib/components/FieldHint.tsx +76 -0
- package/lib/components/ImageAttachment.tsx +171 -0
- package/lib/components/InnerLabelField.tsx +155 -0
- package/lib/components/Input.tsx +179 -0
- package/lib/components/InputField.tsx +147 -0
- package/lib/components/Label.tsx +107 -0
- package/lib/components/LabelField.tsx +75 -0
- package/lib/components/LabeledCheckBox.tsx +65 -0
- package/lib/components/LabeledRadio.tsx +45 -0
- package/lib/components/LinkButton.tsx +90 -0
- package/lib/components/LoginButton.tsx +56 -0
- package/lib/components/PasswordLevel.tsx +58 -0
- package/lib/components/Popover.tsx +274 -0
- package/lib/components/ProfileMenu.tsx +90 -0
- package/lib/components/Radio.tsx +69 -0
- package/lib/components/RadioCard.tsx +70 -0
- package/lib/components/RingLoading.tsx +190 -0
- package/lib/components/SearchField.tsx +49 -0
- package/lib/components/Select.tsx +417 -0
- package/lib/components/SlideDatePicker.tsx +120 -0
- package/lib/components/SpinLoading.tsx +190 -0
- package/lib/components/Switcher.tsx +56 -0
- package/lib/components/TabFormItem.tsx +158 -0
- package/lib/components/Table.tsx +395 -0
- package/lib/components/Textarea.tsx +108 -0
- package/lib/components/Tooltip.tsx +111 -0
- package/lib/components/TransparentLabel.tsx +72 -0
- package/lib/components/TreeDropDown.tsx +69 -0
- package/lib/hooks/MobileSlidePicker/components/Picker.tsx +218 -0
- package/lib/hooks/MobileSlidePicker/components/PickerColumn.tsx +238 -0
- package/lib/hooks/MobileSlidePicker/components/PickerItem.tsx +64 -0
- package/lib/hooks/MobileSlidePicker/index.ts +10 -0
- package/lib/hooks/useActiveTreeItem.tsx +61 -0
- package/lib/hooks/useClickOutside.tsx +20 -0
- package/lib/hooks/useResize.tsx +78 -0
- package/lib/layouts/CLayout.tsx +326 -0
- package/lib/layouts/FieldSection.tsx +64 -0
- package/lib/layouts/TreeSubLayout.tsx +187 -0
- package/lib/providers/ThemeProvider.tsx +99 -0
- package/lib/utils/cn.ts +6 -0
- package/lib/utils/convertImageFileToDataUrl.ts +17 -0
- package/lib/utils/resize.ts +35 -0
- package/lib/utils/types.ts +12 -0
- package/package.json +28 -0
- package/torch-glare.js +24 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import React, { ButtonHTMLAttributes, forwardRef } from "react";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
import { cn } from "../utils/cn";
|
|
5
|
+
import { ButtonVariant, Themes } from "../utils/types";
|
|
6
|
+
|
|
7
|
+
export const buttonVariants = cva(
|
|
8
|
+
"flex items-center whitespace-nowrap justify-center transition-[background,color] duration-200 ease-in-out border border-transparent outline-none leading-none [&-i]:!leading-none",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
// fucus styles for medium screens and above
|
|
13
|
+
PrimeStyle: [
|
|
14
|
+
"bg-background-presentation-action-secondary",
|
|
15
|
+
"text-content-presentation-action-light-primary",
|
|
16
|
+
"hover:bg-background-presentation-action-hover",
|
|
17
|
+
"hover:text-content-presentation-action-hover",
|
|
18
|
+
"focus:lg:focus:md:border lg:focus:md:border-border-presentation-state-focus", // Focus style only for medium screens and above
|
|
19
|
+
"active:bg-background-presentation-action-hover active:text-content-presentation-action-hover",
|
|
20
|
+
],
|
|
21
|
+
BlueSecStyle: [
|
|
22
|
+
"bg-background-presentation-action-secondary",
|
|
23
|
+
"text-content-presentation-action-light-primary",
|
|
24
|
+
"hover:bg-background-presentation-state-information-primary",
|
|
25
|
+
"hover:text-content-presentation-action-hover",
|
|
26
|
+
"focus:lg:border focus:lg:border-border-presentation-state-focus",
|
|
27
|
+
"active:bg-background-presentation-state-information-primary active:text-content-presentation-action-hover",
|
|
28
|
+
],
|
|
29
|
+
YelSecStyle: [
|
|
30
|
+
"bg-background-presentation-action-secondary",
|
|
31
|
+
"text-content-presentation-action-light-primary",
|
|
32
|
+
"hover:bg-background-presentation-state-warning-primary",
|
|
33
|
+
"hover:text-content-presentation-action-light-primary",
|
|
34
|
+
"focus:lg:border focus:lg:border-border-presentation-state-focus",
|
|
35
|
+
"active:bg-background-presentation-state-warning-primary active:text-content-presentation-action-light-primary",
|
|
36
|
+
],
|
|
37
|
+
RedSecStyle: [
|
|
38
|
+
"bg-background-presentation-action-secondary",
|
|
39
|
+
"text-content-presentation-action-light-primary",
|
|
40
|
+
"hover:bg-background-presentation-state-negative-primary",
|
|
41
|
+
"hover:text-content-presentation-action-hover",
|
|
42
|
+
"focus:lg:border focus:lg:border-border-presentation-state-focus",
|
|
43
|
+
"active:bg-background-presentation-state-negative-primary active:text-content-presentation-action-hover",
|
|
44
|
+
],
|
|
45
|
+
BorderStyle: [
|
|
46
|
+
"text-content-presentation-action-light-primary",
|
|
47
|
+
"border border-border-presentation-action-disabled",
|
|
48
|
+
"bg-background-presentation-action-borderstyle",
|
|
49
|
+
"hover:bg-background-presentation-action-hover",
|
|
50
|
+
"hover:text-content-presentation-action-hover",
|
|
51
|
+
"focus:lg:border focus:lg:border-border-presentation-state-focus",
|
|
52
|
+
"focus:lg:text-content-presentation-action-light-primary",
|
|
53
|
+
"focus:hover:lg:text-content-presentation-action-hover",
|
|
54
|
+
"active:bg-background-presentation-action-hover active:text-content-presentation-action-hover",
|
|
55
|
+
],
|
|
56
|
+
PrimeContStyle: [
|
|
57
|
+
"text-content-presentation-action-light-primary",
|
|
58
|
+
"border-transparent bg-transparent",
|
|
59
|
+
"hover:bg-background-presentation-action-contstyle-hover",
|
|
60
|
+
"hover:text-content-presentation-action-light-primary",
|
|
61
|
+
"focus:lg:border focus:lg:border-border-presentation-state-focus",
|
|
62
|
+
"focus:lg:bg-background-presentation-action-borderstyle",
|
|
63
|
+
"active:bg-background-presentation-action-contstyle-hover active:text-content-presentation-action-light-primary",
|
|
64
|
+
],
|
|
65
|
+
BlueContStyle: [
|
|
66
|
+
"text-content-presentation-action-light-primary",
|
|
67
|
+
"border-transparent bg-transparent",
|
|
68
|
+
"hover:bg-background-presentation-action-contstyle-hover",
|
|
69
|
+
"hover:text-content-presentation-action-information-hover",
|
|
70
|
+
"focus:lg:border focus:lg:border-border-presentation-state-focus",
|
|
71
|
+
"focus:lg:bg-background-presentation-action-borderstyle",
|
|
72
|
+
"active:bg-background-presentation-action-contstyle-hover active:text-content-presentation-action-information-hover",
|
|
73
|
+
],
|
|
74
|
+
RedContStyle: [
|
|
75
|
+
"text-content-presentation-action-light-primary",
|
|
76
|
+
"border-transparent bg-transparent",
|
|
77
|
+
"hover:bg-background-presentation-action-contstyle-hover",
|
|
78
|
+
"hover:text-content-presentation-action-negative-hover",
|
|
79
|
+
"focus:lg:border focus:lg:border-border-presentation-state-focus",
|
|
80
|
+
"focus:lg:bg-background-presentation-action-borderstyle",
|
|
81
|
+
"active:bg-background-presentation-action-contstyle-hover active:text-content-presentation-action-negative-hover",
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
size: {
|
|
85
|
+
S: "h-[22px] px-[6px] typography-body-small-medium rounded-[4px] [&_i]:text-[12px]",
|
|
86
|
+
M: "h-[28px] px-[14px] typography-body-large-medium rounded-[4px] [&_i]:text-[18px]",
|
|
87
|
+
L: "h-[34px] px-[22px] typography-body-large-medium rounded-[6px] [&_i]:text-[20px]",
|
|
88
|
+
XL: "h-[40px] px-[30px] typography-headers-medium-medium rounded-[6px] [&_i]:text-[22px]",
|
|
89
|
+
},
|
|
90
|
+
is_loading: {
|
|
91
|
+
true: "",
|
|
92
|
+
},
|
|
93
|
+
disabled: {
|
|
94
|
+
true: "cursor-not-allowed",
|
|
95
|
+
},
|
|
96
|
+
buttonType: {
|
|
97
|
+
button: "",
|
|
98
|
+
icon: "",
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
defaultVariants: {
|
|
102
|
+
size: "M",
|
|
103
|
+
variant: "PrimeStyle",
|
|
104
|
+
buttonType: "button",
|
|
105
|
+
},
|
|
106
|
+
compoundVariants: [
|
|
107
|
+
{
|
|
108
|
+
is_loading: true,
|
|
109
|
+
className: [
|
|
110
|
+
"cursor-wait",
|
|
111
|
+
"bg-background-presentation-action-hover",
|
|
112
|
+
"text-content-presentation-action-hover",
|
|
113
|
+
"hover:bg-background-presentation-action-hover",
|
|
114
|
+
"hover:text-content-presentation-action-hover",
|
|
115
|
+
"focus:lg:border focus:lg:border-transparent",
|
|
116
|
+
"active:bg-background-presentation-action-hover active:text-content-presentation-action-hover",
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
disabled: true,
|
|
121
|
+
className: [
|
|
122
|
+
"cursor-not-allowed",
|
|
123
|
+
"pointer-events-none",
|
|
124
|
+
"bg-background-presentation-action-disabled",
|
|
125
|
+
"text-content-presentation-state-disabled",
|
|
126
|
+
"border-transparent",
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
buttonType: "icon",
|
|
131
|
+
size: "S",
|
|
132
|
+
className: "w-[22px] h-[22px] p-0 leading-[0]",
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
buttonType: "icon",
|
|
136
|
+
size: "M",
|
|
137
|
+
className: "w-[28px] h-[28px] p-0 leading-[0]",
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
buttonType: "icon",
|
|
141
|
+
size: "L",
|
|
142
|
+
className: "w-[34px] h-[34px] p-0 leading-[0]",
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
buttonType: "icon",
|
|
146
|
+
size: "XL",
|
|
147
|
+
className: "w-[40px] h-[40px] p-0 leading-[0]",
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
interface Props
|
|
154
|
+
extends ButtonHTMLAttributes<HTMLButtonElement>,
|
|
155
|
+
VariantProps<typeof buttonVariants> {
|
|
156
|
+
is_loading?: boolean;
|
|
157
|
+
disabled?: boolean;
|
|
158
|
+
asChild?: boolean;
|
|
159
|
+
variant?: ButtonVariant;
|
|
160
|
+
as?: React.ElementType;
|
|
161
|
+
theme?: Themes
|
|
162
|
+
}
|
|
163
|
+
export const Button = forwardRef<HTMLButtonElement, Props>(
|
|
164
|
+
(
|
|
165
|
+
{
|
|
166
|
+
is_loading = false,
|
|
167
|
+
variant,
|
|
168
|
+
size,
|
|
169
|
+
asChild,
|
|
170
|
+
as: Tag = "button",
|
|
171
|
+
buttonType,
|
|
172
|
+
className,
|
|
173
|
+
disabled,
|
|
174
|
+
theme,
|
|
175
|
+
children,
|
|
176
|
+
...props
|
|
177
|
+
},
|
|
178
|
+
ref
|
|
179
|
+
) => {
|
|
180
|
+
const Component = asChild ? Slot : Tag;
|
|
181
|
+
|
|
182
|
+
const wrapTextContent = (children: React.ReactNode) => {
|
|
183
|
+
if (Array.isArray(children)) {
|
|
184
|
+
return children.map((child, index) => {
|
|
185
|
+
if (typeof child === "string" && child.trim() !== "") {
|
|
186
|
+
return (
|
|
187
|
+
<p key={index} className="px-[3px]">
|
|
188
|
+
{child}
|
|
189
|
+
</p>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
return child;
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (children && typeof children === "string" && children.trim() !== "") {
|
|
197
|
+
return <p className="px-[3px]">{children}</p>;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return children;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<Component
|
|
205
|
+
{...props}
|
|
206
|
+
data-theme={theme}
|
|
207
|
+
disabled={disabled || is_loading}
|
|
208
|
+
ref={ref}
|
|
209
|
+
className={cn(
|
|
210
|
+
buttonVariants({
|
|
211
|
+
variant,
|
|
212
|
+
size,
|
|
213
|
+
is_loading,
|
|
214
|
+
buttonType,
|
|
215
|
+
disabled,
|
|
216
|
+
}),
|
|
217
|
+
className
|
|
218
|
+
)}
|
|
219
|
+
>
|
|
220
|
+
{asChild ? (
|
|
221
|
+
React.cloneElement(
|
|
222
|
+
children as React.ReactElement,
|
|
223
|
+
{},
|
|
224
|
+
<>
|
|
225
|
+
{(children as React.ReactElement<any>).props.children}
|
|
226
|
+
{is_loading && <LoadingIcon size={size} />}
|
|
227
|
+
</>
|
|
228
|
+
)
|
|
229
|
+
) : (
|
|
230
|
+
<>
|
|
231
|
+
{wrapTextContent(children)}
|
|
232
|
+
{is_loading && <LoadingIcon size={size} />}
|
|
233
|
+
</>
|
|
234
|
+
)}
|
|
235
|
+
</Component>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
Button.displayName = "Button"
|
|
241
|
+
|
|
242
|
+
export function LoadingIcon({ size, className }: {
|
|
243
|
+
size?: "S" | "M" | "L" | "XL" | null;
|
|
244
|
+
className?: string;
|
|
245
|
+
}) {
|
|
246
|
+
const iconVariants = cva("animate-spin ", {
|
|
247
|
+
variants: {
|
|
248
|
+
size: {
|
|
249
|
+
S: "w-[12px] h-[12px]",
|
|
250
|
+
M: "w-[18px] h-[18px]",
|
|
251
|
+
L: "w-[20px] h-[20px]",
|
|
252
|
+
XL: "w-[20px] h-[20px]"
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
defaultVariants: {
|
|
256
|
+
size: "M",
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
return (
|
|
261
|
+
<svg
|
|
262
|
+
className={cn(iconVariants({ size, className }))}
|
|
263
|
+
viewBox="0 0 12 12"
|
|
264
|
+
fill="none"
|
|
265
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
266
|
+
>
|
|
267
|
+
<path
|
|
268
|
+
d="M11 6C11 8.76142 8.76142 11 6 11C3.23858 11 1 8.76142 1 6C1 3.23858 3.23858 1 6 1C8.76142 1 11 3.23858 11 6ZM2.25 6C2.25 8.07107 3.92893 9.75 6 9.75C8.07107 9.75 9.75 8.07107 9.75 6C9.75 3.92893 8.07107 2.25 6 2.25C3.92893 2.25 2.25 3.92893 2.25 6Z"
|
|
269
|
+
fill="#F4F4F4"
|
|
270
|
+
/>
|
|
271
|
+
<path
|
|
272
|
+
d="M11 6C11 5.34339 10.8707 4.69321 10.6194 4.08658C10.3681 3.47995 9.99983 2.92876 9.53553 2.46447C9.07124 2.00017 8.52004 1.63188 7.91342 1.3806C7.30679 1.12933 6.65661 1 6 1V2.25C6.49246 2.25 6.98009 2.347 7.43506 2.53545C7.89003 2.72391 8.30343 3.00013 8.65165 3.34835C8.99987 3.69657 9.27609 4.10997 9.46455 4.56494C9.653 5.01991 9.75 5.50754 9.75 6H11Z"
|
|
273
|
+
fill="#0075FF"
|
|
274
|
+
/>
|
|
275
|
+
</svg>
|
|
276
|
+
);
|
|
277
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { cn } from '@/utils/cn';
|
|
2
|
+
import React, { HTMLAttributes } from 'react'
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
interface Props extends Omit<HTMLAttributes<HTMLDivElement | HTMLHeadingElement | HTMLParagraphElement | HTMLLabelElement>, 'htmlFor'> {
|
|
7
|
+
as?: React.ElementType;
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
htmlFor?: string;
|
|
10
|
+
}
|
|
11
|
+
export const Card = ({ className, htmlFor, asChild, as: Tag = "section", ...props }: Props) => {
|
|
12
|
+
const Component = asChild ? Slot : Tag;
|
|
13
|
+
return (
|
|
14
|
+
<Component htmlFor={htmlFor} {...props} className={cn(
|
|
15
|
+
"flex flex-col justify-start",
|
|
16
|
+
"gap-2 rounded-[12px] border",
|
|
17
|
+
"transition-all ease-in-out duration-200",
|
|
18
|
+
"p-[16px]",
|
|
19
|
+
"border-border-presentation-global-primary",
|
|
20
|
+
"bg-background-presentation-form-radiocard-base",
|
|
21
|
+
"hover:border-border-presentation-state-focus",
|
|
22
|
+
className
|
|
23
|
+
)} />
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
interface GeneralProps extends HTMLAttributes<HTMLHeadingElement> { }
|
|
30
|
+
|
|
31
|
+
export const CardHeader = ({ className, ...props }: GeneralProps) => {
|
|
32
|
+
return (
|
|
33
|
+
<h1
|
|
34
|
+
{...props}
|
|
35
|
+
className={cn(
|
|
36
|
+
"text-content-presentation-global-primary m-0 typography-headers-medium-semibold",
|
|
37
|
+
className
|
|
38
|
+
)}
|
|
39
|
+
>
|
|
40
|
+
</h1>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const CardDescription = ({ className, ...props }: GeneralProps) => {
|
|
45
|
+
return (
|
|
46
|
+
<article
|
|
47
|
+
{...props}
|
|
48
|
+
className={cn(
|
|
49
|
+
"text-content-presentation-global-primary m-0 typography-body-medium-semibold",
|
|
50
|
+
className
|
|
51
|
+
)}
|
|
52
|
+
>
|
|
53
|
+
</article>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const CardContent = ({ className, ...props }: GeneralProps) => {
|
|
58
|
+
return (
|
|
59
|
+
<section {...props} className={cn("flex gap-1 flex-col items-start flex-1", className)}>
|
|
60
|
+
</section>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { InputHTMLAttributes, forwardRef, useState } from "react";
|
|
3
|
+
import { cn } from "../utils/cn";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
interface CheckBoxProps
|
|
8
|
+
extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
9
|
+
size?: "S" | "M" | "L";
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Checkbox = forwardRef<HTMLInputElement, CheckBoxProps>(
|
|
14
|
+
({ size = "M", ...props }, ref) => {
|
|
15
|
+
const [checked, setChecked] = useState(props.checked);
|
|
16
|
+
return (
|
|
17
|
+
<label htmlFor={props.id} className="flex items-center justify-center gap-1">
|
|
18
|
+
<input
|
|
19
|
+
{...props}
|
|
20
|
+
children={null}
|
|
21
|
+
id={props.id}
|
|
22
|
+
onChange={(e) => {
|
|
23
|
+
props.onChange?.(e);
|
|
24
|
+
setChecked(e.target.checked);
|
|
25
|
+
}}
|
|
26
|
+
type="checkbox"
|
|
27
|
+
hidden
|
|
28
|
+
ref={ref}
|
|
29
|
+
/>
|
|
30
|
+
<CheckboxIcon size={size} checked={checked} disabled={props.disabled} />
|
|
31
|
+
{props.children}
|
|
32
|
+
</label>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
Checkbox.displayName = "Checkbox";
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const glareCheckBoxStyles = cva(
|
|
42
|
+
[
|
|
43
|
+
"w-[16px]",
|
|
44
|
+
"h-[16px]",
|
|
45
|
+
"rounded-[3px]",
|
|
46
|
+
"border",
|
|
47
|
+
"border-border-presentation-action-checkbox-primary",
|
|
48
|
+
"bg-background-presentation-action-borderstyle",
|
|
49
|
+
"flex",
|
|
50
|
+
"items-center",
|
|
51
|
+
"justify-center",
|
|
52
|
+
"transition-colors",
|
|
53
|
+
"group-hover:bg-blue-sparkle-alpha-15 group-hover:border-border-presentation-state-focus",
|
|
54
|
+
],
|
|
55
|
+
{
|
|
56
|
+
variants: {
|
|
57
|
+
checked: {
|
|
58
|
+
true: [
|
|
59
|
+
"bg-background-presentation-state-information-primary border-transparent",
|
|
60
|
+
"group-hover:bg-background-presentation-state-information-primary group-hover:border-transparent",
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
disabled: {
|
|
64
|
+
true: [
|
|
65
|
+
"border-border-presentation-global-primary",
|
|
66
|
+
"!bg-background-presentation-action-disabled",
|
|
67
|
+
"cursor-not-allowed",
|
|
68
|
+
"hover:!border-border-presentation-global-primary",
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
defaultVariants: {
|
|
73
|
+
disabled: false,
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
const CheckboxIcon = ({ size, checked, disabled }: { size: "S" | "M" | "L", checked?: boolean, disabled?: boolean }) => {
|
|
80
|
+
return (
|
|
81
|
+
<div
|
|
82
|
+
className={cn(
|
|
83
|
+
glareCheckBoxStyles({
|
|
84
|
+
disabled: disabled,
|
|
85
|
+
checked,
|
|
86
|
+
}),
|
|
87
|
+
{
|
|
88
|
+
"w-[14px] h-[14px]": size === "S",
|
|
89
|
+
"w-[16px] h-[16px]": size === "M" || size === "L",
|
|
90
|
+
}
|
|
91
|
+
)}
|
|
92
|
+
>
|
|
93
|
+
<i
|
|
94
|
+
className={cn(
|
|
95
|
+
"ri-check-line",
|
|
96
|
+
"text-white transition-opacity opacity-0",
|
|
97
|
+
{
|
|
98
|
+
"opacity-100": checked,
|
|
99
|
+
}
|
|
100
|
+
)}
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
)
|
|
104
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from "react";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { cn } from "../utils/cn";
|
|
4
|
+
import { Themes } from "../utils/types";
|
|
5
|
+
|
|
6
|
+
// Glare counter base styles
|
|
7
|
+
export const glareCounterStyles = cva(
|
|
8
|
+
[
|
|
9
|
+
"flex justify-center items-center",
|
|
10
|
+
"w-[14px] h-[14px]",
|
|
11
|
+
"rounded-full",
|
|
12
|
+
"border border-background-system-body-primary",
|
|
13
|
+
"bg-background-system-state-negative",
|
|
14
|
+
"text-[8px]",
|
|
15
|
+
"text-white",
|
|
16
|
+
"overflow-hidden",
|
|
17
|
+
"h-[15px] w-[15px]",
|
|
18
|
+
],
|
|
19
|
+
{
|
|
20
|
+
variants: {
|
|
21
|
+
variant: {
|
|
22
|
+
default: "bg-background-system-state-negative",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
defaultVariants: {
|
|
26
|
+
variant: "default",
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
// Extracting the types of the variants used in glareCounterStyles
|
|
32
|
+
export type GlareCounterStylesProps = VariantProps<typeof glareCounterStyles>;
|
|
33
|
+
|
|
34
|
+
interface Props
|
|
35
|
+
extends HTMLAttributes<HTMLDivElement>,
|
|
36
|
+
GlareCounterStylesProps {
|
|
37
|
+
label: number; // label of the counter it should be a number
|
|
38
|
+
theme?: Themes
|
|
39
|
+
className?: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const CountBadge: React.FC<Props> = ({ theme, label, variant, className, ...props }) => {
|
|
43
|
+
return (
|
|
44
|
+
<section
|
|
45
|
+
{...props}
|
|
46
|
+
data-theme={theme}
|
|
47
|
+
className={cn(glareCounterStyles({ variant }), className)}
|
|
48
|
+
>
|
|
49
|
+
<p>{label}</p>
|
|
50
|
+
</section>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default CountBadge;
|