@dust-tt/sparkle 0.3.4 → 0.3.5

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.
Files changed (40) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/esm/components/Avatar.d.ts +4 -2
  3. package/dist/esm/components/Avatar.d.ts.map +1 -1
  4. package/dist/esm/components/Avatar.js +10 -2
  5. package/dist/esm/components/Avatar.js.map +1 -1
  6. package/dist/esm/components/Card.d.ts +2 -2
  7. package/dist/esm/components/Card.d.ts.map +1 -1
  8. package/dist/esm/components/Card.js +11 -13
  9. package/dist/esm/components/Card.js.map +1 -1
  10. package/dist/esm/components/Checkbox.d.ts +1 -0
  11. package/dist/esm/components/Checkbox.d.ts.map +1 -1
  12. package/dist/esm/components/Checkbox.js +4 -5
  13. package/dist/esm/components/Checkbox.js.map +1 -1
  14. package/dist/esm/components/Chip.js +25 -40
  15. package/dist/esm/components/Chip.js.map +1 -1
  16. package/dist/esm/components/IconButton.d.ts +9 -7
  17. package/dist/esm/components/IconButton.d.ts.map +1 -1
  18. package/dist/esm/components/IconButton.js +13 -15
  19. package/dist/esm/components/IconButton.js.map +1 -1
  20. package/dist/esm/components/Label.d.ts +6 -2
  21. package/dist/esm/components/Label.d.ts.map +1 -1
  22. package/dist/esm/components/Label.js +16 -6
  23. package/dist/esm/components/Label.js.map +1 -1
  24. package/dist/esm/components/Notification.js +11 -11
  25. package/dist/esm/components/Notification.js.map +1 -1
  26. package/dist/esm/stories/Card.stories.js +2 -2
  27. package/dist/esm/stories/Card.stories.js.map +1 -1
  28. package/dist/esm/stories/IconButton.stories.d.ts +1 -10
  29. package/dist/esm/stories/IconButton.stories.d.ts.map +1 -1
  30. package/dist/esm/styles/global.css +1 -1
  31. package/package.json +1 -1
  32. package/src/components/Avatar.tsx +12 -4
  33. package/src/components/Card.tsx +27 -33
  34. package/src/components/Checkbox.tsx +5 -7
  35. package/src/components/Chip.tsx +70 -70
  36. package/src/components/IconButton.tsx +64 -59
  37. package/src/components/Label.tsx +28 -11
  38. package/src/components/Notification.tsx +12 -12
  39. package/src/stories/Card.stories.tsx +2 -2
  40. package/src/styles/global.css +1 -1
@@ -2,16 +2,7 @@
2
2
  import type { StoryObj } from "@storybook/react";
3
3
  declare const meta: {
4
4
  title: string;
5
- component: import("react").ForwardRefExoticComponent<{
6
- variant?: "primary" | "highlight" | "warning" | "outline" | "ghost" | "ghost-secondary" | null | undefined;
7
- onClick?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
8
- size?: "xs" | "sm" | "md" | "xmini" | "mini" | undefined;
9
- tooltip?: string | undefined;
10
- tooltipPosition?: "top" | "right" | "bottom" | "left" | undefined;
11
- icon: import("react").ComponentType;
12
- className?: string | undefined;
13
- disabled?: boolean | undefined;
14
- } & import("react").RefAttributes<HTMLButtonElement>>;
5
+ component: import("react").ForwardRefExoticComponent<import("../components/IconButton").IconButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
15
6
  };
16
7
  export default meta;
17
8
  type Story = StoryObj<typeof meta>;
@@ -1 +1 @@
1
- {"version":3,"file":"IconButton.stories.d.ts","sourceRoot":"","sources":["../../../src/stories/IconButton.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIvD,QAAA,MAAM,IAAI;;;;;;;;;;;;CAGyB,CAAC;AAEpC,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,iBAAiB,EAAE,KAM/B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KAMnC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAMjC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KAMhC,CAAC"}
1
+ {"version":3,"file":"IconButton.stories.d.ts","sourceRoot":"","sources":["../../../src/stories/IconButton.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIvD,QAAA,MAAM,IAAI;;;CAGyB,CAAC;AAEpC,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,iBAAiB,EAAE,KAM/B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KAMnC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAMjC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KAMhC,CAAC"}
@@ -50,4 +50,4 @@
50
50
  background-color: theme("colors.black"); /* Dark mode base color */
51
51
  --tw-checker-color: theme("colors.slate.950"); /* Dark mode pattern color */
52
52
  }
53
- }
53
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dust-tt/sparkle",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "scripts": {
5
5
  "build": "rm -rf dist && npm run tailwind && npm run build:esm && npm run build:cjs",
6
6
  "tailwind": "tailwindcss -i ./src/styles/tailwind.css -o dist/sparkle.css",
@@ -6,11 +6,19 @@ import { UserIcon } from "@sparkle/icons/app";
6
6
  import { getEmojiAndBackgroundFromUrl } from "@sparkle/lib/avatar/utils";
7
7
  import { cn } from "@sparkle/lib/utils";
8
8
 
9
- const AVATAR_SIZES = ["xs", "sm", "md", "lg", "xl", "2xl", "auto"] as const;
10
- type AvatarSizeType = (typeof AVATAR_SIZES)[number];
9
+ export const AVATAR_SIZES = [
10
+ "xs",
11
+ "sm",
12
+ "md",
13
+ "lg",
14
+ "xl",
15
+ "2xl",
16
+ "auto",
17
+ ] as const;
18
+ export type AvatarSizeType = (typeof AVATAR_SIZES)[number];
11
19
 
12
- const AVATAR_VARIANTS = ["default", "clickable", "disabled"] as const;
13
- type AvatarVariantType = (typeof AVATAR_VARIANTS)[number];
20
+ export const AVATAR_VARIANTS = ["default", "clickable", "disabled"] as const;
21
+ export type AvatarVariantType = (typeof AVATAR_VARIANTS)[number];
14
22
 
15
23
  const avatarVariants = cva(
16
24
  "s-flex s-flex-shrink-0 s-items-center s-justify-center s-overflow-hidden",
@@ -12,39 +12,10 @@ import { XMarkIcon } from "@sparkle/icons/app";
12
12
  import { cn } from "@sparkle/lib/utils";
13
13
 
14
14
  export const CARD_VARIANTS = ["primary", "secondary", "tertiary"] as const;
15
-
16
15
  export type CardVariantType = (typeof CARD_VARIANTS)[number];
17
16
 
18
- const variantClasses: Record<CardVariantType, string> = {
19
- primary: cn(
20
- "s-bg-muted-background",
21
- "s-border-border/0",
22
- "dark:s-bg-muted-background-night",
23
- "dark:s-border-border-night/0"
24
- ),
25
- secondary: cn(
26
- "s-bg-background",
27
- "s-border-border",
28
- "dark:s-bg-background-night",
29
- "dark:s-border-border-night"
30
- ),
31
- tertiary: cn(
32
- "s-bg-background",
33
- "s-border-border/0",
34
- "dark:s-bg-background-night",
35
- "dark:s-border-border-night/0"
36
- ),
37
- };
38
-
39
- export const CARD_VARIANTS_SIZES = ["sm", "md", "lg"] as const;
40
-
41
- export type CardSizeType = (typeof CARD_VARIANTS_SIZES)[number];
42
-
43
- const sizeVariants: Record<CardSizeType, string> = {
44
- sm: "s-p-3 s-rounded-xl",
45
- md: "s-p-4 s-rounded-2xl",
46
- lg: "s-p-5 s-rounded-3xl",
47
- };
17
+ export const CARD_SIZES = ["sm", "md", "lg"] as const;
18
+ export type CardSizeType = (typeof CARD_SIZES)[number];
48
19
 
49
20
  const interactiveClasses = cn(
50
21
  "s-cursor-pointer",
@@ -64,8 +35,31 @@ const cardVariants = cva(
64
35
  ),
65
36
  {
66
37
  variants: {
67
- variant: variantClasses,
68
- size: sizeVariants,
38
+ variant: {
39
+ primary: cn(
40
+ "s-bg-muted-background",
41
+ "s-border-border/0",
42
+ "dark:s-bg-muted-background-night",
43
+ "dark:s-border-border-night/0"
44
+ ),
45
+ secondary: cn(
46
+ "s-bg-background",
47
+ "s-border-border",
48
+ "dark:s-bg-background-night",
49
+ "dark:s-border-border-night"
50
+ ),
51
+ tertiary: cn(
52
+ "s-bg-background",
53
+ "s-border-border/0",
54
+ "dark:s-bg-background-night",
55
+ "dark:s-border-border-night/0"
56
+ ),
57
+ },
58
+ size: {
59
+ sm: "s-p-3 s-rounded-xl",
60
+ md: "s-p-4 s-rounded-2xl",
61
+ lg: "s-p-5 s-rounded-3xl",
62
+ },
69
63
  },
70
64
  defaultVariants: {
71
65
  variant: "primary",
@@ -10,12 +10,7 @@ import { Label } from "./Label";
10
10
  import { Tooltip } from "./Tooltip";
11
11
 
12
12
  export const CHECKBOX_SIZES = ["xs", "sm"] as const;
13
- type CheckboxSizeType = (typeof CHECKBOX_SIZES)[number];
14
-
15
- const checkboxSizeVariant: Record<CheckboxSizeType, string> = {
16
- xs: "s-h-4 s-w-4 s-rounded",
17
- sm: "s-h-5 s-w-5 s-rounded-md",
18
- };
13
+ export type CheckboxSizeType = (typeof CHECKBOX_SIZES)[number];
19
14
 
20
15
  const checkboxStyles = cva(
21
16
  cn(
@@ -34,7 +29,10 @@ const checkboxStyles = cva(
34
29
  "data-[state=indeterminate]:s-bg-primary dark:data-[state=indeterminate]:s-bg-primary-night data-[state=indeterminate]:s-text-white data-[state=indeterminate]:s-border-primary",
35
30
  false: "",
36
31
  },
37
- size: checkboxSizeVariant,
32
+ size: {
33
+ xs: "s-h-4 s-w-4 s-rounded",
34
+ sm: "s-h-5 s-w-5 s-rounded-md",
35
+ },
38
36
  },
39
37
  defaultVariants: {
40
38
  size: "sm",
@@ -29,62 +29,75 @@ export const CHIP_COLORS = [
29
29
 
30
30
  type ChipColorType = (typeof CHIP_COLORS)[number];
31
31
 
32
- const sizeVariants: Record<ChipSizeType, string> = {
33
- mini: "s-rounded-md s-min-h-5 s-text-xs s-font-medium s-px-1.5 s-py-1 s-gap-0.5",
34
- xs: "s-rounded-lg s-min-h-7 s-heading-xs s-px-3 s-gap-1",
35
- sm: "s-rounded-xl s-min-h-9 s-heading-sm s-px-4 s-gap-1.5",
36
- };
37
-
38
- const backgroundVariants: Record<ChipColorType, string> = {
39
- primary: cn(
40
- "s-bg-muted-background s-border-border",
41
- "dark:s-bg-muted-background-night dark:s-border-border-night"
42
- ),
43
- highlight: cn(
44
- "s-bg-highlight-100 s-border-highlight-200",
45
- "dark:s-bg-highlight-100-night dark:s-border-highlight-200-night"
46
- ),
47
- success: cn(
48
- "s-bg-success-100 s-border-success-200",
49
- "dark:s-bg-success-100-night dark:s-border-success-200-night"
50
- ),
51
- info: cn(
52
- "s-bg-info-100 s-border-info-200",
53
- "dark:s-bg-info-100-night dark:s-border-info-200-night"
54
- ),
55
- warning: cn(
56
- "s-bg-warning-100 s-border-warning-200",
57
- "dark:s-bg-warning-100-night dark:s-border-warning-200-night"
58
- ),
59
- green: cn(
60
- "s-bg-green-100 s-border-green-200",
61
- "dark:s-bg-green-100-night dark:s-border-green-200-night"
62
- ),
63
- blue: cn(
64
- "s-bg-blue-100 s-border-blue-200",
65
- "dark:s-bg-blue-100-night dark:s-border-blue-200-night"
66
- ),
67
- rose: cn(
68
- "s-bg-rose-100 s-border-rose-200",
69
- "dark:s-bg-rose-100-night dark:s-border-rose-200-night"
70
- ),
71
- golden: cn(
72
- "s-bg-golden-100 s-border-golden-200",
73
- "dark:s-bg-golden-100-night dark:s-border-golden-200-night"
74
- ),
75
- };
76
-
77
- const textVariants: Record<ChipColorType, string> = {
78
- primary: "s-text-primary-900 dark:s-text-primary-900-night",
79
- highlight: "s-text-highlight-900 dark:s-text-highlight-900-night",
80
- success: "s-text-success-900 dark:s-text-success-900-night",
81
- warning: "s-text-warning-900 dark:s-text-warning-900-night",
82
- info: "s-text-info-900 dark:s-text-info-900-night",
83
- green: "s-text-green-900 dark:s-text-green-900-night",
84
- blue: "s-text-blue-900 dark:s-text-blue-900-night",
85
- rose: "s-text-rose-900 dark:s-text-rose-900-night",
86
- golden: "s-text-golden-900 dark:s-text-golden-900-night",
87
- };
32
+ const chipVariants = cva("s-inline-flex s-box-border s-items-center", {
33
+ variants: {
34
+ size: {
35
+ mini: "s-rounded-md s-min-h-5 s-text-xs s-font-medium s-px-1.5 s-py-1 s-gap-0.5",
36
+ xs: "s-rounded-lg s-min-h-7 s-heading-xs s-px-3 s-gap-1",
37
+ sm: "s-rounded-xl s-min-h-9 s-heading-sm s-px-4 s-gap-1.5",
38
+ },
39
+ color: {
40
+ primary: cn(
41
+ "s-bg-muted-background s-border-border",
42
+ "s-text-primary-900",
43
+ "dark:s-bg-muted-background-night dark:s-border-border-night",
44
+ "dark:s-text-primary-900-night"
45
+ ),
46
+ highlight: cn(
47
+ "s-bg-highlight-100 s-border-highlight-200",
48
+ "s-text-highlight-900",
49
+ "dark:s-bg-highlight-100-night dark:s-border-highlight-200-night",
50
+ "dark:s-text-highlight-900-night"
51
+ ),
52
+ success: cn(
53
+ "s-bg-success-100 s-border-success-200",
54
+ "s-text-success-900",
55
+ "dark:s-bg-success-100-night dark:s-border-success-200-night",
56
+ "dark:s-text-success-900-night"
57
+ ),
58
+ info: cn(
59
+ "s-bg-info-100 s-border-info-200",
60
+ "s-text-info-900",
61
+ "dark:s-bg-info-100-night dark:s-border-info-200-night",
62
+ "dark:s-text-info-900-night"
63
+ ),
64
+ warning: cn(
65
+ "s-bg-warning-100 s-border-warning-200",
66
+ "s-text-warning-900",
67
+ "dark:s-bg-warning-100-night dark:s-border-warning-200-night",
68
+ "dark:s-text-warning-900-night"
69
+ ),
70
+ green: cn(
71
+ "s-bg-green-100 s-border-green-200",
72
+ "s-text-green-900",
73
+ "dark:s-bg-green-100-night dark:s-border-green-200-night",
74
+ "dark:s-text-green-900-night"
75
+ ),
76
+ blue: cn(
77
+ "s-bg-blue-100 s-border-blue-200",
78
+ "s-text-blue-900",
79
+ "dark:s-bg-blue-100-night dark:s-border-blue-200-night",
80
+ "dark:s-text-blue-900-night"
81
+ ),
82
+ rose: cn(
83
+ "s-bg-rose-100 s-border-rose-200",
84
+ "s-text-rose-900",
85
+ "dark:s-bg-rose-100-night dark:s-border-rose-200-night",
86
+ "dark:s-text-rose-900-night"
87
+ ),
88
+ golden: cn(
89
+ "s-bg-golden-100 s-border-golden-200",
90
+ "s-text-golden-900",
91
+ "dark:s-bg-golden-100-night dark:s-border-golden-200-night",
92
+ "dark:s-text-golden-900-night"
93
+ ),
94
+ },
95
+ },
96
+ defaultVariants: {
97
+ size: "xs",
98
+ color: "primary",
99
+ },
100
+ });
88
101
 
89
102
  const closeIconVariants: Record<ChipColorType, string> = {
90
103
  primary: cn(
@@ -125,19 +138,6 @@ const closeIconVariants: Record<ChipColorType, string> = {
125
138
  ),
126
139
  };
127
140
 
128
- const chipVariants = cva("s-inline-flex s-box-border s-items-center", {
129
- variants: {
130
- size: sizeVariants,
131
- text: textVariants,
132
- background: backgroundVariants,
133
- },
134
- defaultVariants: {
135
- size: "xs",
136
- text: "primary",
137
- background: "primary",
138
- },
139
- });
140
-
141
141
  type ChipBaseProps = {
142
142
  size?: ChipSizeType;
143
143
  color?: ChipColorType;
@@ -187,7 +187,7 @@ const Chip = React.forwardRef<HTMLDivElement, ChipProps>(
187
187
  const chipContent = (
188
188
  <div
189
189
  className={cn(
190
- chipVariants({ size, background: color, text: color }),
190
+ chipVariants({ size, color }),
191
191
  className,
192
192
  onClick && "s-cursor-pointer"
193
193
  )}
@@ -2,78 +2,73 @@ import { cva } from "class-variance-authority";
2
2
  import React, { ComponentType, MouseEventHandler } from "react";
3
3
 
4
4
  import { Tooltip } from "@sparkle/components";
5
- import { Button, ButtonVariantType } from "@sparkle/components/Button";
5
+ import { Button, BUTTON_VARIANTS } from "@sparkle/components/Button";
6
6
  import { cn } from "@sparkle/lib/utils";
7
7
 
8
- type IconButtonProps = {
9
- variant?: React.ComponentProps<typeof Button>["variant"];
10
- onClick?: MouseEventHandler<HTMLButtonElement>;
11
- size?: React.ComponentProps<typeof Button>["size"];
12
- tooltip?: string;
13
- tooltipPosition?: React.ComponentProps<typeof Tooltip>["side"];
14
- icon: ComponentType;
15
- className?: string;
16
- disabled?: boolean;
17
- };
18
-
19
- const styleVariants: Record<ButtonVariantType, string> = {
20
- primary: cn(
21
- "s-text-highlight-500 dark:s-text-highlight-500-night",
22
- "hover:s-text-highlight-400 dark:hover:s-text-highlight-500-night",
23
- "active:s-text-highlight-600 dark:active:s-text-highlight-600-night",
24
- "s-text-primary-500 dark:s-text-primary-500-night"
25
- ),
26
- warning: cn(
27
- "s-text-warning-500 dark:s-text-warning-500-night",
28
- "hover:s-text-warning-400 dark:hover:s-text-warning-500-night",
29
- "active:s-text-warning-600 dark:active:s-text-warning-600-night",
30
- "s-text-primary-500 dark:s-text-primary-500-night"
31
- ),
32
- highlight: cn(
33
- "s-text-foreground dark:s-text-foreground-night",
34
- "hover:s-text-highlight-400 dark:hover:s-text-highlight-500-night",
35
- "active:s-text-highlight-600 dark:active:s-text-highlight-600-night",
36
- "s-text-primary-500 dark:s-text-primary-500-night"
37
- ),
38
- outline: cn(
39
- "s-text-primary-700 dark:s-text-primary-700-night",
40
- "hover:s-text-primary-400 dark:hover:s-text-primary-400-night",
41
- "active:s-text-highlight-600 dark:active:s-text-highlight-600-night",
42
- "s-text-primary-500 dark:s-text-primary-500-night"
43
- ),
44
- ghost: cn(
45
- "s-text-white dark:s-text-primary-950",
46
- "hover:s-text-primary-100 dark:hover:s-text-primary-100-night",
47
- "active:s-text-primary-200 dark:active:s-text-primary-200-night",
48
- "s-text-white/50 dark:s-text-primary-950/50"
49
- ),
50
- "ghost-secondary": cn(
51
- "s-text-white",
52
- "hover:s-text-primary-100 dark:hover:s-text-primary-100-night",
53
- "active:s-text-primary-200 dark:active:s-text-primary-200-night",
54
- "s-text-white/50 dark:s-text-primary-950/50"
55
- ),
56
- };
8
+ export const ICON_BUTTON_VARIANTS = BUTTON_VARIANTS;
9
+ export type IconButtonVariantType = (typeof ICON_BUTTON_VARIANTS)[number];
57
10
 
58
11
  const iconButtonVariants = cva(
59
12
  "s-transition-all s-ease-out s-duration-300 s-cursor-pointer hover:s-scale-110",
60
13
  {
61
14
  variants: {
62
- variant: styleVariants,
63
- disabled: {
64
- true: cn(
65
- "s-text-primary-500 dark:s-text-primary-500-night",
66
- "s-cursor-default hover:s-scale-100"
15
+ variant: {
16
+ primary: cn(
17
+ "s-text-highlight-500 dark:s-text-highlight-500-night",
18
+ "hover:s-text-highlight-400 dark:hover:s-text-highlight-500-night",
19
+ "active:s-text-highlight-600 dark:active:s-text-highlight-600-night",
20
+ "s-text-primary-500 dark:s-text-primary-500-night"
21
+ ),
22
+ warning: cn(
23
+ "s-text-warning-500 dark:s-text-warning-500-night",
24
+ "hover:s-text-warning-400 dark:hover:s-text-warning-500-night",
25
+ "active:s-text-warning-600 dark:active:s-text-warning-600-night",
26
+ "s-text-primary-500 dark:s-text-primary-500-night"
27
+ ),
28
+ highlight: cn(
29
+ "s-text-foreground dark:s-text-foreground-night",
30
+ "hover:s-text-highlight-400 dark:hover:s-text-highlight-500-night",
31
+ "active:s-text-highlight-600 dark:active:s-text-highlight-600-night",
32
+ "s-text-primary-500 dark:s-text-primary-500-night"
33
+ ),
34
+ outline: cn(
35
+ "s-text-primary-700 dark:s-text-primary-700-night",
36
+ "hover:s-text-primary-400 dark:hover:s-text-primary-400-night",
37
+ "active:s-text-highlight-600 dark:active:s-text-highlight-600-night",
38
+ "s-text-primary-500 dark:s-text-primary-500-night"
39
+ ),
40
+ ghost: cn(
41
+ "s-text-white dark:s-text-primary-950",
42
+ "hover:s-text-primary-100 dark:hover:s-text-primary-100-night",
43
+ "active:s-text-primary-200 dark:active:s-text-primary-200-night",
44
+ "s-text-white/50 dark:s-text-primary-950/50"
45
+ ),
46
+ "ghost-secondary": cn(
47
+ "s-text-white",
48
+ "hover:s-text-primary-100 dark:hover:s-text-primary-100-night",
49
+ "active:s-text-primary-200 dark:active:s-text-primary-200-night",
50
+ "s-text-white/50 dark:s-text-primary-950/50"
67
51
  ),
68
52
  },
69
53
  },
70
54
  defaultVariants: {
71
55
  variant: "outline",
72
- disabled: false,
73
56
  },
74
57
  }
75
58
  );
76
59
 
60
+ export interface IconButtonProps
61
+ extends Omit<
62
+ React.ComponentPropsWithoutRef<typeof Button>,
63
+ "label" | "variant"
64
+ > {
65
+ variant?: IconButtonVariantType;
66
+ onClick?: MouseEventHandler<HTMLButtonElement>;
67
+ tooltip?: string;
68
+ tooltipPosition?: React.ComponentProps<typeof Tooltip>["side"];
69
+ icon: ComponentType;
70
+ }
71
+
77
72
  const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
78
73
  (
79
74
  {
@@ -90,16 +85,26 @@ const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
90
85
  ) => (
91
86
  <Button
92
87
  tooltip={tooltip}
93
- className={cn(iconButtonVariants({ variant, disabled }), className)}
88
+ className={cn(
89
+ iconButtonVariants({ variant }),
90
+ disabled &&
91
+ cn(
92
+ "s-text-primary-500 dark:s-text-primary-500-night",
93
+ "s-cursor-default hover:s-scale-100"
94
+ ),
95
+ className
96
+ )}
94
97
  onClick={onClick}
95
98
  disabled={disabled}
96
99
  ref={ref}
97
100
  size={size}
98
101
  icon={icon}
99
- variant={null}
102
+ variant="ghost"
100
103
  {...props}
101
104
  />
102
105
  )
103
106
  );
104
107
 
105
- export { IconButton };
108
+ IconButton.displayName = "IconButton";
109
+
110
+ export { IconButton, iconButtonVariants };
@@ -1,33 +1,50 @@
1
1
  import * as LabelPrimitive from "@radix-ui/react-label";
2
+ import { cva, type VariantProps } from "class-variance-authority";
2
3
  import * as React from "react";
3
4
 
4
5
  import { cn } from "@sparkle/lib/utils";
5
6
 
7
+ const labelVariants = cva(
8
+ cn(
9
+ "s-heading-sm",
10
+ "peer-disabled:s-cursor-not-allowed peer-disabled:s-opacity-70"
11
+ ),
12
+ {
13
+ variants: {
14
+ variant: {
15
+ default: cn("s-text-foreground", "dark:s-text-foreground-night"),
16
+ muted: cn(
17
+ "s-text-muted-foreground",
18
+ "dark:s-text-muted-foreground-night"
19
+ ),
20
+ },
21
+ },
22
+ defaultVariants: {
23
+ variant: "default",
24
+ },
25
+ }
26
+ );
27
+
6
28
  export interface LabelProps
7
- extends React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> {
29
+ extends React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>,
30
+ VariantProps<typeof labelVariants> {
8
31
  isMuted?: boolean;
9
32
  }
10
33
 
11
34
  const Label = React.forwardRef<
12
35
  React.ElementRef<typeof LabelPrimitive.Root>,
13
36
  LabelProps
14
- >(({ className, isMuted = false, ...props }, ref) => {
15
- const labelVariants = cn(
16
- "s-heading-sm",
17
- isMuted
18
- ? "s-text-muted-foreground dark:s-text-muted-foreground-night"
19
- : "s-text-foreground dark:s-text-foreground-night",
20
- "peer-disabled:s-cursor-not-allowed peer-disabled:s-opacity-70"
21
- );
37
+ >(({ className, variant, isMuted = false, ...props }, ref) => {
38
+ const effectiveVariant = isMuted ? "muted" : variant;
22
39
 
23
40
  return (
24
41
  <LabelPrimitive.Root
25
42
  ref={ref}
26
- className={cn(labelVariants, className)}
43
+ className={cn(labelVariants({ variant: effectiveVariant }), className)}
27
44
  {...props}
28
45
  />
29
46
  );
30
47
  });
31
48
  Label.displayName = LabelPrimitive.Root.displayName;
32
49
 
33
- export { Label };
50
+ export { Label, labelVariants };
@@ -23,6 +23,16 @@ const NotificationsContext = React.createContext<(n: NotificationType) => void>(
23
23
  (n) => n
24
24
  );
25
25
 
26
+ const notificationVariants = cva("s-pt-0.5", {
27
+ variants: {
28
+ type: {
29
+ success: "s-text-success-600 dark:s-text-success-400-night",
30
+ error: "s-text-warning-500 dark:s-text-warning-500-night",
31
+ info: "s-text-info-600 dark:s-text-info-400-night",
32
+ },
33
+ },
34
+ });
35
+
26
36
  function NotificationContent({
27
37
  type,
28
38
  title,
@@ -42,16 +52,6 @@ function NotificationContent({
42
52
  }
43
53
  })();
44
54
 
45
- const variantClassName = cva("s-pt-0.5", {
46
- variants: {
47
- type: {
48
- success: "s-text-success-600 dark:s-text-success-400-night",
49
- error: "s-text-warning-500 dark:s-text-warning-500-night",
50
- info: "s-text-info-600 dark:s-text-info-400-night",
51
- },
52
- },
53
- });
54
-
55
55
  return (
56
56
  <div
57
57
  className={cn(
@@ -65,14 +65,14 @@ function NotificationContent({
65
65
  <Icon
66
66
  size="lg"
67
67
  visual={icon}
68
- className={variantClassName({ type })}
68
+ className={notificationVariants({ type })}
69
69
  aria-hidden="true"
70
70
  />
71
71
  <div className="s-flex s-min-w-0 s-flex-grow s-flex-col">
72
72
  <div
73
73
  className={cn(
74
74
  "s-heading-md s-line-clamp-1 s-h-6 s-grow",
75
- variantClassName({ type })
75
+ notificationVariants({ type })
76
76
  )}
77
77
  >
78
78
  {title || type}
@@ -3,8 +3,8 @@ import React, { ComponentType } from "react";
3
3
 
4
4
  import { Card, Icon } from "@sparkle/components";
5
5
  import {
6
+ CARD_SIZES,
6
7
  CARD_VARIANTS,
7
- CARD_VARIANTS_SIZES,
8
8
  CardActionButton,
9
9
  CardGrid,
10
10
  } from "@sparkle/components/Card";
@@ -28,7 +28,7 @@ export default meta;
28
28
 
29
29
  export const Demo = () => {
30
30
  const variants = CARD_VARIANTS;
31
- const sizes = CARD_VARIANTS_SIZES;
31
+ const sizes = CARD_SIZES;
32
32
 
33
33
  return (
34
34
  <div className="s-flex s-flex-col s-gap-8 s-text-foreground dark:s-text-foreground-night">
@@ -50,4 +50,4 @@
50
50
  background-color: theme("colors.black"); /* Dark mode base color */
51
51
  --tw-checker-color: theme("colors.slate.950"); /* Dark mode pattern color */
52
52
  }
53
- }
53
+ }