@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,503 @@
1
+ "use client";
2
+
3
+ import React, {
4
+ createContext,
5
+ useContext,
6
+ useEffect,
7
+ useRef,
8
+ useState,
9
+ } from "react";
10
+ import Icon from "@/components/tools/icon/icon";
11
+ import Button from "./button";
12
+
13
+ // ---------------- config knobs ----------------
14
+
15
+ const GAP = 4;
16
+ const TRANSITION =
17
+ "all var(--transition-expressive-color), border-radius var(--transition-expressive), padding-inline var(--transition-expressive)";
18
+
19
+ const SIZE_TO_PADDING = {
20
+ xs: 4,
21
+ sm: 6,
22
+ m: 8,
23
+ l: 12,
24
+ xl: 18,
25
+ } as const;
26
+
27
+ // ---------------- types ----------------
28
+
29
+ type Variant =
30
+ | "primary"
31
+ | "secondary"
32
+ | "tertiary"
33
+ | "outlined"
34
+ | "text"
35
+ | "link";
36
+
37
+ type VariantBools = {
38
+ primary?: boolean;
39
+ secondary?: boolean;
40
+ tertiary?: boolean;
41
+ outlined?: boolean;
42
+ text?: boolean;
43
+ link?: boolean;
44
+ };
45
+
46
+ type SizeBools = {
47
+ xs?: boolean;
48
+ sm?: boolean;
49
+ m?: boolean;
50
+ l?: boolean;
51
+ xl?: boolean;
52
+ };
53
+
54
+ type LabelConfig = string | { text: string; hideWhenInactive?: boolean };
55
+
56
+ type GroupContextValue = {
57
+ variant: Variant;
58
+ btnPadding: number;
59
+ isExclusive: boolean;
60
+ springLayout: boolean;
61
+ isActive: (index: number) => boolean;
62
+ onTabClick: (index: number, toggle: boolean | undefined) => void;
63
+ };
64
+
65
+ const GroupContext = createContext<GroupContextValue | null>(null);
66
+
67
+ // ---------------- usePressed hook ----------------
68
+
69
+ function usePressed(minDurationMs = 350) {
70
+ const [pressed, setPressed] = useState(false);
71
+ const pressedAtRef = useRef<number | null>(null);
72
+ const releaseTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
73
+
74
+ useEffect(
75
+ () => () => {
76
+ if (releaseTimerRef.current) clearTimeout(releaseTimerRef.current);
77
+ },
78
+ [],
79
+ );
80
+
81
+ const press = () => {
82
+ if (releaseTimerRef.current) {
83
+ clearTimeout(releaseTimerRef.current);
84
+ releaseTimerRef.current = null;
85
+ }
86
+ pressedAtRef.current = Date.now();
87
+ setPressed(true);
88
+ };
89
+
90
+ const release = () => {
91
+ const heldFor = pressedAtRef.current
92
+ ? Date.now() - pressedAtRef.current
93
+ : minDurationMs;
94
+ const remaining = Math.max(0, minDurationMs - heldFor);
95
+ if (releaseTimerRef.current) clearTimeout(releaseTimerRef.current);
96
+ releaseTimerRef.current = setTimeout(() => setPressed(false), remaining);
97
+ };
98
+
99
+ return { pressed, press, release };
100
+ }
101
+
102
+ function resolveVariant(p: VariantBools): Variant {
103
+ if (p.primary) return "primary";
104
+ if (p.secondary) return "secondary";
105
+ if (p.tertiary) return "tertiary";
106
+ if (p.outlined) return "outlined";
107
+ if (p.text) return "text";
108
+ if (p.link) return "link";
109
+ return "primary";
110
+ }
111
+
112
+ function resolveSize(p: SizeBools): number {
113
+ if (p.xs) return SIZE_TO_PADDING.xs;
114
+ if (p.sm) return SIZE_TO_PADDING.sm;
115
+ if (p.l) return SIZE_TO_PADDING.l;
116
+ if (p.xl) return SIZE_TO_PADDING.xl;
117
+ return SIZE_TO_PADDING.m;
118
+ }
119
+
120
+ // shared style derivation for Tab and CTA
121
+ function deriveStyles(opts: {
122
+ variant: Variant;
123
+ toggle: boolean | undefined;
124
+ isActive: boolean;
125
+ pressed: boolean;
126
+ hasLabel: boolean;
127
+ hideWhenInactive?: boolean;
128
+ square?: boolean;
129
+ circle?: boolean;
130
+ btnPadding: number;
131
+ }) {
132
+ const {
133
+ variant,
134
+ toggle,
135
+ isActive,
136
+ pressed,
137
+ hasLabel,
138
+ hideWhenInactive,
139
+ square,
140
+ circle,
141
+ btnPadding,
142
+ } = opts;
143
+
144
+ // Padding shape selection:
145
+ // - `square` or `circle` force square padding
146
+ // - Buttons with an always-visible label → square
147
+ // - Icon-only OR labels that hide when inactive → pill
148
+ const useSquare = square || circle || (hasLabel && !hideWhenInactive);
149
+
150
+ // Base settled padding (no press)
151
+ // - Square: always btnPadding
152
+ // - Pill: btnPadding when toggle && active, else btnPadding - btnPadding/1.6
153
+ const basePadding = useSquare
154
+ ? btnPadding
155
+ : toggle && isActive
156
+ ? btnPadding
157
+ : btnPadding - btnPadding / 1.6;
158
+
159
+ // Press bounce: always-positive expansion while pressed
160
+ const bounceMag = Math.min(Math.max(btnPadding / 4, 8), 24);
161
+ const paddingInline = basePadding + (pressed ? bounceMag : 0);
162
+
163
+ // Border radius:
164
+ // - `square` → 14 always
165
+ // - `circle` → 36 always
166
+ // - Else: 36 when toggle && active, 14 otherwise
167
+ const borderRadius = square ? 14 : circle ? 36 : toggle && isActive ? 36 : 14;
168
+
169
+ // Variant key:
170
+ // - primary / secondary / tertiary → -bold when active
171
+ // - outlined → secondary-bold when active
172
+ // - text / link → no change when active
173
+ let variantKey: string = variant;
174
+ if (toggle && isActive) {
175
+ if (
176
+ variant === "primary" ||
177
+ variant === "secondary" ||
178
+ variant === "tertiary"
179
+ ) {
180
+ variantKey = `${variant}-bold`;
181
+ } else if (variant === "outlined") {
182
+ variantKey = "secondary-bold";
183
+ }
184
+ }
185
+
186
+ return { paddingInline, borderRadius, variantKey };
187
+ }
188
+
189
+ // ---------------- Tab ----------------
190
+
191
+ type TabProps = {
192
+ default?: boolean;
193
+ systemName?: string;
194
+ label?: LabelConfig;
195
+ toggle?: boolean;
196
+ /** Force border-radius 14 and square padding regardless of active state */
197
+ square?: boolean;
198
+ /** Force border-radius 36 and square padding regardless of active state */
199
+ circle?: boolean;
200
+ onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
201
+ } & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onClick">;
202
+
203
+ type TabInternalProps = TabProps & { _index?: number };
204
+
205
+ function Tab({
206
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
207
+ default: _isDefault,
208
+ systemName,
209
+ label,
210
+ toggle,
211
+ square = false,
212
+ circle = false,
213
+ onClick,
214
+ _index,
215
+ style,
216
+ ...rest
217
+ }: TabInternalProps) {
218
+ const ctx = useContext(GroupContext);
219
+ if (!ctx || _index === undefined) {
220
+ throw new Error("Button.group.Tab must be a direct child of Button.group");
221
+ }
222
+
223
+ const { pressed, press, release } = usePressed();
224
+ const isActive = ctx.isActive(_index);
225
+
226
+ const labelText = typeof label === "string" ? label : label?.text;
227
+ const hideWhenInactive =
228
+ typeof label === "object" ? !!label.hideWhenInactive : false;
229
+ const labelVisible =
230
+ labelText !== undefined && (!hideWhenInactive || isActive);
231
+ const iconLabel = labelVisible ? labelText : undefined;
232
+ const hasLabel = label !== undefined;
233
+
234
+ const { paddingInline, borderRadius, variantKey } = deriveStyles({
235
+ variant: ctx.variant,
236
+ toggle,
237
+ isActive,
238
+ pressed,
239
+ hasLabel,
240
+ hideWhenInactive,
241
+ square,
242
+ circle,
243
+ btnPadding: ctx.btnPadding,
244
+ });
245
+
246
+ const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
247
+ const isAlreadyActiveExclusive =
248
+ ctx.isExclusive && toggle && ctx.isActive(_index);
249
+ ctx.onTabClick(_index, toggle);
250
+ if (!isAlreadyActiveExclusive) onClick?.(e);
251
+ };
252
+
253
+ return (
254
+ <Button
255
+ {...{ [variantKey]: true }}
256
+ onClick={handleClick}
257
+ onPointerDown={press}
258
+ onPointerUp={release}
259
+ onPointerLeave={release}
260
+ onPointerCancel={release}
261
+ style={{
262
+ padding: ctx.btnPadding,
263
+ paddingInline,
264
+ margin: 0,
265
+ borderRadius,
266
+ transition: TRANSITION,
267
+ ...(ctx.springLayout
268
+ ? { flex: "1 1 auto", minWidth: 0, width: "max-content" }
269
+ : {}),
270
+ ...style,
271
+ }}
272
+ {...rest}
273
+ >
274
+ <Icon systemName={systemName} label={iconLabel} />
275
+ </Button>
276
+ );
277
+ }
278
+
279
+ // ---------------- CTA ----------------
280
+
281
+ type CTAProps = {
282
+ label?: string;
283
+ systemName?: string;
284
+ toggle?: boolean;
285
+ square?: boolean;
286
+ circle?: boolean;
287
+ onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
288
+ } & VariantBools &
289
+ Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onClick">;
290
+
291
+ type CTAInternalProps = CTAProps & {
292
+ btnPadding: number;
293
+ springLayout: boolean;
294
+ };
295
+
296
+ function CTAButton({
297
+ label,
298
+ systemName,
299
+ toggle,
300
+ square = false,
301
+ circle = false,
302
+ onClick,
303
+ style,
304
+ primary,
305
+ secondary,
306
+ tertiary,
307
+ outlined,
308
+ text,
309
+ link,
310
+ btnPadding,
311
+ springLayout,
312
+ ...rest
313
+ }: CTAInternalProps) {
314
+ const variant = resolveVariant({
315
+ primary,
316
+ secondary,
317
+ tertiary,
318
+ outlined,
319
+ text,
320
+ link,
321
+ });
322
+
323
+ const [isActive, setIsActive] = useState(false);
324
+ const { pressed, press, release } = usePressed();
325
+
326
+ const hasLabel = label !== undefined;
327
+
328
+ const { paddingInline, borderRadius, variantKey } = deriveStyles({
329
+ variant,
330
+ toggle,
331
+ isActive,
332
+ pressed,
333
+ hasLabel,
334
+ square,
335
+ circle,
336
+ btnPadding,
337
+ });
338
+
339
+ const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
340
+ if (toggle) setIsActive((a) => !a);
341
+ onClick?.(e);
342
+ };
343
+
344
+ return (
345
+ <Button
346
+ {...{ [variantKey]: true }}
347
+ onClick={handleClick}
348
+ onPointerDown={press}
349
+ onPointerUp={release}
350
+ onPointerLeave={release}
351
+ onPointerCancel={release}
352
+ style={{
353
+ padding: btnPadding,
354
+ paddingInline,
355
+ borderRadius,
356
+ margin: 0,
357
+ transition: TRANSITION,
358
+ ...(springLayout ? { flex: "0 0 auto" } : {}),
359
+ ...style,
360
+ }}
361
+ {...rest}
362
+ >
363
+ <Icon systemName={systemName} label={label} />
364
+ </Button>
365
+ );
366
+ }
367
+
368
+ // ---------------- Group ----------------
369
+
370
+ type ButtonGroupProps = {
371
+ children: React.ReactNode;
372
+ /** When true (default), only one tab can be active at a time. */
373
+ exclusive?: boolean;
374
+ /** Inverse of `exclusive`. If both are set, this wins. */
375
+ multiSelect?: boolean;
376
+ cta?: CTAProps;
377
+ /**
378
+ * Fixed width for the group. When set, tabs share the width with `flex: 1 1 auto`
379
+ * — pressing one tab visibly squeezes its siblings (spring effect).
380
+ * When unset, the group sits at `max-content` (no spring, natural sizes).
381
+ */
382
+ width?: number | string | "fullWidth";
383
+ } & VariantBools &
384
+ SizeBools;
385
+
386
+ function ButtonGroup({
387
+ children,
388
+ exclusive = true,
389
+ multiSelect,
390
+ cta,
391
+ width,
392
+ // size bools
393
+ xs,
394
+ sm,
395
+ m,
396
+ l,
397
+ xl,
398
+ // variant bools
399
+ ...variantBools
400
+ }: ButtonGroupProps) {
401
+ const isExclusive = multiSelect !== undefined ? !multiSelect : exclusive;
402
+ const variant = resolveVariant(variantBools);
403
+ const btnPadding = resolveSize({ xs, sm, m, l, xl });
404
+ const springLayout = width !== undefined;
405
+
406
+ const tabs = React.Children.toArray(children).filter(React.isValidElement);
407
+
408
+ const [activeIndices, setActiveIndices] = useState<Set<number>>(() => {
409
+ const defaults = new Set<number>();
410
+ tabs.forEach((child, idx) => {
411
+ const props = (child as React.ReactElement<TabProps>).props;
412
+ if (props.default) {
413
+ if (isExclusive && defaults.size > 0) return;
414
+ defaults.add(idx);
415
+ }
416
+ });
417
+ return defaults;
418
+ });
419
+
420
+ const handleTabClick = (index: number, toggle: boolean | undefined) => {
421
+ if (!toggle) return;
422
+
423
+ const next = new Set(activeIndices);
424
+ const wasActive = next.has(index);
425
+
426
+ // In exclusive mode, can't deactivate the currently-active tab by clicking it
427
+ if (wasActive && isExclusive) return;
428
+
429
+ if (wasActive) {
430
+ next.delete(index);
431
+ } else {
432
+ if (isExclusive) next.clear();
433
+ next.add(index);
434
+ }
435
+ setActiveIndices(next);
436
+ };
437
+
438
+ const ctxValue: GroupContextValue = {
439
+ variant,
440
+ btnPadding,
441
+ isExclusive,
442
+ springLayout,
443
+ isActive: (i) => activeIndices.has(i),
444
+ onTabClick: handleTabClick,
445
+ };
446
+
447
+ const bounceMag = Math.min(Math.max(btnPadding / 4, 8), 24);
448
+
449
+ const computedMaxWidth =
450
+ width !== undefined ? `${Number(width) + bounceMag * 0}px` : "100%";
451
+
452
+ return (
453
+ <GroupContext.Provider value={ctxValue}>
454
+ <div
455
+ style={{
456
+ display: "flex",
457
+ flexDirection: "row",
458
+ alignItems: "center",
459
+ justifyContent: "center",
460
+ overflow: "hidden",
461
+ overflowX: "auto",
462
+ width: width
463
+ ? computedMaxWidth
464
+ : width == "fullWidth"
465
+ ? "100%"
466
+ : "max-content",
467
+ maxWidth: computedMaxWidth,
468
+ gap: `${GAP * 2}px`,
469
+ }}
470
+ >
471
+ <div
472
+ style={{
473
+ display: "flex",
474
+ flexDirection: "row",
475
+ overflow: "hidden",
476
+ overflowX: "auto",
477
+ flex: springLayout || width == "fullWidth" ? "1 1 auto" : undefined,
478
+ minWidth: 0,
479
+ gap: `${GAP}px`,
480
+ }}
481
+ >
482
+ {tabs.map((tab, index) =>
483
+ React.cloneElement(tab as React.ReactElement<TabInternalProps>, {
484
+ _index: index,
485
+ key: index,
486
+ }),
487
+ )}
488
+ </div>
489
+ {cta && (
490
+ <CTAButton
491
+ {...cta}
492
+ btnPadding={btnPadding}
493
+ springLayout={springLayout}
494
+ />
495
+ )}
496
+ </div>
497
+ </GroupContext.Provider>
498
+ );
499
+ }
500
+
501
+ ButtonGroup.Tab = Tab;
502
+
503
+ export default ButtonGroup;
@@ -0,0 +1,118 @@
1
+ "use client";
2
+
3
+ import React, { useRef } from "react";
4
+ import styles from "./Button.module.css";
5
+ import Ripple, { RippleHandle } from "@/components/tools/ripple/ripple";
6
+ import Icon from "@/components/tools/icon/icon";
7
+
8
+ type FABProps = Omit<
9
+ React.ButtonHTMLAttributes<HTMLButtonElement>,
10
+ "children"
11
+ > & {
12
+ // color booleans — first truthy one wins; defaults to "primary"
13
+ primary?: boolean;
14
+ "primary-bold"?: boolean;
15
+ secondary?: boolean;
16
+ "secondary-bold"?: boolean;
17
+ tertiary?: boolean;
18
+ "tertiary-bold"?: boolean;
19
+ // size booleans — first truthy one wins; defaults to "m"
20
+ xs?: boolean;
21
+ sm?: boolean;
22
+ l?: boolean;
23
+ xl?: boolean;
24
+ elevated?: boolean;
25
+ loading?: boolean;
26
+ rippleColor?: string;
27
+ systemName: string;
28
+ label?: string;
29
+ scaleOff?: boolean;
30
+ };
31
+
32
+ const FAB = React.forwardRef<HTMLButtonElement, FABProps>(
33
+ (
34
+ {
35
+ "primary-bold": primaryBold,
36
+ primary,
37
+ "secondary-bold": secondaryBold,
38
+ secondary,
39
+ "tertiary-bold": tertiaryBold,
40
+ tertiary,
41
+ xs,
42
+ sm,
43
+ l,
44
+ xl,
45
+ elevated = false,
46
+ loading = false,
47
+ disabled,
48
+ onClick,
49
+ systemName,
50
+ label,
51
+ rippleColor,
52
+ scaleOff,
53
+ ...rest
54
+ },
55
+ ref,
56
+ ) => {
57
+ const variant = primaryBold
58
+ ? "primary-bold"
59
+ : primary
60
+ ? "primary"
61
+ : secondaryBold
62
+ ? "secondary-bold"
63
+ : secondary
64
+ ? "secondary"
65
+ : tertiaryBold
66
+ ? "tertiary-bold"
67
+ : tertiary
68
+ ? "tertiary"
69
+ : "primary";
70
+
71
+ const sizeClass = xs
72
+ ? "fabXs"
73
+ : sm
74
+ ? "fabSm"
75
+ : l
76
+ ? "fabL"
77
+ : xl
78
+ ? "fabXl"
79
+ : "fabM";
80
+
81
+ const rippleRef = useRef<RippleHandle>(null);
82
+
83
+ const isDisabled = disabled || loading;
84
+
85
+ const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
86
+ if (!isDisabled) {
87
+ rippleRef.current?.triggerRipple(e);
88
+ onClick?.(e);
89
+ }
90
+ };
91
+
92
+ return (
93
+ <button
94
+ ref={ref}
95
+ disabled={isDisabled}
96
+ className={`${styles[variant]} ${styles.fab} ${styles[sizeClass]} ${scaleOff && styles.scaleOff}`}
97
+ onClick={handleClick}
98
+ {...rest}
99
+ style={
100
+ elevated && !isDisabled
101
+ ? {
102
+ boxShadow:
103
+ "0 1px 1px rgba(0, 0, 0, 0.1), 0 2px 2px rgba(0, 0, 0, 0.1), 0 4px 4px rgba(0, 0, 0, 0.1), 0 6px 6px rgba(0, 0, 0, 0.1)",
104
+ ...rest.style,
105
+ }
106
+ : rest.style
107
+ }
108
+ >
109
+ <Icon systemName={systemName} label={label} />
110
+ <Ripple ref={rippleRef} rippleColor={rippleColor} />
111
+ </button>
112
+ );
113
+ },
114
+ );
115
+
116
+ FAB.displayName = "FAB";
117
+
118
+ export default FAB;