@dust-tt/sparkle 0.2.502 → 0.2.503-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 +1 -1
- package/dist/esm/components/Button.d.ts.map +1 -1
- package/dist/esm/components/Popover.d.ts +9 -2
- package/dist/esm/components/Popover.d.ts.map +1 -1
- package/dist/esm/components/Popover.js +53 -2
- package/dist/esm/components/Popover.js.map +1 -1
- package/dist/esm/components/RadioGroup.js +3 -3
- package/dist/esm/components/index.d.ts +1 -2
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +1 -2
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/stories/AnchoredPopover.stories.d.ts +14 -0
- package/dist/esm/stories/AnchoredPopover.stories.d.ts.map +1 -0
- package/dist/esm/stories/AnchoredPopover.stories.js +69 -0
- package/dist/esm/stories/AnchoredPopover.stories.js.map +1 -0
- package/dist/esm/stories/Breadcrumbs.stories.d.ts.map +1 -1
- package/dist/esm/stories/Breadcrumbs.stories.js +1 -3
- package/dist/esm/stories/Breadcrumbs.stories.js.map +1 -1
- package/dist/sparkle.css +8 -127
- package/package.json +1 -1
- package/src/components/Button.tsx +1 -1
- package/src/components/Popover.tsx +93 -5
- package/src/components/RadioGroup.tsx +3 -3
- package/src/components/index.ts +2 -7
- package/src/stories/AnchoredPopover.stories.tsx +115 -0
- package/src/stories/Breadcrumbs.stories.tsx +1 -3
- package/dist/esm/components/TourGuide.d.ts +0 -39
- package/dist/esm/components/TourGuide.d.ts.map +0 -1
- package/dist/esm/components/TourGuide.js +0 -145
- package/dist/esm/components/TourGuide.js.map +0 -1
- package/dist/esm/stories/TourGuide.stories.d.ts +0 -4
- package/dist/esm/stories/TourGuide.stories.d.ts.map +0 -1
- package/dist/esm/stories/TourGuide.stories.js +0 -133
- package/dist/esm/stories/TourGuide.stories.js.map +0 -1
- package/src/components/TourGuide.tsx +0 -316
- package/src/stories/TourGuide.stories.tsx +0 -472
|
@@ -5,12 +5,11 @@ import { useEffect, useState } from "react";
|
|
|
5
5
|
import { cn } from "@sparkle/lib/utils";
|
|
6
6
|
|
|
7
7
|
const PopoverRoot = PopoverPrimitive.Root;
|
|
8
|
-
|
|
9
8
|
const PopoverTrigger = PopoverPrimitive.Trigger;
|
|
10
|
-
|
|
11
9
|
const PopoverPortal = PopoverPrimitive.Portal;
|
|
10
|
+
const PopoverAnchor = PopoverPrimitive.Anchor;
|
|
12
11
|
|
|
13
|
-
interface PopoverContentProps
|
|
12
|
+
export interface PopoverContentProps
|
|
14
13
|
extends React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> {
|
|
15
14
|
fullWidth?: boolean;
|
|
16
15
|
mountPortal?: boolean;
|
|
@@ -68,7 +67,7 @@ const PopoverContent = React.forwardRef<
|
|
|
68
67
|
const defaultContainer = dialogElements[dialogElements.length - 1];
|
|
69
68
|
setContainer(defaultContainer);
|
|
70
69
|
}
|
|
71
|
-
}, []);
|
|
70
|
+
}, [mountPortal, container]);
|
|
72
71
|
|
|
73
72
|
return mountPortal ? (
|
|
74
73
|
<PopoverPrimitive.Portal container={container}>
|
|
@@ -102,4 +101,93 @@ function Popover({
|
|
|
102
101
|
|
|
103
102
|
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
104
103
|
|
|
105
|
-
|
|
104
|
+
interface AnchoredPopoverProps extends PopoverContentProps {
|
|
105
|
+
open: boolean;
|
|
106
|
+
anchorRef?: React.RefObject<HTMLElement>;
|
|
107
|
+
children: React.ReactNode;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function AnchoredPopover({
|
|
111
|
+
open,
|
|
112
|
+
anchorRef,
|
|
113
|
+
children,
|
|
114
|
+
...props
|
|
115
|
+
}: AnchoredPopoverProps) {
|
|
116
|
+
const [position, setPosition] = useState({
|
|
117
|
+
top: "50%",
|
|
118
|
+
left: "50%",
|
|
119
|
+
width: "0px",
|
|
120
|
+
height: "0px",
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (!open) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const updatePosition = () => {
|
|
129
|
+
if (!anchorRef?.current) {
|
|
130
|
+
setPosition({
|
|
131
|
+
top: "50%",
|
|
132
|
+
left: "50%",
|
|
133
|
+
width: "0px",
|
|
134
|
+
height: "0px",
|
|
135
|
+
});
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const rect = anchorRef.current.getBoundingClientRect();
|
|
140
|
+
setPosition({
|
|
141
|
+
top: `${rect.top}px`,
|
|
142
|
+
left: `${rect.left}px`,
|
|
143
|
+
width: `${rect.width}px`,
|
|
144
|
+
height: `${rect.height}px`,
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
updatePosition();
|
|
149
|
+
|
|
150
|
+
const resizeObserver = new ResizeObserver(updatePosition);
|
|
151
|
+
if (anchorRef?.current) {
|
|
152
|
+
resizeObserver.observe(anchorRef.current);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
156
|
+
|
|
157
|
+
return () => {
|
|
158
|
+
resizeObserver.disconnect();
|
|
159
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
160
|
+
};
|
|
161
|
+
}, [open, anchorRef]);
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<PopoverRoot open={open} modal={false}>
|
|
165
|
+
<PopoverAnchor
|
|
166
|
+
className="s-fixed s-transition-all s-duration-300 s-ease-in-out"
|
|
167
|
+
style={{
|
|
168
|
+
top: position.top,
|
|
169
|
+
left: position.left,
|
|
170
|
+
width: position.width,
|
|
171
|
+
height: position.height,
|
|
172
|
+
}}
|
|
173
|
+
/>
|
|
174
|
+
<PopoverContent
|
|
175
|
+
{...props}
|
|
176
|
+
onOpenAutoFocus={(e) => e.preventDefault()}
|
|
177
|
+
mountPortal={false}
|
|
178
|
+
>
|
|
179
|
+
{children}
|
|
180
|
+
</PopoverContent>
|
|
181
|
+
</PopoverRoot>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export {
|
|
186
|
+
AnchoredPopover,
|
|
187
|
+
Popover,
|
|
188
|
+
PopoverAnchor,
|
|
189
|
+
PopoverContent,
|
|
190
|
+
PopoverPortal,
|
|
191
|
+
PopoverRoot,
|
|
192
|
+
PopoverTrigger,
|
|
193
|
+
};
|
|
@@ -106,7 +106,7 @@ const RadioGroupItem = React.forwardRef<
|
|
|
106
106
|
);
|
|
107
107
|
|
|
108
108
|
const wrappedItem = (
|
|
109
|
-
<div className="s-flex s-items-center s-gap-2
|
|
109
|
+
<div className="s-flex s-w-full s-items-center s-gap-2">
|
|
110
110
|
{tooltipMessage ? (
|
|
111
111
|
<Tooltip trigger={item} label={tooltipMessage} />
|
|
112
112
|
) : (
|
|
@@ -165,12 +165,12 @@ const RadioGroupCustomItem = React.forwardRef<
|
|
|
165
165
|
return (
|
|
166
166
|
<div
|
|
167
167
|
className={cn(
|
|
168
|
-
"s-flex s-
|
|
168
|
+
"s-flex s-w-full s-flex-col",
|
|
169
169
|
className,
|
|
170
170
|
`s-items-${iconPosition}`
|
|
171
171
|
)}
|
|
172
172
|
>
|
|
173
|
-
<div className="s-flex s-items-center s-gap-2
|
|
173
|
+
<div className="s-flex s-w-full s-items-center s-gap-2">
|
|
174
174
|
{item}
|
|
175
175
|
{customItem}
|
|
176
176
|
</div>
|
package/src/components/index.ts
CHANGED
|
@@ -103,7 +103,9 @@ export { PaginatedCitationsGrid } from "./PaginatedCitationsGrid";
|
|
|
103
103
|
export { Pagination } from "./Pagination";
|
|
104
104
|
export { ColorPicker, IconPicker } from "./Picker";
|
|
105
105
|
export {
|
|
106
|
+
AnchoredPopover,
|
|
106
107
|
Popover,
|
|
108
|
+
PopoverAnchor,
|
|
107
109
|
PopoverContent,
|
|
108
110
|
PopoverPortal,
|
|
109
111
|
PopoverRoot,
|
|
@@ -147,13 +149,6 @@ export {
|
|
|
147
149
|
TooltipRoot,
|
|
148
150
|
TooltipTrigger,
|
|
149
151
|
} from "./Tooltip";
|
|
150
|
-
export {
|
|
151
|
-
TourGuide,
|
|
152
|
-
TourGuideCard,
|
|
153
|
-
TourGuideCardContent,
|
|
154
|
-
TourGuideCardTitle,
|
|
155
|
-
TourGuideCardVisual,
|
|
156
|
-
} from "./TourGuide";
|
|
157
152
|
export { Tree } from "./Tree";
|
|
158
153
|
export { TypingAnimation } from "./TypingAnimation";
|
|
159
154
|
export { ValueCard } from "./ValueCard";
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import React, { useRef, useState } from "react";
|
|
3
|
+
|
|
4
|
+
import { Button } from "@sparkle/components/Button";
|
|
5
|
+
import { AnchoredPopover } from "@sparkle/components/Popover";
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
title: "Components/AnchoredPopover",
|
|
9
|
+
component: AnchoredPopover,
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: "centered",
|
|
12
|
+
},
|
|
13
|
+
tags: ["autodocs"],
|
|
14
|
+
} satisfies Meta<typeof AnchoredPopover>;
|
|
15
|
+
|
|
16
|
+
export default meta;
|
|
17
|
+
type Story = StoryObj<typeof meta>;
|
|
18
|
+
|
|
19
|
+
const ExampleWrapper = ({ children }: { children: React.ReactNode }) => (
|
|
20
|
+
<div className="s-flex s-h-[400px] s-w-[600px] s-items-center s-justify-center s-gap-8">
|
|
21
|
+
{children}
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const MultipleAnchorsExample = () => {
|
|
26
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
27
|
+
const [activeRef, setActiveRef] =
|
|
28
|
+
useState<React.RefObject<HTMLButtonElement>>();
|
|
29
|
+
const topRef = useRef<HTMLButtonElement>(null);
|
|
30
|
+
const rightRef = useRef<HTMLButtonElement>(null);
|
|
31
|
+
const bottomRef = useRef<HTMLButtonElement>(null);
|
|
32
|
+
const leftRef = useRef<HTMLButtonElement>(null);
|
|
33
|
+
|
|
34
|
+
const handleClick = (ref: React.RefObject<HTMLButtonElement>) => {
|
|
35
|
+
setActiveRef(ref);
|
|
36
|
+
setIsOpen(true);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<ExampleWrapper>
|
|
41
|
+
<div className="s-relative s-flex s-h-48 s-w-48 s-flex-col s-items-center s-justify-center">
|
|
42
|
+
<div className="s-absolute s-left-1/2 s-top-0 s--translate-x-1/2">
|
|
43
|
+
<Button
|
|
44
|
+
ref={topRef}
|
|
45
|
+
label="Top"
|
|
46
|
+
onClick={() => handleClick(topRef)}
|
|
47
|
+
size="sm"
|
|
48
|
+
/>
|
|
49
|
+
</div>
|
|
50
|
+
<div className="s-absolute s-right-0 s-top-1/2 s--translate-y-1/2">
|
|
51
|
+
<Button
|
|
52
|
+
ref={rightRef}
|
|
53
|
+
label="Right"
|
|
54
|
+
onClick={() => handleClick(rightRef)}
|
|
55
|
+
size="sm"
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
<div className="s-absolute s-bottom-0 s-left-1/2 s--translate-x-1/2">
|
|
59
|
+
<Button
|
|
60
|
+
ref={bottomRef}
|
|
61
|
+
label="Bottom"
|
|
62
|
+
onClick={() => handleClick(bottomRef)}
|
|
63
|
+
size="sm"
|
|
64
|
+
/>
|
|
65
|
+
</div>
|
|
66
|
+
<div className="s-absolute s-left-0 s-top-1/2 s--translate-y-1/2">
|
|
67
|
+
<Button
|
|
68
|
+
ref={leftRef}
|
|
69
|
+
label="Left"
|
|
70
|
+
onClick={() => handleClick(leftRef)}
|
|
71
|
+
size="sm"
|
|
72
|
+
/>
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<AnchoredPopover
|
|
76
|
+
open={isOpen}
|
|
77
|
+
anchorRef={activeRef}
|
|
78
|
+
side={
|
|
79
|
+
activeRef === topRef
|
|
80
|
+
? "top"
|
|
81
|
+
: activeRef === rightRef
|
|
82
|
+
? "right"
|
|
83
|
+
: activeRef === bottomRef
|
|
84
|
+
? "bottom"
|
|
85
|
+
: "left"
|
|
86
|
+
}
|
|
87
|
+
className="s-w-40 s-p-4"
|
|
88
|
+
>
|
|
89
|
+
<div className="s-text-sm">
|
|
90
|
+
This popover is anchored to the{" "}
|
|
91
|
+
{activeRef === topRef
|
|
92
|
+
? "top"
|
|
93
|
+
: activeRef === rightRef
|
|
94
|
+
? "right"
|
|
95
|
+
: activeRef === bottomRef
|
|
96
|
+
? "bottom"
|
|
97
|
+
: "left"}{" "}
|
|
98
|
+
button.
|
|
99
|
+
</div>
|
|
100
|
+
</AnchoredPopover>
|
|
101
|
+
</div>
|
|
102
|
+
</ExampleWrapper>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const Example: Story = {
|
|
107
|
+
args: {
|
|
108
|
+
open: true,
|
|
109
|
+
side: "bottom",
|
|
110
|
+
align: "center",
|
|
111
|
+
sideOffset: 4,
|
|
112
|
+
children: <div>Popover content</div>,
|
|
113
|
+
},
|
|
114
|
+
render: () => <MultipleAnchorsExample />,
|
|
115
|
+
};
|
|
@@ -27,9 +27,7 @@ type BreadcrumbsExampleProps = {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
export const BreadcrumbsExample = (args: BreadcrumbsExampleProps) => {
|
|
30
|
-
const items0 = [
|
|
31
|
-
{ label: "Home", icon: HomeIcon },
|
|
32
|
-
];
|
|
30
|
+
const items0 = [{ label: "Home", icon: HomeIcon }];
|
|
33
31
|
|
|
34
32
|
const items1 = [
|
|
35
33
|
{ label: "Home", href: "#", icon: HomeIcon },
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface TourGuideCardProps {
|
|
3
|
-
anchorRef?: React.RefObject<HTMLDivElement>;
|
|
4
|
-
title?: string;
|
|
5
|
-
content?: React.ReactNode;
|
|
6
|
-
visual?: React.ReactNode;
|
|
7
|
-
onNext?: () => void;
|
|
8
|
-
onDismiss?: () => void;
|
|
9
|
-
isLastStep?: boolean;
|
|
10
|
-
className?: string;
|
|
11
|
-
children?: React.ReactNode;
|
|
12
|
-
asPopover?: boolean;
|
|
13
|
-
align?: "start" | "center" | "end";
|
|
14
|
-
side?: "top" | "right" | "bottom" | "left";
|
|
15
|
-
sideOffset?: number;
|
|
16
|
-
currentIndex?: number;
|
|
17
|
-
totalCards?: number;
|
|
18
|
-
}
|
|
19
|
-
export declare const TourGuideCardTitle: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
20
|
-
export declare const TourGuideCardContent: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
21
|
-
export declare const TourGuideCardVisual: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
22
|
-
interface TourGuideCardActionsProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
23
|
-
currentIndex: number;
|
|
24
|
-
totalCards: number;
|
|
25
|
-
onNext?: () => void;
|
|
26
|
-
onDismiss?: () => void;
|
|
27
|
-
}
|
|
28
|
-
export declare const TourGuideCardActions: React.ForwardRefExoticComponent<TourGuideCardActionsProps & React.RefAttributes<HTMLDivElement>>;
|
|
29
|
-
export declare const TourGuideCard: React.ForwardRefExoticComponent<TourGuideCardProps & React.RefAttributes<HTMLDivElement>>;
|
|
30
|
-
export interface TourGuideProps {
|
|
31
|
-
children: React.ReactNode;
|
|
32
|
-
autoStart?: boolean;
|
|
33
|
-
onStart?: () => void;
|
|
34
|
-
onEnd?: () => void;
|
|
35
|
-
onDismiss?: () => void;
|
|
36
|
-
}
|
|
37
|
-
export declare function TourGuide({ children, autoStart, onStart, onEnd, onDismiss, }: TourGuideProps): React.JSX.Element | null;
|
|
38
|
-
export {};
|
|
39
|
-
//# sourceMappingURL=TourGuide.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TourGuide.d.ts","sourceRoot":"","sources":["../../../src/components/TourGuide.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,UAAU,kBAAkB;IAC1B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACnC,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,kBAAkB,6GAW7B,CAAC;AAGH,eAAO,MAAM,oBAAoB,6GAc/B,CAAC;AAGH,eAAO,MAAM,mBAAmB,6GAc9B,CAAC;AAGH,UAAU,yBACR,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC5C,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,eAAO,MAAM,oBAAoB,kGAyDhC,CAAC;AAGF,eAAO,MAAM,aAAa,2FAsCzB,CAAC;AAGF,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,SAAgB,EAChB,OAAO,EACP,KAAK,EACL,SAAS,GACV,EAAE,cAAc,4BAwHhB"}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { __assign, __read, __rest } from "tslib";
|
|
2
|
-
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
3
|
-
import React, { useEffect, useState } from "react";
|
|
4
|
-
import { Button } from "../components/Button";
|
|
5
|
-
import { cn } from "../lib";
|
|
6
|
-
export var TourGuideCardTitle = React.forwardRef(function (_a, ref) {
|
|
7
|
-
var className = _a.className, children = _a.children, props = __rest(_a, ["className", "children"]);
|
|
8
|
-
return (React.createElement("div", __assign({ ref: ref, className: cn("s-heading-lg s-px-3 s-pt-4", className) }, props), children));
|
|
9
|
-
});
|
|
10
|
-
TourGuideCardTitle.displayName = "TourGuideCardTitle";
|
|
11
|
-
export var TourGuideCardContent = React.forwardRef(function (_a, ref) {
|
|
12
|
-
var className = _a.className, children = _a.children, props = __rest(_a, ["className", "children"]);
|
|
13
|
-
return (React.createElement("div", __assign({ ref: ref, className: cn("s-copy-base s-px-3 s-text-muted-foreground dark:s-text-muted-foreground-night", className) }, props), children));
|
|
14
|
-
});
|
|
15
|
-
TourGuideCardContent.displayName = "TourGuideCardContent";
|
|
16
|
-
export var TourGuideCardVisual = React.forwardRef(function (_a, ref) {
|
|
17
|
-
var className = _a.className, children = _a.children, props = __rest(_a, ["className", "children"]);
|
|
18
|
-
return (React.createElement("div", __assign({ ref: ref, className: cn("s-aspect-video s-bg-muted-background dark:s-bg-muted-background-night", className) }, props), children));
|
|
19
|
-
});
|
|
20
|
-
TourGuideCardVisual.displayName = "TourGuideCardVisual";
|
|
21
|
-
export var TourGuideCardActions = React.forwardRef(function (_a, ref) {
|
|
22
|
-
var currentIndex = _a.currentIndex, totalCards = _a.totalCards, onNext = _a.onNext, onDismiss = _a.onDismiss, className = _a.className, children = _a.children, props = __rest(_a, ["currentIndex", "totalCards", "onNext", "onDismiss", "className", "children"]);
|
|
23
|
-
var isFirstCard = currentIndex === 0;
|
|
24
|
-
var isLastCard = currentIndex === totalCards - 1;
|
|
25
|
-
var isSingleCard = totalCards === 1;
|
|
26
|
-
var showDismiss = !isLastCard && !isSingleCard;
|
|
27
|
-
return (React.createElement("div", __assign({ ref: ref, className: cn("s-flex s-justify-end s-space-x-2 s-p-2 s-pt-4", className) }, props), children ? (children) : (React.createElement(React.Fragment, null,
|
|
28
|
-
showDismiss && onDismiss && (React.createElement(Button, { variant: "outline", label: "Dismiss", onClick: onDismiss })),
|
|
29
|
-
onNext && (React.createElement(Button, { onClick: onNext, variant: "highlight", label: isSingleCard
|
|
30
|
-
? "Ok"
|
|
31
|
-
: isFirstCard
|
|
32
|
-
? "Start Tour"
|
|
33
|
-
: isLastCard
|
|
34
|
-
? "Done"
|
|
35
|
-
: "Next" }))))));
|
|
36
|
-
});
|
|
37
|
-
TourGuideCardActions.displayName = "TourGuideCardActions";
|
|
38
|
-
export var TourGuideCard = React.forwardRef(function (_a) {
|
|
39
|
-
var className = _a.className, children = _a.children, _b = _a.align, align = _b === void 0 ? "center" : _b, _c = _a.side, side = _c === void 0 ? "bottom" : _c, _d = _a.sideOffset, sideOffset = _d === void 0 ? 4 : _d, onNext = _a.onNext, onDismiss = _a.onDismiss, _e = _a.currentIndex, currentIndex = _e === void 0 ? 0 : _e, _f = _a.totalCards, totalCards = _f === void 0 ? 1 : _f;
|
|
40
|
-
return (React.createElement(PopoverPrimitive.Content, { align: align, side: side, sideOffset: sideOffset, className: cn("s-z-50 s-w-[420px] s-max-w-xs s-space-y-0.5 s-overflow-hidden s-rounded-2xl s-border s-shadow-xl s-transition-all s-duration-300 s-ease-in-out", "s-border-highlight-400 s-bg-background s-text-foreground s-ring-2 s-ring-highlight-400/30", "dark:s-border-border-night dark:s-bg-background-night dark:s-text-foreground-night", className), onOpenAutoFocus: function (e) { return e.preventDefault(); } },
|
|
41
|
-
children,
|
|
42
|
-
React.createElement(TourGuideCardActions, { currentIndex: currentIndex, totalCards: totalCards, onNext: onNext, onDismiss: onDismiss })));
|
|
43
|
-
});
|
|
44
|
-
TourGuideCard.displayName = "TourGuideCard";
|
|
45
|
-
export function TourGuide(_a) {
|
|
46
|
-
var children = _a.children, _b = _a.autoStart, autoStart = _b === void 0 ? true : _b, onStart = _a.onStart, onEnd = _a.onEnd, onDismiss = _a.onDismiss;
|
|
47
|
-
var _c = __read(useState(0), 2), currentIndex = _c[0], setCurrentIndex = _c[1];
|
|
48
|
-
var _d = __read(useState(autoStart), 2), isActive = _d[0], setIsActive = _d[1];
|
|
49
|
-
var _e = __read(useState({
|
|
50
|
-
top: "50%",
|
|
51
|
-
left: "50%",
|
|
52
|
-
width: "0px",
|
|
53
|
-
height: "0px",
|
|
54
|
-
}), 2), position = _e[0], setPosition = _e[1];
|
|
55
|
-
// Get all TourGuideCard children - memoize to prevent unnecessary re-renders
|
|
56
|
-
var cards = React.useMemo(function () {
|
|
57
|
-
return React.Children.toArray(children).filter(function (child) {
|
|
58
|
-
return React.isValidElement(child) && child.type === TourGuideCard;
|
|
59
|
-
});
|
|
60
|
-
}, [children]);
|
|
61
|
-
// Only run on mount and when autoStart changes
|
|
62
|
-
useEffect(function () {
|
|
63
|
-
if (autoStart) {
|
|
64
|
-
setIsActive(true);
|
|
65
|
-
setCurrentIndex(0);
|
|
66
|
-
onStart === null || onStart === void 0 ? void 0 : onStart();
|
|
67
|
-
}
|
|
68
|
-
}, [autoStart, onStart]);
|
|
69
|
-
// Handle position updates - use requestAnimationFrame to prevent excessive updates
|
|
70
|
-
useEffect(function () {
|
|
71
|
-
var _a;
|
|
72
|
-
if (!isActive) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
var updatePosition = function () {
|
|
76
|
-
var currentCard = cards[currentIndex];
|
|
77
|
-
if (!(currentCard === null || currentCard === void 0 ? void 0 : currentCard.props.anchorRef)) {
|
|
78
|
-
setPosition({
|
|
79
|
-
top: "50%",
|
|
80
|
-
left: "50%",
|
|
81
|
-
width: "0px",
|
|
82
|
-
height: "0px",
|
|
83
|
-
});
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
var element = currentCard.props.anchorRef.current;
|
|
87
|
-
if (!element) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
var rect = element.getBoundingClientRect();
|
|
91
|
-
setPosition({
|
|
92
|
-
top: "".concat(rect.top, "px"),
|
|
93
|
-
left: "".concat(rect.left, "px"),
|
|
94
|
-
width: "".concat(rect.width, "px"),
|
|
95
|
-
height: "".concat(rect.height, "px"),
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
// Initial update
|
|
99
|
-
updatePosition();
|
|
100
|
-
// Set up resize observer
|
|
101
|
-
var resizeObserver = new ResizeObserver(updatePosition);
|
|
102
|
-
var currentCard = cards[currentIndex];
|
|
103
|
-
if ((_a = currentCard === null || currentCard === void 0 ? void 0 : currentCard.props.anchorRef) === null || _a === void 0 ? void 0 : _a.current) {
|
|
104
|
-
resizeObserver.observe(currentCard.props.anchorRef.current);
|
|
105
|
-
}
|
|
106
|
-
// Set up scroll listener
|
|
107
|
-
window.addEventListener("scroll", updatePosition, true);
|
|
108
|
-
return function () {
|
|
109
|
-
resizeObserver.disconnect();
|
|
110
|
-
window.removeEventListener("scroll", updatePosition, true);
|
|
111
|
-
};
|
|
112
|
-
}, [currentIndex, cards, isActive]);
|
|
113
|
-
var handleNext = function () {
|
|
114
|
-
if (currentIndex + 1 < cards.length) {
|
|
115
|
-
setCurrentIndex(currentIndex + 1);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
setIsActive(false);
|
|
119
|
-
onEnd === null || onEnd === void 0 ? void 0 : onEnd();
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
var handleDismiss = function () {
|
|
123
|
-
setIsActive(false);
|
|
124
|
-
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
125
|
-
};
|
|
126
|
-
if (!isActive || cards.length === 0) {
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
var currentCard = cards[currentIndex];
|
|
130
|
-
return (React.createElement(PopoverPrimitive.Root, { open: isActive, modal: false },
|
|
131
|
-
React.createElement(PopoverPrimitive.Anchor, { className: "s-fixed s-transition-all s-duration-300 s-ease-in-out", style: {
|
|
132
|
-
top: position.top,
|
|
133
|
-
left: position.left,
|
|
134
|
-
width: position.width,
|
|
135
|
-
height: position.height,
|
|
136
|
-
} }),
|
|
137
|
-
React.cloneElement(currentCard, {
|
|
138
|
-
onNext: handleNext,
|
|
139
|
-
onDismiss: handleDismiss,
|
|
140
|
-
currentIndex: currentIndex,
|
|
141
|
-
totalCards: cards.length,
|
|
142
|
-
className: !currentCard.props.anchorRef ? "s-translate-y-[-50%]" : "",
|
|
143
|
-
})));
|
|
144
|
-
}
|
|
145
|
-
//# sourceMappingURL=TourGuide.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TourGuide.js","sourceRoot":"","sources":["../../../src/components/TourGuide.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;A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KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAM,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;IAExC,OAAO,CACL,oBAAC,gBAAgB,CAAC,IAAI,IAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK;QACjD,oBAAC,gBAAgB,CAAC,MAAM,IACtB,SAAS,EAAC,uDAAuD,EACjE,KAAK,EAAE;gBACL,GAAG,EAAE,QAAQ,CAAC,GAAG;gBACjB,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,MAAM,EAAE,QAAQ,CAAC,MAAM;aACxB,GACD;QACD,KAAK,CAAC,YAAY,CAAC,WAAW,EAAE;YAC/B,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,aAAa;YACxB,YAAY,cAAA;YACZ,UAAU,EAAE,KAAK,CAAC,MAAM;YACxB,SAAS,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE;SACtE,CAAC,CACoB,CACzB,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
declare const _default: import("@storybook/core/csf").ComponentAnnotations<import("@storybook/react").ReactRenderer, import("@storybook/react").Args>;
|
|
2
|
-
export default _default;
|
|
3
|
-
export declare const Default: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, import("@storybook/react").Args>;
|
|
4
|
-
//# sourceMappingURL=TourGuide.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TourGuide.stories.d.ts","sourceRoot":"","sources":["../../../src/stories/TourGuide.stories.tsx"],"names":[],"mappings":";AA0CA,wBAMU;AAuaV,eAAO,MAAM,OAAO,2HAAoB,CAAC"}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { __read } from "tslib";
|
|
2
|
-
import React, { useRef, useState } from "react";
|
|
3
|
-
import { Avatar, ConfettiBackground, Tooltip, TypingAnimation, } from "../components";
|
|
4
|
-
import { Button } from "../components/Button";
|
|
5
|
-
import { ActionBrainIcon, ActionGlobeIcon, ActionImageIcon, ActionMagnifyingGlassIcon, ActionScanIcon, ActionTableIcon, PlayIcon, } from "../icons";
|
|
6
|
-
import { BigQueryLogo, ConfluenceLogo, DriveLogo, GithubLogo, GongLogo, IntercomLogo, MicrosoftLogo, NotionLogo, SalesforceLogo, SlackLogo, SnowflakeLogo, ZendeskLogo, } from "../logo";
|
|
7
|
-
import { TourGuide, TourGuideCard, TourGuideCardContent, TourGuideCardTitle, TourGuideCardVisual, } from "../components/TourGuide";
|
|
8
|
-
export default {
|
|
9
|
-
title: "Modules/TourGuide",
|
|
10
|
-
component: TourGuide,
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: "fullscreen",
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
var Template = function () {
|
|
16
|
-
var topRightRef = useRef(null);
|
|
17
|
-
var centerRef = useRef(null);
|
|
18
|
-
var bottomLeftRef = useRef(null);
|
|
19
|
-
var _a = __read(useState(0), 2), key = _a[0], setKey = _a[1];
|
|
20
|
-
var handleRestart = function () {
|
|
21
|
-
setKey(function (k) { return k + 1; });
|
|
22
|
-
};
|
|
23
|
-
var referentRef = useRef(null);
|
|
24
|
-
var filteredAgents = [
|
|
25
|
-
{
|
|
26
|
-
name: "Translator",
|
|
27
|
-
emoji: "💬",
|
|
28
|
-
backgroundColor: "s-bg-green-200",
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: "TrailblazerGuard",
|
|
32
|
-
emoji: "👮",
|
|
33
|
-
backgroundColor: "s-bg-blue-100",
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
name: "Transport",
|
|
37
|
-
emoji: "🚌",
|
|
38
|
-
backgroundColor: "s-bg-blue-200",
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: "TrendTracker",
|
|
42
|
-
emoji: "😻",
|
|
43
|
-
backgroundColor: "s-bg-rose-50",
|
|
44
|
-
},
|
|
45
|
-
];
|
|
46
|
-
return (React.createElement("div", { className: "s-relative s-min-h-screen s-w-full" },
|
|
47
|
-
React.createElement("div", { className: "s-absolute s-left-3 s-top-3" },
|
|
48
|
-
React.createElement(Button, { label: "Restart Tour", onClick: handleRestart })),
|
|
49
|
-
React.createElement("div", { ref: topRightRef, className: "s-absolute s-right-6 s-top-6 s-cursor-pointer s-rounded-lg s-border s-border-blue-100 s-bg-blue-50 s-p-4 s-transition-colors hover:s-bg-blue-100" }, "Top Right Element"),
|
|
50
|
-
React.createElement("div", { ref: centerRef, className: "s-absolute s-left-1/2 s-top-1/2 s--translate-x-1/2 s--translate-y-1/2 s-cursor-pointer s-rounded-lg s-border s-border-green-100 s-bg-green-50 s-p-4 s-transition-colors hover:s-bg-green-100" }, "Centered Element"),
|
|
51
|
-
React.createElement("div", { ref: bottomLeftRef, className: "s-absolute s-bottom-6 s-left-6 s-cursor-pointer s-rounded-lg s-border s-border-red-100 s-bg-red-50 s-p-4 s-transition-colors hover:s-bg-red-100" }, "Bottom Left Element"),
|
|
52
|
-
React.createElement(TourGuide, { key: key, autoStart: true },
|
|
53
|
-
React.createElement(TourGuideCard, null,
|
|
54
|
-
React.createElement(TourGuideCardVisual, { ref: referentRef, className: "s-flex s-items-center s-justify-center s-bg-brand-support-blue s-px-6 s-text-center" },
|
|
55
|
-
React.createElement(ConfettiBackground, { variant: "confetti", referentSize: referentRef }),
|
|
56
|
-
React.createElement("span", { className: "s-heading-3xl" },
|
|
57
|
-
React.createElement(TypingAnimation, { text: "Rise and shine, Edouard! \uD83C\uDF05" }))),
|
|
58
|
-
React.createElement(TourGuideCardTitle, null,
|
|
59
|
-
"Welcome to the",
|
|
60
|
-
" ",
|
|
61
|
-
React.createElement("span", { className: "s-font-semibold s-text-brand-hunter-green" }, "Qonto"),
|
|
62
|
-
" ",
|
|
63
|
-
"workspace."),
|
|
64
|
-
React.createElement(TourGuideCardContent, null,
|
|
65
|
-
" ",
|
|
66
|
-
"Discover the basics of Dust in 3 steps.")),
|
|
67
|
-
React.createElement(TourGuideCard, { anchorRef: centerRef },
|
|
68
|
-
React.createElement(TourGuideCardVisual, { className: "s-relative s-flex s-overflow-hidden s-bg-brand-support-green s-p-4 s-text-center" },
|
|
69
|
-
React.createElement("div", { className: "s-flex s-gap-1" },
|
|
70
|
-
React.createElement("div", { className: "s-flex s-gap-1" },
|
|
71
|
-
React.createElement("div", { className: "s-heading-2xl s-text-highlight" }, "@tra"),
|
|
72
|
-
React.createElement("div", { className: "s-h-[32px] s-w-[3px] s-animate-cursor-blink s-bg-foreground" })),
|
|
73
|
-
React.createElement("div", { className: "s-flex s-h-[240px] s-flex-col s-gap-3 s-rounded-xl s-border s-border-border s-bg-background s-p-3 s-pr-5 s-shadow-xl" }, filteredAgents.map(function (agent) {
|
|
74
|
-
return (React.createElement("div", { key: agent.name, className: "s-heading-base s-flex s-items-center s-gap-2 s-text-foreground" },
|
|
75
|
-
React.createElement(Avatar, { size: "sm", emoji: agent.emoji, backgroundColor: agent.backgroundColor }),
|
|
76
|
-
agent.name));
|
|
77
|
-
})))),
|
|
78
|
-
React.createElement(TourGuideCardTitle, null,
|
|
79
|
-
"Use",
|
|
80
|
-
" ",
|
|
81
|
-
React.createElement("span", { className: "s-font-semibold s-text-highlight" }, "@mentions"),
|
|
82
|
-
" ",
|
|
83
|
-
"to call Agents and\u00A0start a conversation."),
|
|
84
|
-
React.createElement(TourGuideCardContent, { className: "s-py-2" },
|
|
85
|
-
React.createElement(Button, { label: "Watch the full video", icon: PlayIcon, variant: "outline" }))),
|
|
86
|
-
React.createElement(TourGuideCard, { anchorRef: topRightRef },
|
|
87
|
-
React.createElement(TourGuideCardVisual, { className: "s-flex s-flex-col s-items-center s-justify-center s-gap-4 s-bg-brand-support-rose s-px-6 s-text-center" },
|
|
88
|
-
React.createElement("div", { className: "s-grid s-grid-cols-6 s-gap-2" },
|
|
89
|
-
React.createElement(Tooltip, { label: "Google Drive Connection", trigger: React.createElement(Avatar, { size: "md", icon: DriveLogo, backgroundColor: "s-bg-white" }) }),
|
|
90
|
-
React.createElement(Tooltip, { label: "Notion Connection", trigger: React.createElement(Avatar, { size: "md", icon: NotionLogo, backgroundColor: "s-bg-white" }) }),
|
|
91
|
-
React.createElement(Tooltip, { label: "Slack Connection", trigger: React.createElement(Avatar, { size: "md", icon: SlackLogo, backgroundColor: "s-bg-white" }) }),
|
|
92
|
-
React.createElement(Tooltip, { label: "Snowflake Connection", trigger: React.createElement(Avatar, { size: "md", icon: SnowflakeLogo, backgroundColor: "s-bg-white" }) }),
|
|
93
|
-
React.createElement(Tooltip, { label: "BigQuery Connection", trigger: React.createElement(Avatar, { size: "md", icon: BigQueryLogo, backgroundColor: "s-bg-white" }) }),
|
|
94
|
-
React.createElement(Tooltip, { label: "Confluence Connection", trigger: React.createElement(Avatar, { size: "md", icon: ConfluenceLogo, backgroundColor: "s-bg-white" }) }),
|
|
95
|
-
React.createElement(Tooltip, { label: "Intercom Connection", trigger: React.createElement(Avatar, { size: "md", icon: IntercomLogo, backgroundColor: "s-bg-white" }) }),
|
|
96
|
-
React.createElement(Tooltip, { label: "Microsoft Connection", trigger: React.createElement(Avatar, { size: "md", icon: MicrosoftLogo, backgroundColor: "s-bg-white" }) }),
|
|
97
|
-
React.createElement(Tooltip, { label: "Salesforce Connection", trigger: React.createElement(Avatar, { size: "md", icon: SalesforceLogo, backgroundColor: "s-bg-white" }) }),
|
|
98
|
-
React.createElement(Tooltip, { label: "Zendesk Connection", trigger: React.createElement(Avatar, { size: "md", icon: ZendeskLogo, backgroundColor: "s-bg-white" }) }),
|
|
99
|
-
React.createElement(Tooltip, { label: "GitHub Connection", trigger: React.createElement(Avatar, { size: "md", icon: GithubLogo, backgroundColor: "s-bg-white" }) }),
|
|
100
|
-
React.createElement(Tooltip, { label: "Gong Connection", trigger: React.createElement(Avatar, { size: "md", icon: GongLogo, backgroundColor: "s-bg-white" }) }),
|
|
101
|
-
React.createElement(Tooltip, { label: "Search data", trigger: React.createElement(Avatar, { size: "md", icon: ActionMagnifyingGlassIcon, backgroundColor: "s-bg-gray-700", iconColor: "s-text-gray-50" }) }),
|
|
102
|
-
React.createElement(Tooltip, { label: "Quantitative analysis", trigger: React.createElement(Avatar, { size: "md", icon: ActionTableIcon, backgroundColor: "s-bg-gray-700", iconColor: "s-text-gray-50" }) }),
|
|
103
|
-
React.createElement(Tooltip, { label: "Data extraction", trigger: React.createElement(Avatar, { size: "md", icon: ActionScanIcon, backgroundColor: "s-bg-gray-700", iconColor: "s-text-gray-50" }) }),
|
|
104
|
-
React.createElement(Tooltip, { label: "Image generation", trigger: React.createElement(Avatar, { size: "md", icon: ActionImageIcon, backgroundColor: "s-bg-gray-700", iconColor: "s-text-gray-50" }) }),
|
|
105
|
-
React.createElement(Tooltip, { label: "Web search and browsing", trigger: React.createElement(Avatar, { size: "md", icon: ActionGlobeIcon, backgroundColor: "s-bg-gray-700", iconColor: "s-text-gray-50" }) }),
|
|
106
|
-
React.createElement(Tooltip, { label: "Reasoning", trigger: React.createElement(Avatar, { size: "md", icon: ActionBrainIcon, backgroundColor: "s-bg-gray-700", iconColor: "s-text-gray-50" }) }))),
|
|
107
|
-
React.createElement(TourGuideCardTitle, null,
|
|
108
|
-
"Make your agents smarter with\u00A0",
|
|
109
|
-
React.createElement("span", { className: "s-text-brand-red-rose" }, "knowledge and tools"),
|
|
110
|
-
"."),
|
|
111
|
-
React.createElement(TourGuideCardContent, { className: "s-py-2" },
|
|
112
|
-
React.createElement(Button, { label: "Watch the full video", icon: PlayIcon, variant: "outline" }))),
|
|
113
|
-
React.createElement(TourGuideCard, { anchorRef: bottomLeftRef },
|
|
114
|
-
React.createElement(TourGuideCardVisual, { className: "s-flex s-flex-col s-items-center s-justify-center s-gap-0 s-bg-brand-support-golden s-px-6 s-text-center" },
|
|
115
|
-
React.createElement("div", { className: "s-grid s-grid-cols-4 s-gap-2" },
|
|
116
|
-
React.createElement(Tooltip, { label: "FeedbackHelper", trigger: React.createElement(Avatar, { size: "lg", emoji: "\u2764\uFE0F", backgroundColor: "s-bg-rose-100" }) }),
|
|
117
|
-
React.createElement(Tooltip, { label: "RiskAnalyzer", trigger: React.createElement(Avatar, { size: "lg", emoji: "\uD83D\uDC80", backgroundColor: "s-bg-lime-800" }) }),
|
|
118
|
-
React.createElement(Tooltip, { label: "EngagementPro", trigger: React.createElement(Avatar, { size: "lg", emoji: "\uD83D\uDE02", backgroundColor: "s-bg-golden-200" }) }),
|
|
119
|
-
React.createElement(Tooltip, { label: "RunbookMaster", trigger: React.createElement(Avatar, { size: "lg", emoji: "\uD83E\uDDD1\u200D\uD83D\uDE80", backgroundColor: "s-bg-violet-800" }) }),
|
|
120
|
-
React.createElement(Tooltip, { label: "BrandSpecialist", trigger: React.createElement(Avatar, { size: "lg", emoji: "\uD83D\uDC55", backgroundColor: "s-bg-blue-200" }) }),
|
|
121
|
-
React.createElement(Tooltip, { label: "CrisisManager", trigger: React.createElement(Avatar, { size: "lg", emoji: "\uD83D\uDE92", backgroundColor: "s-bg-red-200" }) }),
|
|
122
|
-
React.createElement(Tooltip, { label: "PerformanceCoach", trigger: React.createElement(Avatar, { size: "lg", emoji: "\uD83C\uDFC6", backgroundColor: "s-bg-yellow-200" }) }),
|
|
123
|
-
React.createElement(Tooltip, { label: "StrategyPlanner", trigger: React.createElement(Avatar, { size: "lg", emoji: "\uD83C\uDFAF", backgroundColor: "s-bg-pink-100" }) }))),
|
|
124
|
-
React.createElement(TourGuideCardTitle, null,
|
|
125
|
-
"Create new custom agents",
|
|
126
|
-
" ",
|
|
127
|
-
React.createElement("span", { className: "s-text-brand-orange-golden" }, "designed for your needs"),
|
|
128
|
-
"."),
|
|
129
|
-
React.createElement(TourGuideCardContent, { className: "s-py-2" },
|
|
130
|
-
React.createElement(Button, { label: "Watch the full video", icon: PlayIcon, variant: "outline" }))))));
|
|
131
|
-
};
|
|
132
|
-
export var Default = Template.bind({});
|
|
133
|
-
//# sourceMappingURL=TourGuide.stories.js.map
|