@yamatozhen/design_system 1.0.0

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 (87) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +101 -0
  3. package/package.json +49 -0
  4. package/scripts/postinstall.js +105 -0
  5. package/template/app/ClientNav.tsx +310 -0
  6. package/template/app/globals.css +167 -0
  7. package/template/app/layout.tsx +128 -0
  8. package/template/app/themes/dark-mc.css +51 -0
  9. package/template/app/themes/dark.css +51 -0
  10. package/template/app/themes/light-mc.css +51 -0
  11. package/template/app/themes/light.css +51 -0
  12. package/template/app/themes/theme.css +82 -0
  13. package/template/components/layout/Lightbox/LightboxCard.tsx +100 -0
  14. package/template/components/layout/Lightbox/LightboxGallery.module.css +249 -0
  15. package/template/components/layout/Lightbox/LightboxGallery.tsx +72 -0
  16. package/template/components/layout/Lightbox/LightboxGrid.tsx +186 -0
  17. package/template/components/layout/Lightbox/LightboxModal.module.css +395 -0
  18. package/template/components/layout/Lightbox/LightboxModal.tsx +500 -0
  19. package/template/components/layout/Lightbox/demo.tsx +412 -0
  20. package/template/components/layout/Lightbox/index.ts +30 -0
  21. package/template/components/layout/Lightbox/types.ts +113 -0
  22. package/template/components/layout/Lightbox/useLightboxFilters.ts +140 -0
  23. package/template/components/layout/accordion/Accordion.module.css +149 -0
  24. package/template/components/layout/accordion/Accordion.tsx +114 -0
  25. package/template/components/layout/button/Button.module.css +305 -0
  26. package/template/components/layout/button/ButtonGroup.tsx +503 -0
  27. package/template/components/layout/button/FAB.tsx +118 -0
  28. package/template/components/layout/button/button.tsx +128 -0
  29. package/template/components/layout/button/drop.module.css +229 -0
  30. package/template/components/layout/button/drop.tsx +516 -0
  31. package/template/components/layout/hero/v1/heroSlideshow.module.css +107 -0
  32. package/template/components/layout/hero/v1/heroSlideshow.tsx +233 -0
  33. package/template/components/layout/modals/accessibilityModal/AccessibilityModal.module.css +126 -0
  34. package/template/components/layout/modals/accessibilityModal/AccessibilityModal.tsx +290 -0
  35. package/template/components/layout/modals/alert/Alert.tsx +188 -0
  36. package/template/components/layout/navigation/MioCard.module.css +88 -0
  37. package/template/components/layout/navigation/MioCard.tsx +266 -0
  38. package/template/components/layout/navigation/Wrap.tsx +41 -0
  39. package/template/components/layout/navigation/nav/Nav.module.css +508 -0
  40. package/template/components/layout/navigation/nav/Nav.tsx +167 -0
  41. package/template/components/layout/navigation/nav/NavBar.tsx +419 -0
  42. package/template/components/layout/navigation/nav/NavContext.tsx +259 -0
  43. package/template/components/layout/navigation/nav/NavItem.tsx +173 -0
  44. package/template/components/layout/navigation/nav/NavNew.module.css +373 -0
  45. package/template/components/layout/navigation/nav/NavRail.tsx +315 -0
  46. package/template/components/layout/navigation/nav/NavSection.tsx +102 -0
  47. package/template/components/layout/navigation/nav/NavTab.tsx +25 -0
  48. package/template/components/layout/navigation/nav/navftb/NavFTB.module.css +252 -0
  49. package/template/components/layout/navigation/nav/navftb/NavFTB.tsx +399 -0
  50. package/template/components/layout/navigation/nav/navftb/useTabIndicator.ts +484 -0
  51. package/template/components/layout/navigation/nav/navheader/NavHeader.module.css +59 -0
  52. package/template/components/layout/navigation/nav/navheader/NavHeader.tsx +478 -0
  53. package/template/components/layout/pages/loadingScreen.tsx +102 -0
  54. package/template/components/layout/pages/maintenance/Maintenance.tsx +53 -0
  55. package/template/components/layout/pages/maintenance/maintenance.module.css +163 -0
  56. package/template/components/layout/switch/Switch.module.css +102 -0
  57. package/template/components/layout/switch/Switch.tsx +48 -0
  58. package/template/components/tools/Divider.tsx +11 -0
  59. package/template/components/tools/ProgressiveBlur.tsx +73 -0
  60. package/template/components/tools/ReduceMotionContext.tsx +5 -0
  61. package/template/components/tools/Sinewave.tsx +199 -0
  62. package/template/components/tools/SinewaveProgress.tsx +135 -0
  63. package/template/components/tools/badge/Badge.tsx +28 -0
  64. package/template/components/tools/flubber.d.ts +7 -0
  65. package/template/components/tools/icon/SocialIcons.tsx +88 -0
  66. package/template/components/tools/icon/icon.module.css +0 -0
  67. package/template/components/tools/icon/icon.tsx +125 -0
  68. package/template/components/tools/mobileViewProvider.tsx +58 -0
  69. package/template/components/tools/react-bits/ClickSpark.tsx +177 -0
  70. package/template/components/tools/react-bits/FadeContent.tsx +90 -0
  71. package/template/components/tools/react-bits/GlareHover.tsx +73 -0
  72. package/template/components/tools/react-bits/GradientText/GradientText.css +70 -0
  73. package/template/components/tools/react-bits/GradientText/GradientText.tsx +44 -0
  74. package/template/components/tools/react-bits/Magnet.tsx +118 -0
  75. package/template/components/tools/react-bits/Stepper/Stepper.css +134 -0
  76. package/template/components/tools/react-bits/Stepper/Stepper.tsx +412 -0
  77. package/template/components/tools/ripple/ripple.css +41 -0
  78. package/template/components/tools/ripple/ripple.tsx +53 -0
  79. package/template/components/tools/shape/ShapeLoader.tsx +101 -0
  80. package/template/components/tools/shape/ShapeMorph.tsx +190 -0
  81. package/template/components/tools/shape/ShapePaths.ts +116 -0
  82. package/template/components/tools/switch/Switch.module.css +102 -0
  83. package/template/components/tools/switch/Switch.tsx +48 -0
  84. package/template/components/tools/useBodyScrollLock.tsx +27 -0
  85. package/template/components/tools/useImageColor.ts +47 -0
  86. package/template/components/tools/useNavSheetDrag.tsx +196 -0
  87. package/template/public/fonts/material-symbols/MaterialSymbolsRounded-VariableFont_FILL,GRAD,opsz,wght.woff2 +0 -0
@@ -0,0 +1,484 @@
1
+ import { useCallback, useEffect, useLayoutEffect, useRef } from "react";
2
+ import type { FTBTab } from "../NavContext";
3
+
4
+ // ── Spring constants ────────────────────────────────────────────────────────
5
+ const PK = 200,
6
+ PD = 22;
7
+ const SK = 300,
8
+ SD = 10;
9
+
10
+ const SQUASH_X = 0.26;
11
+ const SQUASH_Y = 0.26;
12
+
13
+ const IDLE = 0;
14
+ const FLYING = 1;
15
+ const ARRIVED = 2;
16
+
17
+ export interface UseTabIndicatorArgs {
18
+ selected: number;
19
+ setSelected: (index: number) => void;
20
+ tabs: FTBTab[];
21
+ elevated: boolean;
22
+ isEmbedded: boolean;
23
+ reduceMotion: boolean;
24
+ onTabChange?: (index: number) => void;
25
+ }
26
+
27
+ export interface UseTabIndicatorReturn {
28
+ containerRef: React.RefObject<HTMLDivElement | null>;
29
+ indicatorRef: React.RefObject<HTMLDivElement | null>;
30
+ registerTab: (index: number) => (el: HTMLElement | null) => void;
31
+ remeasureAndSnap: () => void;
32
+ onTabPointerEnter: (index: number) => void;
33
+ onTabPointerLeave: () => void;
34
+ }
35
+
36
+ /**
37
+ * Owns the floating indicator: geometry cache, the three-spring physics
38
+ * integrator, touch-drag, and all the re-snap effects. No JSX — it writes
39
+ * transform/width straight to `indicatorRef` and reads tab geometry from the
40
+ * refs handed back via `registerTab`. The host component owns selection state
41
+ * and passes it in; the hook calls back through `setSelected`/`onTabChange`
42
+ * only when a drag settles on a new tab.
43
+ */
44
+ export function useTabIndicator({
45
+ selected,
46
+ setSelected,
47
+ tabs,
48
+ elevated,
49
+ isEmbedded,
50
+ reduceMotion,
51
+ onTabChange,
52
+ }: UseTabIndicatorArgs): UseTabIndicatorReturn {
53
+ const containerRef = useRef<HTMLDivElement>(null);
54
+ const indicatorRef = useRef<HTMLDivElement>(null);
55
+ const tabRefs = useRef<(HTMLElement | null)[]>([]);
56
+
57
+ const selectedRef = useRef(selected);
58
+ selectedRef.current = selected;
59
+ const tabsRef = useRef(tabs);
60
+ tabsRef.current = tabs;
61
+ const onTabChangeRef = useRef(onTabChange);
62
+ onTabChangeRef.current = onTabChange;
63
+ const setSelectedRef = useRef(setSelected);
64
+ setSelectedRef.current = setSelected;
65
+
66
+ const pxRef = useRef(0),
67
+ vxRef = useRef(0),
68
+ txRef = useRef(0);
69
+
70
+ const sxRef = useRef(1),
71
+ svxRef = useRef(0),
72
+ stxRef = useRef(1);
73
+ const syRef = useRef(1),
74
+ svyRef = useRef(0),
75
+ styRef = useRef(1);
76
+
77
+ const phaseRef = useRef(IDLE);
78
+ const dirRef = useRef(0);
79
+ const rafRef = useRef<number | null>(null);
80
+ const lastRef = useRef<number | null>(null);
81
+ const readyRef = useRef(false);
82
+
83
+ const tabRectsRef = useRef<{ x: number; width: number }[]>([]);
84
+
85
+ // Caches every tab's scroll-content position in one batched read pass.
86
+ // Geometry only changes on resize / tab-count change, so callers read the
87
+ // cache instead of forcing layout via getBoundingClientRect per frame/drag.
88
+ const measureTabs = useCallback(() => {
89
+ const container = containerRef.current;
90
+ if (!container) return;
91
+ const rects = tabRectsRef.current;
92
+ rects.length = tabRefs.current.length;
93
+ for (let i = 0; i < tabRefs.current.length; i++) {
94
+ const tab = tabRefs.current[i];
95
+ if (!tab) {
96
+ rects[i] = { x: 0, width: 0 };
97
+ continue;
98
+ }
99
+ // offsetLeft/offsetWidth are LAYOUT geometry — unaffected by the wrapper's
100
+ // `whileHover` scale or Framer `layout` transform, and final the instant
101
+ // the style commits. getBoundingClientRect returns the transformed,
102
+ // mid-animation box, so it reports the wrong width and never settles.
103
+ rects[i] = { x: tab.offsetLeft, width: tab.offsetWidth };
104
+ }
105
+ }, []);
106
+
107
+ const getTabRect = useCallback(
108
+ (index: number) => tabRectsRef.current[index] ?? null,
109
+ [],
110
+ );
111
+
112
+ const commit = useCallback(() => {
113
+ const el = indicatorRef.current;
114
+ if (!el) return;
115
+ el.style.transform = `translateX(${pxRef.current}px) scaleX(${sxRef.current}) scaleY(${syRef.current})`;
116
+ }, []);
117
+
118
+ // Per-frame integrator. Three critically-damped springs (position, scaleX,
119
+ // scaleY) advanced with semi-implicit Euler, math inlined to keep the loop
120
+ // allocation-free. FLYING applies directional squash/stretch by velocity;
121
+ // ARRIVED eases the overshoot back to rest. Only touches refs + one transform
122
+ // write — never reads layout — so it stays on the compositor's good side.
123
+ const loop = useCallback(
124
+ (ts: number) => {
125
+ if (!lastRef.current) lastRef.current = ts;
126
+ const dt = Math.min((ts - lastRef.current) / 1000, 0.032);
127
+ lastRef.current = ts;
128
+
129
+ vxRef.current +=
130
+ (-PK * (pxRef.current - txRef.current) - PD * vxRef.current) * dt;
131
+ pxRef.current += vxRef.current * dt;
132
+
133
+ const speed = Math.abs(vxRef.current);
134
+ const dist = Math.abs(pxRef.current - txRef.current);
135
+
136
+ if (phaseRef.current === FLYING) {
137
+ const mag = Math.min(speed / 700, 1);
138
+ if (dirRef.current > 0) {
139
+ stxRef.current = 1 - mag * 0.06;
140
+ styRef.current = 1 + mag * SQUASH_Y;
141
+ } else {
142
+ stxRef.current = 1 + mag * SQUASH_X;
143
+ styRef.current = 1 - mag * 0.08;
144
+ }
145
+ if (dist < 6 && speed < 100) {
146
+ phaseRef.current = ARRIVED;
147
+ if (dirRef.current > 0) {
148
+ stxRef.current = 1 - 0.08;
149
+ styRef.current = 1 + SQUASH_Y * 0.6;
150
+ } else {
151
+ stxRef.current = 1 + SQUASH_X * 0.5;
152
+ styRef.current = 1 - 0.06;
153
+ }
154
+ }
155
+ }
156
+
157
+ if (phaseRef.current === ARRIVED) {
158
+ stxRef.current += (1 - stxRef.current) * Math.min(dt * 6, 1);
159
+ styRef.current += (1 - styRef.current) * Math.min(dt * 6, 1);
160
+ }
161
+
162
+ const effectiveSK = reduceMotion ? 1 : SK;
163
+
164
+ svxRef.current +=
165
+ (-effectiveSK * (sxRef.current - stxRef.current) -
166
+ SD * svxRef.current) *
167
+ dt;
168
+ sxRef.current += svxRef.current * dt;
169
+ svyRef.current +=
170
+ (-effectiveSK * (syRef.current - styRef.current) -
171
+ SD * svyRef.current) *
172
+ dt;
173
+ syRef.current += svyRef.current * dt;
174
+
175
+ commit();
176
+
177
+ const settled =
178
+ dist < 0.15 &&
179
+ speed < 0.4 &&
180
+ Math.abs(sxRef.current - 1) < 0.003 &&
181
+ Math.abs(svxRef.current) < 0.01 &&
182
+ Math.abs(syRef.current - 1) < 0.003 &&
183
+ Math.abs(svyRef.current) < 0.01;
184
+
185
+ if (!settled) {
186
+ rafRef.current = requestAnimationFrame(loop);
187
+ } else {
188
+ sxRef.current = 1;
189
+ svxRef.current = 0;
190
+ stxRef.current = 1;
191
+ syRef.current = 1;
192
+ svyRef.current = 0;
193
+ styRef.current = 1;
194
+ phaseRef.current = IDLE;
195
+ rafRef.current = null;
196
+ lastRef.current = null;
197
+ commit();
198
+ }
199
+ },
200
+ [commit, reduceMotion],
201
+ );
202
+
203
+ // Retargets the indicator to a tab. First call snaps (no animation); after
204
+ // that it kicks off the spring loop toward the new tab's cached position.
205
+ const moveTo = useCallback(
206
+ (index: number) => {
207
+ const rect = getTabRect(index);
208
+ if (!rect) return;
209
+
210
+ const el = indicatorRef.current;
211
+ if (el) el.style.width = `${rect.width}px`;
212
+
213
+ if (!readyRef.current) {
214
+ pxRef.current = rect.x;
215
+ txRef.current = rect.x;
216
+ readyRef.current = true;
217
+ commit();
218
+ return;
219
+ }
220
+
221
+ if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);
222
+
223
+ dirRef.current = rect.x > txRef.current ? 1 : -1;
224
+ txRef.current = rect.x;
225
+ sxRef.current = 1;
226
+ syRef.current = 1;
227
+ svxRef.current = 0;
228
+ svyRef.current = 0;
229
+ stxRef.current = 1;
230
+ styRef.current = 1;
231
+ phaseRef.current = FLYING;
232
+ lastRef.current = null;
233
+
234
+ rafRef.current = requestAnimationFrame(loop);
235
+ },
236
+ [getTabRect, loop, commit],
237
+ );
238
+
239
+ // Hard-snaps the indicator to the selected tab's CURRENT cached geometry
240
+ // (no animation). Assumes the cache is already warm — callers measureTabs()
241
+ // first if the layout just changed.
242
+ const snapToSelected = useCallback(() => {
243
+ if (!readyRef.current) return;
244
+ const rect = getTabRect(selectedRef.current);
245
+ if (!rect) return;
246
+
247
+ if (rafRef.current !== null) {
248
+ cancelAnimationFrame(rafRef.current);
249
+ rafRef.current = null;
250
+ }
251
+ const ind = indicatorRef.current;
252
+ if (ind) ind.style.width = `${rect.width}px`;
253
+ pxRef.current = rect.x;
254
+ txRef.current = rect.x;
255
+ sxRef.current = 1;
256
+ svxRef.current = 0;
257
+ stxRef.current = 1;
258
+ syRef.current = 1;
259
+ svyRef.current = 0;
260
+ styRef.current = 1;
261
+ phaseRef.current = IDLE;
262
+ lastRef.current = null;
263
+ commit();
264
+ }, [getTabRect, commit]);
265
+
266
+ // Warm the geometry cache before the first moveTo and on tab-count change.
267
+ useLayoutEffect(() => {
268
+ measureTabs();
269
+ }, [tabs, measureTabs]);
270
+
271
+ // Re-measure and re-snap whenever the floating/elevated state flips. Offset
272
+ // geometry is final at commit time regardless of the in-flight `layout`
273
+ // transition, so a plain snap here lands on the correct width; the host also
274
+ // calls remeasureAndSnap() on onLayoutAnimationComplete to clean up drift.
275
+ useLayoutEffect(() => {
276
+ measureTabs();
277
+ snapToSelected();
278
+ }, [elevated, isEmbedded, measureTabs, snapToSelected]);
279
+
280
+ useLayoutEffect(() => {
281
+ moveTo(selected);
282
+ }, [selected, moveTo]);
283
+
284
+ // Re-snaps when tab geometry ACTUALLY changes. Incidental reflows (a sibling
285
+ // hovering, a scrollbar toggling, a height-only change) fire the observer
286
+ // too; the guard prevents those from cancelling the animation.
287
+ useEffect(() => {
288
+ const el = containerRef.current;
289
+ if (!el) return;
290
+ const ro = new ResizeObserver(() => {
291
+ const prevRect = readyRef.current
292
+ ? getTabRect(selectedRef.current)
293
+ : null;
294
+ measureTabs();
295
+ if (!readyRef.current) return;
296
+ const rect = getTabRect(selectedRef.current);
297
+ if (!rect) return;
298
+
299
+ if (prevRect && prevRect.x === rect.x && prevRect.width === rect.width) {
300
+ return;
301
+ }
302
+
303
+ snapToSelected();
304
+ });
305
+ ro.observe(el);
306
+ return () => ro.disconnect();
307
+ }, [getTabRect, measureTabs, snapToSelected]);
308
+
309
+ useEffect(
310
+ () => () => {
311
+ if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);
312
+ },
313
+ [],
314
+ );
315
+
316
+ // Touch drag: grab the indicator, follow the finger within the tab bounds,
317
+ // then on release snap to the nearest tab (velocity carries into the spring).
318
+ useEffect(() => {
319
+ const el = containerRef.current;
320
+ if (!el) return;
321
+
322
+ type DragState = {
323
+ startX: number;
324
+ startPx: number;
325
+ lastX: number;
326
+ lastT: number;
327
+ velX: number;
328
+ active: boolean;
329
+ };
330
+ let drag: DragState | null = null;
331
+
332
+ const onTouchStart = (e: TouchEvent) => {
333
+ if (e.touches.length !== 1) return;
334
+ const touch = e.touches[0];
335
+ const ind = indicatorRef.current;
336
+ if (!ind) return;
337
+ const r = ind.getBoundingClientRect();
338
+ if (
339
+ touch.clientX < r.left ||
340
+ touch.clientX > r.right ||
341
+ touch.clientY < r.top ||
342
+ touch.clientY > r.bottom
343
+ )
344
+ return;
345
+ if (rafRef.current !== null) {
346
+ cancelAnimationFrame(rafRef.current);
347
+ rafRef.current = null;
348
+ lastRef.current = null;
349
+ }
350
+ drag = {
351
+ startX: touch.clientX,
352
+ startPx: pxRef.current,
353
+ lastX: touch.clientX,
354
+ lastT: e.timeStamp,
355
+ velX: 0,
356
+ active: false,
357
+ };
358
+ };
359
+
360
+ const onTouchMove = (e: TouchEvent) => {
361
+ if (!drag || e.touches.length !== 1) return;
362
+ const touch = e.touches[0];
363
+ const dx = touch.clientX - drag.startX;
364
+ if (!drag.active) {
365
+ if (Math.abs(dx) < 6) return;
366
+ drag.active = true;
367
+ }
368
+ e.preventDefault();
369
+
370
+ const now = e.timeStamp;
371
+ const dt = now - drag.lastT;
372
+ if (dt > 0) {
373
+ const raw = ((touch.clientX - drag.lastX) / dt) * 1000;
374
+ drag.velX = drag.velX * 0.6 + raw * 0.4;
375
+ }
376
+ drag.lastX = touch.clientX;
377
+ drag.lastT = now;
378
+
379
+ const currentTabs = tabsRef.current;
380
+ const firstRect = getTabRect(0);
381
+ const lastRect = getTabRect(currentTabs.length - 1);
382
+ const minX = firstRect ? firstRect.x : 0;
383
+ const maxX = lastRect ? lastRect.x : 0;
384
+
385
+ pxRef.current = Math.max(minX, Math.min(maxX, drag.startPx + dx));
386
+ txRef.current = pxRef.current;
387
+ vxRef.current = 0;
388
+
389
+ const mag = Math.min(Math.abs(drag.velX) / 700, 1);
390
+ if (drag.velX > 2) {
391
+ sxRef.current = 1 - mag * 0.06;
392
+ syRef.current = 1 + mag * SQUASH_Y;
393
+ } else if (drag.velX < -2) {
394
+ sxRef.current = 1 + mag * SQUASH_X;
395
+ syRef.current = 1 - mag * 0.08;
396
+ } else {
397
+ sxRef.current = 1;
398
+ syRef.current = 1;
399
+ }
400
+ commit();
401
+ };
402
+
403
+ const onTouchEnd = () => {
404
+ if (!drag?.active) {
405
+ drag = null;
406
+ return;
407
+ }
408
+ const { velX } = drag;
409
+ drag = null;
410
+
411
+ const currentTabs = tabsRef.current;
412
+ let nearestIndex = selectedRef.current;
413
+ let minDist = Infinity;
414
+ for (let i = 0; i < currentTabs.length; i++) {
415
+ const rect = getTabRect(i);
416
+ if (!rect) continue;
417
+ const dist = Math.abs(pxRef.current - rect.x);
418
+ if (dist < minDist) {
419
+ minDist = dist;
420
+ nearestIndex = i;
421
+ }
422
+ }
423
+
424
+ vxRef.current = velX;
425
+
426
+ if (nearestIndex !== selectedRef.current) {
427
+ setSelectedRef.current(nearestIndex);
428
+ onTabChangeRef.current?.(nearestIndex);
429
+ } else {
430
+ moveTo(nearestIndex);
431
+ }
432
+ };
433
+
434
+ el.addEventListener("touchstart", onTouchStart, { passive: true });
435
+ el.addEventListener("touchmove", onTouchMove, { passive: false });
436
+ el.addEventListener("touchend", onTouchEnd, { passive: true });
437
+ el.addEventListener("touchcancel", onTouchEnd, { passive: true });
438
+ return () => {
439
+ el.removeEventListener("touchstart", onTouchStart);
440
+ el.removeEventListener("touchmove", onTouchMove);
441
+ el.removeEventListener("touchend", onTouchEnd);
442
+ el.removeEventListener("touchcancel", onTouchEnd);
443
+ };
444
+ }, [commit, getTabRect, moveTo]);
445
+
446
+ // Hovering the selected tab brightens the indicator. Imperative rather than a
447
+ // CSS :has(:hover) rule — :has(:hover) forces a document-wide style recalc on
448
+ // every pointer move and flickers under rapid hovering.
449
+ const onTabPointerEnter = useCallback((index: number) => {
450
+ if (index === selectedRef.current && indicatorRef.current) {
451
+ indicatorRef.current.style.filter = "var(--filterBrightness)";
452
+ }
453
+ }, []);
454
+
455
+ const onTabPointerLeave = useCallback(() => {
456
+ if (indicatorRef.current) indicatorRef.current.style.filter = "";
457
+ }, []);
458
+
459
+ // Stable per-index ref callbacks so tabs don't get null-then-set on every
460
+ // render (which inline `(el) => ...` would cause).
461
+ const tabRefCallbacks = useRef<Array<(el: HTMLElement | null) => void>>([]);
462
+ const registerTab = useCallback((index: number) => {
463
+ if (!tabRefCallbacks.current[index]) {
464
+ tabRefCallbacks.current[index] = (el: HTMLElement | null) => {
465
+ tabRefs.current[index] = el;
466
+ };
467
+ }
468
+ return tabRefCallbacks.current[index];
469
+ }, []);
470
+
471
+ const remeasureAndSnap = useCallback(() => {
472
+ measureTabs();
473
+ snapToSelected();
474
+ }, [measureTabs, snapToSelected]);
475
+
476
+ return {
477
+ containerRef,
478
+ indicatorRef,
479
+ registerTab,
480
+ remeasureAndSnap,
481
+ onTabPointerEnter,
482
+ onTabPointerLeave,
483
+ };
484
+ }
@@ -0,0 +1,59 @@
1
+ .headerBody {
2
+ transition: border-radius var(--transition-expressive-slow);
3
+ }
4
+
5
+ .headerContent {
6
+ transition: padding var(--transition-expressive-slow);
7
+ }
8
+
9
+ .logoWrap img {
10
+ transition:
11
+ transform var(--transition-expressive-slow),
12
+ width var(--transition-expressive-slow),
13
+ height var(--transition-expressive-slow),
14
+ margin var(--transition-expressive-slow);
15
+ }
16
+
17
+ .megamenuContent {
18
+ transition:
19
+ opacity var(--trasnition-expressive-color),
20
+ padding var(--transition-expressive-color);
21
+ }
22
+
23
+ .headerMenu {
24
+ display: flex;
25
+ align-items: center;
26
+ justify-content: center;
27
+ }
28
+ .headerItem {
29
+ font-size: var(--font-size-base);
30
+ border: 1px solid transparent;
31
+ display: flex;
32
+
33
+ height: 44px;
34
+ width: fit-content;
35
+
36
+ background: transparent;
37
+ color: var(--md-sys-color-on-secondary-container);
38
+
39
+ padding: 12px 0;
40
+ border-radius: 60px;
41
+ cursor: pointer;
42
+ &:hover {
43
+ background: var(--globalUIBorderCard);
44
+ }
45
+
46
+ will-change: auto;
47
+ transition:
48
+ padding var(--transition-expressive),
49
+ color var(--transition-expressive-color),
50
+ background var(--transition-expressive-color),
51
+ border var(--transition-expressive-color);
52
+ }
53
+
54
+ .headerItem.active {
55
+ background-color: var(--md-sys-color-primary-container);
56
+ color: var(--md-sys-color-on-primary-container);
57
+ border: 1px solid var(--globalUIBorderCard);
58
+ padding: 12px;
59
+ }