@istmx/ui 0.1.12 → 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.
Files changed (55) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +533 -469
  3. package/bin/istmx.mjs +481 -318
  4. package/package.json +27 -27
  5. package/registry/accordion.tsx +186 -0
  6. package/registry/ai-chat-block/ai-chat-block.tsx +456 -460
  7. package/registry/ai-chat-block/ai-chat-input.tsx +694 -694
  8. package/registry/ai-chat-block/attachment.tsx +466 -466
  9. package/registry/ai-chat-block/chat-code-block.tsx +50 -50
  10. package/registry/ai-chat-block/chat-composer.tsx +51 -51
  11. package/registry/ai-chat-block/chat-logo.tsx +18 -18
  12. package/registry/ai-chat-block/chat-message.tsx +161 -161
  13. package/registry/ai-chat-block/chat-sidebar.tsx +273 -273
  14. package/registry/ai-chat-block/chat-user-avatar.tsx +9 -9
  15. package/registry/ai-chat-block/code-highlighter.tsx +342 -357
  16. package/registry/ai-chat-block/default-attachments.tsx +42 -42
  17. package/registry/ai-chat-block/index.ts +30 -30
  18. package/registry/ai-chat-block/message-content.tsx +287 -287
  19. package/registry/ai-chat-block/message-list.tsx +93 -93
  20. package/registry/ai-chat-block/send-button.tsx +102 -102
  21. package/registry/ai-chat-block/types.ts +70 -71
  22. package/registry/ai-chat-block/utils.ts +6 -6
  23. package/registry/ai-chat-block/voice-button.tsx +66 -66
  24. package/registry/alert-dialog.tsx +229 -0
  25. package/registry/alert.tsx +188 -0
  26. package/registry/animated-text.tsx +228 -225
  27. package/registry/aspect-ratio.tsx +32 -0
  28. package/registry/avatar-group.tsx +66 -0
  29. package/registry/avatar.tsx +121 -0
  30. package/registry/badge.tsx +52 -0
  31. package/registry/bento-grid.tsx +438 -433
  32. package/registry/button.tsx +156 -237
  33. package/registry/carousel.tsx +184 -0
  34. package/registry/dock-navigation.tsx +200 -198
  35. package/registry/drift-canvas.tsx +383 -0
  36. package/registry/drift-wall.tsx +361 -0
  37. package/registry/flex-carousel.tsx +1430 -0
  38. package/registry/guided-gallery.tsx +1506 -0
  39. package/registry/image-accordion.tsx +306 -302
  40. package/registry/image-trail.tsx +126 -121
  41. package/registry/infinite-image-canvas.tsx +268 -263
  42. package/registry/input-otp.tsx +332 -0
  43. package/registry/list-card.tsx +130 -0
  44. package/registry/mobile-menu-dock.tsx +216 -211
  45. package/registry/morph-slider.tsx +756 -0
  46. package/registry/pixel-cat.tsx +972 -1020
  47. package/registry/scroll-canvas-cards.tsx +643 -640
  48. package/registry/scroll-parallax-hero.tsx +566 -565
  49. package/registry/scroll-story-cards.tsx +443 -438
  50. package/registry/slider.tsx +163 -0
  51. package/registry/spotlight-grid.tsx +226 -0
  52. package/registry/streaming-text.tsx +269 -278
  53. package/registry/text-reveal.tsx +311 -307
  54. package/registry/user-avatar.tsx +99 -0
  55. package/registry/utils.ts +6 -6
@@ -0,0 +1,383 @@
1
+ 'use client'
2
+
3
+ import * as React from 'react'
4
+ import { motion, AnimatePresence } from 'motion/react'
5
+ import { IconX } from '@tabler/icons-react'
6
+ import { cn } from '@/lib/utils'
7
+
8
+ export interface DriftCanvasItem {
9
+ id?: string
10
+ image: string
11
+ title: string
12
+ tag?: string
13
+ color?: string
14
+ href?: string
15
+ }
16
+
17
+ export interface DriftCanvasProps {
18
+ items?: DriftCanvasItem[]
19
+ tileWidth?: number
20
+ tileHeight?: number
21
+ gap?: number
22
+ tilt?: number
23
+ turn?: number
24
+ perspective?: number
25
+ friction?: number
26
+ autoDriftSpeed?: number
27
+ className?: string
28
+ style?: React.CSSProperties
29
+ overlayHeading?: string
30
+ overlayDescription?: string
31
+ }
32
+
33
+ interface TileRect {
34
+ x: number
35
+ y: number
36
+ width: number
37
+ height: number
38
+ }
39
+
40
+ const DEFAULT_ITEMS: DriftCanvasItem[] = [
41
+ { id: '1', image: 'https://images.unsplash.com/photo-1737071371043-761e02b1ef95?w=1000&q=85', title: 'Iridescence', tag: 'Shader' },
42
+ { id: '2', image: 'https://images.unsplash.com/photo-1693645325828-62cd35c8da8f?w=1000&q=85', title: 'White Room', tag: 'Motion' },
43
+ { id: '3', image: 'https://images.unsplash.com/photo-1739056238917-d89cd05c48d5?w=1000&q=85', title: 'Liquid Metal', tag: 'WebGL' },
44
+ { id: '4', image: 'https://images.unsplash.com/photo-1747191092806-c7da11881986?w=1000&q=85', title: 'Clay Study', tag: '3D Form' },
45
+ { id: '5', image: 'https://images.unsplash.com/photo-1605034313761-73ea4a0cfbf3?w=1000&q=85', title: 'Monochrome', tag: 'Minimal' },
46
+ { id: '6', image: 'https://images.unsplash.com/photo-1495462911434-be47104d70fa?w=1000&q=85', title: 'Brim Frame', tag: 'Texture' },
47
+ { id: '7', image: 'https://images.unsplash.com/photo-1786835568925-20cd20007ed0?w=1000&q=85', title: 'Three Forms', tag: 'Canvas' },
48
+ { id: '8', image: 'https://images.unsplash.com/photo-1770249196550-ff6c641165cb?w=1000&q=85', title: 'Automaton', tag: 'Interaction' },
49
+ { id: '9', image: 'https://images.unsplash.com/photo-1787181875088-087d612262a7?w=1000&q=85', title: 'Obsidian', tag: 'Component' },
50
+ { id: '10', image: 'https://images.unsplash.com/photo-1770062422885-2dfcbe8fb65b?w=1000&q=85', title: 'Poise Set', tag: 'Layout' },
51
+ { id: '11', image: 'https://images.unsplash.com/photo-1726910133626-9b573eca70ff?w=1000&q=85', title: 'Fins Curved', tag: 'Effects' },
52
+ { id: '12', image: 'https://images.unsplash.com/photo-1604854574958-59047362c165?w=1000&q=85', title: 'Plaster Bust', tag: 'Display' },
53
+ ]
54
+
55
+ export function DriftCanvas({
56
+ items = DEFAULT_ITEMS,
57
+ tileWidth = 260,
58
+ tileHeight = 180,
59
+ gap = 24,
60
+ tilt = 12,
61
+ turn = -10,
62
+ perspective = 1100,
63
+ friction = 0.92,
64
+ autoDriftSpeed = 0.35,
65
+ className = '',
66
+ style,
67
+ overlayHeading,
68
+ overlayDescription,
69
+ }: DriftCanvasProps) {
70
+ const containerRef = React.useRef<HTMLDivElement | null>(null)
71
+ const posRef = React.useRef({ x: 0, y: 0 })
72
+ const velRef = React.useRef({ x: -autoDriftSpeed, y: -autoDriftSpeed * 0.4 })
73
+ const isDraggingRef = React.useRef(false)
74
+ const dragDistanceRef = React.useRef(0)
75
+ const dragStartRef = React.useRef({ x: 0, y: 0, posX: 0, posY: 0 })
76
+ const lastPointerRef = React.useRef({ x: 0, y: 0, t: 0 })
77
+
78
+ const [size, setSize] = React.useState({ width: 1200, height: 700 })
79
+ const [camera, setCamera] = React.useState({ x: 0, y: 0 })
80
+ const [hoveredTile, setHoveredTile] = React.useState<string | null>(null)
81
+ const [selected, setSelected] = React.useState<{ item: DriftCanvasItem; rect: TileRect } | null>(null)
82
+
83
+ React.useEffect(() => {
84
+ const el = containerRef.current
85
+ if (!el) return
86
+ const ro = new ResizeObserver(([entry]) => {
87
+ if (entry) {
88
+ setSize({ width: entry.contentRect.width, height: entry.contentRect.height })
89
+ }
90
+ })
91
+ ro.observe(el)
92
+ return () => ro.disconnect()
93
+ }, [])
94
+
95
+ React.useEffect(() => {
96
+ let rafId: number
97
+ const animate = () => {
98
+ if (!isDraggingRef.current && !selected) {
99
+ velRef.current.x = velRef.current.x * friction + (-autoDriftSpeed) * (1 - friction)
100
+ velRef.current.y = velRef.current.y * friction + (-autoDriftSpeed * 0.4) * (1 - friction)
101
+ posRef.current.x += velRef.current.x
102
+ posRef.current.y += velRef.current.y
103
+ setCamera({ x: posRef.current.x, y: posRef.current.y })
104
+ }
105
+ rafId = requestAnimationFrame(animate)
106
+ }
107
+ rafId = requestAnimationFrame(animate)
108
+ return () => cancelAnimationFrame(rafId)
109
+ }, [friction, autoDriftSpeed, selected])
110
+
111
+ const onPointerDown = (e: React.PointerEvent<HTMLDivElement>) => {
112
+ if (e.button !== 0 || selected) return
113
+ isDraggingRef.current = true
114
+ dragDistanceRef.current = 0
115
+ dragStartRef.current = {
116
+ x: e.clientX,
117
+ y: e.clientY,
118
+ posX: posRef.current.x,
119
+ posY: posRef.current.y,
120
+ }
121
+ lastPointerRef.current = { x: e.clientX, y: e.clientY, t: performance.now() }
122
+ velRef.current = { x: 0, y: 0 }
123
+ e.currentTarget.setPointerCapture(e.pointerId)
124
+ }
125
+
126
+ const onPointerMove = (e: React.PointerEvent<HTMLDivElement>) => {
127
+ if (!isDraggingRef.current || selected) return
128
+ const dx = e.clientX - dragStartRef.current.x
129
+ const dy = e.clientY - dragStartRef.current.y
130
+ dragDistanceRef.current += Math.hypot(dx, dy)
131
+ posRef.current.x = dragStartRef.current.posX - dx
132
+ posRef.current.y = dragStartRef.current.posY - dy
133
+ setCamera({ x: posRef.current.x, y: posRef.current.y })
134
+
135
+ const now = performance.now()
136
+ const dt = Math.max(now - lastPointerRef.current.t, 8)
137
+ velRef.current = {
138
+ x: ((lastPointerRef.current.x - e.clientX) / dt) * 14,
139
+ y: ((lastPointerRef.current.y - e.clientY) / dt) * 14,
140
+ }
141
+ lastPointerRef.current = { x: e.clientX, y: e.clientY, t: now }
142
+ }
143
+
144
+ const onPointerUp = (e: React.PointerEvent<HTMLDivElement>) => {
145
+ if (isDraggingRef.current) {
146
+ isDraggingRef.current = false
147
+ try {
148
+ e.currentTarget.releasePointerCapture(e.pointerId)
149
+ } catch {}
150
+ }
151
+ }
152
+
153
+ const onWheel = (e: React.WheelEvent<HTMLDivElement>) => {
154
+ if (selected) return
155
+ posRef.current.x += e.deltaX * 0.85
156
+ posRef.current.y += e.deltaY * 0.85
157
+ setCamera({ x: posRef.current.x, y: posRef.current.y })
158
+ }
159
+
160
+ const handleTileClick = (item: DriftCanvasItem, e: React.MouseEvent<HTMLDivElement>) => {
161
+ if (dragDistanceRef.current < 8) {
162
+ const b = e.currentTarget.getBoundingClientRect()
163
+ setSelected({
164
+ item,
165
+ rect: {
166
+ x: b.left,
167
+ y: b.top,
168
+ width: b.width,
169
+ height: b.height,
170
+ },
171
+ })
172
+ }
173
+ }
174
+
175
+ const cellW = tileWidth + gap
176
+ const cellH = tileHeight + gap
177
+ const cols = Math.ceil(size.width / cellW) + 5
178
+ const rows = Math.ceil(size.height / cellH) + 5
179
+ const startCol = Math.floor(camera.x / cellW) - 2
180
+ const startRow = Math.floor(camera.y / cellH) - 2
181
+
182
+ const visibleTiles = []
183
+ for (let r = 0; r < rows; r++) {
184
+ for (let c = 0; c < cols; c++) {
185
+ const rowIdx = startRow + r
186
+ const colIdx = startCol + c
187
+ const itemIdx = Math.abs(rowIdx * 7 + colIdx * 11) % items.length
188
+ const item = items[itemIdx]
189
+ const tileKey = `${rowIdx}:${colIdx}`
190
+ const posX = colIdx * cellW - camera.x
191
+ const posY = rowIdx * cellH - camera.y
192
+
193
+ visibleTiles.push({
194
+ key: tileKey,
195
+ item,
196
+ posX,
197
+ posY,
198
+ })
199
+ }
200
+ }
201
+
202
+ const targetW = Math.min(560, (typeof window !== 'undefined' ? window.innerWidth : 1200) - 32)
203
+ const targetH = targetW * (10 / 16) + 110
204
+ const screenCenterX = (typeof window !== 'undefined' ? window.innerWidth : 1200) / 2
205
+ const screenCenterY = (typeof window !== 'undefined' ? window.innerHeight : 800) / 2
206
+
207
+ const initialOffsetX = selected ? selected.rect.x + selected.rect.width / 2 - screenCenterX : 0
208
+ const initialOffsetY = selected ? selected.rect.y + selected.rect.height / 2 - screenCenterY : 0
209
+ const initialScale = selected ? selected.rect.width / targetW : 0.5
210
+
211
+ return (
212
+ <div
213
+ ref={containerRef}
214
+ onPointerDown={onPointerDown}
215
+ onPointerMove={onPointerMove}
216
+ onPointerUp={onPointerUp}
217
+ onPointerCancel={onPointerUp}
218
+ onWheel={onWheel}
219
+ style={{
220
+ perspective: `${perspective}px`,
221
+ ...style,
222
+ }}
223
+ className={cn(
224
+ 'relative w-full h-full overflow-hidden select-none cursor-grab active:cursor-grabbing touch-none bg-neutral-950',
225
+ className,
226
+ )}
227
+ role="region"
228
+ aria-label="Infinite Drifting Component Canvas"
229
+ >
230
+ <div
231
+ style={{
232
+ transform: `translate3d(0, 0, 0) rotateX(${tilt}deg) rotateY(${turn}deg)`,
233
+ transformStyle: 'preserve-3d',
234
+ filter: selected ? 'blur(16px) brightness(0.28)' : 'none',
235
+ transition: 'filter 0.45s cubic-bezier(0.16, 1, 0.3, 1)',
236
+ }}
237
+ className="absolute inset-0 origin-center pointer-events-none"
238
+ >
239
+ {visibleTiles.map(({ key, item, posX, posY }) => {
240
+ const isHovered = hoveredTile === key && !selected
241
+
242
+ return (
243
+ <div
244
+ key={key}
245
+ onClick={(e) => handleTileClick(item, e)}
246
+ style={{
247
+ width: `${tileWidth}px`,
248
+ height: `${tileHeight}px`,
249
+ transform: `translate3d(${posX}px, ${posY}px, ${isHovered ? 48 : 0}px)`,
250
+ transformStyle: 'preserve-3d',
251
+ }}
252
+ className="absolute left-0 top-0 pointer-events-auto rounded-2xl border border-border bg-surface/90 overflow-hidden transition-transform duration-300 ease-out shadow-[0_12px_32px_-8px_rgba(0,0,0,0.65),0_0_0_1px_rgba(255,255,255,0.08)] cursor-pointer"
253
+ >
254
+ <img
255
+ src={item.image}
256
+ alt={item.title}
257
+ draggable={false}
258
+ loading="lazy"
259
+ onPointerEnter={() => !selected && setHoveredTile(key)}
260
+ onPointerLeave={() => setHoveredTile(null)}
261
+ className={`w-full h-full object-cover block transition-transform duration-500 ease-out ${isHovered ? 'scale-105' : ''}`}
262
+ />
263
+ <div className="absolute inset-0 bg-gradient-to-t from-black/85 via-black/25 to-transparent flex flex-col justify-end p-3.5 pointer-events-none">
264
+ {item.tag && (
265
+ <span className="inline-block px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider bg-white/10 text-white backdrop-blur-md self-start border border-white/15 mb-1.5">
266
+ {item.tag}
267
+ </span>
268
+ )}
269
+ <span className="font-grotesk font-bold text-sm tracking-tight text-white leading-snug drop-shadow-sm">
270
+ {item.title}
271
+ </span>
272
+ </div>
273
+ </div>
274
+ )
275
+ })}
276
+ </div>
277
+
278
+ <div className="pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_75%_65%_at_50%_50%,transparent_35%,rgba(9,9,11,0.85)_100%)] z-10" />
279
+
280
+ {(overlayHeading || overlayDescription) && !selected && (
281
+ <div className="pointer-events-none absolute inset-0 z-20 flex flex-col items-center justify-center p-6 text-center">
282
+ {overlayHeading && (
283
+ <h2 className="font-grotesk font-black text-4xl sm:text-6xl tracking-tight text-foreground drop-shadow-md">
284
+ {overlayHeading}
285
+ </h2>
286
+ )}
287
+ {overlayDescription && (
288
+ <p className="mt-2.5 max-w-md text-xs sm:text-sm text-secondary leading-relaxed drop-shadow-xs">
289
+ {overlayDescription}
290
+ </p>
291
+ )}
292
+ </div>
293
+ )}
294
+
295
+ <AnimatePresence>
296
+ {selected && (
297
+ <motion.div
298
+ key="backdrop"
299
+ initial={{ opacity: 0 }}
300
+ animate={{ opacity: 1 }}
301
+ exit={{ opacity: 0 }}
302
+ transition={{ duration: 0.35, ease: 'easeOut' }}
303
+ onClick={() => setSelected(null)}
304
+ className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/65 backdrop-blur-2xl cursor-zoom-out"
305
+ >
306
+ <motion.div
307
+ key="active-modal-card"
308
+ initial={{
309
+ x: initialOffsetX,
310
+ y: initialOffsetY,
311
+ scale: initialScale,
312
+ opacity: 0.8,
313
+ }}
314
+ animate={{
315
+ x: 0,
316
+ y: 0,
317
+ scale: 1,
318
+ opacity: 1,
319
+ }}
320
+ exit={{
321
+ x: initialOffsetX,
322
+ y: initialOffsetY,
323
+ scale: initialScale,
324
+ opacity: 0,
325
+ }}
326
+ transition={{
327
+ type: 'spring',
328
+ stiffness: 280,
329
+ damping: 24,
330
+ mass: 0.7,
331
+ }}
332
+ onClick={(e) => e.stopPropagation()}
333
+ style={{ maxWidth: `${targetW}px` }}
334
+ className="relative w-full rounded-3xl border border-white/20 bg-neutral-900 overflow-hidden shadow-[0_32px_90px_rgba(0,0,0,0.95),0_0_0_1px_rgba(255,255,255,0.12)] cursor-default origin-center"
335
+ >
336
+ <button
337
+ type="button"
338
+ onClick={() => setSelected(null)}
339
+ aria-label="Close card"
340
+ className="absolute top-4 right-4 z-20 p-2 rounded-full bg-black/60 hover:bg-black/90 text-white/80 hover:text-white transition-all backdrop-blur-md border border-white/10 cursor-pointer shadow-lg"
341
+ >
342
+ <IconX className="w-5 h-5" />
343
+ </button>
344
+
345
+ <div className="relative aspect-[16/10] w-full overflow-hidden bg-neutral-950">
346
+ <img
347
+ src={selected.item.image}
348
+ alt={selected.item.title}
349
+ className="w-full h-full object-cover select-none"
350
+ />
351
+ <div className="absolute inset-0 bg-gradient-to-t from-neutral-900 via-transparent to-transparent pointer-events-none" />
352
+ </div>
353
+
354
+ <div className="p-6 sm:p-7 flex items-center justify-between gap-4 bg-neutral-900">
355
+ <div>
356
+ {selected.item.tag && (
357
+ <span className="inline-block px-2.5 py-0.5 rounded-full text-xs font-bold uppercase tracking-wider bg-white/10 text-white/90 border border-white/15 mb-2">
358
+ {selected.item.tag}
359
+ </span>
360
+ )}
361
+ <h3 className="font-grotesk text-2xl font-extrabold tracking-tight text-white">
362
+ {selected.item.title}
363
+ </h3>
364
+ <p className="text-xs text-neutral-400 mt-1">
365
+ Click anywhere outside to return to the canvas.
366
+ </p>
367
+ </div>
368
+
369
+ <button
370
+ type="button"
371
+ onClick={() => setSelected(null)}
372
+ className="px-4 py-2 rounded-xl font-medium text-xs bg-white text-black hover:bg-white/90 active:scale-95 transition-all cursor-pointer font-grotesk shadow-md shrink-0"
373
+ >
374
+ Close
375
+ </button>
376
+ </div>
377
+ </motion.div>
378
+ </motion.div>
379
+ )}
380
+ </AnimatePresence>
381
+ </div>
382
+ )
383
+ }