@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,225 +1,228 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { useEffect, useState } from 'react'
|
|
4
|
-
import type { CSSProperties } from 'react'
|
|
5
|
-
import { AnimatePresence, motion, useReducedMotion } from 'motion/react'
|
|
6
|
-
import { cn } from '@/lib/utils'
|
|
7
|
-
|
|
8
|
-
const DEFAULT_ITEMS = [
|
|
9
|
-
'an AI Engineer',
|
|
10
|
-
'a Full-Stack Developer',
|
|
11
|
-
'a Student',
|
|
12
|
-
'a Mobile Developer',
|
|
13
|
-
]
|
|
14
|
-
|
|
15
|
-
const DIRECTIONS = {
|
|
16
|
-
up: { enter: 5, exit: -5 },
|
|
17
|
-
down: { enter: -5, exit: 5 },
|
|
18
|
-
left: { enter: 7, exit: -7 },
|
|
19
|
-
right: { enter: -7, exit: 7 },
|
|
20
|
-
none: { enter: 0, exit: 0 },
|
|
21
|
-
} as const
|
|
22
|
-
|
|
23
|
-
export type AnimatedTextEffect = 'blur' | 'shimmer' | 'fade' | 'slide' | 'wave'
|
|
24
|
-
export type AnimatedTextDirection = keyof typeof DIRECTIONS
|
|
25
|
-
export type AnimatedTextEffectOptions = {
|
|
26
|
-
blur?: { amount?: number }
|
|
27
|
-
fade?: { from?: number }
|
|
28
|
-
slide?: { distance?: number }
|
|
29
|
-
shimmer?: {
|
|
30
|
-
duration?: number
|
|
31
|
-
width?: number
|
|
32
|
-
color?: string
|
|
33
|
-
highlight?: string
|
|
34
|
-
}
|
|
35
|
-
wave?: { amplitude?: number; stagger?: number }
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type AnimatedTextProps = {
|
|
39
|
-
items?: string[]
|
|
40
|
-
prefix?: string
|
|
41
|
-
effect?: AnimatedTextEffect
|
|
42
|
-
effects?: AnimatedTextEffect[]
|
|
43
|
-
effectOptions?: AnimatedTextEffectOptions
|
|
44
|
-
scale?: number
|
|
45
|
-
direction?: AnimatedTextDirection
|
|
46
|
-
interval?: number
|
|
47
|
-
speed?: number
|
|
48
|
-
className?: string
|
|
49
|
-
textClassName?: string
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function AnimatedText({
|
|
53
|
-
items = DEFAULT_ITEMS,
|
|
54
|
-
prefix,
|
|
55
|
-
effect = 'blur',
|
|
56
|
-
effects = [effect],
|
|
57
|
-
effectOptions,
|
|
58
|
-
scale,
|
|
59
|
-
direction = 'up',
|
|
60
|
-
interval = 2600,
|
|
61
|
-
speed = 0.32,
|
|
62
|
-
className,
|
|
63
|
-
textClassName,
|
|
64
|
-
}
|
|
65
|
-
const [itemIndex, setItemIndex] = useState(0)
|
|
66
|
-
const shouldReduceMotion = useReducedMotion()
|
|
67
|
-
const values = items.length > 0 ? items : ['']
|
|
68
|
-
const currentItem = values[itemIndex % values.length]
|
|
69
|
-
const offset = DIRECTIONS[direction]
|
|
70
|
-
const activeEffects = new Set(effects)
|
|
71
|
-
const hasBlur = activeEffects.has('blur')
|
|
72
|
-
const hasFade = activeEffects.has('fade') || hasBlur
|
|
73
|
-
const hasSlide = activeEffects.has('slide') || hasBlur
|
|
74
|
-
const blurAmount = Math.max(0, effectOptions?.blur?.amount ?? 5)
|
|
75
|
-
const fadeFrom = Math.min(1, Math.max(0, effectOptions?.fade?.from ?? 0))
|
|
76
|
-
const shimmerDuration = Math.max(0.1, effectOptions?.shimmer?.duration ?? 2.6)
|
|
77
|
-
const shimmerWidth = Math.min(
|
|
78
|
-
80,
|
|
79
|
-
Math.max(5, effectOptions?.shimmer?.width ?? 30),
|
|
80
|
-
)
|
|
81
|
-
const shimmerColor = effectOptions?.shimmer?.color ?? 'var(--muted, #71717a)'
|
|
82
|
-
const shimmerHighlight =
|
|
83
|
-
effectOptions?.shimmer?.highlight ?? 'var(--foreground, #18181b)'
|
|
84
|
-
const slideDistance = Math.max(
|
|
85
|
-
0,
|
|
86
|
-
effectOptions?.slide?.distance ?? Math.abs(offset.enter),
|
|
87
|
-
)
|
|
88
|
-
const waveAmplitude = Math.max(0, effectOptions?.wave?.amplitude ?? 4)
|
|
89
|
-
const waveStagger = Math.max(0, effectOptions?.wave?.stagger ?? 0.025)
|
|
90
|
-
const scaleFrom =
|
|
91
|
-
typeof scale === 'number' &&
|
|
92
|
-
Number.isFinite(scale) &&
|
|
93
|
-
scale > 0 &&
|
|
94
|
-
scale !== 1
|
|
95
|
-
? scale
|
|
96
|
-
: undefined
|
|
97
|
-
const shimmerEnabled = activeEffects.has('shimmer') && !shouldReduceMotion
|
|
98
|
-
const waveEnabled = activeEffects.has('wave')
|
|
99
|
-
const enterX =
|
|
100
|
-
direction === 'left' || direction === 'right'
|
|
101
|
-
? Math.sign(offset.enter) * slideDistance
|
|
102
|
-
: 0
|
|
103
|
-
const enterY =
|
|
104
|
-
direction === 'up' || direction === 'down'
|
|
105
|
-
? Math.sign(offset.enter) * slideDistance
|
|
106
|
-
: 0
|
|
107
|
-
const exitX =
|
|
108
|
-
direction === 'left' || direction === 'right'
|
|
109
|
-
? Math.sign(offset.exit) * slideDistance
|
|
110
|
-
: 0
|
|
111
|
-
const exitY =
|
|
112
|
-
direction === 'up' || direction === 'down'
|
|
113
|
-
? Math.sign(offset.exit) * slideDistance
|
|
114
|
-
: 0
|
|
115
|
-
const initialState = {
|
|
116
|
-
...(hasFade ? { opacity: fadeFrom } : {}),
|
|
117
|
-
...(hasSlide ? { x: enterX, y: enterY } : {}),
|
|
118
|
-
...(hasBlur ? { filter: 'blur(' + blurAmount + 'px)' } : {}),
|
|
119
|
-
...(scaleFrom !== undefined ? { scale: scaleFrom } : {}),
|
|
120
|
-
}
|
|
121
|
-
const animateState = {
|
|
122
|
-
...(hasFade ? { opacity: 1 } : {}),
|
|
123
|
-
...(hasSlide ? { x: 0, y: 0 } : {}),
|
|
124
|
-
...(hasBlur ? { filter: 'blur(0px)' } : {}),
|
|
125
|
-
...(scaleFrom !== undefined ? { scale: 1 } : {}),
|
|
126
|
-
...(shimmerEnabled ? { backgroundPosition: ['100% 0', '-120% 0'] } : {}),
|
|
127
|
-
}
|
|
128
|
-
const exitState = {
|
|
129
|
-
...(hasFade ? { opacity: fadeFrom } : {}),
|
|
130
|
-
...(hasSlide ? { x: exitX, y: exitY } : {}),
|
|
131
|
-
...(hasBlur ? { filter: 'blur(' + blurAmount + 'px)' } : {}),
|
|
132
|
-
...(scaleFrom !== undefined ? { scale: scaleFrom } : {}),
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
useEffect(() => {
|
|
136
|
-
if (shouldReduceMotion || values.length < 2 || interval <= 0) return
|
|
137
|
-
|
|
138
|
-
const timer = window.setInterval(() => {
|
|
139
|
-
setItemIndex((index) => (index + 1) % values.length)
|
|
140
|
-
}, interval)
|
|
141
|
-
|
|
142
|
-
return () => window.clearInterval(timer)
|
|
143
|
-
}, [interval, shouldReduceMotion, values.length])
|
|
144
|
-
|
|
145
|
-
return (
|
|
146
|
-
<span
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
aria-
|
|
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
|
-
'--shimmer-
|
|
186
|
-
'--shimmer-
|
|
187
|
-
'--shimmer-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
<span
|
|
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
|
-
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useEffect, useState } from 'react'
|
|
4
|
+
import type { CSSProperties } from 'react'
|
|
5
|
+
import { AnimatePresence, motion, useReducedMotion } from 'motion/react'
|
|
6
|
+
import { cn } from '@/lib/utils'
|
|
7
|
+
|
|
8
|
+
const DEFAULT_ITEMS = [
|
|
9
|
+
'an AI Engineer',
|
|
10
|
+
'a Full-Stack Developer',
|
|
11
|
+
'a Student',
|
|
12
|
+
'a Mobile Developer',
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
const DIRECTIONS = {
|
|
16
|
+
up: { enter: 5, exit: -5 },
|
|
17
|
+
down: { enter: -5, exit: 5 },
|
|
18
|
+
left: { enter: 7, exit: -7 },
|
|
19
|
+
right: { enter: -7, exit: 7 },
|
|
20
|
+
none: { enter: 0, exit: 0 },
|
|
21
|
+
} as const
|
|
22
|
+
|
|
23
|
+
export type AnimatedTextEffect = 'blur' | 'shimmer' | 'fade' | 'slide' | 'wave'
|
|
24
|
+
export type AnimatedTextDirection = keyof typeof DIRECTIONS
|
|
25
|
+
export type AnimatedTextEffectOptions = {
|
|
26
|
+
blur?: { amount?: number }
|
|
27
|
+
fade?: { from?: number }
|
|
28
|
+
slide?: { distance?: number }
|
|
29
|
+
shimmer?: {
|
|
30
|
+
duration?: number
|
|
31
|
+
width?: number
|
|
32
|
+
color?: string
|
|
33
|
+
highlight?: string
|
|
34
|
+
}
|
|
35
|
+
wave?: { amplitude?: number; stagger?: number }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type AnimatedTextProps = {
|
|
39
|
+
items?: string[]
|
|
40
|
+
prefix?: string
|
|
41
|
+
effect?: AnimatedTextEffect
|
|
42
|
+
effects?: AnimatedTextEffect[]
|
|
43
|
+
effectOptions?: AnimatedTextEffectOptions
|
|
44
|
+
scale?: number
|
|
45
|
+
direction?: AnimatedTextDirection
|
|
46
|
+
interval?: number
|
|
47
|
+
speed?: number
|
|
48
|
+
className?: string
|
|
49
|
+
textClassName?: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const AnimatedText = forwardRef<HTMLSpanElement, AnimatedTextProps>(function AnimatedText({
|
|
53
|
+
items = DEFAULT_ITEMS,
|
|
54
|
+
prefix,
|
|
55
|
+
effect = 'blur',
|
|
56
|
+
effects = [effect],
|
|
57
|
+
effectOptions,
|
|
58
|
+
scale,
|
|
59
|
+
direction = 'up',
|
|
60
|
+
interval = 2600,
|
|
61
|
+
speed = 0.32,
|
|
62
|
+
className,
|
|
63
|
+
textClassName,
|
|
64
|
+
}, ref) {
|
|
65
|
+
const [itemIndex, setItemIndex] = useState(0)
|
|
66
|
+
const shouldReduceMotion = useReducedMotion()
|
|
67
|
+
const values = items.length > 0 ? items : ['']
|
|
68
|
+
const currentItem = values[itemIndex % values.length]
|
|
69
|
+
const offset = DIRECTIONS[direction]
|
|
70
|
+
const activeEffects = new Set(effects)
|
|
71
|
+
const hasBlur = activeEffects.has('blur')
|
|
72
|
+
const hasFade = activeEffects.has('fade') || hasBlur
|
|
73
|
+
const hasSlide = activeEffects.has('slide') || hasBlur
|
|
74
|
+
const blurAmount = Math.max(0, effectOptions?.blur?.amount ?? 5)
|
|
75
|
+
const fadeFrom = Math.min(1, Math.max(0, effectOptions?.fade?.from ?? 0))
|
|
76
|
+
const shimmerDuration = Math.max(0.1, effectOptions?.shimmer?.duration ?? 2.6)
|
|
77
|
+
const shimmerWidth = Math.min(
|
|
78
|
+
80,
|
|
79
|
+
Math.max(5, effectOptions?.shimmer?.width ?? 30),
|
|
80
|
+
)
|
|
81
|
+
const shimmerColor = effectOptions?.shimmer?.color ?? 'var(--muted, #71717a)'
|
|
82
|
+
const shimmerHighlight =
|
|
83
|
+
effectOptions?.shimmer?.highlight ?? 'var(--foreground, #18181b)'
|
|
84
|
+
const slideDistance = Math.max(
|
|
85
|
+
0,
|
|
86
|
+
effectOptions?.slide?.distance ?? Math.abs(offset.enter),
|
|
87
|
+
)
|
|
88
|
+
const waveAmplitude = Math.max(0, effectOptions?.wave?.amplitude ?? 4)
|
|
89
|
+
const waveStagger = Math.max(0, effectOptions?.wave?.stagger ?? 0.025)
|
|
90
|
+
const scaleFrom =
|
|
91
|
+
typeof scale === 'number' &&
|
|
92
|
+
Number.isFinite(scale) &&
|
|
93
|
+
scale > 0 &&
|
|
94
|
+
scale !== 1
|
|
95
|
+
? scale
|
|
96
|
+
: undefined
|
|
97
|
+
const shimmerEnabled = activeEffects.has('shimmer') && !shouldReduceMotion
|
|
98
|
+
const waveEnabled = activeEffects.has('wave')
|
|
99
|
+
const enterX =
|
|
100
|
+
direction === 'left' || direction === 'right'
|
|
101
|
+
? Math.sign(offset.enter) * slideDistance
|
|
102
|
+
: 0
|
|
103
|
+
const enterY =
|
|
104
|
+
direction === 'up' || direction === 'down'
|
|
105
|
+
? Math.sign(offset.enter) * slideDistance
|
|
106
|
+
: 0
|
|
107
|
+
const exitX =
|
|
108
|
+
direction === 'left' || direction === 'right'
|
|
109
|
+
? Math.sign(offset.exit) * slideDistance
|
|
110
|
+
: 0
|
|
111
|
+
const exitY =
|
|
112
|
+
direction === 'up' || direction === 'down'
|
|
113
|
+
? Math.sign(offset.exit) * slideDistance
|
|
114
|
+
: 0
|
|
115
|
+
const initialState = {
|
|
116
|
+
...(hasFade ? { opacity: fadeFrom } : {}),
|
|
117
|
+
...(hasSlide ? { x: enterX, y: enterY } : {}),
|
|
118
|
+
...(hasBlur ? { filter: 'blur(' + blurAmount + 'px)' } : {}),
|
|
119
|
+
...(scaleFrom !== undefined ? { scale: scaleFrom } : {}),
|
|
120
|
+
}
|
|
121
|
+
const animateState = {
|
|
122
|
+
...(hasFade ? { opacity: 1 } : {}),
|
|
123
|
+
...(hasSlide ? { x: 0, y: 0 } : {}),
|
|
124
|
+
...(hasBlur ? { filter: 'blur(0px)' } : {}),
|
|
125
|
+
...(scaleFrom !== undefined ? { scale: 1 } : {}),
|
|
126
|
+
...(shimmerEnabled ? { backgroundPosition: ['100% 0', '-120% 0'] } : {}),
|
|
127
|
+
}
|
|
128
|
+
const exitState = {
|
|
129
|
+
...(hasFade ? { opacity: fadeFrom } : {}),
|
|
130
|
+
...(hasSlide ? { x: exitX, y: exitY } : {}),
|
|
131
|
+
...(hasBlur ? { filter: 'blur(' + blurAmount + 'px)' } : {}),
|
|
132
|
+
...(scaleFrom !== undefined ? { scale: scaleFrom } : {}),
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (shouldReduceMotion || values.length < 2 || interval <= 0) return
|
|
137
|
+
|
|
138
|
+
const timer = window.setInterval(() => {
|
|
139
|
+
setItemIndex((index) => (index + 1) % values.length)
|
|
140
|
+
}, interval)
|
|
141
|
+
|
|
142
|
+
return () => window.clearInterval(timer)
|
|
143
|
+
}, [interval, shouldReduceMotion, values.length])
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<span
|
|
147
|
+
ref={ref}
|
|
148
|
+
className={cn(
|
|
149
|
+
'relative inline-flex min-h-5 items-center overflow-hidden align-top text-sm sm:text-base',
|
|
150
|
+
className,
|
|
151
|
+
)}
|
|
152
|
+
aria-live="polite"
|
|
153
|
+
aria-atomic="true"
|
|
154
|
+
>
|
|
155
|
+
{prefix ? <span className="mr-1.5 shrink-0">{prefix}</span> : null}
|
|
156
|
+
<AnimatePresence mode="wait" initial={false}>
|
|
157
|
+
<motion.span
|
|
158
|
+
key={itemIndex + ':' + currentItem}
|
|
159
|
+
initial={shouldReduceMotion ? false : initialState}
|
|
160
|
+
animate={animateState}
|
|
161
|
+
exit={shouldReduceMotion ? { opacity: 0 } : exitState}
|
|
162
|
+
transition={{
|
|
163
|
+
duration: shouldReduceMotion ? 0 : speed,
|
|
164
|
+
ease: 'easeOut',
|
|
165
|
+
...(shimmerEnabled
|
|
166
|
+
? {
|
|
167
|
+
backgroundPosition: {
|
|
168
|
+
duration: shimmerDuration,
|
|
169
|
+
ease: 'easeInOut',
|
|
170
|
+
repeat: Infinity,
|
|
171
|
+
},
|
|
172
|
+
}
|
|
173
|
+
: {}),
|
|
174
|
+
}}
|
|
175
|
+
className={cn(
|
|
176
|
+
'font-medium whitespace-nowrap',
|
|
177
|
+
activeEffects.has('shimmer') &&
|
|
178
|
+
(shimmerEnabled
|
|
179
|
+
? 'bg-[linear-gradient(100deg,var(--shimmer-color)_var(--shimmer-start),var(--shimmer-highlight)_50%,var(--shimmer-color)_var(--shimmer-end))] bg-[length:220%_100%] bg-clip-text text-transparent'
|
|
180
|
+
: 'text-foreground'),
|
|
181
|
+
textClassName,
|
|
182
|
+
)}
|
|
183
|
+
style={
|
|
184
|
+
{
|
|
185
|
+
'--shimmer-start': 50 - shimmerWidth / 2 + '%',
|
|
186
|
+
'--shimmer-end': 50 + shimmerWidth / 2 + '%',
|
|
187
|
+
'--shimmer-color': shimmerColor,
|
|
188
|
+
'--shimmer-highlight': shimmerHighlight,
|
|
189
|
+
} as CSSProperties
|
|
190
|
+
}
|
|
191
|
+
>
|
|
192
|
+
{waveEnabled ? (
|
|
193
|
+
<>
|
|
194
|
+
<span className="sr-only">{currentItem}</span>
|
|
195
|
+
<span aria-hidden="true" className="inline-flex">
|
|
196
|
+
{Array.from(currentItem).map((character, index) => (
|
|
197
|
+
<motion.span
|
|
198
|
+
key={index + '-' + character}
|
|
199
|
+
initial={shouldReduceMotion ? false : { y: waveAmplitude }}
|
|
200
|
+
animate={
|
|
201
|
+
shouldReduceMotion
|
|
202
|
+
? { y: 0 }
|
|
203
|
+
: { y: [waveAmplitude, -waveAmplitude * 0.75, 0] }
|
|
204
|
+
}
|
|
205
|
+
transition={{
|
|
206
|
+
duration: shouldReduceMotion ? 0 : speed * 0.7,
|
|
207
|
+
delay: shouldReduceMotion ? 0 : index * waveStagger,
|
|
208
|
+
ease: 'easeOut',
|
|
209
|
+
}}
|
|
210
|
+
className="inline-block"
|
|
211
|
+
>
|
|
212
|
+
{character === ' ' ? '\u00a0' : character}
|
|
213
|
+
</motion.span>
|
|
214
|
+
))}
|
|
215
|
+
</span>
|
|
216
|
+
</>
|
|
217
|
+
) : (
|
|
218
|
+
currentItem
|
|
219
|
+
)}
|
|
220
|
+
</motion.span>
|
|
221
|
+
</AnimatePresence>
|
|
222
|
+
</span>
|
|
223
|
+
)
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
AnimatedText.displayName = 'AnimatedText'
|
|
227
|
+
|
|
228
|
+
export default AnimatedText
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { motion, useReducedMotion, type HTMLMotionProps } from 'motion/react'
|
|
5
|
+
import { cn } from '@/lib/utils'
|
|
6
|
+
|
|
7
|
+
export interface AspectRatioProps extends Omit<HTMLMotionProps<'div'>, 'ref'> {
|
|
8
|
+
ratio?: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const AspectRatio = React.forwardRef<HTMLDivElement, AspectRatioProps>(
|
|
12
|
+
({ className, ratio = 16 / 9, style, ...props }, ref) => {
|
|
13
|
+
const reduceMotion = useReducedMotion()
|
|
14
|
+
const safeRatio = Number.isFinite(ratio) && ratio > 0 ? ratio : 16 / 9
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<motion.div
|
|
18
|
+
{...props}
|
|
19
|
+
ref={ref}
|
|
20
|
+
layout={reduceMotion ? false : true}
|
|
21
|
+
transition={reduceMotion ? { duration: 0 } : { type: 'spring', stiffness: 360, damping: 34, mass: 0.7 }}
|
|
22
|
+
data-slot="aspect-ratio"
|
|
23
|
+
style={{ ...style, aspectRatio: safeRatio }}
|
|
24
|
+
className={cn('relative w-full', className)}
|
|
25
|
+
/>
|
|
26
|
+
)
|
|
27
|
+
},
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
AspectRatio.displayName = 'AspectRatio'
|
|
31
|
+
|
|
32
|
+
export { AspectRatio }
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { motion, useReducedMotion } from 'motion/react'
|
|
5
|
+
import { Avatar, AvatarFallback, AvatarImage, type AvatarSize } from '@/components/ui/avatar'
|
|
6
|
+
import { cn } from '@/lib/utils'
|
|
7
|
+
|
|
8
|
+
export interface AvatarGroupItem {
|
|
9
|
+
src?: string
|
|
10
|
+
alt: string
|
|
11
|
+
fallback: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AvatarGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
15
|
+
items: AvatarGroupItem[]
|
|
16
|
+
max?: number
|
|
17
|
+
size?: AvatarSize
|
|
18
|
+
overlap?: number
|
|
19
|
+
showCount?: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const AvatarGroup = React.forwardRef<HTMLDivElement, AvatarGroupProps>(
|
|
23
|
+
({ className, items, max = 4, size = 'md', overlap = 12, showCount = true, ...props }, ref) => {
|
|
24
|
+
const reduceMotion = useReducedMotion()
|
|
25
|
+
const visibleItems = items.slice(0, Math.max(0, max))
|
|
26
|
+
const remaining = Math.max(0, items.length - visibleItems.length)
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div
|
|
30
|
+
{...props}
|
|
31
|
+
ref={ref}
|
|
32
|
+
role="group"
|
|
33
|
+
data-slot="avatar-group"
|
|
34
|
+
className={cn('inline-flex items-center', className)}
|
|
35
|
+
>
|
|
36
|
+
{visibleItems.map((item, index) => (
|
|
37
|
+
<motion.span
|
|
38
|
+
key={`${item.alt}-${index}`}
|
|
39
|
+
whileHover={reduceMotion ? undefined : { y: -6, scale: 1.1, zIndex: 20 }}
|
|
40
|
+
transition={reduceMotion ? { duration: 0 } : { type: 'spring', stiffness: 420, damping: 22, mass: 0.65 }}
|
|
41
|
+
style={{ zIndex: visibleItems.length - index, marginLeft: index > 0 ? -overlap : undefined, transformOrigin: '50% 100%' }}
|
|
42
|
+
className="relative inline-flex rounded-full"
|
|
43
|
+
>
|
|
44
|
+
<Avatar size={size} aria-label={item.alt} className="ring-2 ring-background">
|
|
45
|
+
{item.src && <AvatarImage src={item.src} alt={item.alt} />}
|
|
46
|
+
<AvatarFallback>{item.fallback}</AvatarFallback>
|
|
47
|
+
</Avatar>
|
|
48
|
+
</motion.span>
|
|
49
|
+
))}
|
|
50
|
+
{showCount && remaining > 0 && (
|
|
51
|
+
<span
|
|
52
|
+
aria-label={`${remaining} more ${remaining === 1 ? 'person' : 'people'}`}
|
|
53
|
+
className={cn('relative z-10 inline-grid shrink-0 place-items-center rounded-full border-2 border-background bg-muted font-grotesk font-semibold text-muted-foreground', size === 'sm' ? 'size-8 text-[10px]' : size === 'md' ? 'size-10 text-xs' : size === 'lg' ? 'size-12 text-sm' : size === 'xl' ? 'size-16 text-base' : 'size-24 text-lg')}
|
|
54
|
+
style={{ marginLeft: -overlap }}
|
|
55
|
+
>
|
|
56
|
+
+{remaining}
|
|
57
|
+
</span>
|
|
58
|
+
)}
|
|
59
|
+
</div>
|
|
60
|
+
)
|
|
61
|
+
},
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
AvatarGroup.displayName = 'AvatarGroup'
|
|
65
|
+
|
|
66
|
+
export { AvatarGroup }
|