@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/bento-grid.tsx
CHANGED
|
@@ -1,433 +1,438 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { Children,
|
|
4
|
-
import type { CSSProperties, MouseEvent, ReactNode } from 'react'
|
|
5
|
-
import Link from 'next/link'
|
|
6
|
-
import { motion, useReducedMotion } from 'motion/react'
|
|
7
|
-
import { IconArrowRight, IconArrowUpRight } from '@tabler/icons-react'
|
|
8
|
-
import { cn } from '@/lib/utils'
|
|
9
|
-
|
|
10
|
-
export type BentoCardProps = {
|
|
11
|
-
title: ReactNode
|
|
12
|
-
description?: ReactNode
|
|
13
|
-
icon?: ReactNode
|
|
14
|
-
badge?: ReactNode
|
|
15
|
-
badgeClassName?: string
|
|
16
|
-
href?: string
|
|
17
|
-
target?: string
|
|
18
|
-
rel?: string
|
|
19
|
-
external?: boolean
|
|
20
|
-
cta?: ReactNode
|
|
21
|
-
ctaHref?: string
|
|
22
|
-
ctaTarget?: string
|
|
23
|
-
ctaRel?: string
|
|
24
|
-
ctaExternal?: boolean
|
|
25
|
-
ctaClassName?: string
|
|
26
|
-
header?: ReactNode
|
|
27
|
-
headerClassName?: string
|
|
28
|
-
footer?: ReactNode
|
|
29
|
-
footerClassName?: string
|
|
30
|
-
className?: string
|
|
31
|
-
innerClassName?: string
|
|
32
|
-
featured?: boolean
|
|
33
|
-
colSpan?: 1 | 2 | 3 | 4 | 5 | 6 | string
|
|
34
|
-
rowSpan?: 1 | 2 | 3 | 4 | string
|
|
35
|
-
gradient?: boolean
|
|
36
|
-
gradientAngle?: number
|
|
37
|
-
gradientOpacity?: number
|
|
38
|
-
gradientSpacing?: number
|
|
39
|
-
gradientColor?: string
|
|
40
|
-
animate?: boolean
|
|
41
|
-
onClick?: (event: MouseEvent<HTMLElement>) => void
|
|
42
|
-
children?: ReactNode
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export type BentoGridProps = {
|
|
46
|
-
children?: ReactNode
|
|
47
|
-
items?: BentoCardProps[]
|
|
48
|
-
className?: string
|
|
49
|
-
gridClassName?: string
|
|
50
|
-
cardClassName?: string
|
|
51
|
-
cols?: 1 | 2 | 3 | 4 | 5 | 6 | number
|
|
52
|
-
gap?: string
|
|
53
|
-
gradient?: boolean
|
|
54
|
-
gradientAngle?: number
|
|
55
|
-
gradientOpacity?: number
|
|
56
|
-
gradientSpacing?: number
|
|
57
|
-
gradientColor?: string
|
|
58
|
-
positions?: string[]
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const DEFAULT_POSITIONS = [
|
|
62
|
-
'col-span-1 sm:col-span-1 lg:col-start-1 lg:col-span-1 lg:row-start-1 lg:row-span-1',
|
|
63
|
-
'col-span-1 sm:col-span-1 lg:col-start-1 lg:col-span-1 lg:row-start-2 lg:row-span-1',
|
|
64
|
-
'col-span-1 sm:col-span-2 lg:col-start-2 lg:col-span-2 lg:row-start-1 lg:row-span-2',
|
|
65
|
-
'col-span-1 sm:col-span-1 lg:col-start-4 lg:col-span-1 lg:row-start-1 lg:row-span-1',
|
|
66
|
-
'col-span-1 sm:col-span-1 lg:col-start-4 lg:col-span-1 lg:row-start-2 lg:row-span-1',
|
|
67
|
-
]
|
|
68
|
-
|
|
69
|
-
function isExternalUrl(url?: string): boolean {
|
|
70
|
-
if (!url) return false
|
|
71
|
-
return /^(?:https?:)?\/\//.test(url)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function BentoCardInner({
|
|
75
|
-
title,
|
|
76
|
-
description,
|
|
77
|
-
icon,
|
|
78
|
-
badge,
|
|
79
|
-
badgeClassName,
|
|
80
|
-
cta,
|
|
81
|
-
ctaHref,
|
|
82
|
-
ctaTarget,
|
|
83
|
-
ctaRel,
|
|
84
|
-
ctaExternal,
|
|
85
|
-
ctaClassName,
|
|
86
|
-
header,
|
|
87
|
-
headerClassName,
|
|
88
|
-
footer,
|
|
89
|
-
footerClassName,
|
|
90
|
-
children,
|
|
91
|
-
featured,
|
|
92
|
-
external,
|
|
93
|
-
}: Omit<
|
|
94
|
-
BentoCardProps,
|
|
95
|
-
| 'className'
|
|
96
|
-
| 'innerClassName'
|
|
97
|
-
| 'href'
|
|
98
|
-
| 'target'
|
|
99
|
-
| 'rel'
|
|
100
|
-
| 'colSpan'
|
|
101
|
-
| 'rowSpan'
|
|
102
|
-
| 'gradient'
|
|
103
|
-
| 'gradientAngle'
|
|
104
|
-
| 'gradientOpacity'
|
|
105
|
-
| 'gradientSpacing'
|
|
106
|
-
| 'gradientColor'
|
|
107
|
-
| 'animate'
|
|
108
|
-
| 'onClick'
|
|
109
|
-
> & {
|
|
110
|
-
external: boolean
|
|
111
|
-
}) {
|
|
112
|
-
const isCtaExternal = ctaExternal ?? isExternalUrl(ctaHref)
|
|
113
|
-
const resolvedCtaTarget =
|
|
114
|
-
ctaTarget ?? (isCtaExternal ? '_blank' : undefined)
|
|
115
|
-
const resolvedCtaRel =
|
|
116
|
-
ctaRel ?? (isCtaExternal ? 'noopener noreferrer' : undefined)
|
|
117
|
-
|
|
118
|
-
const ctaContent = cta && (
|
|
119
|
-
<div
|
|
120
|
-
className={cn(
|
|
121
|
-
'relative z-10 mt-3.5 flex items-center gap-1.5 pt-0.5 text-[11px] font-medium text-muted/70 transition-[color,opacity] duration-200 ease-out group-hover:text-foreground group-hover:opacity-100 sm:text-xs',
|
|
122
|
-
ctaClassName,
|
|
123
|
-
)}
|
|
124
|
-
>
|
|
125
|
-
<span className="transition-colors duration-200 ease-out">{cta}</span>
|
|
126
|
-
{isCtaExternal || external ? (
|
|
127
|
-
<IconArrowUpRight
|
|
128
|
-
size={13}
|
|
129
|
-
className="inline-block shrink-0 text-muted/60 transition-[transform,color] duration-200 ease-out group-hover:translate-x-0.5 group-hover:-translate-y-0.5 group-hover:text-foreground motion-reduce:transform-none"
|
|
130
|
-
/>
|
|
131
|
-
) : (
|
|
132
|
-
<IconArrowRight
|
|
133
|
-
size={12}
|
|
134
|
-
className="inline-block shrink-0 text-muted/60 transition-[transform,color] duration-200 ease-out group-hover:translate-x-1 group-hover:text-foreground motion-reduce:transform-none"
|
|
135
|
-
/>
|
|
136
|
-
)}
|
|
137
|
-
</div>
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
return (
|
|
141
|
-
<>
|
|
142
|
-
<div className="relative z-10 flex flex-col">
|
|
143
|
-
<div className="flex items-center justify-between gap-2">
|
|
144
|
-
{icon && (
|
|
145
|
-
<div className="mb-3 flex h-8 w-8 items-center justify-center rounded-lg border border-border/40 bg-surface/30 text-foreground/75 transition-all duration-300 ease-out group-hover:border-foreground/20 group-hover:bg-surface/60 group-hover:text-foreground">
|
|
146
|
-
<span className="inline-flex transition-transform duration-300 ease-out group-hover:-translate-y-0.5 group-hover:scale-110 group-hover:-rotate-3 motion-reduce:transform-none">
|
|
147
|
-
{icon}
|
|
148
|
-
</span>
|
|
149
|
-
</div>
|
|
150
|
-
)}
|
|
151
|
-
{badge && (
|
|
152
|
-
<div
|
|
153
|
-
className={cn(
|
|
154
|
-
'mb-3 inline-flex items-center rounded-md border border-border/40 bg-surface/30 px-2 py-0.5 text-[10px] font-medium text-muted transition-colors group-hover:text-foreground',
|
|
155
|
-
badgeClassName,
|
|
156
|
-
)}
|
|
157
|
-
>
|
|
158
|
-
{badge}
|
|
159
|
-
</div>
|
|
160
|
-
)}
|
|
161
|
-
</div>
|
|
162
|
-
|
|
163
|
-
<h3
|
|
164
|
-
className={cn(
|
|
165
|
-
'font-display font-semibold tracking-tight text-foreground',
|
|
166
|
-
featured
|
|
167
|
-
? 'text-sm sm:text-base lg:text-[17px]'
|
|
168
|
-
: 'text-sm sm:text-[15px]',
|
|
169
|
-
)}
|
|
170
|
-
>
|
|
171
|
-
{title}
|
|
172
|
-
</h3>
|
|
173
|
-
{description && (
|
|
174
|
-
<p className="font-secondary mt-1.5 text-xs leading-relaxed text-muted/80 sm:text-[12.5px]">
|
|
175
|
-
{description}
|
|
176
|
-
</p>
|
|
177
|
-
)}
|
|
178
|
-
</div>
|
|
179
|
-
|
|
180
|
-
{header && (
|
|
181
|
-
<div
|
|
182
|
-
className={cn(
|
|
183
|
-
'relative z-10 my-3 flex-1 overflow-hidden rounded-xl transition-all duration-300 sm:my-3.5',
|
|
184
|
-
featured
|
|
185
|
-
? 'min-h-[170px] sm:min-h-[190px] md:min-h-[210px] lg:min-h-[220px]'
|
|
186
|
-
: 'min-h-[64px]',
|
|
187
|
-
headerClassName,
|
|
188
|
-
)}
|
|
189
|
-
>
|
|
190
|
-
{header}
|
|
191
|
-
</div>
|
|
192
|
-
)}
|
|
193
|
-
|
|
194
|
-
{children && <div className="relative z-10 mt-3">{children}</div>}
|
|
195
|
-
|
|
196
|
-
{footer && (
|
|
197
|
-
<div className={cn('relative z-10 mt-3', footerClassName)}>
|
|
198
|
-
{footer}
|
|
199
|
-
</div>
|
|
200
|
-
)}
|
|
201
|
-
|
|
202
|
-
{cta &&
|
|
203
|
-
(ctaHref ? (
|
|
204
|
-
<Link
|
|
205
|
-
href={ctaHref}
|
|
206
|
-
target={resolvedCtaTarget}
|
|
207
|
-
rel={resolvedCtaRel}
|
|
208
|
-
className="relative z-20 inline-block focus:outline-none"
|
|
209
|
-
onClick={(e) => e.stopPropagation()}
|
|
210
|
-
>
|
|
211
|
-
{ctaContent}
|
|
212
|
-
</Link>
|
|
213
|
-
) : (
|
|
214
|
-
ctaContent
|
|
215
|
-
))}
|
|
216
|
-
</>
|
|
217
|
-
)
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export function BentoCard({
|
|
221
|
-
title,
|
|
222
|
-
description,
|
|
223
|
-
icon,
|
|
224
|
-
badge,
|
|
225
|
-
badgeClassName,
|
|
226
|
-
href,
|
|
227
|
-
target,
|
|
228
|
-
rel,
|
|
229
|
-
external,
|
|
230
|
-
cta,
|
|
231
|
-
ctaHref,
|
|
232
|
-
ctaTarget,
|
|
233
|
-
ctaRel,
|
|
234
|
-
ctaExternal,
|
|
235
|
-
ctaClassName,
|
|
236
|
-
header,
|
|
237
|
-
headerClassName,
|
|
238
|
-
footer,
|
|
239
|
-
footerClassName,
|
|
240
|
-
className,
|
|
241
|
-
innerClassName,
|
|
242
|
-
featured = false,
|
|
243
|
-
colSpan,
|
|
244
|
-
rowSpan,
|
|
245
|
-
gradient = true,
|
|
246
|
-
gradientAngle = 315,
|
|
247
|
-
gradientOpacity = 0.012,
|
|
248
|
-
gradientSpacing = 22,
|
|
249
|
-
gradientColor = 'var(--foreground)',
|
|
250
|
-
animate = true,
|
|
251
|
-
onClick,
|
|
252
|
-
children,
|
|
253
|
-
}
|
|
254
|
-
const reduceMotion = useReducedMotion()
|
|
255
|
-
const isExternal = external ?? isExternalUrl(href)
|
|
256
|
-
const resolvedTarget = target ?? (isExternal ? '_blank' : undefined)
|
|
257
|
-
const resolvedRel = rel ?? (isExternal ? 'noopener noreferrer' : undefined)
|
|
258
|
-
|
|
259
|
-
const cardInnerClassName = cn(
|
|
260
|
-
'relative flex h-full flex-1 flex-col justify-between overflow-hidden rounded-xl border p-4 transition-all duration-300 sm:p-5 lg:p-5 xl:p-6',
|
|
261
|
-
'border-border/30 bg-background/65 group-hover:border-foreground/20 group-hover:bg-background/80',
|
|
262
|
-
href &&
|
|
263
|
-
'focus-visible:ring-2 focus-visible:ring-foreground focus-visible:outline-none',
|
|
264
|
-
innerClassName,
|
|
265
|
-
)
|
|
266
|
-
|
|
267
|
-
const colSpanClass =
|
|
268
|
-
typeof colSpan === 'number'
|
|
269
|
-
? `col-span-${colSpan}`
|
|
270
|
-
: typeof colSpan === 'string'
|
|
271
|
-
? colSpan
|
|
272
|
-
: undefined
|
|
273
|
-
|
|
274
|
-
const rowSpanClass =
|
|
275
|
-
typeof rowSpan === 'number'
|
|
276
|
-
? `row-span-${rowSpan}`
|
|
277
|
-
: typeof rowSpan === 'string'
|
|
278
|
-
? rowSpan
|
|
279
|
-
: undefined
|
|
280
|
-
|
|
281
|
-
const cardGradientStyle: CSSProperties = gradient
|
|
282
|
-
? {
|
|
283
|
-
backgroundImage: `repeating-linear-gradient(${gradientAngle}deg, ${gradientColor} 0px, ${gradientColor} 1px, transparent 1px, transparent ${gradientSpacing}px)`,
|
|
284
|
-
opacity: gradientOpacity,
|
|
285
|
-
}
|
|
286
|
-
: {}
|
|
287
|
-
|
|
288
|
-
const innerContent = (
|
|
289
|
-
<>
|
|
290
|
-
{gradient && (
|
|
291
|
-
<div
|
|
292
|
-
className="pointer-events-none absolute inset-0"
|
|
293
|
-
style={cardGradientStyle}
|
|
294
|
-
/>
|
|
295
|
-
)}
|
|
296
|
-
<BentoCardInner
|
|
297
|
-
title={title}
|
|
298
|
-
description={description}
|
|
299
|
-
icon={icon}
|
|
300
|
-
badge={badge}
|
|
301
|
-
badgeClassName={badgeClassName}
|
|
302
|
-
cta={cta}
|
|
303
|
-
ctaHref={ctaHref}
|
|
304
|
-
ctaTarget={ctaTarget}
|
|
305
|
-
ctaRel={ctaRel}
|
|
306
|
-
ctaExternal={ctaExternal}
|
|
307
|
-
ctaClassName={ctaClassName}
|
|
308
|
-
header={header}
|
|
309
|
-
headerClassName={headerClassName}
|
|
310
|
-
footer={footer}
|
|
311
|
-
footerClassName={footerClassName}
|
|
312
|
-
featured={featured}
|
|
313
|
-
external={isExternal}
|
|
314
|
-
>
|
|
315
|
-
{children}
|
|
316
|
-
</BentoCardInner>
|
|
317
|
-
</>
|
|
318
|
-
)
|
|
319
|
-
|
|
320
|
-
const motionProps =
|
|
321
|
-
animate && !reduceMotion
|
|
322
|
-
? {
|
|
323
|
-
initial: { opacity: 0, y: 12 },
|
|
324
|
-
whileInView: { opacity: 1, y: 0 },
|
|
325
|
-
viewport: { once: true, amount: 0.15 },
|
|
326
|
-
transition: { duration: 0.45, ease: 'easeOut' as const },
|
|
327
|
-
}
|
|
328
|
-
: {}
|
|
329
|
-
|
|
330
|
-
return (
|
|
331
|
-
<motion.div
|
|
332
|
-
{
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
'
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
cols ===
|
|
389
|
-
cols ===
|
|
390
|
-
cols ===
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { Children, cloneElement, forwardRef, isValidElement } from 'react'
|
|
4
|
+
import type { CSSProperties, MouseEvent, ReactNode } from 'react'
|
|
5
|
+
import Link from 'next/link'
|
|
6
|
+
import { motion, useReducedMotion } from 'motion/react'
|
|
7
|
+
import { IconArrowRight, IconArrowUpRight } from '@tabler/icons-react'
|
|
8
|
+
import { cn } from '@/lib/utils'
|
|
9
|
+
|
|
10
|
+
export type BentoCardProps = {
|
|
11
|
+
title: ReactNode
|
|
12
|
+
description?: ReactNode
|
|
13
|
+
icon?: ReactNode
|
|
14
|
+
badge?: ReactNode
|
|
15
|
+
badgeClassName?: string
|
|
16
|
+
href?: string
|
|
17
|
+
target?: string
|
|
18
|
+
rel?: string
|
|
19
|
+
external?: boolean
|
|
20
|
+
cta?: ReactNode
|
|
21
|
+
ctaHref?: string
|
|
22
|
+
ctaTarget?: string
|
|
23
|
+
ctaRel?: string
|
|
24
|
+
ctaExternal?: boolean
|
|
25
|
+
ctaClassName?: string
|
|
26
|
+
header?: ReactNode
|
|
27
|
+
headerClassName?: string
|
|
28
|
+
footer?: ReactNode
|
|
29
|
+
footerClassName?: string
|
|
30
|
+
className?: string
|
|
31
|
+
innerClassName?: string
|
|
32
|
+
featured?: boolean
|
|
33
|
+
colSpan?: 1 | 2 | 3 | 4 | 5 | 6 | string
|
|
34
|
+
rowSpan?: 1 | 2 | 3 | 4 | string
|
|
35
|
+
gradient?: boolean
|
|
36
|
+
gradientAngle?: number
|
|
37
|
+
gradientOpacity?: number
|
|
38
|
+
gradientSpacing?: number
|
|
39
|
+
gradientColor?: string
|
|
40
|
+
animate?: boolean
|
|
41
|
+
onClick?: (event: MouseEvent<HTMLElement>) => void
|
|
42
|
+
children?: ReactNode
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type BentoGridProps = {
|
|
46
|
+
children?: ReactNode
|
|
47
|
+
items?: BentoCardProps[]
|
|
48
|
+
className?: string
|
|
49
|
+
gridClassName?: string
|
|
50
|
+
cardClassName?: string
|
|
51
|
+
cols?: 1 | 2 | 3 | 4 | 5 | 6 | number
|
|
52
|
+
gap?: string
|
|
53
|
+
gradient?: boolean
|
|
54
|
+
gradientAngle?: number
|
|
55
|
+
gradientOpacity?: number
|
|
56
|
+
gradientSpacing?: number
|
|
57
|
+
gradientColor?: string
|
|
58
|
+
positions?: string[]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const DEFAULT_POSITIONS = [
|
|
62
|
+
'col-span-1 sm:col-span-1 lg:col-start-1 lg:col-span-1 lg:row-start-1 lg:row-span-1',
|
|
63
|
+
'col-span-1 sm:col-span-1 lg:col-start-1 lg:col-span-1 lg:row-start-2 lg:row-span-1',
|
|
64
|
+
'col-span-1 sm:col-span-2 lg:col-start-2 lg:col-span-2 lg:row-start-1 lg:row-span-2',
|
|
65
|
+
'col-span-1 sm:col-span-1 lg:col-start-4 lg:col-span-1 lg:row-start-1 lg:row-span-1',
|
|
66
|
+
'col-span-1 sm:col-span-1 lg:col-start-4 lg:col-span-1 lg:row-start-2 lg:row-span-1',
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
function isExternalUrl(url?: string): boolean {
|
|
70
|
+
if (!url) return false
|
|
71
|
+
return /^(?:https?:)?\/\//.test(url)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function BentoCardInner({
|
|
75
|
+
title,
|
|
76
|
+
description,
|
|
77
|
+
icon,
|
|
78
|
+
badge,
|
|
79
|
+
badgeClassName,
|
|
80
|
+
cta,
|
|
81
|
+
ctaHref,
|
|
82
|
+
ctaTarget,
|
|
83
|
+
ctaRel,
|
|
84
|
+
ctaExternal,
|
|
85
|
+
ctaClassName,
|
|
86
|
+
header,
|
|
87
|
+
headerClassName,
|
|
88
|
+
footer,
|
|
89
|
+
footerClassName,
|
|
90
|
+
children,
|
|
91
|
+
featured,
|
|
92
|
+
external,
|
|
93
|
+
}: Omit<
|
|
94
|
+
BentoCardProps,
|
|
95
|
+
| 'className'
|
|
96
|
+
| 'innerClassName'
|
|
97
|
+
| 'href'
|
|
98
|
+
| 'target'
|
|
99
|
+
| 'rel'
|
|
100
|
+
| 'colSpan'
|
|
101
|
+
| 'rowSpan'
|
|
102
|
+
| 'gradient'
|
|
103
|
+
| 'gradientAngle'
|
|
104
|
+
| 'gradientOpacity'
|
|
105
|
+
| 'gradientSpacing'
|
|
106
|
+
| 'gradientColor'
|
|
107
|
+
| 'animate'
|
|
108
|
+
| 'onClick'
|
|
109
|
+
> & {
|
|
110
|
+
external: boolean
|
|
111
|
+
}) {
|
|
112
|
+
const isCtaExternal = ctaExternal ?? isExternalUrl(ctaHref)
|
|
113
|
+
const resolvedCtaTarget =
|
|
114
|
+
ctaTarget ?? (isCtaExternal ? '_blank' : undefined)
|
|
115
|
+
const resolvedCtaRel =
|
|
116
|
+
ctaRel ?? (isCtaExternal ? 'noopener noreferrer' : undefined)
|
|
117
|
+
|
|
118
|
+
const ctaContent = cta && (
|
|
119
|
+
<div
|
|
120
|
+
className={cn(
|
|
121
|
+
'relative z-10 mt-3.5 flex items-center gap-1.5 pt-0.5 text-[11px] font-medium text-muted/70 transition-[color,opacity] duration-200 ease-out group-hover:text-foreground group-hover:opacity-100 sm:text-xs',
|
|
122
|
+
ctaClassName,
|
|
123
|
+
)}
|
|
124
|
+
>
|
|
125
|
+
<span className="transition-colors duration-200 ease-out">{cta}</span>
|
|
126
|
+
{isCtaExternal || external ? (
|
|
127
|
+
<IconArrowUpRight
|
|
128
|
+
size={13}
|
|
129
|
+
className="inline-block shrink-0 text-muted/60 transition-[transform,color] duration-200 ease-out group-hover:translate-x-0.5 group-hover:-translate-y-0.5 group-hover:text-foreground motion-reduce:transform-none"
|
|
130
|
+
/>
|
|
131
|
+
) : (
|
|
132
|
+
<IconArrowRight
|
|
133
|
+
size={12}
|
|
134
|
+
className="inline-block shrink-0 text-muted/60 transition-[transform,color] duration-200 ease-out group-hover:translate-x-1 group-hover:text-foreground motion-reduce:transform-none"
|
|
135
|
+
/>
|
|
136
|
+
)}
|
|
137
|
+
</div>
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<>
|
|
142
|
+
<div className="relative z-10 flex flex-col">
|
|
143
|
+
<div className="flex items-center justify-between gap-2">
|
|
144
|
+
{icon && (
|
|
145
|
+
<div className="mb-3 flex h-8 w-8 items-center justify-center rounded-lg border border-border/40 bg-surface/30 text-foreground/75 transition-all duration-300 ease-out group-hover:border-foreground/20 group-hover:bg-surface/60 group-hover:text-foreground">
|
|
146
|
+
<span className="inline-flex transition-transform duration-300 ease-out group-hover:-translate-y-0.5 group-hover:scale-110 group-hover:-rotate-3 motion-reduce:transform-none">
|
|
147
|
+
{icon}
|
|
148
|
+
</span>
|
|
149
|
+
</div>
|
|
150
|
+
)}
|
|
151
|
+
{badge && (
|
|
152
|
+
<div
|
|
153
|
+
className={cn(
|
|
154
|
+
'mb-3 inline-flex items-center rounded-md border border-border/40 bg-surface/30 px-2 py-0.5 text-[10px] font-medium text-muted transition-colors group-hover:text-foreground',
|
|
155
|
+
badgeClassName,
|
|
156
|
+
)}
|
|
157
|
+
>
|
|
158
|
+
{badge}
|
|
159
|
+
</div>
|
|
160
|
+
)}
|
|
161
|
+
</div>
|
|
162
|
+
|
|
163
|
+
<h3
|
|
164
|
+
className={cn(
|
|
165
|
+
'font-display font-semibold tracking-tight text-foreground',
|
|
166
|
+
featured
|
|
167
|
+
? 'text-sm sm:text-base lg:text-[17px]'
|
|
168
|
+
: 'text-sm sm:text-[15px]',
|
|
169
|
+
)}
|
|
170
|
+
>
|
|
171
|
+
{title}
|
|
172
|
+
</h3>
|
|
173
|
+
{description && (
|
|
174
|
+
<p className="font-secondary mt-1.5 text-xs leading-relaxed text-muted/80 sm:text-[12.5px]">
|
|
175
|
+
{description}
|
|
176
|
+
</p>
|
|
177
|
+
)}
|
|
178
|
+
</div>
|
|
179
|
+
|
|
180
|
+
{header && (
|
|
181
|
+
<div
|
|
182
|
+
className={cn(
|
|
183
|
+
'relative z-10 my-3 flex-1 overflow-hidden rounded-xl transition-all duration-300 sm:my-3.5',
|
|
184
|
+
featured
|
|
185
|
+
? 'min-h-[170px] sm:min-h-[190px] md:min-h-[210px] lg:min-h-[220px]'
|
|
186
|
+
: 'min-h-[64px]',
|
|
187
|
+
headerClassName,
|
|
188
|
+
)}
|
|
189
|
+
>
|
|
190
|
+
{header}
|
|
191
|
+
</div>
|
|
192
|
+
)}
|
|
193
|
+
|
|
194
|
+
{children && <div className="relative z-10 mt-3">{children}</div>}
|
|
195
|
+
|
|
196
|
+
{footer && (
|
|
197
|
+
<div className={cn('relative z-10 mt-3', footerClassName)}>
|
|
198
|
+
{footer}
|
|
199
|
+
</div>
|
|
200
|
+
)}
|
|
201
|
+
|
|
202
|
+
{cta &&
|
|
203
|
+
(ctaHref ? (
|
|
204
|
+
<Link
|
|
205
|
+
href={ctaHref}
|
|
206
|
+
target={resolvedCtaTarget}
|
|
207
|
+
rel={resolvedCtaRel}
|
|
208
|
+
className="relative z-20 inline-block focus:outline-none"
|
|
209
|
+
onClick={(e) => e.stopPropagation()}
|
|
210
|
+
>
|
|
211
|
+
{ctaContent}
|
|
212
|
+
</Link>
|
|
213
|
+
) : (
|
|
214
|
+
ctaContent
|
|
215
|
+
))}
|
|
216
|
+
</>
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export const BentoCard = forwardRef<HTMLDivElement, BentoCardProps>(function BentoCard({
|
|
221
|
+
title,
|
|
222
|
+
description,
|
|
223
|
+
icon,
|
|
224
|
+
badge,
|
|
225
|
+
badgeClassName,
|
|
226
|
+
href,
|
|
227
|
+
target,
|
|
228
|
+
rel,
|
|
229
|
+
external,
|
|
230
|
+
cta,
|
|
231
|
+
ctaHref,
|
|
232
|
+
ctaTarget,
|
|
233
|
+
ctaRel,
|
|
234
|
+
ctaExternal,
|
|
235
|
+
ctaClassName,
|
|
236
|
+
header,
|
|
237
|
+
headerClassName,
|
|
238
|
+
footer,
|
|
239
|
+
footerClassName,
|
|
240
|
+
className,
|
|
241
|
+
innerClassName,
|
|
242
|
+
featured = false,
|
|
243
|
+
colSpan,
|
|
244
|
+
rowSpan,
|
|
245
|
+
gradient = true,
|
|
246
|
+
gradientAngle = 315,
|
|
247
|
+
gradientOpacity = 0.012,
|
|
248
|
+
gradientSpacing = 22,
|
|
249
|
+
gradientColor = 'var(--foreground)',
|
|
250
|
+
animate = true,
|
|
251
|
+
onClick,
|
|
252
|
+
children,
|
|
253
|
+
}, ref) {
|
|
254
|
+
const reduceMotion = useReducedMotion()
|
|
255
|
+
const isExternal = external ?? isExternalUrl(href)
|
|
256
|
+
const resolvedTarget = target ?? (isExternal ? '_blank' : undefined)
|
|
257
|
+
const resolvedRel = rel ?? (isExternal ? 'noopener noreferrer' : undefined)
|
|
258
|
+
|
|
259
|
+
const cardInnerClassName = cn(
|
|
260
|
+
'relative flex h-full flex-1 flex-col justify-between overflow-hidden rounded-xl border p-4 transition-all duration-300 sm:p-5 lg:p-5 xl:p-6',
|
|
261
|
+
'border-border/30 bg-background/65 group-hover:border-foreground/20 group-hover:bg-background/80',
|
|
262
|
+
href &&
|
|
263
|
+
'focus-visible:ring-2 focus-visible:ring-foreground focus-visible:outline-none',
|
|
264
|
+
innerClassName,
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
const colSpanClass =
|
|
268
|
+
typeof colSpan === 'number'
|
|
269
|
+
? `col-span-${colSpan}`
|
|
270
|
+
: typeof colSpan === 'string'
|
|
271
|
+
? colSpan
|
|
272
|
+
: undefined
|
|
273
|
+
|
|
274
|
+
const rowSpanClass =
|
|
275
|
+
typeof rowSpan === 'number'
|
|
276
|
+
? `row-span-${rowSpan}`
|
|
277
|
+
: typeof rowSpan === 'string'
|
|
278
|
+
? rowSpan
|
|
279
|
+
: undefined
|
|
280
|
+
|
|
281
|
+
const cardGradientStyle: CSSProperties = gradient
|
|
282
|
+
? {
|
|
283
|
+
backgroundImage: `repeating-linear-gradient(${gradientAngle}deg, ${gradientColor} 0px, ${gradientColor} 1px, transparent 1px, transparent ${gradientSpacing}px)`,
|
|
284
|
+
opacity: gradientOpacity,
|
|
285
|
+
}
|
|
286
|
+
: {}
|
|
287
|
+
|
|
288
|
+
const innerContent = (
|
|
289
|
+
<>
|
|
290
|
+
{gradient && (
|
|
291
|
+
<div
|
|
292
|
+
className="pointer-events-none absolute inset-0"
|
|
293
|
+
style={cardGradientStyle}
|
|
294
|
+
/>
|
|
295
|
+
)}
|
|
296
|
+
<BentoCardInner
|
|
297
|
+
title={title}
|
|
298
|
+
description={description}
|
|
299
|
+
icon={icon}
|
|
300
|
+
badge={badge}
|
|
301
|
+
badgeClassName={badgeClassName}
|
|
302
|
+
cta={cta}
|
|
303
|
+
ctaHref={ctaHref}
|
|
304
|
+
ctaTarget={ctaTarget}
|
|
305
|
+
ctaRel={ctaRel}
|
|
306
|
+
ctaExternal={ctaExternal}
|
|
307
|
+
ctaClassName={ctaClassName}
|
|
308
|
+
header={header}
|
|
309
|
+
headerClassName={headerClassName}
|
|
310
|
+
footer={footer}
|
|
311
|
+
footerClassName={footerClassName}
|
|
312
|
+
featured={featured}
|
|
313
|
+
external={isExternal}
|
|
314
|
+
>
|
|
315
|
+
{children}
|
|
316
|
+
</BentoCardInner>
|
|
317
|
+
</>
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
const motionProps =
|
|
321
|
+
animate && !reduceMotion
|
|
322
|
+
? {
|
|
323
|
+
initial: { opacity: 0, y: 12 },
|
|
324
|
+
whileInView: { opacity: 1, y: 0 },
|
|
325
|
+
viewport: { once: true, amount: 0.15 },
|
|
326
|
+
transition: { duration: 0.45, ease: 'easeOut' as const },
|
|
327
|
+
}
|
|
328
|
+
: {}
|
|
329
|
+
|
|
330
|
+
return (
|
|
331
|
+
<motion.div
|
|
332
|
+
ref={ref}
|
|
333
|
+
{...motionProps}
|
|
334
|
+
onClick={onClick}
|
|
335
|
+
className={cn(
|
|
336
|
+
'group relative flex h-full flex-col rounded-2xl border p-1 transition-all duration-300',
|
|
337
|
+
'border-border/40 bg-surface/10 hover:border-foreground/20 hover:bg-surface/15',
|
|
338
|
+
(href || onClick) && 'cursor-pointer',
|
|
339
|
+
colSpanClass,
|
|
340
|
+
rowSpanClass,
|
|
341
|
+
className,
|
|
342
|
+
)}
|
|
343
|
+
>
|
|
344
|
+
{href ? (
|
|
345
|
+
<Link
|
|
346
|
+
href={href}
|
|
347
|
+
target={resolvedTarget}
|
|
348
|
+
rel={resolvedRel}
|
|
349
|
+
className={cardInnerClassName}
|
|
350
|
+
>
|
|
351
|
+
{innerContent}
|
|
352
|
+
</Link>
|
|
353
|
+
) : (
|
|
354
|
+
<div className={cardInnerClassName}>{innerContent}</div>
|
|
355
|
+
)}
|
|
356
|
+
</motion.div>
|
|
357
|
+
)
|
|
358
|
+
})
|
|
359
|
+
|
|
360
|
+
BentoCard.displayName = 'BentoCard'
|
|
361
|
+
|
|
362
|
+
export const BentoGrid = forwardRef<HTMLDivElement, BentoGridProps>(function BentoGrid({
|
|
363
|
+
children,
|
|
364
|
+
items,
|
|
365
|
+
className,
|
|
366
|
+
gridClassName,
|
|
367
|
+
cardClassName,
|
|
368
|
+
cols = 4,
|
|
369
|
+
gap = 'gap-3 sm:gap-3.5 lg:gap-4',
|
|
370
|
+
gradient = true,
|
|
371
|
+
gradientAngle = 315,
|
|
372
|
+
gradientOpacity = 0.01,
|
|
373
|
+
gradientSpacing = 24,
|
|
374
|
+
gradientColor = 'var(--foreground)',
|
|
375
|
+
positions = DEFAULT_POSITIONS,
|
|
376
|
+
}, ref) {
|
|
377
|
+
const gridStyle: CSSProperties = gradient
|
|
378
|
+
? {
|
|
379
|
+
backgroundImage: `repeating-linear-gradient(${gradientAngle}deg, ${gradientColor} 0px, ${gradientColor} 1px, transparent 1px, transparent ${gradientSpacing}px)`,
|
|
380
|
+
opacity: gradientOpacity,
|
|
381
|
+
}
|
|
382
|
+
: {}
|
|
383
|
+
|
|
384
|
+
const defaultGridClass =
|
|
385
|
+
gridClassName ??
|
|
386
|
+
cn(
|
|
387
|
+
'relative grid grid-cols-1 sm:grid-cols-2 lg:grid-rows-[minmax(200px,1fr)_minmax(200px,1fr)]',
|
|
388
|
+
cols === 1 && 'lg:grid-cols-1',
|
|
389
|
+
cols === 2 && 'lg:grid-cols-2',
|
|
390
|
+
cols === 3 && 'lg:grid-cols-3',
|
|
391
|
+
cols === 4 && 'lg:grid-cols-4',
|
|
392
|
+
cols === 5 && 'lg:grid-cols-5',
|
|
393
|
+
cols === 6 && 'lg:grid-cols-6',
|
|
394
|
+
gap,
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
return (
|
|
398
|
+
<div ref={ref} className={cn('relative mx-auto w-full max-w-5xl', className)}>
|
|
399
|
+
{gradient && (
|
|
400
|
+
<div
|
|
401
|
+
className="pointer-events-none absolute inset-0 rounded-2xl"
|
|
402
|
+
style={gridStyle}
|
|
403
|
+
/>
|
|
404
|
+
)}
|
|
405
|
+
|
|
406
|
+
<div className={defaultGridClass}>
|
|
407
|
+
{items
|
|
408
|
+
? items.map((item, index) => (
|
|
409
|
+
<BentoCard
|
|
410
|
+
key={typeof item.title === 'string' ? item.title : index}
|
|
411
|
+
{...item}
|
|
412
|
+
featured={item.featured ?? index === 2}
|
|
413
|
+
className={cn(
|
|
414
|
+
positions[index % positions.length],
|
|
415
|
+
cardClassName,
|
|
416
|
+
item.className,
|
|
417
|
+
)}
|
|
418
|
+
/>
|
|
419
|
+
))
|
|
420
|
+
: Children.map(children, (child, index) => {
|
|
421
|
+
if (!isValidElement<BentoCardProps>(child)) return child
|
|
422
|
+
return cloneElement(child, {
|
|
423
|
+
featured: child.props.featured ?? index === 2,
|
|
424
|
+
className: cn(
|
|
425
|
+
positions[index % positions.length],
|
|
426
|
+
cardClassName,
|
|
427
|
+
child.props.className,
|
|
428
|
+
),
|
|
429
|
+
})
|
|
430
|
+
})}
|
|
431
|
+
</div>
|
|
432
|
+
</div>
|
|
433
|
+
)
|
|
434
|
+
})
|
|
435
|
+
|
|
436
|
+
BentoGrid.displayName = 'BentoGrid'
|
|
437
|
+
|
|
438
|
+
export default BentoGrid
|