@istmx/ui 0.1.11 → 0.1.13
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/LICENSE +21 -21
- package/README.md +533 -463
- package/bin/istmx.mjs +481 -314
- package/package.json +27 -27
- package/registry/accordion.tsx +186 -0
- package/registry/ai-chat-block/ai-chat-block.tsx +456 -460
- package/registry/ai-chat-block/ai-chat-input.tsx +694 -694
- package/registry/ai-chat-block/attachment.tsx +466 -466
- package/registry/ai-chat-block/chat-code-block.tsx +50 -50
- package/registry/ai-chat-block/chat-composer.tsx +51 -51
- package/registry/ai-chat-block/chat-logo.tsx +18 -18
- package/registry/ai-chat-block/chat-message.tsx +161 -161
- package/registry/ai-chat-block/chat-sidebar.tsx +273 -273
- package/registry/ai-chat-block/chat-user-avatar.tsx +9 -9
- package/registry/ai-chat-block/code-highlighter.tsx +342 -357
- package/registry/ai-chat-block/default-attachments.tsx +42 -42
- package/registry/ai-chat-block/index.ts +30 -30
- package/registry/ai-chat-block/message-content.tsx +287 -287
- package/registry/ai-chat-block/message-list.tsx +93 -93
- package/registry/ai-chat-block/send-button.tsx +102 -102
- package/registry/ai-chat-block/types.ts +70 -71
- package/registry/ai-chat-block/utils.ts +6 -6
- package/registry/ai-chat-block/voice-button.tsx +66 -66
- package/registry/alert-dialog.tsx +229 -0
- package/registry/alert.tsx +188 -0
- package/registry/animated-text.tsx +228 -225
- package/registry/aspect-ratio.tsx +32 -0
- package/registry/avatar-group.tsx +66 -0
- package/registry/avatar.tsx +121 -0
- package/registry/badge.tsx +52 -0
- package/registry/bento-grid.tsx +438 -433
- package/registry/button.tsx +156 -237
- package/registry/carousel.tsx +184 -0
- package/registry/dock-navigation.tsx +200 -198
- package/registry/drift-canvas.tsx +383 -0
- package/registry/drift-wall.tsx +361 -0
- package/registry/flex-carousel.tsx +1430 -0
- package/registry/guided-gallery.tsx +1506 -0
- package/registry/image-accordion.tsx +306 -302
- package/registry/image-trail.tsx +126 -121
- package/registry/infinite-image-canvas.tsx +268 -263
- package/registry/input-otp.tsx +332 -0
- package/registry/list-card.tsx +130 -0
- package/registry/mobile-menu-dock.tsx +216 -211
- package/registry/morph-slider.tsx +756 -0
- package/registry/pixel-cat.tsx +972 -1020
- package/registry/scroll-canvas-cards.tsx +643 -0
- package/registry/scroll-parallax-hero.tsx +566 -565
- package/registry/scroll-story-cards.tsx +443 -438
- package/registry/slider.tsx +163 -0
- package/registry/spotlight-grid.tsx +226 -0
- package/registry/streaming-text.tsx +269 -278
- package/registry/text-reveal.tsx +311 -307
- package/registry/user-avatar.tsx +99 -0
- package/registry/utils.ts +6 -6
|
@@ -1,302 +1,306 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { useId, useState } from 'react'
|
|
4
|
-
import type { CSSProperties } from 'react'
|
|
5
|
-
import {
|
|
6
|
-
AnimatePresence,
|
|
7
|
-
LayoutGroup,
|
|
8
|
-
motion,
|
|
9
|
-
useReducedMotion,
|
|
10
|
-
} from 'motion/react'
|
|
11
|
-
import { cn } from '@/lib/utils'
|
|
12
|
-
|
|
13
|
-
export type ImageAccordionItem = {
|
|
14
|
-
id?: string
|
|
15
|
-
src: string
|
|
16
|
-
alt: string
|
|
17
|
-
title: string
|
|
18
|
-
description?: string
|
|
19
|
-
className?: string
|
|
20
|
-
imageClassName?: string
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type ImageAccordionGlow = {
|
|
24
|
-
color?: string
|
|
25
|
-
position?: string
|
|
26
|
-
size?: string
|
|
27
|
-
opacity?: number
|
|
28
|
-
blur?: number
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export type ImageAccordionProps = {
|
|
32
|
-
images: ImageAccordionItem[]
|
|
33
|
-
className?: string
|
|
34
|
-
stackClassName?: string
|
|
35
|
-
cardClassName?: string
|
|
36
|
-
imageClassName?: string
|
|
37
|
-
previewClassName?: string
|
|
38
|
-
visibleCount?: number
|
|
39
|
-
glow?: false | ImageAccordionGlow
|
|
40
|
-
transition?: {
|
|
41
|
-
stiffness?: number
|
|
42
|
-
damping?: number
|
|
43
|
-
mass?: number
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function ImageAccordion({
|
|
48
|
-
images,
|
|
49
|
-
className,
|
|
50
|
-
stackClassName,
|
|
51
|
-
cardClassName,
|
|
52
|
-
imageClassName,
|
|
53
|
-
previewClassName,
|
|
54
|
-
visibleCount = 5,
|
|
55
|
-
glow = {},
|
|
56
|
-
transition,
|
|
57
|
-
}
|
|
58
|
-
const [stackImages, setStackImages] = useState(images)
|
|
59
|
-
const [activeImage, setActiveImage] = useState<ImageAccordionItem | null>(
|
|
60
|
-
null,
|
|
61
|
-
)
|
|
62
|
-
const reduceMotion = useReducedMotion()
|
|
63
|
-
const layoutId = useId()
|
|
64
|
-
const visibleLimit = Number.isFinite(visibleCount)
|
|
65
|
-
? Math.max(1, Math.floor(visibleCount))
|
|
66
|
-
: 5
|
|
67
|
-
const visibleImages = stackImages.slice(0, visibleLimit)
|
|
68
|
-
const glowOptions = typeof glow === 'object' ? glow : {}
|
|
69
|
-
const spring = {
|
|
70
|
-
type: 'spring' as const,
|
|
71
|
-
stiffness: transition?.stiffness ?? 190,
|
|
72
|
-
damping: transition?.damping ?? 24,
|
|
73
|
-
mass: transition?.mass ?? 0.8,
|
|
74
|
-
}
|
|
75
|
-
const glowStyle = {
|
|
76
|
-
'--image-accordion-glow-color': glowOptions.color ?? 'var(--foreground)',
|
|
77
|
-
'--image-accordion-glow-position': glowOptions.position ?? 'center',
|
|
78
|
-
'--image-accordion-glow-size': glowOptions.size ?? '72%',
|
|
79
|
-
'--image-accordion-glow-opacity': Math.min(
|
|
80
|
-
1,
|
|
81
|
-
Math.max(0, glowOptions.opacity ?? 0.24),
|
|
82
|
-
),
|
|
83
|
-
'--image-accordion-glow-blur': `${Math.max(0, glowOptions.blur ?? 18)}px`,
|
|
84
|
-
} as CSSProperties
|
|
85
|
-
const getImageKey = (image: ImageAccordionItem) => image.id ?? image.src
|
|
86
|
-
const activePosition = activeImage
|
|
87
|
-
? stackImages.findIndex(
|
|
88
|
-
(image) => getImageKey(image) === getImageKey(activeImage),
|
|
89
|
-
) + 1
|
|
90
|
-
: 0
|
|
91
|
-
|
|
92
|
-
function selectImage(image: ImageAccordionItem) {
|
|
93
|
-
const imageKey = getImageKey(image)
|
|
94
|
-
|
|
95
|
-
if (activeImage && getImageKey(activeImage) === imageKey) {
|
|
96
|
-
setActiveImage(null)
|
|
97
|
-
return
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
setActiveImage(image)
|
|
101
|
-
setStackImages((current) => [
|
|
102
|
-
...current.filter((item) => getImageKey(item) !== imageKey),
|
|
103
|
-
image,
|
|
104
|
-
])
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return (
|
|
108
|
-
<LayoutGroup id={layoutId}>
|
|
109
|
-
<section
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useId, useState } from 'react'
|
|
4
|
+
import type { CSSProperties } from 'react'
|
|
5
|
+
import {
|
|
6
|
+
AnimatePresence,
|
|
7
|
+
LayoutGroup,
|
|
8
|
+
motion,
|
|
9
|
+
useReducedMotion,
|
|
10
|
+
} from 'motion/react'
|
|
11
|
+
import { cn } from '@/lib/utils'
|
|
12
|
+
|
|
13
|
+
export type ImageAccordionItem = {
|
|
14
|
+
id?: string
|
|
15
|
+
src: string
|
|
16
|
+
alt: string
|
|
17
|
+
title: string
|
|
18
|
+
description?: string
|
|
19
|
+
className?: string
|
|
20
|
+
imageClassName?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type ImageAccordionGlow = {
|
|
24
|
+
color?: string
|
|
25
|
+
position?: string
|
|
26
|
+
size?: string
|
|
27
|
+
opacity?: number
|
|
28
|
+
blur?: number
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type ImageAccordionProps = {
|
|
32
|
+
images: ImageAccordionItem[]
|
|
33
|
+
className?: string
|
|
34
|
+
stackClassName?: string
|
|
35
|
+
cardClassName?: string
|
|
36
|
+
imageClassName?: string
|
|
37
|
+
previewClassName?: string
|
|
38
|
+
visibleCount?: number
|
|
39
|
+
glow?: false | ImageAccordionGlow
|
|
40
|
+
transition?: {
|
|
41
|
+
stiffness?: number
|
|
42
|
+
damping?: number
|
|
43
|
+
mass?: number
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const ImageAccordion = forwardRef<HTMLElement, ImageAccordionProps>(function ImageAccordion({
|
|
48
|
+
images,
|
|
49
|
+
className,
|
|
50
|
+
stackClassName,
|
|
51
|
+
cardClassName,
|
|
52
|
+
imageClassName,
|
|
53
|
+
previewClassName,
|
|
54
|
+
visibleCount = 5,
|
|
55
|
+
glow = {},
|
|
56
|
+
transition,
|
|
57
|
+
}, ref) {
|
|
58
|
+
const [stackImages, setStackImages] = useState(images)
|
|
59
|
+
const [activeImage, setActiveImage] = useState<ImageAccordionItem | null>(
|
|
60
|
+
null,
|
|
61
|
+
)
|
|
62
|
+
const reduceMotion = useReducedMotion()
|
|
63
|
+
const layoutId = useId()
|
|
64
|
+
const visibleLimit = Number.isFinite(visibleCount)
|
|
65
|
+
? Math.max(1, Math.floor(visibleCount))
|
|
66
|
+
: 5
|
|
67
|
+
const visibleImages = stackImages.slice(0, visibleLimit)
|
|
68
|
+
const glowOptions = typeof glow === 'object' ? glow : {}
|
|
69
|
+
const spring = {
|
|
70
|
+
type: 'spring' as const,
|
|
71
|
+
stiffness: transition?.stiffness ?? 190,
|
|
72
|
+
damping: transition?.damping ?? 24,
|
|
73
|
+
mass: transition?.mass ?? 0.8,
|
|
74
|
+
}
|
|
75
|
+
const glowStyle = {
|
|
76
|
+
'--image-accordion-glow-color': glowOptions.color ?? 'var(--foreground)',
|
|
77
|
+
'--image-accordion-glow-position': glowOptions.position ?? 'center',
|
|
78
|
+
'--image-accordion-glow-size': glowOptions.size ?? '72%',
|
|
79
|
+
'--image-accordion-glow-opacity': Math.min(
|
|
80
|
+
1,
|
|
81
|
+
Math.max(0, glowOptions.opacity ?? 0.24),
|
|
82
|
+
),
|
|
83
|
+
'--image-accordion-glow-blur': `${Math.max(0, glowOptions.blur ?? 18)}px`,
|
|
84
|
+
} as CSSProperties
|
|
85
|
+
const getImageKey = (image: ImageAccordionItem) => image.id ?? image.src
|
|
86
|
+
const activePosition = activeImage
|
|
87
|
+
? stackImages.findIndex(
|
|
88
|
+
(image) => getImageKey(image) === getImageKey(activeImage),
|
|
89
|
+
) + 1
|
|
90
|
+
: 0
|
|
91
|
+
|
|
92
|
+
function selectImage(image: ImageAccordionItem) {
|
|
93
|
+
const imageKey = getImageKey(image)
|
|
94
|
+
|
|
95
|
+
if (activeImage && getImageKey(activeImage) === imageKey) {
|
|
96
|
+
setActiveImage(null)
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
setActiveImage(image)
|
|
101
|
+
setStackImages((current) => [
|
|
102
|
+
...current.filter((item) => getImageKey(item) !== imageKey),
|
|
103
|
+
image,
|
|
104
|
+
])
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<LayoutGroup id={layoutId}>
|
|
109
|
+
<section
|
|
110
|
+
ref={ref}
|
|
111
|
+
aria-label="Image accordion"
|
|
112
|
+
className={cn(
|
|
113
|
+
'grid gap-5 md:grid-cols-[minmax(240px,0.8fr)_minmax(0,1.5fr)] md:items-center md:gap-6',
|
|
114
|
+
className,
|
|
115
|
+
)}
|
|
116
|
+
>
|
|
117
|
+
<div className={stackClassName}>
|
|
118
|
+
<div
|
|
119
|
+
role="group"
|
|
120
|
+
aria-label="Choose an image"
|
|
121
|
+
className="relative mx-auto h-[19rem] w-full max-w-[22rem] sm:h-[22rem]"
|
|
122
|
+
>
|
|
123
|
+
{visibleImages.map((image, index) => {
|
|
124
|
+
const imageKey = getImageKey(image)
|
|
125
|
+
const isActive =
|
|
126
|
+
activeImage !== null &&
|
|
127
|
+
getImageKey(activeImage) === imageKey
|
|
128
|
+
const originalIndex = images.findIndex(
|
|
129
|
+
(item) => getImageKey(item) === imageKey,
|
|
130
|
+
)
|
|
131
|
+
const offset = visibleImages.length - index - 1
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<motion.button
|
|
135
|
+
key={imageKey}
|
|
136
|
+
type="button"
|
|
137
|
+
aria-label={
|
|
138
|
+
isActive
|
|
139
|
+
? `Hide preview for ${image.title}`
|
|
140
|
+
: `Show image ${index + 1}: ${image.title}`
|
|
141
|
+
}
|
|
142
|
+
aria-pressed={isActive}
|
|
143
|
+
onClick={() => selectImage(image)}
|
|
144
|
+
initial={false}
|
|
145
|
+
animate={{
|
|
146
|
+
x: index * 13,
|
|
147
|
+
y: index * 14,
|
|
148
|
+
rotate: (index - offset / 2) * 1.4,
|
|
149
|
+
scale: 1 - offset * 0.018,
|
|
150
|
+
}}
|
|
151
|
+
whileHover={
|
|
152
|
+
reduceMotion
|
|
153
|
+
? undefined
|
|
154
|
+
: { x: index * 13 - 5, y: index * 14 - 7, scale: 1.035 }
|
|
155
|
+
}
|
|
156
|
+
whileTap={reduceMotion ? undefined : { scale: 0.98 }}
|
|
157
|
+
transition={{
|
|
158
|
+
type: 'spring',
|
|
159
|
+
stiffness: 280,
|
|
160
|
+
damping: 25,
|
|
161
|
+
mass: 0.8,
|
|
162
|
+
}}
|
|
163
|
+
style={
|
|
164
|
+
{
|
|
165
|
+
...glowStyle,
|
|
166
|
+
left: `${index * 7}%`,
|
|
167
|
+
top: `${index * 7}%`,
|
|
168
|
+
zIndex: visibleImages.length - index,
|
|
169
|
+
} as CSSProperties
|
|
170
|
+
}
|
|
171
|
+
className={cn(
|
|
172
|
+
'group isolate absolute aspect-[4/3] w-[70%] cursor-pointer overflow-visible rounded-xl text-left focus-visible:ring-2 focus-visible:ring-foreground focus-visible:ring-offset-4 focus-visible:ring-offset-background focus-visible:outline-none',
|
|
173
|
+
!reduceMotion && 'transition-transform duration-300',
|
|
174
|
+
cardClassName,
|
|
175
|
+
image.className,
|
|
176
|
+
)}
|
|
177
|
+
>
|
|
178
|
+
{glow !== false ? (
|
|
179
|
+
<span
|
|
180
|
+
aria-hidden="true"
|
|
181
|
+
className={cn(
|
|
182
|
+
'pointer-events-none absolute -inset-3 -z-10 rounded-[inherit] bg-[radial-gradient(ellipse_at_var(--image-accordion-glow-position),var(--image-accordion-glow-color)_0%,transparent_var(--image-accordion-glow-size))] blur-[var(--image-accordion-glow-blur)] transition-opacity duration-300',
|
|
183
|
+
isActive
|
|
184
|
+
? 'opacity-[var(--image-accordion-glow-opacity)]'
|
|
185
|
+
: 'opacity-0 group-hover:opacity-[var(--image-accordion-glow-opacity)] group-focus-visible:opacity-[var(--image-accordion-glow-opacity)]',
|
|
186
|
+
)}
|
|
187
|
+
/>
|
|
188
|
+
) : null}
|
|
189
|
+
|
|
190
|
+
<span
|
|
191
|
+
className={cn(
|
|
192
|
+
'border-border/70 bg-surface group-hover:border-foreground/55 relative block size-full overflow-hidden rounded-xl border shadow-[0_12px_32px_-18px_rgba(0,0,0,0.7)] transition-colors duration-300',
|
|
193
|
+
isActive && 'border-foreground/60',
|
|
194
|
+
)}
|
|
195
|
+
>
|
|
196
|
+
<motion.img
|
|
197
|
+
layoutId={
|
|
198
|
+
isActive
|
|
199
|
+
? undefined
|
|
200
|
+
: `${layoutId}-image-${originalIndex}`
|
|
201
|
+
}
|
|
202
|
+
src={image.src}
|
|
203
|
+
alt={image.alt}
|
|
204
|
+
loading="lazy"
|
|
205
|
+
decoding="async"
|
|
206
|
+
referrerPolicy="no-referrer"
|
|
207
|
+
draggable={false}
|
|
208
|
+
transition={spring}
|
|
209
|
+
className={cn(
|
|
210
|
+
'size-full object-cover',
|
|
211
|
+
!reduceMotion &&
|
|
212
|
+
'transition-transform duration-500 ease-out group-hover:scale-105',
|
|
213
|
+
imageClassName,
|
|
214
|
+
image.imageClassName,
|
|
215
|
+
)}
|
|
216
|
+
/>
|
|
217
|
+
<span className="absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/75 via-black/20 to-transparent px-3 pt-8 pb-2 text-xs font-medium text-white opacity-0 transition-opacity duration-300 group-hover:opacity-100 group-focus-visible:opacity-100">
|
|
218
|
+
{String(index + 1).padStart(2, '0')} / {image.title}
|
|
219
|
+
</span>
|
|
220
|
+
</span>
|
|
221
|
+
</motion.button>
|
|
222
|
+
)
|
|
223
|
+
})}
|
|
224
|
+
</div>
|
|
225
|
+
|
|
226
|
+
<div className="text-muted mt-3 flex items-center justify-between font-mono text-[10px] tracking-[0.14em] uppercase">
|
|
227
|
+
<span>Image stack</span>
|
|
228
|
+
<span>
|
|
229
|
+
{String(visibleImages.length).padStart(2, '0')} /{' '}
|
|
230
|
+
{String(stackImages.length).padStart(2, '0')} images
|
|
231
|
+
</span>
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
<div
|
|
236
|
+
className={cn(
|
|
237
|
+
'border-border/70 bg-surface/30 relative flex aspect-[4/3] min-h-64 items-center justify-center overflow-hidden rounded-xl border md:min-h-0',
|
|
238
|
+
previewClassName,
|
|
239
|
+
)}
|
|
240
|
+
>
|
|
241
|
+
<AnimatePresence mode="wait" initial={false}>
|
|
242
|
+
{activeImage ? (
|
|
243
|
+
<motion.figure
|
|
244
|
+
key={getImageKey(activeImage)}
|
|
245
|
+
initial={reduceMotion ? { opacity: 0 } : { opacity: 0.8 }}
|
|
246
|
+
animate={{ opacity: 1 }}
|
|
247
|
+
exit={{ opacity: 0 }}
|
|
248
|
+
transition={{ duration: reduceMotion ? 0 : 0.22 }}
|
|
249
|
+
className="absolute inset-0 m-0"
|
|
250
|
+
>
|
|
251
|
+
<motion.img
|
|
252
|
+
layoutId={`${layoutId}-image-${images.findIndex((image) => getImageKey(image) === getImageKey(activeImage))}`}
|
|
253
|
+
src={activeImage.src}
|
|
254
|
+
alt={activeImage.alt}
|
|
255
|
+
decoding="async"
|
|
256
|
+
referrerPolicy="no-referrer"
|
|
257
|
+
draggable={false}
|
|
258
|
+
transition={spring}
|
|
259
|
+
className={cn(
|
|
260
|
+
'size-full object-cover',
|
|
261
|
+
imageClassName,
|
|
262
|
+
activeImage.imageClassName,
|
|
263
|
+
)}
|
|
264
|
+
/>
|
|
265
|
+
<figcaption className="absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/85 via-black/40 to-transparent px-5 pt-16 pb-5 text-white sm:px-7 sm:pb-7">
|
|
266
|
+
<p className="font-mono text-[10px] tracking-[0.18em] text-white/65 uppercase">
|
|
267
|
+
Image {String(activePosition).padStart(2, '0')} /{' '}
|
|
268
|
+
{String(stackImages.length).padStart(2, '0')}
|
|
269
|
+
</p>
|
|
270
|
+
<h2 className="mt-2 text-xl font-medium tracking-tight sm:text-2xl">
|
|
271
|
+
{activeImage.title}
|
|
272
|
+
</h2>
|
|
273
|
+
{activeImage.description ? (
|
|
274
|
+
<p className="mt-1 max-w-lg text-sm leading-6 text-white/75">
|
|
275
|
+
{activeImage.description}
|
|
276
|
+
</p>
|
|
277
|
+
) : null}
|
|
278
|
+
</figcaption>
|
|
279
|
+
</motion.figure>
|
|
280
|
+
) : (
|
|
281
|
+
<motion.div
|
|
282
|
+
key="empty-preview"
|
|
283
|
+
initial={reduceMotion ? false : { opacity: 0 }}
|
|
284
|
+
animate={{ opacity: 1 }}
|
|
285
|
+
exit={{ opacity: 0 }}
|
|
286
|
+
transition={{ duration: reduceMotion ? 0 : 0.2 }}
|
|
287
|
+
className="px-6 text-center"
|
|
288
|
+
>
|
|
289
|
+
<p className="text-muted font-mono text-[10px] tracking-[0.18em] uppercase">
|
|
290
|
+
Preview
|
|
291
|
+
</p>
|
|
292
|
+
<p className="text-muted mt-2 text-sm">
|
|
293
|
+
Select a corner to reveal an image.
|
|
294
|
+
</p>
|
|
295
|
+
</motion.div>
|
|
296
|
+
)}
|
|
297
|
+
</AnimatePresence>
|
|
298
|
+
</div>
|
|
299
|
+
</section>
|
|
300
|
+
</LayoutGroup>
|
|
301
|
+
)
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
ImageAccordion.displayName = 'ImageAccordion'
|
|
305
|
+
|
|
306
|
+
export default ImageAccordion
|