@dust-tt/sparkle 0.2.271 → 0.2.272-rc-2
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/dist/cjs/index.js +8186 -8284
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/AssistantPreview.d.ts.map +1 -1
- package/dist/esm/components/AssistantPreview.js +1 -1
- package/dist/esm/components/AssistantPreview.js.map +1 -1
- package/dist/esm/components/Banner.js +1 -1
- package/dist/esm/components/Banner.js.map +1 -1
- package/dist/esm/components/BarHeader.js +5 -5
- package/dist/esm/components/BarHeader.js.map +1 -1
- package/dist/esm/components/Button.d.ts +20 -24
- package/dist/esm/components/Button.d.ts.map +1 -1
- package/dist/esm/components/Button.js +72 -117
- package/dist/esm/components/Button.js.map +1 -1
- package/dist/esm/components/Checkbox.js +2 -2
- package/dist/esm/components/Checkbox.js.map +1 -1
- package/dist/esm/components/Citation.js +1 -1
- package/dist/esm/components/Citation.js.map +1 -1
- package/dist/esm/components/DataTable.js +2 -2
- package/dist/esm/components/DataTable.js.map +1 -1
- package/dist/esm/components/Dialog.d.ts +2 -2
- package/dist/esm/components/Dialog.d.ts.map +1 -1
- package/dist/esm/components/Dialog.js +2 -2
- package/dist/esm/components/Dialog.js.map +1 -1
- package/dist/esm/components/FilterChips.d.ts.map +1 -1
- package/dist/esm/components/FilterChips.js +1 -1
- package/dist/esm/components/FilterChips.js.map +1 -1
- package/dist/esm/components/IconButton.d.ts +4 -3
- package/dist/esm/components/IconButton.d.ts.map +1 -1
- package/dist/esm/components/IconButton.js +37 -65
- package/dist/esm/components/IconButton.js.map +1 -1
- package/dist/esm/components/Markdown.d.ts.map +1 -1
- package/dist/esm/components/Markdown.js +2 -2
- package/dist/esm/components/Markdown.js.map +1 -1
- package/dist/esm/components/Notification.js +1 -1
- package/dist/esm/components/Notification.js.map +1 -1
- package/dist/esm/components/Pagination.d.ts.map +1 -1
- package/dist/esm/components/Pagination.js +2 -2
- package/dist/esm/components/Pagination.js.map +1 -1
- package/dist/esm/components/Popup.js +1 -1
- package/dist/esm/components/Popup.js.map +1 -1
- package/dist/esm/components/RadioGroup.d.ts.map +1 -1
- package/dist/esm/components/RadioGroup.js +14 -6
- package/dist/esm/components/RadioGroup.js.map +1 -1
- package/dist/esm/components/Searchbar.js +1 -1
- package/dist/esm/components/Searchbar.js.map +1 -1
- package/dist/esm/components/Spinner.d.ts +6 -2
- package/dist/esm/components/Spinner.d.ts.map +1 -1
- package/dist/esm/components/Spinner.js +34 -47
- package/dist/esm/components/Spinner.js.map +1 -1
- package/dist/esm/components/Tree.d.ts +1 -2
- package/dist/esm/components/Tree.d.ts.map +1 -1
- package/dist/esm/components/Tree.js +16 -24
- package/dist/esm/components/Tree.js.map +1 -1
- package/dist/esm/components/ZoomableImageCitationWrapper.js +1 -1
- package/dist/esm/stories/Banner.stories.js +1 -1
- package/dist/esm/stories/Banner.stories.js.map +1 -1
- package/dist/esm/stories/Button.stories.d.ts +3 -16
- package/dist/esm/stories/Button.stories.d.ts.map +1 -1
- package/dist/esm/stories/Button.stories.js +53 -166
- package/dist/esm/stories/Button.stories.js.map +1 -1
- package/dist/esm/stories/CardButton.stories.js +1 -1
- package/dist/esm/stories/CardButton.stories.js.map +1 -1
- package/dist/esm/stories/ContextItem.stories.d.ts.map +1 -1
- package/dist/esm/stories/ContextItem.stories.js +5 -5
- package/dist/esm/stories/ContextItem.stories.js.map +1 -1
- package/dist/esm/stories/Dialog.stories.js +1 -1
- package/dist/esm/stories/Dialog.stories.js.map +1 -1
- package/dist/esm/stories/DropdownMenu.stories.d.ts.map +1 -1
- package/dist/esm/stories/DropdownMenu.stories.js +7 -7
- package/dist/esm/stories/DropdownMenu.stories.js.map +1 -1
- package/dist/esm/stories/IconButton.stories.js +4 -4
- package/dist/esm/stories/IconButton.stories.js.map +1 -1
- package/dist/esm/stories/Markdown.stories.d.ts +1 -2
- package/dist/esm/stories/Markdown.stories.d.ts.map +1 -1
- package/dist/esm/stories/Modal.stories.d.ts.map +1 -1
- package/dist/esm/stories/Modal.stories.js +1 -2
- package/dist/esm/stories/Modal.stories.js.map +1 -1
- package/dist/esm/stories/NewDropdown.stories.js +2 -2
- package/dist/esm/stories/NewDropdown.stories.js.map +1 -1
- package/dist/esm/stories/Page.stories.d.ts.map +1 -1
- package/dist/esm/stories/Page.stories.js +6 -6
- package/dist/esm/stories/Page.stories.js.map +1 -1
- package/dist/esm/stories/Popover.stories.js +1 -1
- package/dist/esm/stories/Popover.stories.js.map +1 -1
- package/dist/esm/stories/RadioGroup.stories.d.ts.map +1 -1
- package/dist/esm/stories/RadioGroup.stories.js +4 -4
- package/dist/esm/stories/RadioGroup.stories.js.map +1 -1
- package/dist/esm/stories/Searchbar.stories.js +3 -3
- package/dist/esm/stories/Searchbar.stories.js.map +1 -1
- package/dist/esm/stories/SliderToggle.stories.js +2 -2
- package/dist/esm/stories/SliderToggle.stories.js.map +1 -1
- package/dist/esm/stories/Tree.stories.d.ts.map +1 -1
- package/dist/esm/stories/Tree.stories.js +17 -17
- package/dist/esm/stories/Tree.stories.js.map +1 -1
- package/dist/sparkle.css +148 -235
- package/package.json +1 -1
- package/src/components/AssistantPreview.tsx +1 -5
- package/src/components/Banner.tsx +1 -1
- package/src/components/BarHeader.tsx +8 -11
- package/src/components/Button.tsx +164 -237
- package/src/components/Checkbox.tsx +3 -3
- package/src/components/Citation.tsx +1 -1
- package/src/components/DataTable.tsx +2 -2
- package/src/components/Dialog.tsx +5 -5
- package/src/components/FilterChips.tsx +1 -2
- package/src/components/IconButton.tsx +51 -87
- package/src/components/Markdown.tsx +2 -3
- package/src/components/Notification.tsx +1 -1
- package/src/components/Pagination.tsx +2 -8
- package/src/components/Popup.tsx +1 -1
- package/src/components/RadioGroup.tsx +22 -18
- package/src/components/Searchbar.tsx +1 -1
- package/src/components/Spinner.tsx +45 -68
- package/src/components/Tree.tsx +18 -37
- package/src/components/ZoomableImageCitationWrapper.tsx +1 -1
- package/src/stories/Banner.stories.tsx +1 -1
- package/src/stories/Button.stories.tsx +60 -606
- package/src/stories/CardButton.stories.tsx +1 -1
- package/src/stories/ContextItem.stories.tsx +6 -11
- package/src/stories/Dialog.stories.tsx +1 -1
- package/src/stories/DropdownMenu.stories.tsx +8 -27
- package/src/stories/IconButton.stories.tsx +4 -4
- package/src/stories/Modal.stories.tsx +1 -2
- package/src/stories/NewDropdown.stories.tsx +2 -16
- package/src/stories/Page.stories.tsx +6 -9
- package/src/stories/Popover.stories.tsx +1 -1
- package/src/stories/RadioGroup.stories.tsx +5 -8
- package/src/stories/Searchbar.stories.tsx +3 -3
- package/src/stories/SliderToggle.stories.tsx +2 -2
- package/src/stories/Tree.stories.tsx +9 -22
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
1
2
|
import React, { ComponentType, MouseEventHandler } from "react";
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
+
import { Button, ButtonVariantType } from "@sparkle/components/Button";
|
|
4
5
|
|
|
5
|
-
import { Icon
|
|
6
|
+
import { Icon } from "./Icon";
|
|
6
7
|
import { Tooltip } from "./Tooltip";
|
|
7
8
|
|
|
8
9
|
type IconButtonProps = {
|
|
9
|
-
variant?:
|
|
10
|
+
variant?: React.ComponentProps<typeof Button>["variant"];
|
|
10
11
|
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
11
|
-
size?:
|
|
12
|
+
size?: React.ComponentProps<typeof Button>["size"];
|
|
12
13
|
tooltip?: string;
|
|
13
14
|
tooltipPosition?: React.ComponentProps<typeof Tooltip>["side"];
|
|
14
|
-
icon
|
|
15
|
+
icon: ComponentType;
|
|
15
16
|
className?: string;
|
|
16
17
|
disabled?: boolean;
|
|
17
18
|
};
|
|
@@ -19,100 +20,63 @@ type IconButtonProps = {
|
|
|
19
20
|
const baseClasses =
|
|
20
21
|
"s-transition-all s-ease-out s-duration-300 s-cursor-pointer hover:s-scale-110";
|
|
21
22
|
|
|
22
|
-
const
|
|
23
|
-
primary:
|
|
24
|
-
|
|
25
|
-
hover:
|
|
26
|
-
active:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
dark:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
active: "dark:active:s-text-action-600-dark",
|
|
56
|
-
disabled: "dark:s-text-element-500-dark",
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
tertiary: {
|
|
60
|
-
base: "s-text-element-700",
|
|
61
|
-
hover: "hover:s-text-action-400",
|
|
62
|
-
active: "active:s-text-action-600",
|
|
63
|
-
disabled: "s-text-element-500",
|
|
64
|
-
dark: {
|
|
65
|
-
base: "dark:s-text-element-700-dark",
|
|
66
|
-
hover: "dark:hover:s-text-action-500-dark",
|
|
67
|
-
active: "dark:active:s-text-action-600-dark",
|
|
68
|
-
disabled: "dark:s-text-element-500-dark",
|
|
23
|
+
const styleVariants: Record<ButtonVariantType, string> = {
|
|
24
|
+
primary:
|
|
25
|
+
"s-text-action-500 dark:s-text-action-500-dark" +
|
|
26
|
+
"hover:s-text-action-400 dark:hover:s-text-action-500-dark" +
|
|
27
|
+
"active:s-text-action-600 dark:active:s-text-action-600-dark" +
|
|
28
|
+
"s-text-element-500 dark:s-text-element-500-dark",
|
|
29
|
+
warning:
|
|
30
|
+
"s-text-warning-500 dark:s-text-warning-500-dark" +
|
|
31
|
+
"hover:s-text-warning-400 dark:hover:s-text-warning-500-dark" +
|
|
32
|
+
"active:s-text-warning-600 dark:active:s-text-warning-600-dark" +
|
|
33
|
+
"s-text-element-500 dark:s-text-element-500-dark",
|
|
34
|
+
highlight:
|
|
35
|
+
"s-text-element-900 dark:s-text-element-900-dark" +
|
|
36
|
+
"hover:s-text-action-400 dark:hover:s-text-action-500-dark" +
|
|
37
|
+
"active:s-text-action-600 dark:active:s-text-action-600-dark" +
|
|
38
|
+
"s-text-element-500 dark:s-text-element-500-dark",
|
|
39
|
+
outline:
|
|
40
|
+
"s-text-element-700 dark:s-text-element-700-dark" +
|
|
41
|
+
"hover:s-text-action-400 dark:hover:s-text-action-500-dark" +
|
|
42
|
+
"active:s-text-action-600 dark:active:s-text-action-600-dark" +
|
|
43
|
+
"s-text-element-500 dark:s-text-element-500-dark",
|
|
44
|
+
ghost:
|
|
45
|
+
"s-text-white s-text-white" +
|
|
46
|
+
"hover:s-text-slate-100 hover:s-text-slate-100" +
|
|
47
|
+
"active:s-text-slate-200 active:s-text-slate-200" +
|
|
48
|
+
"s-text-white/50 s-text-white/50",
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const iconButtonVariants = cva(baseClasses, {
|
|
52
|
+
variants: {
|
|
53
|
+
variant: styleVariants,
|
|
54
|
+
disabled: {
|
|
55
|
+
true: "s-text-element-500 s-cursor-default hover:s-scale-100",
|
|
69
56
|
},
|
|
70
57
|
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
active: "active:s-text-slate-200",
|
|
75
|
-
disabled: "s-text-white/50",
|
|
76
|
-
dark: {
|
|
77
|
-
base: "s-text-white",
|
|
78
|
-
hover: "hover:s-text-slate-100",
|
|
79
|
-
active: "active:s-text-slate-200",
|
|
80
|
-
disabled: "s-text-white/50",
|
|
81
|
-
},
|
|
58
|
+
defaultVariants: {
|
|
59
|
+
variant: "outline",
|
|
60
|
+
disabled: false,
|
|
82
61
|
},
|
|
83
|
-
};
|
|
62
|
+
});
|
|
84
63
|
|
|
85
64
|
export function IconButton({
|
|
86
|
-
variant
|
|
65
|
+
variant,
|
|
87
66
|
onClick,
|
|
88
67
|
disabled = false,
|
|
89
68
|
tooltip,
|
|
90
|
-
tooltipPosition
|
|
69
|
+
tooltipPosition,
|
|
91
70
|
icon,
|
|
92
|
-
className
|
|
93
|
-
size
|
|
71
|
+
className,
|
|
72
|
+
size,
|
|
94
73
|
}: IconButtonProps) {
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
const finalIconClasses = classNames(
|
|
99
|
-
className,
|
|
100
|
-
baseClasses,
|
|
101
|
-
iconGroup.base,
|
|
102
|
-
disabled ? iconGroup.disabled : iconGroup.hover,
|
|
103
|
-
disabled ? "" : iconGroup.active,
|
|
104
|
-
iconGroup.dark.base,
|
|
105
|
-
disabled ? iconGroup.dark.disabled : iconGroup.dark.hover,
|
|
106
|
-
disabled ? "" : iconGroup.dark.active
|
|
107
|
-
);
|
|
74
|
+
const iconSize = size || "sm";
|
|
75
|
+
const buttonClasses = iconButtonVariants({ variant, disabled, className });
|
|
108
76
|
|
|
109
77
|
const IconButtonContent = (
|
|
110
|
-
<button
|
|
111
|
-
|
|
112
|
-
onClick={disabled ? undefined : onClick}
|
|
113
|
-
disabled={disabled}
|
|
114
|
-
>
|
|
115
|
-
{icon && <Icon visual={icon} size={size as IconProps["size"]} />}
|
|
78
|
+
<button className={buttonClasses} onClick={onClick} disabled={disabled}>
|
|
79
|
+
<Icon visual={icon} size={iconSize} />
|
|
116
80
|
</button>
|
|
117
81
|
);
|
|
118
82
|
|
|
@@ -146,13 +146,12 @@ export function Markdown({
|
|
|
146
146
|
{childrenContent && (
|
|
147
147
|
<Button
|
|
148
148
|
size="xs"
|
|
149
|
-
variant="
|
|
149
|
+
variant="ghost"
|
|
150
150
|
onClick={async (e) => {
|
|
151
151
|
e.preventDefault();
|
|
152
152
|
await handleCopy();
|
|
153
153
|
}}
|
|
154
|
-
|
|
155
|
-
labelVisible={false}
|
|
154
|
+
tooltip="Copy"
|
|
156
155
|
icon={isCopied ? ClipboardCheckIcon : ClipboardIcon}
|
|
157
156
|
/>
|
|
158
157
|
)}
|
|
@@ -75,11 +75,8 @@ export function Pagination({
|
|
|
75
75
|
)}
|
|
76
76
|
>
|
|
77
77
|
<Button
|
|
78
|
-
variant="
|
|
78
|
+
variant="ghost"
|
|
79
79
|
size={size === "xs" ? "xs" : "sm"}
|
|
80
|
-
label="previous"
|
|
81
|
-
labelVisible={false}
|
|
82
|
-
disabledTooltip={true}
|
|
83
80
|
disabled={!canPreviousPage}
|
|
84
81
|
icon={ChevronLeftIcon}
|
|
85
82
|
onClick={previousPage}
|
|
@@ -96,11 +93,8 @@ export function Pagination({
|
|
|
96
93
|
</div>
|
|
97
94
|
|
|
98
95
|
<Button
|
|
99
|
-
variant="
|
|
96
|
+
variant="ghost"
|
|
100
97
|
size={size === "xs" ? "xs" : "sm"}
|
|
101
|
-
label="next"
|
|
102
|
-
labelVisible={false}
|
|
103
|
-
disabledTooltip={true}
|
|
104
98
|
disabled={!canNextPage}
|
|
105
99
|
icon={ChevronRightIcon}
|
|
106
100
|
onClick={nextPage}
|
package/src/components/Popup.tsx
CHANGED
|
@@ -3,12 +3,11 @@ import { cva, VariantProps } from "class-variance-authority";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
|
|
5
5
|
import { Tooltip } from "@sparkle/components/Tooltip";
|
|
6
|
-
import { CircleIcon } from "@sparkle/icons";
|
|
7
6
|
import { cn } from "@sparkle/lib/utils";
|
|
8
7
|
|
|
9
8
|
const radioStyles = cva(
|
|
10
9
|
cn(
|
|
11
|
-
"s-aspect-square s-
|
|
10
|
+
"s-aspect-square s-rounded-full s-border s-border-border-darker s-text-foreground",
|
|
12
11
|
"focus-visible:s-outline-none focus-visible:s-ring-2 focus-visible:s-ring-offset-2 focus-visible:s-ring-ring",
|
|
13
12
|
"disabled:s-cursor-not-allowed disabled:s-opacity-50",
|
|
14
13
|
"checked:s-ring-0 checked:s-bg-action-500"
|
|
@@ -26,6 +25,21 @@ const radioStyles = cva(
|
|
|
26
25
|
}
|
|
27
26
|
);
|
|
28
27
|
|
|
28
|
+
const radioIndicatorStyles = cva(
|
|
29
|
+
"s-bg-primary s-flex s-items-center s-justify-center s-rounded-full",
|
|
30
|
+
{
|
|
31
|
+
variants: {
|
|
32
|
+
size: {
|
|
33
|
+
xs: "s-h-2 s-w-2 s-ml-[3px]",
|
|
34
|
+
sm: "s-h-2.5 s-w-2.5 s-ml-1",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
defaultVariants: {
|
|
38
|
+
size: "xs",
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
|
|
29
43
|
const RadioGroup = React.forwardRef<
|
|
30
44
|
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
|
31
45
|
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
|
|
@@ -66,14 +80,9 @@ const RadioGroupItem = React.forwardRef<
|
|
|
66
80
|
className={cn(radioStyles({ size }), className)}
|
|
67
81
|
{...props}
|
|
68
82
|
>
|
|
69
|
-
<RadioGroupPrimitive.Indicator
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
size === "xs" ? "s-h-2.5 s-w-2.5" : "s-h-3 s-w-3",
|
|
73
|
-
"s-fill-current s-text-current focus:s-bg-action-50-dark"
|
|
74
|
-
)}
|
|
75
|
-
/>
|
|
76
|
-
</RadioGroupPrimitive.Indicator>
|
|
83
|
+
<RadioGroupPrimitive.Indicator
|
|
84
|
+
className={radioIndicatorStyles({ size })}
|
|
85
|
+
/>
|
|
77
86
|
</RadioGroupPrimitive.Item>
|
|
78
87
|
}
|
|
79
88
|
label={<span>{tooltipMessage}</span>}
|
|
@@ -84,14 +93,9 @@ const RadioGroupItem = React.forwardRef<
|
|
|
84
93
|
className={cn(radioStyles({ size }), className)}
|
|
85
94
|
{...props}
|
|
86
95
|
>
|
|
87
|
-
<RadioGroupPrimitive.Indicator
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
size === "xs" ? "s-h-2.5 s-w-2.5" : "s-h-3 s-w-3",
|
|
91
|
-
"s-fill-current s-text-current focus:s-bg-action-50-dark"
|
|
92
|
-
)}
|
|
93
|
-
/>
|
|
94
|
-
</RadioGroupPrimitive.Indicator>
|
|
96
|
+
<RadioGroupPrimitive.Indicator
|
|
97
|
+
className={radioIndicatorStyles({ size })}
|
|
98
|
+
/>
|
|
95
99
|
</RadioGroupPrimitive.Item>
|
|
96
100
|
)}
|
|
97
101
|
</div>
|
|
@@ -11,12 +11,27 @@ import animLightXS from "@sparkle/lottie/spinnerLight";
|
|
|
11
11
|
import animLightLG from "@sparkle/lottie/spinnerLightLG";
|
|
12
12
|
import animSimpleLight from "@sparkle/lottie/spinnerLightXS";
|
|
13
13
|
|
|
14
|
+
const SPINNER_SIZES = ["xs", "sm", "md", "lg", "xl", "xxl"] as const;
|
|
15
|
+
|
|
16
|
+
type SpinnerSizeType = (typeof SPINNER_SIZES)[number];
|
|
17
|
+
|
|
18
|
+
const SPINNER_VARIANTS = [
|
|
19
|
+
"color",
|
|
20
|
+
"light",
|
|
21
|
+
"dark",
|
|
22
|
+
"pink900",
|
|
23
|
+
"purple900",
|
|
24
|
+
"slate400",
|
|
25
|
+
] as const;
|
|
26
|
+
|
|
27
|
+
type SpinnerVariantType = (typeof SPINNER_VARIANTS)[number];
|
|
28
|
+
|
|
14
29
|
export interface SpinnerProps {
|
|
15
|
-
size?:
|
|
16
|
-
variant?:
|
|
30
|
+
size?: SpinnerSizeType;
|
|
31
|
+
variant?: SpinnerVariantType;
|
|
17
32
|
}
|
|
18
33
|
|
|
19
|
-
const pxSizeClasses = {
|
|
34
|
+
const pxSizeClasses: Record<SpinnerSizeType, string> = {
|
|
20
35
|
xs: "16",
|
|
21
36
|
sm: "20",
|
|
22
37
|
md: "24",
|
|
@@ -27,16 +42,12 @@ const pxSizeClasses = {
|
|
|
27
42
|
|
|
28
43
|
type LottieColorType = [number, number, number, number];
|
|
29
44
|
|
|
30
|
-
const colors:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
slate900: [0.0588, 0.0902, 0.1647, 1], // #0F172A
|
|
45
|
+
const colors: Record<Exclude<SpinnerVariantType, "color">, LottieColorType> = {
|
|
46
|
+
light: [1, 1, 1, 1],
|
|
47
|
+
dark: [0.0588, 0.0902, 0.1647, 1],
|
|
34
48
|
purple900: [0.298, 0.1137, 0.5843, 1], // #4C1D95
|
|
35
|
-
sky900: [0.0471, 0.2902, 0.4314, 1], // #0C4A6E
|
|
36
49
|
pink900: [0.5137, 0.0941, 0.2627, 1], // #831843
|
|
37
|
-
|
|
38
|
-
warning900: [0.498, 0.1137, 0.1137, 1], // #7F1D1D
|
|
39
|
-
action900: [0.1176, 0.2275, 0.5412, 1], // #1E3A8A
|
|
50
|
+
slate400: [0.5647, 0.6314, 0.7176, 1], // #94a3b8
|
|
40
51
|
};
|
|
41
52
|
|
|
42
53
|
const isColorArray = (arr: unknown): arr is LottieColorType => {
|
|
@@ -75,73 +86,39 @@ const Spinner: React.FC<SpinnerProps> = ({
|
|
|
75
86
|
|
|
76
87
|
switch (size) {
|
|
77
88
|
case "xs":
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
anim = animDarkXS;
|
|
85
|
-
break;
|
|
86
|
-
|
|
87
|
-
default:
|
|
88
|
-
anim = animColorXS;
|
|
89
|
-
}
|
|
89
|
+
anim =
|
|
90
|
+
variant === "light"
|
|
91
|
+
? animSimpleLight
|
|
92
|
+
: variant === "dark"
|
|
93
|
+
? animDarkXS
|
|
94
|
+
: animColorXS;
|
|
90
95
|
break;
|
|
91
|
-
|
|
92
96
|
case "xl":
|
|
93
97
|
case "xxl":
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
anim = animDarkLG;
|
|
101
|
-
break;
|
|
102
|
-
|
|
103
|
-
default:
|
|
104
|
-
anim = animColorLG;
|
|
105
|
-
}
|
|
98
|
+
anim =
|
|
99
|
+
variant === "light"
|
|
100
|
+
? animLightLG
|
|
101
|
+
: variant === "dark"
|
|
102
|
+
? animDarkLG
|
|
103
|
+
: animColorLG;
|
|
106
104
|
break;
|
|
107
|
-
|
|
108
105
|
default:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
anim = animDark;
|
|
116
|
-
break;
|
|
117
|
-
|
|
118
|
-
default:
|
|
119
|
-
anim = animColor;
|
|
120
|
-
}
|
|
106
|
+
anim =
|
|
107
|
+
variant === "light"
|
|
108
|
+
? animLightXS
|
|
109
|
+
: variant === "dark"
|
|
110
|
+
? animDark
|
|
111
|
+
: animColor;
|
|
121
112
|
}
|
|
122
113
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (newColor) {
|
|
129
|
-
replaceColors(animationData, newColor);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return (
|
|
133
|
-
<Lottie
|
|
134
|
-
animationData={animationData}
|
|
135
|
-
style={{ width: `${fullSize}px`, height: `${fullSize}px` }}
|
|
136
|
-
loop
|
|
137
|
-
autoplay
|
|
138
|
-
/>
|
|
139
|
-
);
|
|
140
|
-
}
|
|
114
|
+
const animationData =
|
|
115
|
+
variant === "color"
|
|
116
|
+
? anim
|
|
117
|
+
: replaceColors(JSON.parse(JSON.stringify(anim)), colors[variant]);
|
|
141
118
|
|
|
142
119
|
return (
|
|
143
120
|
<Lottie
|
|
144
|
-
animationData={
|
|
121
|
+
animationData={animationData}
|
|
145
122
|
style={{ width: `${fullSize}px`, height: `${fullSize}px` }}
|
|
146
123
|
loop
|
|
147
124
|
autoplay
|
package/src/components/Tree.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import React, { ComponentType, ReactNode, useState } from "react";
|
|
|
2
2
|
|
|
3
3
|
import Spinner from "@sparkle/components/Spinner";
|
|
4
4
|
import { ArrowDownSIcon, ArrowRightSIcon } from "@sparkle/icons";
|
|
5
|
-
import {
|
|
5
|
+
import { cn } from "@sparkle/lib/utils";
|
|
6
6
|
|
|
7
7
|
import { Checkbox, CheckboxProps } from "./Checkbox";
|
|
8
8
|
import { Icon } from "./Icon";
|
|
@@ -49,11 +49,10 @@ export function Tree({
|
|
|
49
49
|
</div>
|
|
50
50
|
) : (
|
|
51
51
|
<div
|
|
52
|
-
className={
|
|
53
|
-
"s-flex s-flex-col s-gap-
|
|
54
|
-
isBoxed
|
|
55
|
-
|
|
56
|
-
: ""
|
|
52
|
+
className={cn(
|
|
53
|
+
"s-flex s-flex-col s-gap-0.5 s-overflow-hidden",
|
|
54
|
+
isBoxed &&
|
|
55
|
+
"s-rounded-xl s-border s-border-structure-200 s-bg-structure-50 s-p-4"
|
|
57
56
|
)}
|
|
58
57
|
>
|
|
59
58
|
{modifiedChildren}
|
|
@@ -62,9 +61,9 @@ export function Tree({
|
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
const treeItemStyleClasses = {
|
|
65
|
-
base: "s-group/tree s-flex s-cursor-default s-flex-row s-items-center",
|
|
64
|
+
base: "s-group/tree s-flex s-cursor-default s-flex-row s-items-center s-gap-2 s-py-1.5",
|
|
66
65
|
isNavigatableBase:
|
|
67
|
-
"s-border s-transition-colors s-duration-300 s-ease-out s-cursor-pointer",
|
|
66
|
+
"s-rounded-lg s-pl-1.5 s-pr-3 s-border s-transition-colors s-duration-300 s-ease-out s-cursor-pointer",
|
|
68
67
|
isNavigatableUnselected:
|
|
69
68
|
"s-border-structure-200/0 s-bg-white/0 hover:s-border-structure-200 hover:s-bg-white",
|
|
70
69
|
isNavigatableSelected: "s-border-structure-200 s-bg-white",
|
|
@@ -73,7 +72,6 @@ const treeItemStyleClasses = {
|
|
|
73
72
|
interface TreeItemProps {
|
|
74
73
|
label?: string;
|
|
75
74
|
type?: "node" | "item" | "leaf";
|
|
76
|
-
size?: "sm" | "md";
|
|
77
75
|
tailwindIconTextColor?: string;
|
|
78
76
|
visual?: ComponentType<{ className?: string }>;
|
|
79
77
|
checkbox?: CheckboxProps;
|
|
@@ -104,7 +102,6 @@ Tree.Item = function ({
|
|
|
104
102
|
type = "node",
|
|
105
103
|
className = "",
|
|
106
104
|
labelClassName = "",
|
|
107
|
-
size = "sm",
|
|
108
105
|
tailwindIconTextColor = "s-text-element-800",
|
|
109
106
|
visual,
|
|
110
107
|
checkbox,
|
|
@@ -145,25 +142,18 @@ Tree.Item = function ({
|
|
|
145
142
|
return (
|
|
146
143
|
<>
|
|
147
144
|
<div
|
|
148
|
-
className={
|
|
149
|
-
className ? className : "",
|
|
145
|
+
className={cn(
|
|
150
146
|
treeItemStyleClasses.base,
|
|
151
147
|
onItemClick ? "s-cursor-pointer" : "",
|
|
152
148
|
isNavigatable ? treeItemStyleClasses.isNavigatableBase : "",
|
|
153
|
-
isNavigatable
|
|
154
|
-
? size === "sm"
|
|
155
|
-
? "s-gap-1 s-rounded-lg s-py-1 s-pl-1.5 s-pr-3"
|
|
156
|
-
: "s-gap-2 s-rounded-lg s-py-2 s-pl-2.5 s-pr-4"
|
|
157
|
-
: size === "sm"
|
|
158
|
-
? "s-gap-1 s-py-1"
|
|
159
|
-
: "s-gap-2 s-py-2",
|
|
160
149
|
isNavigatable
|
|
161
150
|
? isSelected
|
|
162
151
|
? treeItemStyleClasses.isNavigatableSelected
|
|
163
152
|
: treeItemStyleClasses.isNavigatableUnselected
|
|
164
153
|
: "",
|
|
165
154
|
isExpanded ? "is-expanded" : "is-collapsed",
|
|
166
|
-
type
|
|
155
|
+
type,
|
|
156
|
+
className
|
|
167
157
|
)}
|
|
168
158
|
onClick={onItemClick ? onItemClick : undefined}
|
|
169
159
|
>
|
|
@@ -171,7 +161,7 @@ Tree.Item = function ({
|
|
|
171
161
|
<IconButton
|
|
172
162
|
icon={isExpanded ? ArrowDownSIcon : ArrowRightSIcon}
|
|
173
163
|
size="xs"
|
|
174
|
-
variant="
|
|
164
|
+
variant="outline"
|
|
175
165
|
onClick={(e) => {
|
|
176
166
|
e.stopPropagation();
|
|
177
167
|
if (effectiveOnChevronClick) {
|
|
@@ -182,28 +172,19 @@ Tree.Item = function ({
|
|
|
182
172
|
)}
|
|
183
173
|
{type === "leaf" && <div className="s-w-4 s-flex-shrink-0"></div>}
|
|
184
174
|
{checkbox && <Checkbox {...checkbox} size="xs" />}
|
|
185
|
-
<Icon
|
|
186
|
-
visual={visual}
|
|
187
|
-
size={size === "sm" ? "sm" : "md"}
|
|
188
|
-
className={classNames("s-flex-shrink-0", tailwindIconTextColor)}
|
|
189
|
-
/>
|
|
190
|
-
|
|
175
|
+
<Icon visual={visual} size="xs" className={tailwindIconTextColor} />
|
|
191
176
|
<div
|
|
192
|
-
className={
|
|
193
|
-
`s-truncate s-font-medium s-text-element-900 ${labelClassName}`,
|
|
194
|
-
size === "sm" ? "s-ml-1 s-text-sm" : "s-ml-1 s-text-base"
|
|
195
|
-
)}
|
|
177
|
+
className={`s-font-regular s-truncate s-text-sm s-text-element-900 ${labelClassName}`}
|
|
196
178
|
>
|
|
197
179
|
{label}
|
|
198
180
|
</div>
|
|
199
181
|
<div className="s-grow" />
|
|
200
182
|
{actions && (
|
|
201
183
|
<div
|
|
202
|
-
className={
|
|
184
|
+
className={cn(
|
|
203
185
|
"s-flex s-gap-2 s-pl-4",
|
|
204
|
-
areActionsFading
|
|
205
|
-
|
|
206
|
-
: ""
|
|
186
|
+
areActionsFading &&
|
|
187
|
+
"s-transform s-opacity-0 s-duration-300 group-hover/tree:s-opacity-100"
|
|
207
188
|
)}
|
|
208
189
|
>
|
|
209
190
|
{actions}
|
|
@@ -211,7 +192,7 @@ Tree.Item = function ({
|
|
|
211
192
|
)}
|
|
212
193
|
</div>
|
|
213
194
|
{React.Children.count(childrenToRender) > 0 && (
|
|
214
|
-
<div className="s-pl-
|
|
195
|
+
<div className="s-pl-4">{childrenToRender}</div>
|
|
215
196
|
)}
|
|
216
197
|
</>
|
|
217
198
|
);
|
|
@@ -223,7 +204,7 @@ interface TreeEmptyProps {
|
|
|
223
204
|
|
|
224
205
|
Tree.Empty = function ({ label }: TreeEmptyProps) {
|
|
225
206
|
return (
|
|
226
|
-
<div className="s-py-1 s-pl-6 s-text-sm s-
|
|
207
|
+
<div className="s-font-regular s-py-1.5 s-pl-6 s-text-sm s-text-muted-foreground">
|
|
227
208
|
{label}
|
|
228
209
|
</div>
|
|
229
210
|
);
|
|
@@ -20,7 +20,7 @@ export const BasicBanner = () => {
|
|
|
20
20
|
<p>
|
|
21
21
|
Join us in Denver from June 7 – 9 to see what’s coming next
|
|
22
22
|
</p>
|
|
23
|
-
<Button variant="
|
|
23
|
+
<Button variant="ghost" size="sm" label="Register Now" />
|
|
24
24
|
</div>
|
|
25
25
|
</Banner>
|
|
26
26
|
<Banner variant="incident">
|