@istmx/ui 0.1.2 → 0.1.3
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/README.md +131 -17
- package/bin/istmx.mjs +14 -7
- package/package.json +1 -1
- package/registry/image-accordion.tsx +302 -0
package/README.md
CHANGED
|
@@ -1,34 +1,148 @@
|
|
|
1
|
-
# ISTMX UI
|
|
1
|
+
# ISTMX UI
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Editable UI components for your codebase. ISTMX adds the component source to
|
|
4
|
+
your project so you can read it, change it, and make it yours.
|
|
5
|
+
|
|
6
|
+
**Website:** [aryanonai.vercel.app](http://aryanonai.vercel.app/)
|
|
5
7
|
|
|
6
8
|
## Add a component
|
|
7
9
|
|
|
8
|
-
Run
|
|
10
|
+
Run the command from your project root:
|
|
9
11
|
|
|
10
12
|
```sh
|
|
11
13
|
npx @istmx/ui add animated-text
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Or use your preferred package manager:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
12
19
|
pnpm dlx @istmx/ui add animated-text
|
|
13
20
|
yarn dlx @istmx/ui add animated-text
|
|
14
21
|
bunx @istmx/ui add animated-text
|
|
15
22
|
```
|
|
16
23
|
|
|
17
|
-
|
|
24
|
+
Add the image stack component with:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npx @istmx/ui add image-accordion
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The CLI detects your package manager, copies the editable component to
|
|
18
31
|
`components/ui/animated-text.tsx`, adds the shared `cn` helper at
|
|
19
|
-
`lib/utils.ts`
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
32
|
+
`lib/utils.ts` if it is missing, and installs any missing dependencies:
|
|
33
|
+
|
|
34
|
+
- [Motion](https://motion.dev/) for animation
|
|
35
|
+
- [clsx](https://www.npmjs.com/package/clsx) and [tailwind-merge](https://www.npmjs.com/package/tailwind-merge) for class composition
|
|
36
|
+
|
|
37
|
+
Your project should already use React and have Tailwind CSS configured. After
|
|
38
|
+
installation, the component is yours to edit; your app does not need to import
|
|
39
|
+
runtime code from `@istmx/ui`.
|
|
40
|
+
|
|
41
|
+
## Animated Text
|
|
42
|
+
|
|
43
|
+
Import the copied source into your app:
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import AnimatedText from '@/components/ui/animated-text'
|
|
47
|
+
|
|
48
|
+
export function Intro() {
|
|
49
|
+
return (
|
|
50
|
+
<p>
|
|
51
|
+
I'm{' '}
|
|
52
|
+
<AnimatedText
|
|
53
|
+
items={['an AI engineer', 'a full-stack developer', 'a builder']}
|
|
54
|
+
effects={['blur', 'fade', 'shimmer']}
|
|
55
|
+
interval={2400}
|
|
56
|
+
/>
|
|
57
|
+
</p>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
```
|
|
23
61
|
|
|
24
|
-
|
|
25
|
-
`
|
|
26
|
-
|
|
62
|
+
Available effects are `blur`, `fade`, `shimmer`, `slide`, and `wave`. Use the
|
|
63
|
+
`effect` prop for one effect, or `effects` to combine several. The component
|
|
64
|
+
respects the user's reduced-motion setting.
|
|
27
65
|
|
|
28
|
-
|
|
66
|
+
### Customize the text and shimmer
|
|
67
|
+
|
|
68
|
+
Use `className` to style the wrapper and `textClassName` to style the changing
|
|
69
|
+
text. For shimmer, set custom CSS colors with `effectOptions`:
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
<AnimatedText
|
|
73
|
+
items={['an AI engineer', 'a builder']}
|
|
74
|
+
effects={['blur', 'shimmer']}
|
|
75
|
+
textClassName="font-semibold"
|
|
76
|
+
effectOptions={{
|
|
77
|
+
shimmer: {
|
|
78
|
+
color: '#71717a',
|
|
79
|
+
highlight: '#f4f4f5',
|
|
80
|
+
duration: 2.2,
|
|
81
|
+
width: 36,
|
|
82
|
+
},
|
|
83
|
+
}}
|
|
84
|
+
/>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Other options include `direction`, `interval`, `speed`, `scale`, and effect
|
|
88
|
+
settings for blur, fade, slide, and wave. The full component implementation is
|
|
89
|
+
in your `components/ui/animated-text.tsx` file.
|
|
90
|
+
|
|
91
|
+
## CLI options
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
npx @istmx/ui add animated-text --no-install
|
|
95
|
+
npx @istmx/ui add animated-text --overwrite
|
|
96
|
+
npx @istmx/ui add image-accordion
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
- `--no-install` copies the source and prints the dependency command instead
|
|
100
|
+
of installing packages.
|
|
101
|
+
- `--overwrite` replaces component and helper files that already exist.
|
|
102
|
+
|
|
103
|
+
Component names accept either hyphens or spaces: `animated-text` or `animated
|
|
104
|
+
text`.
|
|
105
|
+
|
|
106
|
+
## Image Accordion
|
|
107
|
+
|
|
108
|
+
The CLI copies an editable component to `components/ui/image-accordion.tsx`.
|
|
109
|
+
Pass any number of image objects; five are visible in the stack by default.
|
|
110
|
+
Selecting an image animates it into the preview canvas, moves it to the end of
|
|
111
|
+
the collection, and rotates the next image into the visible stack. Set
|
|
112
|
+
`visibleCount` to change how many cards are shown.
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
import ImageAccordion from '@/components/ui/image-accordion'
|
|
116
|
+
|
|
117
|
+
export function Gallery() {
|
|
118
|
+
return (
|
|
119
|
+
<ImageAccordion
|
|
120
|
+
images={[
|
|
121
|
+
{ src: '/images/coast.jpg', alt: 'Coastal cliffs', title: 'The coast' },
|
|
122
|
+
{ src: '/images/forest.jpg', alt: 'A forest', title: 'The forest' },
|
|
123
|
+
{ src: '/images/city.jpg', alt: 'A city at dusk', title: 'The city' },
|
|
124
|
+
{ src: '/images/lake.jpg', alt: 'A mountain lake', title: 'The lake' },
|
|
125
|
+
{ src: '/images/desert.jpg', alt: 'A desert path', title: 'The desert' },
|
|
126
|
+
{ src: '/images/peaks.jpg', alt: 'Snowy peaks', title: 'The peaks' },
|
|
127
|
+
]}
|
|
128
|
+
visibleCount={5}
|
|
129
|
+
className="mx-auto max-w-5xl"
|
|
130
|
+
cardClassName="rounded-lg"
|
|
131
|
+
imageClassName="object-cover"
|
|
132
|
+
glow={{ color: '#d4d4d8', opacity: 0.2, blur: 16 }}
|
|
133
|
+
transition={{ stiffness: 190, damping: 24, mass: 0.8 }}
|
|
134
|
+
/>
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
```
|
|
29
138
|
|
|
30
|
-
|
|
31
|
-
|
|
139
|
+
`ImageAccordionItem` supports `id`, `src`, `alt`, `title`, optional
|
|
140
|
+
`description`, and per-card `className` and `imageClassName`. The component
|
|
141
|
+
also accepts `stackClassName` and `previewClassName`; `glow={false}` disables
|
|
142
|
+
the radial hover glow. Its spring, glow color/position/size/opacity/blur, and
|
|
143
|
+
visible stack count are configurable. React, Motion, Tailwind CSS, `clsx`, and
|
|
144
|
+
`tailwind-merge` are used; React and Tailwind CSS should already be configured
|
|
145
|
+
in the consuming project.
|
|
32
146
|
|
|
33
|
-
The
|
|
34
|
-
|
|
147
|
+
The CLI requires Node.js 18 or later. The npm package is `@istmx/ui`; the
|
|
148
|
+
installed executable is named `istmx`.
|
package/bin/istmx.mjs
CHANGED
|
@@ -6,7 +6,11 @@ import { access, mkdir, readFile, writeFile } from 'node:fs/promises'
|
|
|
6
6
|
import path from 'node:path'
|
|
7
7
|
import { fileURLToPath } from 'node:url'
|
|
8
8
|
|
|
9
|
-
const VERSION = '0.1.
|
|
9
|
+
const VERSION = '0.1.3'
|
|
10
|
+
const COMPONENTS = {
|
|
11
|
+
'animated-text': { fileName: 'animated-text.tsx' },
|
|
12
|
+
'image-accordion': { fileName: 'image-accordion.tsx' },
|
|
13
|
+
}
|
|
10
14
|
const DEPENDENCIES = ['motion', 'clsx', 'tailwind-merge']
|
|
11
15
|
const COMMANDS = {
|
|
12
16
|
npm: ['install'],
|
|
@@ -56,7 +60,9 @@ Options:
|
|
|
56
60
|
--overwrite Replace component files that already exist
|
|
57
61
|
|
|
58
62
|
Components:
|
|
59
|
-
|
|
63
|
+
${Object.keys(COMPONENTS)
|
|
64
|
+
.map((name) => ` ${name}`)
|
|
65
|
+
.join('\n')}`)
|
|
60
66
|
}
|
|
61
67
|
|
|
62
68
|
function detectPackageManager(projectPackage) {
|
|
@@ -160,9 +166,10 @@ function installDependencies(manager, dependencies) {
|
|
|
160
166
|
}
|
|
161
167
|
|
|
162
168
|
async function addComponent(component, options) {
|
|
163
|
-
|
|
169
|
+
const definition = COMPONENTS[component]
|
|
170
|
+
if (!definition) {
|
|
164
171
|
throw new Error(
|
|
165
|
-
`Unknown component "${component}". Available
|
|
172
|
+
`Unknown component "${component}". Available components: ${Object.keys(COMPONENTS).join(', ')}. Run istmx --help to see available components.`,
|
|
166
173
|
)
|
|
167
174
|
}
|
|
168
175
|
|
|
@@ -177,12 +184,12 @@ async function addComponent(component, options) {
|
|
|
177
184
|
CURRENT_DIRECTORY,
|
|
178
185
|
'components',
|
|
179
186
|
'ui',
|
|
180
|
-
|
|
187
|
+
definition.fileName,
|
|
181
188
|
)
|
|
182
189
|
const utilityPath = path.join(CURRENT_DIRECTORY, 'lib', 'utils.ts')
|
|
183
190
|
|
|
184
191
|
await writeRegistryFile('utils.ts', utilityPath, options.overwrite)
|
|
185
|
-
await writeRegistryFile(
|
|
192
|
+
await writeRegistryFile(definition.fileName, componentPath, options.overwrite)
|
|
186
193
|
|
|
187
194
|
if (options.noInstall) {
|
|
188
195
|
const missing = DEPENDENCIES.filter(
|
|
@@ -209,7 +216,7 @@ async function addComponent(component, options) {
|
|
|
209
216
|
|
|
210
217
|
console.log(`\n${green('Done!')} ${component} is ready to edit.`)
|
|
211
218
|
console.log(
|
|
212
|
-
` ${muted('Import from')} ${cyan(
|
|
219
|
+
` ${muted('Import from')} ${cyan(`@/components/ui/${component}`)}`,
|
|
213
220
|
)
|
|
214
221
|
console.log(` ${muted('Dependencies')} ${cyan(DEPENDENCIES.join(', '))}\n`)
|
|
215
222
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,302 @@
|
|
|
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
|
+
}: ImageAccordionProps) {
|
|
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
|
+
aria-label="Image accordion"
|
|
111
|
+
className={cn(
|
|
112
|
+
'grid gap-5 md:grid-cols-[minmax(240px,0.8fr)_minmax(0,1.5fr)] md:items-center md:gap-6',
|
|
113
|
+
className,
|
|
114
|
+
)}
|
|
115
|
+
>
|
|
116
|
+
<div className={stackClassName}>
|
|
117
|
+
<div
|
|
118
|
+
role="group"
|
|
119
|
+
aria-label="Choose an image"
|
|
120
|
+
className="relative mx-auto h-[19rem] w-full max-w-[22rem] sm:h-[22rem]"
|
|
121
|
+
>
|
|
122
|
+
{visibleImages.map((image, index) => {
|
|
123
|
+
const imageKey = getImageKey(image)
|
|
124
|
+
const isActive =
|
|
125
|
+
activeImage !== null && getImageKey(activeImage) === imageKey
|
|
126
|
+
const originalIndex = images.findIndex(
|
|
127
|
+
(item) => getImageKey(item) === imageKey,
|
|
128
|
+
)
|
|
129
|
+
const offset = visibleImages.length - index - 1
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<motion.button
|
|
133
|
+
key={imageKey}
|
|
134
|
+
type="button"
|
|
135
|
+
aria-label={
|
|
136
|
+
isActive
|
|
137
|
+
? `Hide preview for ${image.title}`
|
|
138
|
+
: `Show image ${index + 1}: ${image.title}`
|
|
139
|
+
}
|
|
140
|
+
aria-pressed={isActive}
|
|
141
|
+
onClick={() => selectImage(image)}
|
|
142
|
+
initial={false}
|
|
143
|
+
animate={{
|
|
144
|
+
x: index * 13,
|
|
145
|
+
y: index * 14,
|
|
146
|
+
rotate: (index - offset / 2) * 1.4,
|
|
147
|
+
scale: 1 - offset * 0.018,
|
|
148
|
+
}}
|
|
149
|
+
whileHover={
|
|
150
|
+
reduceMotion
|
|
151
|
+
? undefined
|
|
152
|
+
: { x: index * 13 - 5, y: index * 14 - 7, scale: 1.035 }
|
|
153
|
+
}
|
|
154
|
+
whileTap={reduceMotion ? undefined : { scale: 0.98 }}
|
|
155
|
+
transition={{
|
|
156
|
+
type: 'spring',
|
|
157
|
+
stiffness: 280,
|
|
158
|
+
damping: 25,
|
|
159
|
+
mass: 0.8,
|
|
160
|
+
}}
|
|
161
|
+
style={
|
|
162
|
+
{
|
|
163
|
+
...glowStyle,
|
|
164
|
+
left: `${index * 7}%`,
|
|
165
|
+
top: `${index * 7}%`,
|
|
166
|
+
zIndex: visibleImages.length - index,
|
|
167
|
+
} as CSSProperties
|
|
168
|
+
}
|
|
169
|
+
className={cn(
|
|
170
|
+
'group focus-visible:ring-foreground focus-visible:ring-offset-background absolute isolate aspect-[4/3] w-[70%] cursor-pointer overflow-visible rounded-xl text-left focus-visible:ring-2 focus-visible:ring-offset-4 focus-visible:outline-none',
|
|
171
|
+
!reduceMotion && 'transition-transform duration-300',
|
|
172
|
+
cardClassName,
|
|
173
|
+
image.className,
|
|
174
|
+
)}
|
|
175
|
+
>
|
|
176
|
+
{glow !== false ? (
|
|
177
|
+
<span
|
|
178
|
+
aria-hidden="true"
|
|
179
|
+
className={cn(
|
|
180
|
+
'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',
|
|
181
|
+
isActive
|
|
182
|
+
? 'opacity-[var(--image-accordion-glow-opacity)]'
|
|
183
|
+
: 'opacity-0 group-hover:opacity-[var(--image-accordion-glow-opacity)] group-focus-visible:opacity-[var(--image-accordion-glow-opacity)]',
|
|
184
|
+
)}
|
|
185
|
+
/>
|
|
186
|
+
) : null}
|
|
187
|
+
|
|
188
|
+
<span
|
|
189
|
+
className={cn(
|
|
190
|
+
'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',
|
|
191
|
+
isActive && 'border-foreground/60',
|
|
192
|
+
)}
|
|
193
|
+
>
|
|
194
|
+
<motion.img
|
|
195
|
+
layoutId={
|
|
196
|
+
isActive
|
|
197
|
+
? undefined
|
|
198
|
+
: `${layoutId}-image-${originalIndex}`
|
|
199
|
+
}
|
|
200
|
+
src={image.src}
|
|
201
|
+
alt={image.alt}
|
|
202
|
+
loading="lazy"
|
|
203
|
+
decoding="async"
|
|
204
|
+
referrerPolicy="no-referrer"
|
|
205
|
+
draggable={false}
|
|
206
|
+
transition={spring}
|
|
207
|
+
className={cn(
|
|
208
|
+
'size-full object-cover',
|
|
209
|
+
!reduceMotion &&
|
|
210
|
+
'transition-transform duration-500 ease-out group-hover:scale-105',
|
|
211
|
+
imageClassName,
|
|
212
|
+
image.imageClassName,
|
|
213
|
+
)}
|
|
214
|
+
/>
|
|
215
|
+
<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">
|
|
216
|
+
{String(index + 1).padStart(2, '0')} / {image.title}
|
|
217
|
+
</span>
|
|
218
|
+
</span>
|
|
219
|
+
</motion.button>
|
|
220
|
+
)
|
|
221
|
+
})}
|
|
222
|
+
</div>
|
|
223
|
+
|
|
224
|
+
<div className="text-muted mt-3 flex items-center justify-between font-mono text-[10px] tracking-[0.14em] uppercase">
|
|
225
|
+
<span>Image stack</span>
|
|
226
|
+
<span>
|
|
227
|
+
{String(visibleImages.length).padStart(2, '0')} /{' '}
|
|
228
|
+
{String(stackImages.length).padStart(2, '0')} images
|
|
229
|
+
</span>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
|
|
233
|
+
<div
|
|
234
|
+
className={cn(
|
|
235
|
+
'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',
|
|
236
|
+
previewClassName,
|
|
237
|
+
)}
|
|
238
|
+
>
|
|
239
|
+
<AnimatePresence mode="wait" initial={false}>
|
|
240
|
+
{activeImage ? (
|
|
241
|
+
<motion.figure
|
|
242
|
+
key={getImageKey(activeImage)}
|
|
243
|
+
initial={reduceMotion ? { opacity: 0 } : { opacity: 0.8 }}
|
|
244
|
+
animate={{ opacity: 1 }}
|
|
245
|
+
exit={{ opacity: 0 }}
|
|
246
|
+
transition={{ duration: reduceMotion ? 0 : 0.22 }}
|
|
247
|
+
className="absolute inset-0 m-0"
|
|
248
|
+
>
|
|
249
|
+
<motion.img
|
|
250
|
+
layoutId={`${layoutId}-image-${images.findIndex((image) => getImageKey(image) === getImageKey(activeImage))}`}
|
|
251
|
+
src={activeImage.src}
|
|
252
|
+
alt={activeImage.alt}
|
|
253
|
+
decoding="async"
|
|
254
|
+
referrerPolicy="no-referrer"
|
|
255
|
+
draggable={false}
|
|
256
|
+
transition={spring}
|
|
257
|
+
className={cn(
|
|
258
|
+
'size-full object-cover',
|
|
259
|
+
imageClassName,
|
|
260
|
+
activeImage.imageClassName,
|
|
261
|
+
)}
|
|
262
|
+
/>
|
|
263
|
+
<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">
|
|
264
|
+
<p className="font-mono text-[10px] tracking-[0.18em] text-white/65 uppercase">
|
|
265
|
+
Image {String(activePosition).padStart(2, '0')} /{' '}
|
|
266
|
+
{String(stackImages.length).padStart(2, '0')}
|
|
267
|
+
</p>
|
|
268
|
+
<h2 className="mt-2 text-xl font-medium tracking-tight sm:text-2xl">
|
|
269
|
+
{activeImage.title}
|
|
270
|
+
</h2>
|
|
271
|
+
{activeImage.description ? (
|
|
272
|
+
<p className="mt-1 max-w-lg text-sm leading-6 text-white/75">
|
|
273
|
+
{activeImage.description}
|
|
274
|
+
</p>
|
|
275
|
+
) : null}
|
|
276
|
+
</figcaption>
|
|
277
|
+
</motion.figure>
|
|
278
|
+
) : (
|
|
279
|
+
<motion.div
|
|
280
|
+
key="empty-preview"
|
|
281
|
+
initial={reduceMotion ? false : { opacity: 0 }}
|
|
282
|
+
animate={{ opacity: 1 }}
|
|
283
|
+
exit={{ opacity: 0 }}
|
|
284
|
+
transition={{ duration: reduceMotion ? 0 : 0.2 }}
|
|
285
|
+
className="px-6 text-center"
|
|
286
|
+
>
|
|
287
|
+
<p className="text-muted font-mono text-[10px] tracking-[0.18em] uppercase">
|
|
288
|
+
Preview
|
|
289
|
+
</p>
|
|
290
|
+
<p className="text-muted mt-2 text-sm">
|
|
291
|
+
Select a corner to reveal an image.
|
|
292
|
+
</p>
|
|
293
|
+
</motion.div>
|
|
294
|
+
)}
|
|
295
|
+
</AnimatePresence>
|
|
296
|
+
</div>
|
|
297
|
+
</section>
|
|
298
|
+
</LayoutGroup>
|
|
299
|
+
)
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export default ImageAccordion
|