@dust-tt/sparkle 0.2.528 → 0.2.529-rc-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/dist/cjs/index.js +1 -1
- package/dist/esm/components/AssistantCard.d.ts +2 -2
- package/dist/esm/components/AssistantCard.d.ts.map +1 -1
- package/dist/esm/components/Button.d.ts +24 -8
- package/dist/esm/components/Button.d.ts.map +1 -1
- package/dist/esm/components/Button.js +29 -33
- package/dist/esm/components/Button.js.map +1 -1
- package/dist/esm/components/Card.d.ts +12 -1
- package/dist/esm/components/Card.d.ts.map +1 -1
- package/dist/esm/components/Card.js.map +1 -1
- package/dist/esm/components/EmptyCTA.d.ts +3 -3
- package/dist/esm/components/EmptyCTA.d.ts.map +1 -1
- package/dist/esm/components/EmptyCTA.js +1 -1
- package/dist/esm/components/EmptyCTA.js.map +1 -1
- package/dist/esm/components/IconButton.d.ts.map +1 -1
- package/dist/esm/components/IconButton.js +1 -1
- package/dist/esm/components/IconButton.js.map +1 -1
- package/dist/esm/components/LinkWrapper.d.ts +1 -0
- package/dist/esm/components/LinkWrapper.d.ts.map +1 -1
- package/dist/esm/components/LinkWrapper.js +2 -2
- package/dist/esm/components/LinkWrapper.js.map +1 -1
- package/dist/esm/components/SplitButton.d.ts +3 -3
- package/dist/esm/components/SplitButton.d.ts.map +1 -1
- package/dist/esm/components/SplitButton.js.map +1 -1
- package/dist/esm/components/Tabs.d.ts +1 -1
- package/dist/esm/components/Tabs.js +1 -1
- package/dist/esm/components/Tabs.js.map +1 -1
- package/dist/esm/components/index.d.ts +1 -1
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/context.d.ts +1 -0
- package/dist/esm/context.d.ts.map +1 -1
- package/dist/esm/context.js +7 -4
- package/dist/esm/context.js.map +1 -1
- package/dist/esm/stories/Button.stories.d.ts +2 -2
- package/dist/esm/stories/Button.stories.d.ts.map +1 -1
- package/dist/esm/stories/Button.stories.js +12 -5
- package/dist/esm/stories/Button.stories.js.map +1 -1
- package/dist/esm/stories/Chip.stories.d.ts +1 -0
- package/dist/esm/stories/Chip.stories.d.ts.map +1 -1
- package/dist/esm/stories/EmptyCTA.stories.d.ts.map +1 -1
- package/dist/esm/stories/EmptyCTA.stories.js +4 -6
- package/dist/esm/stories/EmptyCTA.stories.js.map +1 -1
- package/dist/esm/stories/IconButton.stories.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/AssistantCard.tsx +2 -2
- package/src/components/Button.tsx +148 -91
- package/src/components/Card.tsx +2 -2
- package/src/components/EmptyCTA.tsx +11 -13
- package/src/components/IconButton.tsx +0 -1
- package/src/components/LinkWrapper.tsx +26 -19
- package/src/components/SplitButton.tsx +4 -4
- package/src/components/Tabs.tsx +1 -1
- package/src/components/index.ts +2 -2
- package/src/context.tsx +18 -4
- package/src/stories/Button.stories.tsx +24 -4
- package/src/stories/EmptyCTA.stories.tsx +3 -6
package/src/context.tsx
CHANGED
|
@@ -2,6 +2,8 @@ import React, { ComponentType, MouseEvent, ReactNode } from "react";
|
|
|
2
2
|
import type { UrlObject } from "url";
|
|
3
3
|
import url from "url";
|
|
4
4
|
|
|
5
|
+
import { cn } from "./lib/utils";
|
|
6
|
+
|
|
5
7
|
type SparkleLinkProps = {
|
|
6
8
|
href: string | UrlObject;
|
|
7
9
|
className?: string;
|
|
@@ -22,6 +24,7 @@ type SparkleLinkProps = {
|
|
|
22
24
|
target?: string;
|
|
23
25
|
rel?: string;
|
|
24
26
|
prefetch?: boolean;
|
|
27
|
+
disabled?: boolean;
|
|
25
28
|
};
|
|
26
29
|
|
|
27
30
|
export type SparkleContextLinkType = ComponentType<
|
|
@@ -34,12 +37,24 @@ export type SparkleContextType = {
|
|
|
34
37
|
};
|
|
35
38
|
};
|
|
36
39
|
|
|
40
|
+
// To mimic disabled button behavior, we disable pointer events
|
|
41
|
+
// if disabled is true.
|
|
37
42
|
export const aLink: SparkleContextLinkType = React.forwardRef<
|
|
38
43
|
HTMLAnchorElement,
|
|
39
44
|
SparkleLinkProps
|
|
40
45
|
>(
|
|
41
46
|
(
|
|
42
|
-
{
|
|
47
|
+
{
|
|
48
|
+
href,
|
|
49
|
+
className,
|
|
50
|
+
ariaCurrent,
|
|
51
|
+
ariaLabel,
|
|
52
|
+
onClick,
|
|
53
|
+
children,
|
|
54
|
+
target,
|
|
55
|
+
rel,
|
|
56
|
+
disabled,
|
|
57
|
+
},
|
|
43
58
|
ref
|
|
44
59
|
) => {
|
|
45
60
|
const hrefAsString = typeof href !== "string" ? url.format(href) : href;
|
|
@@ -48,7 +63,7 @@ export const aLink: SparkleContextLinkType = React.forwardRef<
|
|
|
48
63
|
<a
|
|
49
64
|
ref={ref}
|
|
50
65
|
href={hrefAsString}
|
|
51
|
-
className={className}
|
|
66
|
+
className={cn(className, disabled && "s-pointer-events-none")}
|
|
52
67
|
aria-current={ariaCurrent}
|
|
53
68
|
aria-label={ariaLabel}
|
|
54
69
|
onClick={onClick}
|
|
@@ -64,10 +79,9 @@ export const aLink: SparkleContextLinkType = React.forwardRef<
|
|
|
64
79
|
export const noHrefLink: SparkleContextLinkType = React.forwardRef<
|
|
65
80
|
HTMLAnchorElement,
|
|
66
81
|
SparkleLinkProps
|
|
67
|
-
>(({
|
|
82
|
+
>(({ ariaCurrent, ariaLabel, onClick, children }, ref) => (
|
|
68
83
|
<a
|
|
69
84
|
ref={ref}
|
|
70
|
-
className={className}
|
|
71
85
|
aria-current={ariaCurrent}
|
|
72
86
|
aria-label={ariaLabel}
|
|
73
87
|
onClick={onClick}
|
|
@@ -120,6 +120,13 @@ const ButtonBySize = ({
|
|
|
120
120
|
label="Button with href"
|
|
121
121
|
href="hello"
|
|
122
122
|
/>
|
|
123
|
+
<Button
|
|
124
|
+
size={size}
|
|
125
|
+
variant="primary"
|
|
126
|
+
label="Button with href and disabled"
|
|
127
|
+
href="hello"
|
|
128
|
+
disabled={true}
|
|
129
|
+
/>
|
|
123
130
|
</div>
|
|
124
131
|
<div className="s-flex s-items-center s-gap-4">
|
|
125
132
|
<Button size={size} label="Button" isLoading />
|
|
@@ -140,10 +147,23 @@ const ButtonBySize = ({
|
|
|
140
147
|
|
|
141
148
|
export const Gallery: Story = {
|
|
142
149
|
render: () => (
|
|
143
|
-
<div className="s-flex s-flex-col s-gap-
|
|
144
|
-
<
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
<div className="s-flex s-flex-col s-gap-6">
|
|
151
|
+
<div className="s-flex s-flex-col s-gap-4">
|
|
152
|
+
<ButtonBySize size="xs" />
|
|
153
|
+
<ButtonBySize size="sm" />
|
|
154
|
+
<ButtonBySize size="md" />
|
|
155
|
+
</div>
|
|
156
|
+
<Separator />
|
|
157
|
+
<h3 className="s-text-primary dark:s-text-primary-50">With tooltip</h3>
|
|
158
|
+
<div className="s-flex s-gap-4">
|
|
159
|
+
<Button label="Button with tooltip" tooltip="Hello" />
|
|
160
|
+
<Button
|
|
161
|
+
label="Button as link with tooltip"
|
|
162
|
+
href="https://dust.tt"
|
|
163
|
+
target="_blank"
|
|
164
|
+
tooltip="Hello"
|
|
165
|
+
/>
|
|
166
|
+
</div>
|
|
147
167
|
</div>
|
|
148
168
|
),
|
|
149
169
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Meta } from "@storybook/react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { CloudArrowDownIcon
|
|
4
|
+
import { EmptyCTA, EmptyCTAButton } from "@sparkle/components";
|
|
5
|
+
import { CloudArrowDownIcon } from "@sparkle/icons/app";
|
|
6
6
|
|
|
7
7
|
const meta = {
|
|
8
8
|
title: "Components/EmptyCTA",
|
|
@@ -12,7 +12,7 @@ export default meta;
|
|
|
12
12
|
|
|
13
13
|
export const Demo = () => {
|
|
14
14
|
return (
|
|
15
|
-
<div
|
|
15
|
+
<div>
|
|
16
16
|
<div className="s-flex s-items-center s-space-x-2">
|
|
17
17
|
<EmptyCTA
|
|
18
18
|
action={
|
|
@@ -24,9 +24,6 @@ export const Demo = () => {
|
|
|
24
24
|
message="You don't have any spaces yet."
|
|
25
25
|
/>
|
|
26
26
|
</div>
|
|
27
|
-
<div className="s-flex s-items-center s-space-x-2">
|
|
28
|
-
<EmptyCTA action={<Button icon={PlusIcon} label="Add domain" />} />
|
|
29
|
-
</div>
|
|
30
27
|
</div>
|
|
31
28
|
);
|
|
32
29
|
};
|