@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,412 @@
1
+ import React, {
2
+ useState,
3
+ useEffect,
4
+ Children,
5
+ useRef,
6
+ HTMLAttributes,
7
+ ReactNode,
8
+ JSX,
9
+ } from "react";
10
+ import { motion, AnimatePresence, Variants } from "framer-motion";
11
+
12
+ import "./Stepper.css";
13
+ import Button from "../../../layout/button/button";
14
+ import Icon from "../../icon/icon";
15
+ import FadeContent from "../FadeContent";
16
+
17
+ interface StepperProps extends HTMLAttributes<HTMLDivElement> {
18
+ children: ReactNode;
19
+ initialStep?: number;
20
+ onStepChange?: (step: number) => void;
21
+ onFinalStepCompleted?: () => void;
22
+ stepCircleContainerClassName?: string;
23
+ stepContainerClassName?: string;
24
+ contentClassName?: string;
25
+ footerClassName?: string;
26
+ backButtonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;
27
+ nextButtonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;
28
+ backButtonText?: string;
29
+ nextButtonText?: string;
30
+ nextButtonIcon?: string;
31
+ lastNextButtonIcon?: string;
32
+ lastNextButtonText?: string;
33
+ disableStepIndicators?: boolean;
34
+ renderStepIndicator?: (props: RenderStepIndicatorProps) => ReactNode;
35
+ }
36
+
37
+ interface RenderStepIndicatorProps {
38
+ step: number;
39
+ currentStep: number;
40
+ onStepClick: (clicked: number) => void;
41
+ }
42
+
43
+ export default function Stepper({
44
+ children,
45
+ initialStep = 1,
46
+ onStepChange = () => {},
47
+ onFinalStepCompleted = () => {},
48
+ stepCircleContainerClassName = "",
49
+ stepContainerClassName = "",
50
+ contentClassName = "",
51
+ footerClassName = "",
52
+ backButtonProps = {},
53
+ nextButtonProps = {},
54
+ backButtonText = "Back",
55
+ nextButtonText = "Continue",
56
+ disableStepIndicators = false,
57
+ renderStepIndicator,
58
+ nextButtonIcon = "keyboard_arrow_right",
59
+ lastNextButtonText = "Complete",
60
+ lastNextButtonIcon = "send",
61
+ ...rest
62
+ }: StepperProps) {
63
+ const [currentStep, setCurrentStep] = useState<number>(initialStep);
64
+ const [direction, setDirection] = useState<number>(0);
65
+ const stepsArray = Children.toArray(children);
66
+ const totalSteps = stepsArray.length;
67
+ const isCompleted = currentStep > totalSteps;
68
+ const isLastStep = currentStep === totalSteps;
69
+
70
+ const updateStep = (newStep: number) => {
71
+ setCurrentStep(newStep);
72
+ if (newStep > totalSteps) {
73
+ onFinalStepCompleted();
74
+ } else {
75
+ onStepChange(newStep);
76
+ }
77
+ };
78
+
79
+ const handleBack = () => {
80
+ if (currentStep > 1) {
81
+ setDirection(-1);
82
+ updateStep(currentStep - 1);
83
+ }
84
+ };
85
+
86
+ const handleNext = () => {
87
+ if (!isLastStep) {
88
+ setDirection(1);
89
+ updateStep(currentStep + 1);
90
+ }
91
+ };
92
+
93
+ const handleComplete = () => {
94
+ setDirection(1);
95
+ updateStep(totalSteps + 1);
96
+ };
97
+
98
+ return (
99
+ <FadeContent
100
+ blur={true}
101
+ duration={500}
102
+ easing="ease-out"
103
+ initialOpacity={0}
104
+ >
105
+ <div className="outer-container" {...rest}>
106
+ <div
107
+ className={`step-circle-container elevated${stepCircleContainerClassName}`}
108
+ >
109
+ <div className={`step-indicator-row ${stepContainerClassName}`}>
110
+ {stepsArray.map((_, index) => {
111
+ const stepNumber = index + 1;
112
+ const isNotLastStep = index < totalSteps - 1;
113
+ return (
114
+ <React.Fragment key={stepNumber}>
115
+ {renderStepIndicator ? (
116
+ renderStepIndicator({
117
+ step: stepNumber,
118
+ currentStep,
119
+ onStepClick: (clicked) => {
120
+ setDirection(clicked > currentStep ? 1 : -1);
121
+ updateStep(clicked);
122
+ },
123
+ })
124
+ ) : (
125
+ <StepIndicator
126
+ step={stepNumber}
127
+ disableStepIndicators={disableStepIndicators}
128
+ currentStep={currentStep}
129
+ onClickStep={(clicked) => {
130
+ setDirection(clicked > currentStep ? 1 : -1);
131
+ updateStep(clicked);
132
+ }}
133
+ />
134
+ )}
135
+ {isNotLastStep && (
136
+ <StepConnector isComplete={currentStep > stepNumber} />
137
+ )}
138
+ </React.Fragment>
139
+ );
140
+ })}
141
+ </div>
142
+
143
+ <StepContentWrapper
144
+ isCompleted={isCompleted}
145
+ currentStep={currentStep}
146
+ direction={direction}
147
+ className={`step-content-default ${contentClassName}`}
148
+ >
149
+ {stepsArray[currentStep - 1]}
150
+ </StepContentWrapper>
151
+ {!isCompleted && (
152
+ <div className={`footer-container ${footerClassName}`}>
153
+ <div
154
+ className={`footer-nav ${currentStep !== 1 ? "spread" : "end"}`}
155
+ >
156
+ {currentStep !== 1 && (
157
+ <Button
158
+ id={""}
159
+ text
160
+ className="back-button"
161
+ onClick={() => handleBack()}
162
+ {...backButtonProps}
163
+ >
164
+ {backButtonText}
165
+ </Button>
166
+ )}
167
+ <Button
168
+ id={""}
169
+ primary
170
+ className="next-button"
171
+ onClick={isLastStep ? handleComplete : handleNext}
172
+ {...nextButtonProps}
173
+ >
174
+ <Icon
175
+ systemName={
176
+ isLastStep ? lastNextButtonIcon : nextButtonIcon
177
+ }
178
+ label={isLastStep ? lastNextButtonText : nextButtonText}
179
+ />
180
+ </Button>
181
+ </div>
182
+ </div>
183
+ )}
184
+ </div>
185
+ </div>
186
+ </FadeContent>
187
+ );
188
+ }
189
+
190
+ interface StepContentWrapperProps {
191
+ isCompleted: boolean;
192
+ currentStep: number;
193
+ direction: number;
194
+ children: ReactNode;
195
+ className?: string;
196
+ }
197
+
198
+ function StepContentWrapper({
199
+ isCompleted,
200
+ currentStep,
201
+ direction,
202
+ children,
203
+ className,
204
+ }: StepContentWrapperProps) {
205
+ const [parentHeight, setParentHeight] = useState<number>(0);
206
+
207
+ return (
208
+ <motion.div
209
+ className={className}
210
+ style={{ position: "relative", overflow: "hidden" }}
211
+ animate={{ height: isCompleted ? 0 : parentHeight }}
212
+ transition={{ type: "spring", duration: 0.4 }}
213
+ >
214
+ <AnimatePresence initial={false} mode="sync" custom={direction}>
215
+ {!isCompleted && (
216
+ <SlideTransition
217
+ key={currentStep}
218
+ direction={direction}
219
+ onHeightReady={(h) => setParentHeight(h)}
220
+ >
221
+ {children}
222
+ </SlideTransition>
223
+ )}
224
+ </AnimatePresence>
225
+ </motion.div>
226
+ );
227
+ }
228
+
229
+ interface SlideTransitionProps {
230
+ children: ReactNode;
231
+ direction: number;
232
+ onHeightReady: (h: number) => void;
233
+ }
234
+
235
+ function SlideTransition({
236
+ children,
237
+ direction,
238
+ onHeightReady,
239
+ }: SlideTransitionProps) {
240
+ const containerRef = useRef<HTMLDivElement | null>(null);
241
+
242
+ useEffect(() => {
243
+ const el = containerRef.current;
244
+ if (!el) return;
245
+ const ro = new ResizeObserver((entries) => {
246
+ const h = entries[0]?.contentRect.height;
247
+ if (h !== undefined) onHeightReady(h);
248
+ });
249
+ ro.observe(el);
250
+ return () => ro.disconnect();
251
+ }, [onHeightReady]);
252
+
253
+ return (
254
+ <motion.div
255
+ ref={containerRef}
256
+ custom={direction}
257
+ variants={stepVariants}
258
+ initial="enter"
259
+ animate="center"
260
+ exit="exit"
261
+ transition={{ duration: 0.4 }}
262
+ style={{ position: "absolute", left: 0, right: 0, top: 0 }}
263
+ >
264
+ {children}
265
+ </motion.div>
266
+ );
267
+ }
268
+
269
+ const stepVariants: Variants = {
270
+ enter: (dir: number) => ({
271
+ x: dir >= 0 ? "100%" : "-100%", // <-- Slide in from right if going forward, from left if going back
272
+ opacity: 0,
273
+ }),
274
+ center: {
275
+ x: "0%",
276
+ opacity: 1,
277
+ },
278
+ exit: (dir: number) => ({
279
+ x: dir >= 0 ? "-50%" : "50%", // <-- Slide out to left if going forward, to right if going back
280
+ opacity: 0,
281
+ }),
282
+ };
283
+
284
+ interface StepProps {
285
+ children: ReactNode;
286
+ }
287
+
288
+ export function Step({ children }: StepProps): JSX.Element {
289
+ return <div className="step-default">{children}</div>;
290
+ }
291
+
292
+ interface StepIndicatorProps {
293
+ step: number;
294
+ currentStep: number;
295
+ onClickStep: (step: number) => void;
296
+ disableStepIndicators?: boolean;
297
+ }
298
+
299
+ function StepIndicator({
300
+ step,
301
+ currentStep,
302
+ onClickStep,
303
+ disableStepIndicators,
304
+ }: StepIndicatorProps) {
305
+ const status =
306
+ currentStep === step
307
+ ? "active"
308
+ : currentStep < step
309
+ ? "inactive"
310
+ : "complete";
311
+
312
+ const handleClick = () => {
313
+ if (step !== currentStep && !disableStepIndicators) {
314
+ onClickStep(step);
315
+ }
316
+ };
317
+
318
+ return (
319
+ <motion.div
320
+ onClick={handleClick}
321
+ className="step-indicator"
322
+ animate={status}
323
+ initial={false}
324
+ >
325
+ <motion.div
326
+ variants={{
327
+ inactive: {
328
+ scale: 1,
329
+ backgroundColor: "var(--md-sys-color-surface-container-highest)",
330
+ color: "var(--md-sys-color-on-surface)",
331
+ },
332
+ active: {
333
+ scale: 1,
334
+ backgroundColor: "var(--md-sys-color-primary)",
335
+ color: "var(--md-sys-color-on-primary)",
336
+ },
337
+ complete: {
338
+ scale: 1,
339
+ backgroundColor: "var(--md-sys-color-primary)",
340
+ color: "var(--md-sys-color-on-primary)",
341
+ },
342
+ }}
343
+ transition={{ duration: 0.3 }}
344
+ className="step-indicator-inner"
345
+ >
346
+ {status === "complete" ? (
347
+ <CheckIcon className="check-icon" />
348
+ ) : status === "active" ? (
349
+ <div className="active-dot" />
350
+ ) : (
351
+ <span className="step-number">{step}</span>
352
+ )}
353
+ </motion.div>
354
+ </motion.div>
355
+ );
356
+ }
357
+
358
+ interface StepConnectorProps {
359
+ isComplete: boolean;
360
+ }
361
+
362
+ function StepConnector({ isComplete }: StepConnectorProps) {
363
+ const lineVariants: Variants = {
364
+ incomplete: { width: 0, backgroundColor: "transparent" },
365
+ complete: { width: "100%", backgroundColor: "var(--md-sys-color-primary)" },
366
+ };
367
+
368
+ return (
369
+ <div
370
+ className="step-connector"
371
+ style={{
372
+ backgroundColor: "var(--md-sys-color-surface-container-highest)",
373
+ }}
374
+ >
375
+ <motion.div
376
+ className="step-connector-inner"
377
+ variants={lineVariants}
378
+ initial={false}
379
+ animate={isComplete ? "complete" : "incomplete"}
380
+ transition={{ duration: 0.4 }}
381
+ />
382
+ </div>
383
+ );
384
+ }
385
+
386
+ type CheckIconProps = React.SVGProps<SVGSVGElement>;
387
+
388
+ function CheckIcon(props: CheckIconProps) {
389
+ return (
390
+ <svg
391
+ {...props}
392
+ fill="none"
393
+ stroke="currentColor"
394
+ strokeWidth={2}
395
+ viewBox="0 0 24 24"
396
+ >
397
+ <motion.path
398
+ initial={{ pathLength: 0 }}
399
+ animate={{ pathLength: 1 }}
400
+ transition={{
401
+ delay: 0.1,
402
+ type: "tween",
403
+ ease: "easeOut",
404
+ duration: 0.3,
405
+ }}
406
+ strokeLinecap="round"
407
+ strokeLinejoin="round"
408
+ d="M5 13l4 4L19 7"
409
+ />
410
+ </svg>
411
+ );
412
+ }
@@ -0,0 +1,41 @@
1
+ .ripple-container {
2
+ position: absolute;
3
+ top: 0;
4
+ left: 0;
5
+ right: 0;
6
+ bottom: 0;
7
+ border-radius: inherit;
8
+
9
+ z-index: inherit;
10
+ overflow: hidden;
11
+ display: inline-block;
12
+ width: 100%;
13
+ height: 100%;
14
+ pointer-events: none; /* so it doesn’t block clicks */
15
+ }
16
+
17
+ .ripple {
18
+ opacity: 0.5;
19
+ inset: 0;
20
+ position: absolute;
21
+ border-radius: 50%;
22
+ background-color: var(--rippleColor, currentColor);
23
+
24
+ filter: blur(4px);
25
+ -webkit-filter: blur(4px);
26
+ transform: scale(0);
27
+ animation: ripple-animation 700ms linear;
28
+ pointer-events: none;
29
+ will-change: transform, opacity;
30
+ }
31
+
32
+ @keyframes ripple-animation {
33
+ to {
34
+ transform: scale(4);
35
+ opacity: 0;
36
+ }
37
+ }
38
+
39
+ [data-reduce-motion="true"] .ripple {
40
+ animation-duration: 1ms;
41
+ }
@@ -0,0 +1,53 @@
1
+ "use client";
2
+
3
+ import React, { forwardRef, useImperativeHandle, useRef } from "react";
4
+ import "./ripple.css";
5
+
6
+ export interface RippleHandle {
7
+ triggerRipple: (e: React.MouseEvent) => void;
8
+ }
9
+
10
+ interface RippleProps {
11
+ rippleColor?: string;
12
+ }
13
+
14
+ const Ripple = forwardRef<RippleHandle, RippleProps>(({ rippleColor }, ref) => {
15
+ const containerRef = useRef<HTMLDivElement>(null);
16
+ const rippleColorRef = useRef(rippleColor);
17
+ rippleColorRef.current = rippleColor;
18
+
19
+ useImperativeHandle(ref, () => ({
20
+ triggerRipple(e) {
21
+ const container = containerRef.current;
22
+ if (!container) return;
23
+
24
+ const circle = document.createElement("span");
25
+ circle.className = "ripple";
26
+
27
+ if (rippleColorRef.current) {
28
+ circle.style.setProperty("--rippleColor", rippleColorRef.current);
29
+ }
30
+
31
+ const rect = container.getBoundingClientRect();
32
+ const size = Math.max(rect.width, rect.height);
33
+ const x = e.clientX - rect.left - size / 2;
34
+ const y = e.clientY - rect.top - size / 2;
35
+
36
+ circle.style.width = circle.style.height = `${size}px`;
37
+ circle.style.left = `${x}px`;
38
+ circle.style.top = `${y}px`;
39
+
40
+ container.appendChild(circle);
41
+
42
+ circle.addEventListener("animationend", () => {
43
+ circle.remove();
44
+ });
45
+ },
46
+ }));
47
+
48
+ return <div ref={containerRef} className="ripple-container" />;
49
+ });
50
+
51
+ Ripple.displayName = "Ripple";
52
+
53
+ export default Ripple;
@@ -0,0 +1,101 @@
1
+ "use client";
2
+ import React, { useState, useEffect, useRef, useMemo } from "react";
3
+ import { motion, useAnimationControls } from "framer-motion";
4
+ import dynamic from "next/dynamic";
5
+ const ShapeMorph = dynamic(() => import("./ShapeMorph"), { ssr: false });
6
+ import type { ShapeType } from "./ShapePaths";
7
+
8
+ // Defined outside — stable reference, never reallocated.
9
+ const SHAPE_SEQUENCE: ShapeType[] = [
10
+ "12-sided-cookie",
11
+ "9-sided-cookie",
12
+ "square",
13
+ "oval",
14
+ "sunny",
15
+ "4-sided-cookie",
16
+ "flower",
17
+ "very-sunny",
18
+ ];
19
+
20
+ const MOTION_DIV_STYLE: React.CSSProperties = {
21
+ display: "flex",
22
+ alignItems: "center",
23
+ justifyContent: "center",
24
+ };
25
+
26
+ export default function ShapeOrchestrator({
27
+ withBackground = false,
28
+ variant = "primary",
29
+ scale = 1,
30
+ }: {
31
+ withBackground?: boolean;
32
+ variant?: "primary" | "secondary" | "tertiary";
33
+ scale?: number;
34
+ }) {
35
+ const [index, setIndex] = useState(0);
36
+ const scaleControls = useAnimationControls();
37
+
38
+ // Guard against calling controls.start() before the motion.div has
39
+ // attached to the DOM. Framer Motion v12 warns (isMounted === false)
40
+ // if start() is invoked before the motion component's own mount effect
41
+ // has run, which can happen in Strict Mode's double-invoke cycle.
42
+ const isMountedRef = useRef(false);
43
+
44
+ useEffect(() => {
45
+ isMountedRef.current = true;
46
+ return () => {
47
+ isMountedRef.current = false;
48
+ };
49
+ }, []);
50
+
51
+ useEffect(() => {
52
+ const interval = setInterval(() => {
53
+ setIndex((prev) => (prev + 1) % SHAPE_SEQUENCE.length);
54
+ if (isMountedRef.current) {
55
+ scaleControls.start({
56
+ scale: [1, 1.06, 0.94, 1],
57
+ transition: { duration: 0.6, ease: "linear" },
58
+ });
59
+ }
60
+ }, 600);
61
+
62
+ return () => clearInterval(interval);
63
+ }, [scaleControls]);
64
+
65
+ // Memoised so the object reference is stable across renders that don't
66
+ // change withBackground, variant, or scale.
67
+ const wrapperStyle = useMemo<React.CSSProperties>(
68
+ () => ({
69
+ width: "fit-content",
70
+ height: "fit-content",
71
+ padding: "8px",
72
+ borderRadius: "50%",
73
+ display: "flex",
74
+ alignItems: "center",
75
+ scale,
76
+ justifyContent: "center",
77
+ backgroundColor: withBackground
78
+ ? `var(--md-sys-color-${variant}-container)`
79
+ : "transparent",
80
+ }),
81
+ [withBackground, variant, scale],
82
+ );
83
+
84
+ return (
85
+ <div className="a11y-shape-loader" style={wrapperStyle}>
86
+ <motion.div
87
+ animate={scaleControls}
88
+ initial={{ scale: 1 }}
89
+ style={MOTION_DIV_STYLE}
90
+ >
91
+ <ShapeMorph
92
+ shape={SHAPE_SEQUENCE[index]}
93
+ size={84}
94
+ color={`var(--md-sys-color-${variant})`}
95
+ duration={0.6}
96
+ swapRotation={45}
97
+ />
98
+ </motion.div>
99
+ </div>
100
+ );
101
+ }