@dust-tt/sparkle 0.2.467 → 0.2.469

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.
@@ -32,76 +32,7 @@ export type ButtonVariantType = (typeof BUTTON_VARIANTS)[number];
32
32
  export const BUTTON_SIZES = ["mini", "xs", "sm", "md"] as const;
33
33
  export type ButtonSizeType = (typeof BUTTON_SIZES)[number];
34
34
 
35
- const styleVariants: Record<ButtonVariantType, string> = {
36
- primary: cn(
37
- "s-bg-primary-800 dark:s-bg-primary-800-night",
38
- "s-text-primary-50 dark:s-text-primary-50-night",
39
- "hover:s-bg-primary-light dark:hover:s-bg-primary-dark-night",
40
- "active:s-bg-primary-dark dark:active:s-bg-primary-light-night",
41
- "disabled:s-bg-primary-muted disabled:s-text-highlight-50/60 dark:disabled:s-bg-primary-muted-night"
42
- ),
43
- highlight: cn(
44
- "s-bg-highlight",
45
- "s-text-highlight-50",
46
- "hover:s-bg-highlight-light",
47
- "active:s-bg-highlight-dark",
48
- "disabled:s-bg-highlight-muted disabled:s-text-highlight-50/60 dark:disabled:s-bg-highlight-muted-night"
49
- ),
50
- warning: cn(
51
- "s-bg-warning",
52
- "s-text-warning-50",
53
- "hover:s-bg-warning-light",
54
- "active:s-bg-warning-dark",
55
- "disabled:s-bg-warning-muted disabled:s-text-highlight-50/60 dark:disabled:s-bg-warning-muted-night"
56
- ),
57
- outline: cn(
58
- "s-border",
59
- "s-border-border dark:s-border-border-night",
60
- "s-text-primary dark:s-text-primary-night",
61
- "s-bg-background dark:s-bg-background-night",
62
- "hover:s-text-primary dark:hover:s-text-primary-night",
63
- "hover:s-bg-primary-100 dark:hover:s-bg-primary-900",
64
- "hover:s-border-primary-150 dark:hover:s-border-border-night",
65
- "active:s-bg-primary-300 dark:active:s-bg-primary-900",
66
- "disabled:s-text-primary-muted dark:disabled:s-text-primary-muted-night",
67
- "disabled:s-border-primary-100 dark:disabled:s-border-primary-100-night"
68
- ),
69
- ghost: cn(
70
- "s-border",
71
- "s-border-border/0 dark:s-border-border-night/0",
72
- "s-text-foreground dark:s-text-white",
73
- "hover:s-bg-primary-100 dark:hover:s-bg-primary-900",
74
- "hover:s-text-primary-900 dark:hover:s-text-white",
75
- "hover:s-border-border-dark dark:hover:s-border-border-night",
76
- "active:s-bg-primary-300 dark:active:s-bg-primary-900",
77
- "disabled:s-text-primary-400 dark:disabled:s-text-primary-400-night"
78
- ),
79
- "ghost-secondary": cn(
80
- "s-border",
81
- "s-border-border/0 dark:s-border-border-night/0",
82
- "s-text-muted-foreground dark:s-text-muted-foreground-night",
83
- "hover:s-bg-primary-100 dark:hover:s-bg-primary-900",
84
- "hover:s-text-primary-900 dark:hover:s-text-primary-900-night",
85
- "hover:s-border-border-dark dark:hover:s-border-border-night",
86
- "active:s-bg-primary-300 dark:active:s-bg-primary-900",
87
- "disabled:s-text-primary-400 dark:disabled:s-text-primary-400-night"
88
- ),
89
- };
90
-
91
- const sizeVariants: Record<ButtonSizeType, string> = {
92
- mini: "s-h-7 s-p-1.5 s-rounded-lg s-label-xs s-gap-1.5",
93
- xs: "s-h-7 s-px-2.5 s-rounded-lg s-label-xs s-gap-1.5",
94
- sm: "s-h-9 s-px-3 s-rounded-xl s-label-sm s-gap-2",
95
- md: "s-h-12 s-px-4 s-py-2 s-rounded-2xl s-label-base s-gap-2.5",
96
- };
97
-
98
- const labelVariants: Record<ButtonSizeType, string> = {
99
- mini: "s-label-xs",
100
- xs: "s-label-xs",
101
- sm: "s-label-sm",
102
- md: "s-label-base",
103
- };
104
-
35
+ // Define button styling with cva
105
36
  const buttonVariants = cva(
106
37
  cn(
107
38
  "s-inline-flex s-items-center s-justify-center s-whitespace-nowrap s-ring-offset-background s-transition-colors",
@@ -110,44 +41,124 @@ const buttonVariants = cva(
110
41
  ),
111
42
  {
112
43
  variants: {
113
- variant: styleVariants,
114
- size: sizeVariants,
44
+ variant: {
45
+ primary: cn(
46
+ "s-bg-primary-800 dark:s-bg-primary-800-night",
47
+ "s-text-primary-50 dark:s-text-primary-50-night",
48
+ "hover:s-bg-primary-light dark:hover:s-bg-primary-dark-night",
49
+ "active:s-bg-primary-dark dark:active:s-bg-primary-light-night",
50
+ "disabled:s-bg-primary-muted disabled:s-text-highlight-50/60 dark:disabled:s-bg-primary-muted-night"
51
+ ),
52
+ highlight: cn(
53
+ "s-bg-highlight",
54
+ "s-text-highlight-50",
55
+ "hover:s-bg-highlight-light",
56
+ "active:s-bg-highlight-dark",
57
+ "disabled:s-bg-highlight-muted disabled:s-text-highlight-50/60 dark:disabled:s-bg-highlight-muted-night"
58
+ ),
59
+ warning: cn(
60
+ "s-bg-warning",
61
+ "s-text-warning-50",
62
+ "hover:s-bg-warning-light",
63
+ "active:s-bg-warning-dark",
64
+ "disabled:s-bg-warning-muted disabled:s-text-highlight-50/60 dark:disabled:s-bg-warning-muted-night"
65
+ ),
66
+ outline: cn(
67
+ "s-border",
68
+ "s-border-border dark:s-border-border-night",
69
+ "s-text-primary dark:s-text-primary-night",
70
+ "s-bg-background dark:s-bg-background-night",
71
+ "hover:s-text-primary dark:hover:s-text-primary-night",
72
+ "hover:s-bg-primary-100 dark:hover:s-bg-primary-900",
73
+ "hover:s-border-primary-150 dark:hover:s-border-border-night",
74
+ "active:s-bg-primary-300 dark:active:s-bg-primary-900",
75
+ "disabled:s-text-primary-muted dark:disabled:s-text-primary-muted-night",
76
+ "disabled:s-border-primary-100 dark:disabled:s-border-primary-100-night"
77
+ ),
78
+ ghost: cn(
79
+ "s-border",
80
+ "s-border-border/0 dark:s-border-border-night/0",
81
+ "s-text-foreground dark:s-text-white",
82
+ "hover:s-bg-primary-100 dark:hover:s-bg-primary-900",
83
+ "hover:s-text-primary-900 dark:hover:s-text-white",
84
+ "hover:s-border-border-dark dark:hover:s-border-border-night",
85
+ "active:s-bg-primary-300 dark:active:s-bg-primary-900",
86
+ "disabled:s-text-primary-400 dark:disabled:s-text-primary-400-night"
87
+ ),
88
+ "ghost-secondary": cn(
89
+ "s-border",
90
+ "s-border-border/0 dark:s-border-border-night/0",
91
+ "s-text-muted-foreground dark:s-text-muted-foreground-night",
92
+ "hover:s-bg-primary-100 dark:hover:s-bg-primary-900",
93
+ "hover:s-text-primary-900 dark:hover:s-text-primary-900-night",
94
+ "hover:s-border-border-dark dark:hover:s-border-border-night",
95
+ "active:s-bg-primary-300 dark:active:s-bg-primary-900",
96
+ "disabled:s-text-primary-400 dark:disabled:s-text-primary-400-night"
97
+ ),
98
+ },
99
+ size: {
100
+ mini: "s-h-7 s-p-1.5 s-rounded-lg s-label-xs s-gap-1.5",
101
+ xs: "s-h-7 s-px-2.5 s-rounded-lg s-label-xs s-gap-1.5",
102
+ sm: "s-h-9 s-px-3 s-rounded-xl s-label-sm s-gap-2",
103
+ md: "s-h-12 s-px-4 s-py-2 s-rounded-2xl s-label-base s-gap-2.5",
104
+ },
105
+ },
106
+ defaultVariants: {
107
+ variant: "primary",
108
+ size: "sm",
115
109
  },
116
110
  }
117
111
  );
118
112
 
113
+ const labelVariants = cva("", {
114
+ variants: {
115
+ size: {
116
+ mini: "s-label-xs",
117
+ xs: "s-label-xs",
118
+ sm: "s-label-sm",
119
+ md: "s-label-base",
120
+ },
121
+ },
122
+ defaultVariants: {
123
+ size: "sm",
124
+ },
125
+ });
126
+
119
127
  type SpinnerVariant = NonNullable<SpinnerProps["variant"]>;
120
128
 
121
129
  const spinnerVariantsMap: Record<ButtonVariantType, SpinnerVariant> = {
122
- primary: "light",
123
- highlight: "light",
124
- warning: "light",
125
- outline: "dark",
126
- ghost: "dark",
127
- "ghost-secondary": "dark",
130
+ primary: "gray50",
131
+ highlight: "gray50",
132
+ warning: "gray50",
133
+ outline: "gray500",
134
+ ghost: "gray500",
135
+ "ghost-secondary": "gray400",
128
136
  };
129
137
 
130
- const spinnerVariantsMapIsLoading: Record<ButtonVariantType, SpinnerVariant> = {
131
- primary: "light",
132
- highlight: "light",
133
- warning: "light",
134
- outline: "slate400",
135
- ghost: "slate400",
136
- "ghost-secondary": "dark",
137
- };
138
+ const chevronVariantMap = {
139
+ primary: "s-text-white/70",
140
+ outline: "s-text-foreground/70 dark:s-text-foreground-night/70",
141
+ ghost: "s-text-foreground/70 dark:s-text-foreground-night/70",
142
+ "ghost-secondary": "s-text-foreground/70 dark:s-text-foreground-night/70",
143
+ highlight: "s-text-white/70",
144
+ warning: "s-text-white/70",
145
+ } as const;
138
146
 
139
147
  export interface MetaButtonProps
140
148
  extends React.ButtonHTMLAttributes<HTMLButtonElement>,
141
149
  VariantProps<typeof buttonVariants> {
142
150
  asChild?: boolean;
143
- variant?: ButtonVariantType | null;
144
151
  }
145
152
 
146
153
  const MetaButton = React.forwardRef<HTMLButtonElement, MetaButtonProps>(
147
- ({ className, asChild = false, children, ...props }, ref) => {
154
+ ({ className, asChild = false, variant, size, children, ...props }, ref) => {
148
155
  const Comp = asChild ? Slot : "button";
149
156
  return (
150
- <Comp className={className} ref={ref} {...props}>
157
+ <Comp
158
+ className={cn(buttonVariants({ variant, size, className }))}
159
+ ref={ref}
160
+ {...props}
161
+ >
151
162
  {children}
152
163
  </Comp>
153
164
  );
@@ -204,12 +215,18 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
204
215
  ref
205
216
  ) => {
206
217
  const iconsSize = size === "mini" ? "sm" : size;
207
- const spinnerVariant = isLoading
208
- ? (variant && spinnerVariantsMapIsLoading[variant]) || "slate400"
209
- : (variant && spinnerVariantsMap[variant]) || "slate400";
218
+ const spinnerVariant =
219
+ (variant && spinnerVariantsMap[variant]) || "gray400";
210
220
 
211
221
  const renderIcon = (visual: React.ComponentType, extraClass = "") => (
212
- <Icon visual={visual} size={iconsSize} className={extraClass} />
222
+ <Icon visual={visual} size={iconsSize} className={cn(extraClass)} />
223
+ );
224
+ const renderChevron = (visual: React.ComponentType, extraClass = "") => (
225
+ <Icon
226
+ visual={visual}
227
+ size={iconsSize}
228
+ className={cn(variant ? chevronVariantMap[variant] : "", extraClass)}
229
+ />
213
230
  );
214
231
 
215
232
  const showCounter = isCounter && counterValue != null;
@@ -227,7 +244,10 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
227
244
 
228
245
  {showContainer && (
229
246
  <div
230
- className={cn("s-flex s-items-center s-gap-2", labelVariants[size])}
247
+ className={cn(
248
+ "s-flex s-items-center s-gap-2",
249
+ labelVariants({ size })
250
+ )}
231
251
  >
232
252
  {label}
233
253
  {showCounter && (
@@ -240,7 +260,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
240
260
  )}
241
261
  </div>
242
262
  )}
243
- {isSelect && renderIcon(ChevronDownIcon, isLoading ? "" : "-s-mr-1")}
263
+ {isSelect && renderChevron(ChevronDownIcon, isLoading ? "" : "-s-mr-1")}
244
264
  </>
245
265
  );
246
266
 
@@ -248,12 +268,9 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
248
268
  <MetaButton
249
269
  ref={ref}
250
270
  size={size}
271
+ variant={variant}
251
272
  disabled={isLoading || props.disabled}
252
- className={cn(
253
- buttonVariants({ variant, size }),
254
- isPulsing && "s-animate-pulse",
255
- className
256
- )}
273
+ className={cn(isPulsing && "s-animate-pulse", className)}
257
274
  aria-label={ariaLabel || tooltip || label}
258
275
  style={
259
276
  {
@@ -4,7 +4,7 @@ import * as React from "react";
4
4
  import { cn } from "@sparkle/lib/utils";
5
5
 
6
6
  const labelVariants = cn(
7
- "s-text-sm s-font-semibold s-leading-none",
7
+ "s-heading-sm",
8
8
  "s-text-foreground dark:s-text-foreground-night",
9
9
  "peer-disabled:s-cursor-not-allowed peer-disabled:s-opacity-70"
10
10
  );
@@ -4,7 +4,11 @@ import React from "react";
4
4
  import {
5
5
  ActionBeerIcon,
6
6
  ActionFlagIcon,
7
+ ActionImageIcon,
8
+ ActionMagnifyingGlassIcon,
9
+ ActionScanIcon,
7
10
  ActionShirtIcon,
11
+ ActionTableIcon,
8
12
  ActionUmbrellaIcon,
9
13
  } from "@sparkle/icons/actions";
10
14
  import SvgHome from "@sparkle/icons/actions/Home";
@@ -124,6 +128,49 @@ export const AvatarExample = () => (
124
128
  <Avatar size="xl" icon={ActionShirtIcon} />
125
129
  <Avatar size="xxl" icon={StarStrokeIcon} />
126
130
  </div>
131
+ <div className="heading-2xl">Tools example</div>
132
+ <div>Remote MCP Servers</div>
133
+ <div className="s-flex s-gap-4">
134
+ <Avatar size="md" icon={SvgHome} />
135
+ <Avatar size="md" icon={ActionBeerIcon} />
136
+ <Avatar size="md" icon={ActionUmbrellaIcon} />
137
+ <Avatar size="md" icon={ActionFlagIcon} />
138
+ <Avatar size="md" icon={ActionShirtIcon} />
139
+ <Avatar size="md" icon={StarStrokeIcon} />
140
+ </div>
141
+ <div>Internal Tools Servers</div>
142
+ <div className="s-flex s-gap-4">
143
+ <Avatar
144
+ size="md"
145
+ icon={ActionTableIcon}
146
+ backgroundColor="s-bg-gray-700"
147
+ iconColor="s-text-gray-50"
148
+ />
149
+ <Avatar
150
+ size="md"
151
+ icon={ActionMagnifyingGlassIcon}
152
+ backgroundColor="s-bg-gray-700"
153
+ iconColor="s-text-gray-50"
154
+ />
155
+ <Avatar
156
+ size="md"
157
+ icon={ActionImageIcon}
158
+ backgroundColor="s-bg-gray-700"
159
+ iconColor="s-text-gray-50"
160
+ />
161
+ <Avatar
162
+ size="md"
163
+ icon={ActionScanIcon}
164
+ backgroundColor="s-bg-gray-700"
165
+ iconColor="s-text-gray-50"
166
+ />
167
+ </div>
168
+ <div>Platforms integrations</div>
169
+ <div className="s-flex s-gap-4">
170
+ <Avatar size="md" icon={DriveLogo} backgroundColor="s-bg-gray-900" />
171
+ <Avatar size="md" icon={NotionLogo} backgroundColor="s-bg-white" />
172
+ <Avatar size="md" icon={SlackLogo} hexBgColor="#421D51" />
173
+ </div>
127
174
  </div>
128
175
  );
129
176