@dust-tt/sparkle 0.7.1 → 0.7.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 +5 -5
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/components/Citation.js +1 -1
- package/dist/esm/components/ImagePreview.d.ts +3 -2
- package/dist/esm/components/ImagePreview.d.ts.map +1 -1
- package/dist/esm/components/ImagePreview.js +23 -10
- package/dist/esm/components/ImagePreview.js.map +1 -1
- package/dist/esm/components/InteractiveImageGrid.js +2 -2
- package/dist/esm/components/InteractiveImageGrid.js.map +1 -1
- package/dist/esm/lottie/collapseBar.d.ts +21 -21
- package/dist/esm/lottie/spinnerColorLG.d.ts +125 -125
- package/dist/esm/lottie/spinnerColorXS.d.ts +11 -11
- package/dist/esm/lottie/spinnerDarkXS.d.ts +38 -38
- package/dist/esm/lottie/spinnerLight.d.ts +66 -66
- package/dist/esm/stories/ImagePreview.stories.d.ts +2 -4
- package/dist/esm/stories/ImagePreview.stories.d.ts.map +1 -1
- package/dist/esm/stories/ImagePreview.stories.js +24 -48
- package/dist/esm/stories/ImagePreview.stories.js.map +1 -1
- package/dist/sparkle.css +7 -6
- package/package.json +1 -1
- package/src/components/Citation.tsx +1 -1
- package/src/components/ImagePreview.tsx +27 -11
- package/src/components/InteractiveImageGrid.tsx +2 -2
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { ArrowDownOnSquareIcon, XMarkIcon } from "@sparkle/icons/app";
|
|
10
10
|
import { cn } from "@sparkle/lib/utils";
|
|
11
11
|
|
|
12
|
-
export const IMAGE_PREVIEW_VARIANTS = ["
|
|
12
|
+
export const IMAGE_PREVIEW_VARIANTS = ["embedded", "standalone"] as const;
|
|
13
13
|
export type ImagePreviewVariantType = (typeof IMAGE_PREVIEW_VARIANTS)[number];
|
|
14
14
|
|
|
15
15
|
export const IMAGE_PREVIEW_TITLE_POSITIONS = ["bottom", "center"] as const;
|
|
@@ -17,19 +17,22 @@ export type ImagePreviewTitlePositionType =
|
|
|
17
17
|
(typeof IMAGE_PREVIEW_TITLE_POSITIONS)[number];
|
|
18
18
|
|
|
19
19
|
const containerVariants = cva(
|
|
20
|
-
cn("s-
|
|
20
|
+
cn("s-cursor-pointer s-overflow-hidden s-rounded-xl"),
|
|
21
21
|
{
|
|
22
22
|
variants: {
|
|
23
23
|
variant: {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// Embedded inside a parent component (like Citation) that provides the group
|
|
25
|
+
embedded: "s-absolute s-inset-0",
|
|
26
|
+
// Standalone, self-contained component managing its own hover
|
|
27
|
+
standalone: cn(
|
|
28
|
+
"s-group/image-preview",
|
|
26
29
|
"s-relative s-aspect-square",
|
|
27
30
|
"s-bg-muted-background dark:s-bg-muted-background-night"
|
|
28
31
|
),
|
|
29
32
|
},
|
|
30
33
|
},
|
|
31
34
|
defaultVariants: {
|
|
32
|
-
variant: "
|
|
35
|
+
variant: "embedded",
|
|
33
36
|
},
|
|
34
37
|
}
|
|
35
38
|
);
|
|
@@ -38,8 +41,7 @@ const overlayVariants = cva(
|
|
|
38
41
|
cn(
|
|
39
42
|
"s-absolute s-inset-0 s-z-10",
|
|
40
43
|
"s-bg-primary-100/60 dark:s-bg-primary-100-night/60",
|
|
41
|
-
"s-opacity-0 s-transition s-duration-200"
|
|
42
|
-
"group-hover/grid-image:s-opacity-100"
|
|
44
|
+
"s-opacity-0 s-transition s-duration-200"
|
|
43
45
|
),
|
|
44
46
|
{
|
|
45
47
|
variants: {
|
|
@@ -50,9 +52,16 @@ const overlayVariants = cva(
|
|
|
50
52
|
),
|
|
51
53
|
center: "s-flex s-items-center s-justify-center",
|
|
52
54
|
},
|
|
55
|
+
variant: {
|
|
56
|
+
// Embedded: uses parent's s-group for hover
|
|
57
|
+
embedded: "group-hover:s-opacity-100",
|
|
58
|
+
// Standalone: uses its own s-group/image-preview
|
|
59
|
+
standalone: "group-hover/image-preview:s-opacity-100",
|
|
60
|
+
},
|
|
53
61
|
},
|
|
54
62
|
defaultVariants: {
|
|
55
63
|
titlePosition: "bottom",
|
|
64
|
+
variant: "embedded",
|
|
56
65
|
},
|
|
57
66
|
}
|
|
58
67
|
);
|
|
@@ -102,7 +111,7 @@ const ImagePreview = React.forwardRef<HTMLDivElement, ImagePreviewProps>(
|
|
|
102
111
|
onClose,
|
|
103
112
|
onClick,
|
|
104
113
|
className,
|
|
105
|
-
variant = "
|
|
114
|
+
variant = "embedded",
|
|
106
115
|
titlePosition = "bottom",
|
|
107
116
|
manageZoomDialog = true,
|
|
108
117
|
},
|
|
@@ -166,10 +175,15 @@ const ImagePreview = React.forwardRef<HTMLDivElement, ImagePreviewProps>(
|
|
|
166
175
|
<img
|
|
167
176
|
src={imgSrc}
|
|
168
177
|
alt={alt}
|
|
169
|
-
className=
|
|
178
|
+
className={cn(
|
|
179
|
+
"s-h-full s-w-full s-object-cover s-transition s-duration-200",
|
|
180
|
+
variant === "embedded"
|
|
181
|
+
? "group-hover:s-blur-sm"
|
|
182
|
+
: "group-hover/image-preview:s-blur-sm"
|
|
183
|
+
)}
|
|
170
184
|
/>
|
|
171
185
|
{/* Overlay with title - shown on hover */}
|
|
172
|
-
<div className={overlayVariants({ titlePosition })}>
|
|
186
|
+
<div className={overlayVariants({ titlePosition, variant })}>
|
|
173
187
|
<span className={titleVariants({ titlePosition })}>
|
|
174
188
|
{title}
|
|
175
189
|
</span>
|
|
@@ -179,7 +193,9 @@ const ImagePreview = React.forwardRef<HTMLDivElement, ImagePreviewProps>(
|
|
|
179
193
|
className={cn(
|
|
180
194
|
"s-absolute s-right-2 s-top-2 s-z-20",
|
|
181
195
|
"s-opacity-0 s-transition-opacity s-duration-200",
|
|
182
|
-
"
|
|
196
|
+
variant === "embedded"
|
|
197
|
+
? "group-hover:s-opacity-100"
|
|
198
|
+
: "group-hover/image-preview:s-opacity-100"
|
|
183
199
|
)}
|
|
184
200
|
>
|
|
185
201
|
{onClose && (
|
|
@@ -85,7 +85,7 @@ function InteractiveImageGrid({
|
|
|
85
85
|
isLoading={images[0].isLoading}
|
|
86
86
|
onClick={() => setCurrentImageIndex(0)}
|
|
87
87
|
onClose={onClose ? () => onClose() : undefined}
|
|
88
|
-
variant="
|
|
88
|
+
variant="embedded"
|
|
89
89
|
titlePosition="center"
|
|
90
90
|
manageZoomDialog={false}
|
|
91
91
|
/>
|
|
@@ -101,7 +101,7 @@ function InteractiveImageGrid({
|
|
|
101
101
|
downloadUrl={image.downloadUrl}
|
|
102
102
|
isLoading={image.isLoading}
|
|
103
103
|
onClick={() => setCurrentImageIndex(idx)}
|
|
104
|
-
variant="
|
|
104
|
+
variant="embedded"
|
|
105
105
|
titlePosition="center"
|
|
106
106
|
manageZoomDialog={false}
|
|
107
107
|
/>
|