@istmx/ui 0.1.9 → 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.
@@ -0,0 +1,565 @@
1
+ 'use client'
2
+
3
+ import { useRef } from 'react'
4
+ import type { RefObject } from 'react'
5
+ import {
6
+ cubicBezier,
7
+ motion,
8
+ useReducedMotion,
9
+ useScroll,
10
+ useSpring,
11
+ useTransform,
12
+ } from 'motion/react'
13
+ import type { MotionValue } from 'motion/react'
14
+ import { cn } from '@/lib/utils'
15
+
16
+ export type ScrollParallaxHeroFeature = {
17
+ label?: string
18
+ title: string
19
+ description: string
20
+ }
21
+
22
+ export type ScrollParallaxHeroProps = {
23
+ image: string
24
+ imageAlt?: string
25
+ sideImages?: [string, string]
26
+ showSideCards?: boolean
27
+ heroHeading?: string
28
+ hintText?: string
29
+ showHint?: boolean
30
+ sectionHeading?: string
31
+ sectionSubheading?: string
32
+ captionEyebrow?: string
33
+ captionHeading?: string
34
+ captionSubheading?: string
35
+ marqueeText?: string
36
+ showMarquee?: boolean
37
+ chapters?: [string, string, string]
38
+ showChapters?: boolean
39
+ features?: ScrollParallaxHeroFeature[]
40
+ showProgressBar?: boolean
41
+ scrollLength?: number
42
+ className?: string
43
+ scrollContainerRef?: RefObject<HTMLElement | null>
44
+ fullBleed?: boolean
45
+ }
46
+
47
+ const DEFAULT_FEATURES: ScrollParallaxHeroFeature[] = [
48
+ {
49
+ label: 'Depth',
50
+ title: 'Multi-layer perspective',
51
+ description: 'Decoupled planes move at independent speeds for tactile dimension.',
52
+ },
53
+ {
54
+ label: 'Expansion',
55
+ title: 'Full-bleed scale',
56
+ description: 'The framed view gracefully opens to immerse the entire viewport.',
57
+ },
58
+ {
59
+ label: 'Precision',
60
+ title: 'Harmonic physics',
61
+ description: 'Spring damping and easing curves tuned to feel weighted and steady.',
62
+ },
63
+ ]
64
+
65
+ const frameEase = cubicBezier(0.65, 0, 0.35, 1)
66
+ const softEase = cubicBezier(0.22, 1, 0.36, 1)
67
+
68
+ function ParallaxWord({
69
+ word,
70
+ index,
71
+ lineIndex,
72
+ progress,
73
+ reduce,
74
+ }: {
75
+ word: string
76
+ index: number
77
+ lineIndex: number
78
+ progress: MotionValue<number>
79
+ reduce: boolean
80
+ }) {
81
+ const lift = reduce ? 0 : -(6 + index * 2.4)
82
+ const y = useTransform(progress, [0.03, 0.2], ['0svh', `${lift}svh`])
83
+ const blur = useTransform(
84
+ progress,
85
+ [0.06, 0.18],
86
+ reduce ? ['blur(0px)', 'blur(0px)'] : ['blur(0px)', 'blur(10px)'],
87
+ )
88
+
89
+ return (
90
+ <motion.span
91
+ initial={{
92
+ opacity: 0,
93
+ y: reduce ? 0 : 36,
94
+ filter: reduce ? 'blur(0px)' : 'blur(10px)',
95
+ }}
96
+ animate={{ opacity: 1, y: 0, filter: 'blur(0px)' }}
97
+ transition={{
98
+ duration: reduce ? 0 : 0.9,
99
+ delay: reduce ? 0 : lineIndex * 0.16 + index * 0.05,
100
+ ease: softEase,
101
+ }}
102
+ className="inline-block"
103
+ >
104
+ <motion.span style={{ y, filter: blur }} className="inline-block">
105
+ {word}
106
+ </motion.span>
107
+ </motion.span>
108
+ )
109
+ }
110
+
111
+ function SideCard({
112
+ src,
113
+ side,
114
+ progress,
115
+ reduce,
116
+ }: {
117
+ src: string
118
+ side: 'left' | 'right'
119
+ progress: MotionValue<number>
120
+ reduce: boolean
121
+ }) {
122
+ const isLeft = side === 'left'
123
+ const y = useTransform(
124
+ progress,
125
+ [0.1, 0.7],
126
+ reduce ? ['0svh', '0svh'] : isLeft ? ['22svh', '-18svh'] : ['34svh', '-26svh'],
127
+ )
128
+ const x = useTransform(
129
+ progress,
130
+ [0.1, 0.7],
131
+ reduce ? ['0%', '0%'] : isLeft ? ['0%', '-30%'] : ['0%', '30%'],
132
+ )
133
+ const rotate = useTransform(
134
+ progress,
135
+ [0.1, 0.7],
136
+ reduce ? [0, 0] : isLeft ? [-8, -2] : [7, 2],
137
+ )
138
+ const opacity = useTransform(progress, [0.14, 0.3, 0.5, 0.64], [0, 1, 1, 0])
139
+ const imageY = useTransform(
140
+ progress,
141
+ [0.1, 0.7],
142
+ reduce ? ['0%', '0%'] : ['-8%', '8%'],
143
+ )
144
+
145
+ return (
146
+ <motion.div
147
+ aria-hidden="true"
148
+ style={{ y, x, rotate, opacity }}
149
+ className={cn(
150
+ 'pointer-events-none absolute z-[1] aspect-[3/4] w-[24%] max-w-56 overflow-hidden rounded-xl shadow-[0_30px_80px_rgba(0,0,0,0.35)] sm:w-[19%]',
151
+ isLeft ? 'top-[26%] left-[4%] sm:left-[7%]' : 'top-[34%] right-[4%] sm:right-[7%]',
152
+ )}
153
+ >
154
+ <motion.img
155
+ src={src}
156
+ alt=""
157
+ draggable={false}
158
+ style={{ y: imageY }}
159
+ className="absolute inset-0 size-full scale-125 object-cover"
160
+ loading="lazy"
161
+ />
162
+ <div className="absolute inset-0 bg-gradient-to-t from-black/40 to-transparent" />
163
+ </motion.div>
164
+ )
165
+ }
166
+
167
+ function FeatureCard({
168
+ item,
169
+ index,
170
+ progress,
171
+ reduce,
172
+ }: {
173
+ item: ScrollParallaxHeroFeature
174
+ index: number
175
+ progress: MotionValue<number>
176
+ reduce: boolean
177
+ }) {
178
+ const start = 0.74 + index * 0.05
179
+ const opacity = useTransform(progress, [start, start + 0.1], [0, 1])
180
+ const y = useTransform(
181
+ progress,
182
+ [start, start + 0.1],
183
+ reduce ? [0, 0] : [20, 0],
184
+ )
185
+
186
+ return (
187
+ <motion.div
188
+ style={{ opacity, y }}
189
+ className="border-border/60 bg-surface/40 backdrop-blur-md rounded-xl border p-3.5 sm:p-4.5"
190
+ >
191
+ {item.label && (
192
+ <p className="font-mono text-[10px] tracking-[0.16em] uppercase text-muted">
193
+ {item.label}
194
+ </p>
195
+ )}
196
+ <h4 className="font-display mt-1 text-sm font-semibold tracking-tight text-foreground sm:text-base">
197
+ {item.title}
198
+ </h4>
199
+ <p className="text-muted mt-1 text-xs leading-relaxed">
200
+ {item.description}
201
+ </p>
202
+ </motion.div>
203
+ )
204
+ }
205
+
206
+ function Chapter({
207
+ label,
208
+ range,
209
+ progress,
210
+ reduce,
211
+ }: {
212
+ label: string
213
+ range: [number, number, number, number]
214
+ progress: MotionValue<number>
215
+ reduce: boolean
216
+ }) {
217
+ const opacity = useTransform(progress, range, [0, 1, 1, 0])
218
+ const y = useTransform(
219
+ progress,
220
+ range,
221
+ reduce ? [0, 0, 0, 0] : [8, 0, 0, -8],
222
+ )
223
+
224
+ return (
225
+ <motion.span
226
+ style={{ opacity, y }}
227
+ className="text-muted absolute inset-x-0 text-center font-mono text-[10px] tracking-[0.18em] uppercase"
228
+ >
229
+ {label}
230
+ </motion.span>
231
+ )
232
+ }
233
+
234
+ export default function ScrollParallaxHero({
235
+ image,
236
+ imageAlt = '',
237
+ sideImages,
238
+ showSideCards = true,
239
+ heroHeading = 'Make room for\na different perspective.',
240
+ hintText = 'Scroll to begin',
241
+ showHint = true,
242
+ sectionHeading = 'Look closer.',
243
+ sectionSubheading = 'A study in scale and perspective',
244
+ captionEyebrow = 'Focus',
245
+ captionHeading,
246
+ captionSubheading,
247
+ marqueeText = 'Scale · Depth · Motion · Perspective ·',
248
+ showMarquee = true,
249
+ chapters = ['Perspective', 'Scale', 'Detail'],
250
+ showChapters = true,
251
+ features = DEFAULT_FEATURES,
252
+ showProgressBar = true,
253
+ scrollLength = 380,
254
+ className,
255
+ scrollContainerRef,
256
+ fullBleed = false,
257
+ }: ScrollParallaxHeroProps) {
258
+ const sceneRef = useRef<HTMLElement>(null)
259
+ const reduceMotion = useReducedMotion()
260
+ const reduce = Boolean(reduceMotion)
261
+
262
+ const { scrollYProgress } = useScroll({
263
+ container: scrollContainerRef,
264
+ target: sceneRef,
265
+ offset: ['start start', 'end end'],
266
+ })
267
+
268
+ const springProgress = useSpring(scrollYProgress, {
269
+ stiffness: 110,
270
+ damping: 26,
271
+ mass: 0.4,
272
+ restDelta: 0.0004,
273
+ })
274
+ const p = reduce ? scrollYProgress : springProgress
275
+
276
+ const [leftImage, rightImage] = sideImages ?? [image, image]
277
+
278
+ const backdropTint = useTransform(p, [0.18, 0.34], [0, 1])
279
+
280
+ // Clear gap: Hero heading fades out early (0.05 -> 0.18) with upward lift
281
+ const heroOpacity = useTransform(p, [0.05, 0.18], [1, 0])
282
+ const heroScale = useTransform(p, [0.05, 0.18], reduce ? [1, 1] : [1, 0.94])
283
+ const heroY = useTransform(p, [0.05, 0.18], reduce ? ['0svh', '0svh'] : ['0svh', '-8svh'])
284
+ const hintOpacity = useTransform(p, [0.02, 0.09], [1, 0])
285
+
286
+ const gridY = useTransform(p, [0, 1], reduce ? ['0%', '0%'] : ['0%', '-14%'])
287
+ const orbAY = useTransform(p, [0, 1], reduce ? ['0%', '0%'] : ['0%', '-60%'])
288
+ const orbBY = useTransform(p, [0, 1], reduce ? ['0%', '0%'] : ['0%', '45%'])
289
+ const orbAX = useTransform(p, [0, 1], reduce ? ['0%', '0%'] : ['0%', '25%'])
290
+ const orbBX = useTransform(p, [0, 1], reduce ? ['0%', '0%'] : ['0%', '-30%'])
291
+
292
+ const marqueeOpacity = useTransform(p, [0.22, 0.36, 0.56, 0.72], [0, 1, 1, 0])
293
+ const marqueeAX = useTransform(p, [0.2, 0.75], reduce ? ['0%', '0%'] : ['8%', '-32%'])
294
+ const marqueeBX = useTransform(p, [0.2, 0.75], reduce ? ['0%', '0%'] : ['-34%', '6%'])
295
+
296
+ const frameProgress = useTransform(p, [0.2, 0.9], [0, 1], { ease: frameEase })
297
+ const frameWidth = useTransform(frameProgress, [0, 1], ['58%', '100%'])
298
+ const frameHeight = useTransform(frameProgress, [0, 1], ['56svh', '100svh'])
299
+ const frameRadius = useTransform(frameProgress, [0, 0.85, 1], [26, 6, 0])
300
+ const frameRotateX = useTransform(frameProgress, [0, 1], reduce ? [0, 0] : [9, 0])
301
+ const frameRotateZ = useTransform(frameProgress, [0, 1], reduce ? [0, 0] : [-2.5, 0])
302
+ const frameOpacity = useTransform(p, [0.16, 0.26], [0, 1])
303
+ const frameShadowOpacity = useTransform(frameProgress, [0, 0.9, 1], [1, 0.6, 0])
304
+
305
+ const imageY = useTransform(frameProgress, [0, 1], reduce ? ['0%', '0%'] : ['10%', '-10%'])
306
+ const imageX = useTransform(frameProgress, [0, 1], reduce ? ['0%', '0%'] : ['-3%', '3%'])
307
+ const imageScale = useTransform(frameProgress, [0, 1], reduce ? [1, 1] : [1.28, 1.08])
308
+ const imageSaturate = useTransform(
309
+ frameProgress,
310
+ [0, 1],
311
+ reduce ? ['saturate(1)', 'saturate(1)'] : ['saturate(0.7) brightness(0.9)', 'saturate(1.1) brightness(1)'],
312
+ )
313
+ const shineX = useTransform(p, [0.3, 0.9], reduce ? ['-120%', '-120%'] : ['-120%', '220%'])
314
+
315
+ const ghostProgress = useTransform(p, [0.28, 0.98], [0, 1], { ease: frameEase })
316
+ const ghostWidth = useTransform(ghostProgress, [0, 1], ['58%', '100%'])
317
+ const ghostHeight = useTransform(ghostProgress, [0, 1], ['56svh', '100svh'])
318
+ const ghostRadius = useTransform(ghostProgress, [0, 0.85, 1], [26, 6, 0])
319
+ const ghostOpacity = useTransform(p, [0.22, 0.34, 0.94, 1], [0, 0.7, 0.7, 0])
320
+
321
+ // "Look closer" fades in only AFTER the hero heading fades out (gap between 0.18 and 0.26)
322
+ const framingOpacity = useTransform(p, [0.26, 0.36, 0.58, 0.68], [0, 1, 1, 0])
323
+ const titleY = useTransform(p, [0.26, 0.68], reduce ? ['0svh', '0svh'] : ['3svh', '-5svh'])
324
+
325
+ const captionOpacity = useTransform(p, [0.68, 0.84], [0, 1])
326
+ const captionY = useTransform(p, [0.68, 0.84], reduce ? [0, 0] : [24, 0])
327
+ const featuresFade = useTransform(p, [0.72, 0.82], [0, 1])
328
+ const vignette = useTransform(p, [0.6, 0.95], [0, 1])
329
+ const barScale = useTransform(p, [0.06, 0.96], [0, 1])
330
+
331
+ const resolvedCaptionHeading = captionHeading ?? sectionHeading
332
+ const resolvedCaptionSubheading = captionSubheading ?? sectionSubheading
333
+ const headingLines = heroHeading.split('\n')
334
+ let wordCounter = -1
335
+
336
+ return (
337
+ <section
338
+ ref={sceneRef}
339
+ aria-label="Scroll parallax image reveal"
340
+ style={{ height: `${scrollLength}svh` }}
341
+ className={cn(
342
+ fullBleed
343
+ ? 'relative left-1/2 w-screen -translate-x-1/2'
344
+ : 'relative w-full overflow-clip rounded-xl',
345
+ className,
346
+ )}
347
+ >
348
+ <div className="bg-background text-foreground sticky top-0 flex h-svh w-full items-center justify-center overflow-hidden [perspective:1400px]">
349
+ <motion.div
350
+ aria-hidden="true"
351
+ style={{ y: gridY }}
352
+ className="pointer-events-none absolute inset-x-0 -top-[8%] z-0 h-[125%] [mask-image:radial-gradient(ellipse_at_50%_45%,black,transparent_70%)] bg-[linear-gradient(to_right,color-mix(in_srgb,var(--foreground)_8%,transparent)_1px,transparent_1px),linear-gradient(to_bottom,color-mix(in_srgb,var(--foreground)_8%,transparent)_1px,transparent_1px)] bg-[size:56px_56px]"
353
+ />
354
+
355
+ <motion.div
356
+ aria-hidden="true"
357
+ style={{ y: orbAY, x: orbAX }}
358
+ className="pointer-events-none absolute -top-[10%] -left-[10%] z-0 size-[46vmin] rounded-full bg-[color-mix(in_srgb,var(--foreground)_10%,transparent)] blur-3xl"
359
+ />
360
+ <motion.div
361
+ aria-hidden="true"
362
+ style={{ y: orbBY, x: orbBX }}
363
+ className="pointer-events-none absolute -right-[8%] bottom-[2%] z-0 size-[40vmin] rounded-full bg-[color-mix(in_srgb,var(--foreground)_8%,transparent)] blur-3xl"
364
+ />
365
+
366
+ <motion.div
367
+ aria-hidden="true"
368
+ style={{ opacity: backdropTint }}
369
+ className="bg-surface/20 pointer-events-none absolute inset-0 z-0"
370
+ />
371
+
372
+ {showMarquee && (
373
+ <motion.div
374
+ aria-hidden="true"
375
+ style={{ opacity: marqueeOpacity }}
376
+ className="pointer-events-none absolute inset-0 z-[1] flex flex-col justify-center gap-[2vmin] overflow-hidden"
377
+ >
378
+ <motion.p
379
+ style={{ x: marqueeAX }}
380
+ className="font-display text-[clamp(4rem,14vw,12rem)] leading-[0.9] tracking-[-0.05em] whitespace-nowrap text-transparent [-webkit-text-stroke:1px_color-mix(in_srgb,var(--foreground)_18%,transparent)]"
381
+ >
382
+ {marqueeText} {marqueeText} {marqueeText}
383
+ </motion.p>
384
+ <motion.p
385
+ style={{ x: marqueeBX }}
386
+ className="font-display text-[clamp(4rem,14vw,12rem)] leading-[0.9] tracking-[-0.05em] whitespace-nowrap text-transparent [-webkit-text-stroke:1px_color-mix(in_srgb,var(--foreground)_10%,transparent)]"
387
+ >
388
+ {marqueeText} {marqueeText} {marqueeText}
389
+ </motion.p>
390
+ </motion.div>
391
+ )}
392
+
393
+ {showSideCards && (
394
+ <>
395
+ <SideCard src={leftImage} side="left" progress={p} reduce={reduce} />
396
+ <SideCard src={rightImage} side="right" progress={p} reduce={reduce} />
397
+ </>
398
+ )}
399
+
400
+ {/* Hero heading with clean scroll gap before section heading appears */}
401
+ <motion.h1
402
+ style={{ opacity: heroOpacity, scale: heroScale, y: heroY }}
403
+ className="font-display text-foreground absolute z-10 max-w-5xl px-6 text-center text-[clamp(2.75rem,8.5vw,7.5rem)] font-semibold leading-[0.94] tracking-[-0.05em]"
404
+ >
405
+ {headingLines.map((line, lineIndex) => (
406
+ <span key={`${line}-${lineIndex}`} className="block">
407
+ {line.split(' ').map((word, i) => {
408
+ wordCounter += 1
409
+ return (
410
+ <span key={`${word}-${i}`}>
411
+ <ParallaxWord
412
+ word={word}
413
+ index={wordCounter}
414
+ lineIndex={lineIndex}
415
+ progress={p}
416
+ reduce={reduce}
417
+ />{' '}
418
+ </span>
419
+ )
420
+ })}
421
+ </span>
422
+ ))}
423
+ </motion.h1>
424
+
425
+ {showHint && (
426
+ <motion.div
427
+ aria-hidden="true"
428
+ style={{ opacity: hintOpacity }}
429
+ className="pointer-events-none absolute bottom-[6svh] z-10 flex flex-col items-center gap-2"
430
+ >
431
+ <span className="text-muted text-xs">{hintText}</span>
432
+ <span className="bg-border relative block h-10 w-px overflow-hidden">
433
+ <motion.span
434
+ animate={reduce ? undefined : { y: ['-100%', '100%'] }}
435
+ transition={{ duration: 1.6, repeat: Infinity, ease: 'easeInOut' }}
436
+ className="bg-foreground absolute inset-0 block"
437
+ />
438
+ </span>
439
+ </motion.div>
440
+ )}
441
+
442
+ {/* Section heading ("Look closer.") appears only after hero heading is gone */}
443
+ <motion.div
444
+ style={{ opacity: framingOpacity, y: titleY }}
445
+ className="pointer-events-none absolute top-[8svh] z-10 px-6 text-center"
446
+ >
447
+ <h2 className="font-display text-4xl font-semibold tracking-[-0.04em] text-foreground sm:text-6xl">
448
+ {sectionHeading}
449
+ </h2>
450
+ <p className="text-muted mt-2 text-sm sm:text-base">{sectionSubheading}</p>
451
+ </motion.div>
452
+
453
+ <motion.div
454
+ aria-hidden="true"
455
+ style={{
456
+ width: ghostWidth,
457
+ height: ghostHeight,
458
+ borderRadius: ghostRadius,
459
+ opacity: ghostOpacity,
460
+ y: reduce ? 0 : 18,
461
+ }}
462
+ className="bg-surface/20 border-border/30 absolute z-[2] overflow-hidden border"
463
+ />
464
+
465
+ <motion.figure
466
+ style={{
467
+ width: frameWidth,
468
+ height: frameHeight,
469
+ borderRadius: frameRadius,
470
+ rotateX: frameRotateX,
471
+ rotateZ: frameRotateZ,
472
+ opacity: frameOpacity,
473
+ }}
474
+ className="border-border/40 bg-surface relative isolate z-[3] overflow-hidden border [transform-style:preserve-3d]"
475
+ >
476
+ <motion.div
477
+ aria-hidden="true"
478
+ style={{ opacity: frameShadowOpacity }}
479
+ className="pointer-events-none absolute inset-0 z-10 rounded-[inherit] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.08)]"
480
+ />
481
+
482
+ <motion.img
483
+ src={image}
484
+ alt={imageAlt}
485
+ draggable={false}
486
+ style={{ y: imageY, x: imageX, scale: imageScale, filter: imageSaturate }}
487
+ className="absolute inset-0 size-full object-cover will-change-transform"
488
+ />
489
+
490
+ <motion.div
491
+ aria-hidden="true"
492
+ style={{ x: shineX }}
493
+ className="pointer-events-none absolute inset-y-0 z-[2] w-1/3 -skew-x-12 bg-gradient-to-r from-transparent via-white/10 to-transparent"
494
+ />
495
+
496
+ <div
497
+ aria-hidden="true"
498
+ className="pointer-events-none absolute inset-0 z-[3] bg-gradient-to-t from-background/90 via-background/30 to-background/10"
499
+ />
500
+
501
+ <motion.div
502
+ aria-hidden="true"
503
+ style={{ opacity: vignette }}
504
+ className="pointer-events-none absolute inset-0 z-[3] bg-[radial-gradient(ellipse_at_center,transparent_45%,rgba(0,0,0,0.45))]"
505
+ />
506
+ </motion.figure>
507
+
508
+ <motion.div
509
+ style={{ opacity: captionOpacity, y: captionY }}
510
+ className="pointer-events-none absolute bottom-[25svh] left-6 z-10 max-w-2xl sm:bottom-[27svh] sm:left-10"
511
+ >
512
+ {captionEyebrow && (
513
+ <p className="font-mono text-[10px] tracking-[0.2em] uppercase text-muted">
514
+ {captionEyebrow}
515
+ </p>
516
+ )}
517
+ <h3 className="font-display mt-1 text-3xl font-semibold tracking-tight text-foreground drop-shadow-md sm:text-5xl">
518
+ {resolvedCaptionHeading}
519
+ </h3>
520
+ <p className="text-muted mt-1.5 max-w-lg text-xs sm:text-sm">
521
+ {resolvedCaptionSubheading}
522
+ </p>
523
+ </motion.div>
524
+
525
+ {features.length > 0 ? (
526
+ <motion.div
527
+ style={{ opacity: featuresFade }}
528
+ className="pointer-events-none absolute inset-x-0 bottom-0 z-10 grid grid-cols-1 gap-3 px-6 pb-[7svh] sm:grid-cols-3 sm:gap-5 sm:px-10"
529
+ >
530
+ {features.slice(0, 3).map((item, index) => (
531
+ <FeatureCard
532
+ key={`${item.title}-${index}`}
533
+ item={item}
534
+ index={index}
535
+ progress={p}
536
+ reduce={reduce}
537
+ />
538
+ ))}
539
+ </motion.div>
540
+ ) : null}
541
+
542
+ {showChapters && chapters && chapters.length >= 3 && (
543
+ <div
544
+ aria-hidden="true"
545
+ className="text-muted pointer-events-none absolute inset-x-0 bottom-[2.5svh] z-20 flex h-5 items-center justify-center"
546
+ >
547
+ <div className="relative h-5 w-44">
548
+ <Chapter label={chapters[0]} range={[0, 0.06, 0.2, 0.3]} progress={p} reduce={reduce} />
549
+ <Chapter label={chapters[1]} range={[0.26, 0.38, 0.62, 0.72]} progress={p} reduce={reduce} />
550
+ <Chapter label={chapters[2]} range={[0.68, 0.8, 0.96, 1]} progress={p} reduce={reduce} />
551
+ </div>
552
+ </div>
553
+ )}
554
+
555
+ {showProgressBar && (
556
+ <motion.div
557
+ aria-hidden="true"
558
+ style={{ scaleX: barScale }}
559
+ className="bg-foreground/30 absolute inset-x-0 bottom-0 z-30 h-0.5 origin-left"
560
+ />
561
+ )}
562
+ </div>
563
+ </section>
564
+ )
565
+ }