@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
package/registry/image-trail.tsx
CHANGED
|
@@ -1,121 +1,126 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { useRef, useState } from 'react'
|
|
4
|
-
import type { PointerEvent } from 'react'
|
|
5
|
-
import { AnimatePresence, motion, useReducedMotion } from 'motion/react'
|
|
6
|
-
import { cn } from '@/lib/utils'
|
|
7
|
-
|
|
8
|
-
export type ImageTrailItem = {
|
|
9
|
-
src: string
|
|
10
|
-
alt: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type ImageTrailProps = {
|
|
14
|
-
images: ImageTrailItem[]
|
|
15
|
-
className?: string
|
|
16
|
-
imageClassName?: string
|
|
17
|
-
throttle?: number
|
|
18
|
-
maxTrailItems?: number
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type TrailImage = ImageTrailItem & {
|
|
22
|
-
id: number
|
|
23
|
-
x: number
|
|
24
|
-
y: number
|
|
25
|
-
rotate: number
|
|
26
|
-
driftX: number
|
|
27
|
-
driftY: number
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
images,
|
|
32
|
-
className,
|
|
33
|
-
imageClassName,
|
|
34
|
-
throttle = 160,
|
|
35
|
-
maxTrailItems = 5,
|
|
36
|
-
}
|
|
37
|
-
const [trail, setTrail] = useState<TrailImage[]>([])
|
|
38
|
-
const lastSpawn = useRef(0)
|
|
39
|
-
const nextId = useRef(0)
|
|
40
|
-
const reduceMotion = useReducedMotion()
|
|
41
|
-
|
|
42
|
-
function handlePointerMove(event: PointerEvent<HTMLDivElement>) {
|
|
43
|
-
if (reduceMotion || images.length === 0) return
|
|
44
|
-
|
|
45
|
-
const now = performance.now()
|
|
46
|
-
if (now - lastSpawn.current < Math.max(0, throttle)) return
|
|
47
|
-
lastSpawn.current = now
|
|
48
|
-
|
|
49
|
-
const bounds = event.currentTarget.getBoundingClientRect()
|
|
50
|
-
const id = nextId.current++
|
|
51
|
-
const image = images[id % images.length]
|
|
52
|
-
const x = event.clientX - bounds.left
|
|
53
|
-
const y = event.clientY - bounds.top
|
|
54
|
-
|
|
55
|
-
setTrail((current) => [
|
|
56
|
-
...current,
|
|
57
|
-
{
|
|
58
|
-
...image,
|
|
59
|
-
id,
|
|
60
|
-
x,
|
|
61
|
-
y,
|
|
62
|
-
rotate: (id % 2 === 0 ? -1 : 1) * (4 + (id % 4) * 2),
|
|
63
|
-
driftX: (id % 2 === 0 ? -1 : 1) * (12 + (id % 3) * 5),
|
|
64
|
-
driftY: -18 - (id % 3) * 7,
|
|
65
|
-
},
|
|
66
|
-
].slice(-Math.max(1, maxTrailItems)))
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<div
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useRef, useState } from 'react'
|
|
4
|
+
import type { PointerEvent } from 'react'
|
|
5
|
+
import { AnimatePresence, motion, useReducedMotion } from 'motion/react'
|
|
6
|
+
import { cn } from '@/lib/utils'
|
|
7
|
+
|
|
8
|
+
export type ImageTrailItem = {
|
|
9
|
+
src: string
|
|
10
|
+
alt: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type ImageTrailProps = {
|
|
14
|
+
images: ImageTrailItem[]
|
|
15
|
+
className?: string
|
|
16
|
+
imageClassName?: string
|
|
17
|
+
throttle?: number
|
|
18
|
+
maxTrailItems?: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type TrailImage = ImageTrailItem & {
|
|
22
|
+
id: number
|
|
23
|
+
x: number
|
|
24
|
+
y: number
|
|
25
|
+
rotate: number
|
|
26
|
+
driftX: number
|
|
27
|
+
driftY: number
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const ImageTrail = forwardRef<HTMLDivElement, ImageTrailProps>(function ImageTrail({
|
|
31
|
+
images,
|
|
32
|
+
className,
|
|
33
|
+
imageClassName,
|
|
34
|
+
throttle = 160,
|
|
35
|
+
maxTrailItems = 5,
|
|
36
|
+
}, ref) {
|
|
37
|
+
const [trail, setTrail] = useState<TrailImage[]>([])
|
|
38
|
+
const lastSpawn = useRef(0)
|
|
39
|
+
const nextId = useRef(0)
|
|
40
|
+
const reduceMotion = useReducedMotion()
|
|
41
|
+
|
|
42
|
+
function handlePointerMove(event: PointerEvent<HTMLDivElement>) {
|
|
43
|
+
if (reduceMotion || images.length === 0) return
|
|
44
|
+
|
|
45
|
+
const now = performance.now()
|
|
46
|
+
if (now - lastSpawn.current < Math.max(0, throttle)) return
|
|
47
|
+
lastSpawn.current = now
|
|
48
|
+
|
|
49
|
+
const bounds = event.currentTarget.getBoundingClientRect()
|
|
50
|
+
const id = nextId.current++
|
|
51
|
+
const image = images[id % images.length]
|
|
52
|
+
const x = event.clientX - bounds.left
|
|
53
|
+
const y = event.clientY - bounds.top
|
|
54
|
+
|
|
55
|
+
setTrail((current) => [
|
|
56
|
+
...current,
|
|
57
|
+
{
|
|
58
|
+
...image,
|
|
59
|
+
id,
|
|
60
|
+
x,
|
|
61
|
+
y,
|
|
62
|
+
rotate: (id % 2 === 0 ? -1 : 1) * (4 + (id % 4) * 2),
|
|
63
|
+
driftX: (id % 2 === 0 ? -1 : 1) * (12 + (id % 3) * 5),
|
|
64
|
+
driftY: -18 - (id % 3) * 7,
|
|
65
|
+
},
|
|
66
|
+
].slice(-Math.max(1, maxTrailItems)))
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div
|
|
71
|
+
ref={ref}
|
|
72
|
+
role="group"
|
|
73
|
+
aria-label="Move or tap over the canvas to create an image trail"
|
|
74
|
+
onPointerMove={handlePointerMove}
|
|
75
|
+
onPointerDown={handlePointerMove}
|
|
76
|
+
className={cn(
|
|
77
|
+
'border-border bg-surface relative isolate h-[24rem] w-full touch-pan-y overflow-hidden rounded-2xl border bg-[radial-gradient(ellipse_at_50%_40%,color-mix(in_srgb,var(--foreground)_9%,transparent),transparent_55%),linear-gradient(145deg,color-mix(in_srgb,var(--foreground)_3%,var(--background)),var(--background))] sm:h-[32rem]',
|
|
78
|
+
className,
|
|
79
|
+
)}
|
|
80
|
+
>
|
|
81
|
+
<div
|
|
82
|
+
aria-hidden="true"
|
|
83
|
+
className="pointer-events-none absolute inset-0 bg-[linear-gradient(to_right,color-mix(in_srgb,var(--foreground)_3%,transparent)_1px,transparent_1px),linear-gradient(to_bottom,color-mix(in_srgb,var(--foreground)_3%,transparent)_1px,transparent_1px)] bg-size-[48px_48px] opacity-30"
|
|
84
|
+
/>
|
|
85
|
+
<div className="pointer-events-none absolute inset-x-0 top-5 z-10 flex justify-center px-4">
|
|
86
|
+
<span className="border-border/70 bg-background/75 text-muted rounded-full border px-4 py-2 text-xs shadow-sm backdrop-blur-md">
|
|
87
|
+
Move or tap to explore
|
|
88
|
+
</span>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<AnimatePresence initial={false}>
|
|
92
|
+
{trail.map((item) => (
|
|
93
|
+
<motion.img
|
|
94
|
+
key={item.id}
|
|
95
|
+
src={item.src}
|
|
96
|
+
alt=""
|
|
97
|
+
aria-hidden="true"
|
|
98
|
+
draggable={false}
|
|
99
|
+
initial={{ opacity: 0, scale: 0.72, rotate: item.rotate + 8 }}
|
|
100
|
+
animate={{
|
|
101
|
+
opacity: [0, 1, 0.88, 0],
|
|
102
|
+
scale: [0.72, 1, 1, 0.86],
|
|
103
|
+
rotate: item.rotate,
|
|
104
|
+
x: item.driftX,
|
|
105
|
+
y: item.driftY,
|
|
106
|
+
}}
|
|
107
|
+
exit={{ opacity: 0, scale: 0.8 }}
|
|
108
|
+
transition={{ duration: 1.15, times: [0, 0.16, 0.58, 1], ease: 'easeOut' }}
|
|
109
|
+
onAnimationComplete={() =>
|
|
110
|
+
setTrail((current) => current.filter((image) => image.id !== item.id))
|
|
111
|
+
}
|
|
112
|
+
style={{ left: item.x, top: item.y }}
|
|
113
|
+
className={cn(
|
|
114
|
+
'pointer-events-none absolute -ml-[5.25rem] -mt-[7rem] h-56 w-40 rounded-xl border border-white/70 object-cover shadow-[0_18px_50px_-18px_rgba(0,0,0,0.65)] sm:-ml-[6rem] sm:-mt-[8rem] sm:h-64 sm:w-48',
|
|
115
|
+
imageClassName,
|
|
116
|
+
)}
|
|
117
|
+
/>
|
|
118
|
+
))}
|
|
119
|
+
</AnimatePresence>
|
|
120
|
+
</div>
|
|
121
|
+
)
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
ImageTrail.displayName = 'ImageTrail'
|
|
125
|
+
|
|
126
|
+
export default ImageTrail
|