@istmx/ui 0.1.10 → 0.1.11

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.
@@ -1,605 +0,0 @@
1
- 'use client'
2
-
3
- import { useEffect, useId, useRef, useState, useSyncExternalStore } from 'react'
4
- import type { CSSProperties, RefObject } from 'react'
5
- import { createPortal } from 'react-dom'
6
- import { AnimatePresence, motion, useReducedMotion } from 'motion/react'
7
- import {
8
- IconArrowRight,
9
- IconFile,
10
- IconHeadphones,
11
- IconPaperclip,
12
- IconPhoto,
13
- IconVideo,
14
- IconX,
15
- IconZoomIn,
16
- } from '@tabler/icons-react'
17
- import { cn } from './utils'
18
- import type { AttachmentOption, ChatAttachmentKind } from './types'
19
-
20
- type AnimatedAccentBorderProps = {
21
- color: string
22
- duration?: number
23
- intensity?: number
24
- }
25
-
26
- function AnimatedAccentBorder({
27
- color,
28
- duration = 5,
29
- intensity = 1,
30
- }: AnimatedAccentBorderProps) {
31
- const borderRef = useRef<SVGSVGElement>(null)
32
- const glowFilterId = `${useId().replace(/:/g, '')}-organic-glow`
33
- const [size, setSize] = useState({ width: 0, height: 0 })
34
- const reduceMotion = useReducedMotion()
35
-
36
- useEffect(() => {
37
- const border = borderRef.current
38
- if (!border) return
39
-
40
- const observer = new ResizeObserver(() => {
41
- const { width, height } = border.getBoundingClientRect()
42
- setSize((current) =>
43
- Math.abs(current.width - width) < 0.5 &&
44
- Math.abs(current.height - height) < 0.5
45
- ? current
46
- : { width, height },
47
- )
48
- })
49
-
50
- observer.observe(border)
51
- return () => observer.disconnect()
52
- }, [])
53
-
54
- const measuredWidth = Math.max(1, size.width)
55
- const measuredHeight = Math.max(1, size.height)
56
- const width = Math.max(0, measuredWidth - 1)
57
- const height = Math.max(0, measuredHeight - 1)
58
- const radius = Math.min(15.5, width / 2, height / 2)
59
- const pathLength = Math.max(
60
- 0,
61
- 2 * (width + height - 4 * radius) + 2 * Math.PI * radius,
62
- )
63
- const dashLength = pathLength * 0.22
64
- const highlightColor = `color-mix(in srgb, ${color} 62%, white)`
65
- const animate = reduceMotion ? undefined : { strokeDashoffset: -pathLength }
66
- const transition = {
67
- duration: Math.max(1, duration),
68
- ease: 'linear' as const,
69
- repeat: Infinity,
70
- }
71
- const shape = {
72
- x: 0.5,
73
- y: 0.5,
74
- width,
75
- height,
76
- rx: radius,
77
- fill: 'none',
78
- }
79
- const animatedShape = {
80
- ...shape,
81
- strokeDasharray: `${dashLength} ${pathLength - dashLength}`,
82
- strokeLinecap: 'round' as const,
83
- initial: { strokeDashoffset: 0 },
84
- animate,
85
- transition,
86
- }
87
-
88
- return (
89
- <svg
90
- ref={borderRef}
91
- aria-hidden="true"
92
- viewBox={`0 0 ${measuredWidth} ${measuredHeight}`}
93
- className="pointer-events-none absolute -top-px -left-px z-20 overflow-visible"
94
- style={{
95
- width: 'calc(100% + 2px)',
96
- height: 'calc(100% + 2px)',
97
- opacity: Math.min(1, Math.max(0, intensity)),
98
- }}
99
- >
100
- <defs>
101
- <filter
102
- id={glowFilterId}
103
- x="-35%"
104
- y="-60%"
105
- width="170%"
106
- height="220%"
107
- colorInterpolationFilters="sRGB"
108
- >
109
- <feTurbulence
110
- type="fractalNoise"
111
- baseFrequency="0.01 0.08"
112
- numOctaves="2"
113
- seed="7"
114
- result="edgeNoise"
115
- />
116
- <feDisplacementMap
117
- in="SourceGraphic"
118
- in2="edgeNoise"
119
- scale="18"
120
- xChannelSelector="R"
121
- yChannelSelector="G"
122
- result="unevenEdge"
123
- />
124
- <feGaussianBlur in="unevenEdge" stdDeviation="10" />
125
- </filter>
126
- </defs>
127
- <rect {...shape} stroke={color} strokeWidth="1.5" opacity="0.38" />
128
- <rect
129
- {...shape}
130
- stroke={color}
131
- strokeWidth="8"
132
- filter={`url(#${glowFilterId})`}
133
- opacity="0.55"
134
- />
135
- <motion.rect
136
- {...animatedShape}
137
- stroke={color}
138
- strokeWidth="14"
139
- filter={`url(#${glowFilterId})`}
140
- opacity="0.7"
141
- />
142
- <motion.rect
143
- {...animatedShape}
144
- stroke={color}
145
- strokeWidth="8"
146
- filter={`url(#${glowFilterId})`}
147
- opacity="0.9"
148
- />
149
- <motion.rect
150
- {...animatedShape}
151
- stroke={highlightColor}
152
- strokeWidth="3.5"
153
- />
154
- </svg>
155
- )
156
- }
157
-
158
- const subscribeToNothing = () => () => {}
159
- const getClientSnapshot = () => true
160
- const getServerSnapshot = () => false
161
-
162
- export type AttachmentDialogProps = {
163
- id?: string
164
- anchorRef: RefObject<HTMLButtonElement | null>
165
- open: boolean
166
- title?: string
167
- description?: string
168
- options: readonly AttachmentOption[]
169
- onSelect: (option: AttachmentOption) => void
170
- onClose: () => void
171
- accentColor?: string
172
- }
173
-
174
- export default function AttachmentDialog({
175
- id,
176
- anchorRef,
177
- open,
178
- title = 'Add to message',
179
- description = 'Choose a file type to attach.',
180
- options,
181
- onSelect,
182
- onClose,
183
- accentColor,
184
- }: AttachmentDialogProps) {
185
- const panelRef = useRef<HTMLDivElement>(null)
186
- const returnFocusRef = useRef<HTMLElement | null>(null)
187
- const onCloseRef = useRef(onClose)
188
- const generatedId = useId().replace(/:/g, '')
189
- const titleId = `${id ?? generatedId}-title`
190
- const descriptionId = `${id ?? generatedId}-description`
191
- const mounted = useSyncExternalStore(
192
- subscribeToNothing,
193
- getClientSnapshot,
194
- getServerSnapshot,
195
- )
196
- const [position, setPosition] = useState<{
197
- left: number
198
- top?: number
199
- bottom?: number
200
- } | null>(null)
201
- const reduceMotion = useReducedMotion()
202
-
203
- useEffect(() => {
204
- onCloseRef.current = onClose
205
- }, [onClose])
206
-
207
- useEffect(() => {
208
- if (!open) return
209
-
210
- returnFocusRef.current = document.activeElement as HTMLElement | null
211
- const updatePosition = () => {
212
- const anchor = anchorRef.current
213
- if (!anchor) return
214
- const rect = anchor.getBoundingClientRect()
215
- const width = Math.min(304, window.innerWidth - 24)
216
- const panelHeight = Math.min(
217
- panelRef.current?.offsetHeight ?? 288,
218
- window.innerHeight * 0.5,
219
- )
220
- const left = Math.max(
221
- 12,
222
- Math.min(rect.left, window.innerWidth - width - 12),
223
- )
224
- if (rect.top >= panelHeight + 20) {
225
- setPosition({ left, bottom: window.innerHeight - rect.top + 8 })
226
- } else {
227
- setPosition({
228
- left,
229
- top: Math.min(rect.bottom + 8, window.innerHeight - panelHeight - 12),
230
- })
231
- }
232
- }
233
-
234
- const frame = window.requestAnimationFrame(() => {
235
- updatePosition()
236
- panelRef.current
237
- ?.querySelector<HTMLButtonElement>('button:not(:disabled)')
238
- ?.focus()
239
- })
240
-
241
- window.addEventListener('resize', updatePosition)
242
- window.addEventListener('scroll', updatePosition, true)
243
-
244
- function onPointerDown(event: PointerEvent) {
245
- const target = event.target
246
- if (
247
- target instanceof Node &&
248
- !panelRef.current?.contains(target) &&
249
- !anchorRef.current?.contains(target)
250
- ) {
251
- onCloseRef.current()
252
- }
253
- }
254
-
255
- function onKeyDown(event: KeyboardEvent) {
256
- if (event.key === 'Escape') {
257
- event.preventDefault()
258
- onCloseRef.current()
259
- return
260
- }
261
- if (event.key !== 'Tab') return
262
-
263
- const focusable = Array.from(
264
- panelRef.current?.querySelectorAll<HTMLElement>(
265
- 'button:not(:disabled), [href], input:not(:disabled), [tabindex]:not([tabindex="-1"])',
266
- ) ?? [],
267
- )
268
- if (!focusable.length) return
269
- const first = focusable[0]
270
- const last = focusable[focusable.length - 1]
271
- if (event.shiftKey && document.activeElement === first) {
272
- event.preventDefault()
273
- last.focus()
274
- } else if (!event.shiftKey && document.activeElement === last) {
275
- event.preventDefault()
276
- first.focus()
277
- }
278
- }
279
-
280
- document.addEventListener('keydown', onKeyDown)
281
- document.addEventListener('pointerdown', onPointerDown)
282
- return () => {
283
- window.cancelAnimationFrame(frame)
284
- document.removeEventListener('keydown', onKeyDown)
285
- document.removeEventListener('pointerdown', onPointerDown)
286
- window.removeEventListener('resize', updatePosition)
287
- window.removeEventListener('scroll', updatePosition, true)
288
- returnFocusRef.current?.focus()
289
- }
290
- }, [open, anchorRef])
291
-
292
- const dialog = (
293
- <AnimatePresence>
294
- {open && position ? (
295
- <motion.div
296
- key="attachment-dialog-popover"
297
- initial={{ opacity: 0 }}
298
- animate={{ opacity: 1 }}
299
- exit={{ opacity: 0 }}
300
- transition={{ duration: reduceMotion ? 0.08 : 0.2 }}
301
- style={{
302
- left: position.left,
303
- top: position.top,
304
- bottom: position.bottom,
305
- }}
306
- className="fixed z-[100]"
307
- >
308
- <motion.div
309
- ref={panelRef}
310
- id={id ?? `${generatedId}-attachment-dialog`}
311
- role="dialog"
312
- aria-modal="true"
313
- aria-labelledby={titleId}
314
- aria-describedby={descriptionId}
315
- initial={
316
- reduceMotion ? { opacity: 0 } : { opacity: 0, x: 28, y: 8 }
317
- }
318
- animate={{ opacity: 1, x: 0, y: 0 }}
319
- exit={reduceMotion ? { opacity: 0 } : { opacity: 0, x: 20 }}
320
- transition={
321
- reduceMotion
322
- ? { duration: 0.08 }
323
- : { type: 'spring', stiffness: 390, damping: 34, mass: 0.75 }
324
- }
325
- style={
326
- { '--chat-accent': accentColor ?? '#0369a1' } as CSSProperties
327
- }
328
- className="text-foreground relative flex max-h-[min(50vh,18rem)] w-[min(19rem,calc(100vw-1.5rem))] flex-col rounded-2xl border border-transparent shadow-[0_18px_54px_-16px_rgba(0,0,0,0.65)]"
329
- >
330
- <div className="bg-background text-foreground relative z-10 flex max-h-[min(50vh,18rem)] w-full flex-col overflow-hidden rounded-2xl">
331
- <div className="border-border/60 flex items-start gap-2.5 border-b px-3 py-3 sm:px-4">
332
- <span className="border-border/70 bg-surface/60 text-muted flex size-8 shrink-0 items-center justify-center rounded-lg border">
333
- <IconPaperclip size={17} stroke={1.7} aria-hidden="true" />
334
- </span>
335
- <div className="min-w-0 flex-1">
336
- <h2
337
- id={titleId}
338
- className="font-display text-[13px] font-semibold tracking-tight"
339
- >
340
- {title}
341
- </h2>
342
- <p
343
- id={descriptionId}
344
- className="text-muted mt-0.5 text-[11px] leading-4"
345
- >
346
- {description}
347
- </p>
348
- </div>
349
- <button
350
- type="button"
351
- onClick={onClose}
352
- aria-label="Close attachment options"
353
- className="text-muted hover:text-foreground focus-visible:outline-foreground flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-lg transition-colors focus-visible:outline-2 focus-visible:outline-offset-2"
354
- >
355
- <IconX size={16} stroke={1.7} aria-hidden="true" />
356
- </button>
357
- </div>
358
-
359
- <div className="min-h-0 [scrollbar-width:none] overflow-y-auto overscroll-contain p-2 [&::-webkit-scrollbar]:hidden">
360
- {options.map((option) => (
361
- <button
362
- key={option.id}
363
- type="button"
364
- disabled={option.disabled}
365
- onClick={() => onSelect(option)}
366
- className="group focus-visible:outline-foreground hover:bg-surface/70 focus-visible:bg-surface/70 flex w-full cursor-pointer items-center gap-2.5 rounded-lg px-2 py-2 text-left transition-colors focus-visible:outline-2 focus-visible:outline-offset-[-2px] disabled:cursor-not-allowed disabled:opacity-45 sm:px-2.5"
367
- >
368
- <span className="border-border/70 bg-surface/45 text-muted flex size-8 shrink-0 items-center justify-center rounded-lg border transition-colors group-hover:border-[var(--chat-accent,var(--foreground))]/40 group-hover:text-[var(--chat-accent,var(--foreground))]">
369
- {option.icon ?? (
370
- <IconPaperclip
371
- size={17}
372
- stroke={1.7}
373
- aria-hidden="true"
374
- />
375
- )}
376
- </span>
377
- <span className="min-w-0 flex-1">
378
- <span className="font-display block text-xs font-medium">
379
- {option.label}
380
- </span>
381
- <span className="text-muted mt-0.5 block text-[10px] leading-3.5">
382
- {option.description ?? option.accept}
383
- </span>
384
- </span>
385
- <IconArrowRight
386
- size={15}
387
- stroke={1.6}
388
- aria-hidden="true"
389
- className="text-muted/45 shrink-0 transition-transform group-hover:translate-x-0.5 group-hover:text-[var(--chat-accent,var(--foreground))]"
390
- />
391
- </button>
392
- ))}
393
- </div>
394
- <div className="border-border/50 text-muted border-t px-3 py-2 font-mono text-[9px] tracking-[0.12em] uppercase sm:px-4">
395
- {options.length} attachment{' '}
396
- {options.length === 1 ? 'option' : 'options'}
397
- </div>
398
- </div>
399
- <AnimatedAccentBorder color={accentColor ?? '#0369a1'} />
400
- </motion.div>
401
- </motion.div>
402
- ) : null}
403
- </AnimatePresence>
404
- )
405
-
406
- return mounted ? createPortal(dialog, document.body) : null
407
- }
408
-
409
- type AttachmentPreviewProps = {
410
- file: File
411
- name: string
412
- kind: ChatAttachmentKind
413
- src?: string
414
- thumbnailClassName?: string
415
- }
416
-
417
- function PreviewIcon({ kind }: { kind: ChatAttachmentKind }) {
418
- const Icon =
419
- kind === 'image'
420
- ? IconPhoto
421
- : kind === 'video'
422
- ? IconVideo
423
- : kind === 'audio'
424
- ? IconHeadphones
425
- : IconFile
426
- return <Icon size={18} stroke={1.7} aria-hidden="true" />
427
- }
428
-
429
- export function AttachmentPreview({
430
- file,
431
- name,
432
- kind,
433
- src,
434
- thumbnailClassName,
435
- }: AttachmentPreviewProps) {
436
- const [open, setOpen] = useState(false)
437
- const [previewUrl, setPreviewUrl] = useState(src ?? '')
438
- const fileUrlRef = useRef('')
439
- const thumbnailRef = useRef<HTMLImageElement>(null)
440
- const closeRef = useRef<HTMLButtonElement>(null)
441
- const triggerRef = useRef<HTMLButtonElement>(null)
442
- const reduceMotion = useReducedMotion()
443
-
444
- useEffect(() => {
445
- if (src) return
446
- const url = URL.createObjectURL(file)
447
- fileUrlRef.current = url
448
- if (thumbnailRef.current) thumbnailRef.current.src = url
449
- return () => {
450
- fileUrlRef.current = ''
451
- URL.revokeObjectURL(url)
452
- }
453
- }, [file, src])
454
-
455
- useEffect(() => {
456
- if (!open) return
457
- closeRef.current?.focus()
458
- const onKeyDown = (event: KeyboardEvent) => {
459
- if (event.key === 'Escape') setOpen(false)
460
- }
461
- const trigger = triggerRef.current
462
- document.addEventListener('keydown', onKeyDown)
463
- return () => {
464
- document.removeEventListener('keydown', onKeyDown)
465
- trigger?.focus()
466
- }
467
- }, [open])
468
-
469
- const dialog = (
470
- <AnimatePresence>
471
- {open ? (
472
- <motion.div
473
- className="fixed inset-0 z-[500] flex items-center justify-center p-3 sm:p-8"
474
- initial={{ opacity: 0 }}
475
- animate={{ opacity: 1 }}
476
- exit={{ opacity: 0 }}
477
- transition={{ duration: reduceMotion ? 0.08 : 0.18 }}
478
- role="presentation"
479
- onMouseDown={(event) => {
480
- if (event.target === event.currentTarget) setOpen(false)
481
- }}
482
- >
483
- <div
484
- className="absolute inset-0 bg-black/80 backdrop-blur-sm"
485
- aria-hidden="true"
486
- />
487
- <motion.section
488
- role="dialog"
489
- aria-modal="true"
490
- aria-label={`Preview: ${name}`}
491
- className="border-border/70 bg-background relative z-10 flex max-h-[92dvh] w-full max-w-5xl flex-col overflow-hidden rounded-2xl border shadow-2xl"
492
- initial={reduceMotion ? { scale: 1 } : { scale: 0.96, y: 12 }}
493
- animate={{ scale: 1, y: 0 }}
494
- exit={reduceMotion ? { scale: 1 } : { scale: 0.98, y: 8 }}
495
- transition={
496
- reduceMotion
497
- ? { duration: 0.08 }
498
- : { type: 'spring', stiffness: 360, damping: 30 }
499
- }
500
- >
501
- <div className="border-border/60 flex min-h-12 items-center gap-3 border-b px-3 py-2.5 sm:px-4">
502
- <span className="text-muted bg-surface/70 flex size-8 shrink-0 items-center justify-center rounded-lg">
503
- <PreviewIcon kind={kind} />
504
- </span>
505
- <span className="min-w-0 flex-1 truncate text-sm font-medium">
506
- {name}
507
- </span>
508
- <button
509
- ref={closeRef}
510
- type="button"
511
- onClick={() => setOpen(false)}
512
- aria-label="Close file preview"
513
- className="text-muted hover:bg-surface hover:text-foreground flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-lg transition-colors"
514
- >
515
- <IconX size={17} stroke={1.7} aria-hidden="true" />
516
- </button>
517
- </div>
518
- <div className="flex min-h-0 flex-1 items-center justify-center overflow-auto bg-black/20 p-3 sm:p-6">
519
- {kind === 'image' && previewUrl ? (
520
- // eslint-disable-next-line @next/next/no-img-element
521
- <img
522
- src={previewUrl}
523
- alt={name}
524
- className="max-h-[calc(92dvh-8rem)] max-w-full rounded-lg object-contain"
525
- />
526
- ) : kind === 'video' && previewUrl ? (
527
- <video
528
- src={previewUrl}
529
- controls
530
- playsInline
531
- className="max-h-[calc(92dvh-8rem)] max-w-full rounded-lg"
532
- />
533
- ) : kind === 'audio' && previewUrl ? (
534
- <audio src={previewUrl} controls className="w-full max-w-xl" />
535
- ) : file.type === 'application/pdf' && previewUrl ? (
536
- <iframe
537
- title={`Preview: ${name}`}
538
- src={previewUrl}
539
- className="h-[min(72vh,48rem)] w-full rounded-lg border-0"
540
- />
541
- ) : (
542
- <div className="text-muted flex flex-col items-center gap-3 py-12 text-center">
543
- <span className="bg-surface/70 flex size-14 items-center justify-center rounded-2xl">
544
- <PreviewIcon kind={kind} />
545
- </span>
546
- <p className="max-w-sm text-sm">
547
- A preview isn’t available for this file type.
548
- </p>
549
- <a
550
- href={previewUrl}
551
- download={name}
552
- className="text-foreground bg-surface hover:bg-surface/80 rounded-lg px-3 py-2 text-xs font-medium"
553
- >
554
- Download file
555
- </a>
556
- </div>
557
- )}
558
- </div>
559
- </motion.section>
560
- </motion.div>
561
- ) : null}
562
- </AnimatePresence>
563
- )
564
-
565
- return (
566
- <>
567
- <button
568
- ref={triggerRef}
569
- type="button"
570
- onClick={() => {
571
- setPreviewUrl(src ?? fileUrlRef.current)
572
- setOpen(true)
573
- }}
574
- aria-label={`Preview ${name}`}
575
- title={`Preview ${name}`}
576
- className={cn(
577
- 'group/preview border-border/60 bg-background/70 text-muted relative flex shrink-0 cursor-zoom-in items-center justify-center overflow-hidden rounded-lg border',
578
- thumbnailClassName,
579
- )}
580
- >
581
- {kind === 'image' && previewUrl ? (
582
- // eslint-disable-next-line @next/next/no-img-element
583
- <img
584
- ref={thumbnailRef}
585
- src={previewUrl}
586
- alt=""
587
- aria-hidden="true"
588
- className="size-full object-cover"
589
- />
590
- ) : (
591
- <PreviewIcon kind={kind} />
592
- )}
593
- <span
594
- aria-hidden="true"
595
- className="absolute inset-0 flex items-center justify-center bg-black/45 text-white opacity-0 transition-opacity duration-150 group-hover/preview:opacity-100 group-focus-visible/preview:opacity-100"
596
- >
597
- <IconZoomIn size={16} stroke={1.8} />
598
- </span>
599
- </button>
600
- {typeof document !== 'undefined'
601
- ? createPortal(dialog, document.body)
602
- : null}
603
- </>
604
- )
605
- }
@@ -1,102 +0,0 @@
1
- 'use client'
2
-
3
- import {
4
- AnimatePresence,
5
- motion,
6
- useAnimationControls,
7
- useReducedMotion,
8
- } from 'motion/react'
9
- import { IconArrowUp, IconCheck, IconLoader, IconPlayerStop } from '@tabler/icons-react'
10
-
11
- export type SendButtonProps = {
12
- state: 'idle' | 'ready' | 'sending' | 'sent'
13
- disabled?: boolean
14
- label?: string
15
- shakeControls?: ReturnType<typeof useAnimationControls>
16
- onClick: () => void
17
- onStop?: () => void
18
- }
19
-
20
- export default function SendButton({
21
- state,
22
- disabled = false,
23
- label = 'Send message',
24
- shakeControls,
25
- onClick,
26
- onStop,
27
- }: SendButtonProps) {
28
- const reduceMotion = useReducedMotion()
29
- const active = state === 'ready' || state === 'sent'
30
- const canStop = state === 'sending' && Boolean(onStop)
31
-
32
- return (
33
- <motion.button
34
- type="button"
35
- onClick={canStop ? onStop : onClick}
36
- aria-label={canStop ? 'Stop generating response' : state === 'sending' ? 'Sending message' : label}
37
- title={canStop ? 'Stop generating' : label}
38
- aria-disabled={disabled || (!active && !canStop)}
39
- disabled={disabled || (!active && !canStop)}
40
- animate={shakeControls}
41
- whileTap={reduceMotion || (!active && !canStop) ? undefined : { scale: 0.9 }}
42
- whileHover={reduceMotion || state !== 'ready' ? undefined : { y: -1 }}
43
- className={`focus-visible:outline-foreground relative flex size-8 shrink-0 items-center justify-center rounded-xl border transition-[color,background-color,border-color,box-shadow] duration-200 focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-60 sm:size-9 ${
44
- canStop
45
- ? 'border-[var(--chat-accent,var(--foreground))] bg-[var(--chat-accent,var(--foreground))] text-white hover:opacity-85'
46
- : active
47
- ? 'border-[var(--chat-accent,var(--foreground))] bg-[var(--chat-accent,var(--foreground))] text-white hover:shadow-[0_10px_26px_-12px_var(--chat-accent,var(--foreground))]'
48
- : 'border-border/70 bg-surface/40 text-muted/60'
49
- }`}
50
- >
51
- <AnimatePresence mode="wait" initial={false}>
52
- {state === 'sending' && canStop ? (
53
- <motion.span
54
- key="stop"
55
- initial={{ opacity: 0, scale: 0.7 }}
56
- animate={{ opacity: 1, scale: 1 }}
57
- exit={{ opacity: 0, scale: 0.7 }}
58
- className="flex items-center justify-center"
59
- >
60
- <IconPlayerStop size={13} fill="currentColor" aria-hidden="true" />
61
- </motion.span>
62
- ) : state === 'sending' ? (
63
- <motion.span
64
- key="sending"
65
- initial={{ opacity: 0, scale: 0.7 }}
66
- animate={{ opacity: 1, scale: 1 }}
67
- exit={{ opacity: 0, scale: 0.7 }}
68
- className="flex items-center justify-center"
69
- >
70
- <IconLoader
71
- size={16}
72
- stroke={1.8}
73
- aria-hidden="true"
74
- className="motion-safe:animate-spin"
75
- />
76
- </motion.span>
77
- ) : state === 'sent' ? (
78
- <motion.span
79
- key="sent"
80
- initial={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}
81
- animate={{ opacity: 1, scale: 1 }}
82
- exit={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}
83
- transition={reduceMotion ? { duration: 0 } : { type: 'spring', stiffness: 520, damping: 24 }}
84
- className="flex items-center justify-center"
85
- >
86
- <IconCheck size={17} stroke={2} aria-hidden="true" />
87
- </motion.span>
88
- ) : (
89
- <motion.span
90
- key="idle"
91
- initial={reduceMotion ? { opacity: 0 } : { opacity: 0, y: 5 }}
92
- animate={{ opacity: 1, y: 0 }}
93
- exit={reduceMotion ? { opacity: 0 } : { opacity: 0, y: -5 }}
94
- className="flex items-center justify-center"
95
- >
96
- <IconArrowUp size={17} stroke={1.9} aria-hidden="true" />
97
- </motion.span>
98
- )}
99
- </AnimatePresence>
100
- </motion.button>
101
- )
102
- }