@yamatozhen/design_system 1.0.1 → 1.1.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 (184) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +101 -101
  3. package/package.json +50 -50
  4. package/scripts/postinstall.js +91 -91
  5. package/template/app/ClientNav.tsx +258 -310
  6. package/template/app/globals.css +2 -167
  7. package/template/app/layout.tsx +94 -82
  8. package/template/app/themes/dark-mc 2.css +51 -0
  9. package/template/app/themes/dark-mc.css +51 -51
  10. package/template/app/themes/dark.css +51 -51
  11. package/template/app/themes/light 2.css +51 -0
  12. package/template/app/themes/light-mc 2.css +51 -0
  13. package/template/app/themes/light-mc.css +51 -51
  14. package/template/app/themes/light.css +51 -51
  15. package/template/app/themes/theme 2.css +272 -0
  16. package/template/app/themes/theme.css +272 -82
  17. package/template/components/{layout/button → (buttons)}/Button.module.css +351 -305
  18. package/template/components/{layout/button → (buttons)}/ButtonGroup.tsx +414 -503
  19. package/template/components/{layout/button → (buttons)}/FAB.tsx +119 -118
  20. package/template/components/(buttons)/button.tsx +164 -0
  21. package/template/components/(controls)/slider/Slider.module.css +250 -0
  22. package/template/components/(controls)/slider/Slider.tsx +386 -0
  23. package/template/components/(controls)/switch/Switch.module.css +108 -0
  24. package/template/components/(controls)/switch/Switch.tsx +69 -0
  25. package/template/components/(date & time)/calendar/Calendar.module.css +125 -0
  26. package/template/components/(date & time)/calendar/Calendar.tsx +206 -0
  27. package/template/components/(date & time)/dateField/DateField.module.css +25 -0
  28. package/template/components/(date & time)/dateField/DateField.tsx +193 -0
  29. package/template/components/(date & time)/datePicker/DatePicker.tsx +118 -0
  30. package/template/components/(date & time)/dateRangePicker/DateRangePicker.tsx +144 -0
  31. package/template/components/(date & time)/rangeCalendar/RangeCalendar.module.css +203 -0
  32. package/template/components/(date & time)/rangeCalendar/RangeCalendar.tsx +263 -0
  33. package/template/components/(date & time)/shared/dateUtils.ts +107 -0
  34. package/template/components/(date & time)/timeField/TimeField.module.css +39 -0
  35. package/template/components/(date & time)/timeField/TimeField.tsx +158 -0
  36. package/template/components/(feedback)/circularProgress/CircularProgress.tsx +646 -0
  37. package/template/components/(feedback)/linearProgress/LinearProgress.tsx +337 -0
  38. package/template/components/(feedback)/meter/Meter.tsx +111 -0
  39. package/template/components/(feedback)/skeleton/Skeleton.module.css +49 -0
  40. package/template/components/(feedback)/skeleton/Skeleton.tsx +32 -0
  41. package/template/components/(feedback)/spinner/Spinner.module.css +27 -0
  42. package/template/components/(feedback)/spinner/Spinner.tsx +60 -0
  43. package/template/components/(forms)/checkbox/Checkbox.tsx +121 -0
  44. package/template/components/(forms)/checkboxGroup/CheckboxGroup.tsx +83 -0
  45. package/template/components/(forms)/description/Description.tsx +34 -0
  46. package/template/components/(forms)/errorMessage/ErrorMessage.tsx +31 -0
  47. package/template/components/(forms)/fieldError/FieldError.tsx +39 -0
  48. package/template/components/(forms)/fieldset/Fieldset.tsx +51 -0
  49. package/template/components/(forms)/form/Form.tsx +54 -0
  50. package/template/components/(forms)/input/Input.tsx +50 -0
  51. package/template/components/(forms)/inputGroup/InputGroup.tsx +65 -0
  52. package/template/components/(forms)/inputOtp/InputOtp.tsx +139 -0
  53. package/template/components/(forms)/label/Label.tsx +46 -0
  54. package/template/components/(forms)/numberField/NumberField.tsx +292 -0
  55. package/template/components/(forms)/radioGroup/RadioGroup.tsx +175 -0
  56. package/template/components/(forms)/searchField/SearchField.tsx +139 -0
  57. package/template/components/(forms)/shared/field.module.css +75 -0
  58. package/template/components/(forms)/shared/fieldContext.ts +28 -0
  59. package/template/components/(forms)/textArea/TextArea.tsx +55 -0
  60. package/template/components/(forms)/textField/TextField.tsx +91 -0
  61. package/template/components/{layout → (layout)}/Lightbox/LightboxCard.tsx +100 -100
  62. package/template/components/{layout → (layout)}/Lightbox/LightboxGallery.module.css +249 -249
  63. package/template/components/{layout → (layout)}/Lightbox/LightboxGallery.tsx +72 -72
  64. package/template/components/{layout → (layout)}/Lightbox/LightboxGrid.tsx +185 -186
  65. package/template/components/{layout → (layout)}/Lightbox/LightboxModal.module.css +395 -395
  66. package/template/components/{layout → (layout)}/Lightbox/LightboxModal.tsx +498 -500
  67. package/template/components/{layout → (layout)}/Lightbox/demo.tsx +396 -412
  68. package/template/components/{layout → (layout)}/Lightbox/index.ts +30 -30
  69. package/template/components/{layout → (layout)}/Lightbox/types.ts +101 -113
  70. package/template/components/{layout → (layout)}/Lightbox/useLightboxFilters.ts +140 -140
  71. package/template/components/(layout)/accordion/Accordion.module.css +108 -0
  72. package/template/components/(layout)/accordion/Accordion.tsx +251 -0
  73. package/template/components/(layout)/card/Card.module.css +136 -0
  74. package/template/components/(layout)/card/Card.tsx +371 -0
  75. package/template/components/(layout)/list/List.module.css +83 -0
  76. package/template/components/(layout)/list/List.tsx +332 -0
  77. package/template/components/{layout → (layout)}/navigation/Wrap.tsx +41 -41
  78. package/template/components/(layout)/navigation/breadcrumbs/Breadcrumbs.tsx +145 -0
  79. package/template/components/{layout/navigation/nav/Nav.module.css → (layout)/navigation/nav/Nav.module.css.old} +474 -508
  80. package/template/components/{layout → (layout)}/navigation/nav/Nav.tsx +186 -167
  81. package/template/components/{layout → (layout)}/navigation/nav/NavBar.tsx +396 -419
  82. package/template/components/{layout → (layout)}/navigation/nav/NavContext.tsx +259 -259
  83. package/template/components/{layout → (layout)}/navigation/nav/NavItem.tsx +195 -173
  84. package/template/components/{layout → (layout)}/navigation/nav/NavNew.module.css +406 -373
  85. package/template/components/{layout → (layout)}/navigation/nav/NavRail.tsx +317 -315
  86. package/template/components/{layout → (layout)}/navigation/nav/NavSection.tsx +101 -102
  87. package/template/components/{layout → (layout)}/navigation/nav/NavTab.tsx +25 -25
  88. package/template/components/{layout → (layout)}/navigation/nav/navftb/NavFTB.module.css +253 -252
  89. package/template/components/{layout → (layout)}/navigation/nav/navftb/NavFTB.tsx +448 -399
  90. package/template/components/{layout → (layout)}/navigation/nav/navftb/useTabIndicator.ts +498 -484
  91. package/template/components/{layout → (layout)}/navigation/nav/navheader/NavHeader.module.css +59 -59
  92. package/template/components/{layout → (layout)}/navigation/nav/navheader/NavHeader.tsx +465 -473
  93. package/template/components/(layout)/navigation/pagination/Pagination.tsx +261 -0
  94. package/template/components/{layout → (layout)}/pages/loadingScreen.tsx +117 -102
  95. package/template/components/{layout → (layout)}/pages/maintenance/Maintenance.tsx +52 -52
  96. package/template/components/{layout → (layout)}/pages/maintenance/maintenance.module.css +162 -162
  97. package/template/components/(layout)/scrollShadow/ScrollShadow.module.css +81 -0
  98. package/template/components/(layout)/scrollShadow/ScrollShadow.tsx +161 -0
  99. package/template/components/(layout)/scrollShadow/useScrollShadow.ts +130 -0
  100. package/template/components/(layout)/separator/Separator.tsx +112 -0
  101. package/template/components/(overlays)/accessibilityModal/AccessibilityModal.tsx +307 -0
  102. package/template/components/(overlays)/drawer/Drawer.tsx +953 -0
  103. package/template/components/(overlays)/modal/Modal.tsx +654 -0
  104. package/template/components/(overlays)/popover/Popover.tsx +420 -0
  105. package/template/components/(overlays)/toast/Toast.tsx +692 -0
  106. package/template/components/(pickers)/autocomplete/Autocomplete.tsx +24 -0
  107. package/template/components/(pickers)/comboBox/ComboBox.tsx +21 -0
  108. package/template/components/(pickers)/select/Select.tsx +188 -0
  109. package/template/components/(pickers)/shared/FilterableField.tsx +223 -0
  110. package/template/components/(pickers)/shared/PickerItem.ts +13 -0
  111. package/template/components/tools/CustomScrollbar 2.tsx +107 -0
  112. package/template/components/tools/CustomScrollbar.tsx +107 -0
  113. package/template/components/tools/Divider 2.tsx +11 -0
  114. package/template/components/tools/Divider.tsx +11 -11
  115. package/template/components/tools/ReduceMotionContext 2.tsx +5 -0
  116. package/template/components/tools/ReduceMotionContext.tsx +5 -5
  117. package/template/components/tools/Sinewave 2.tsx +206 -0
  118. package/template/components/tools/Sinewave.tsx +396 -199
  119. package/template/components/tools/SinewaveProgress 2.tsx +140 -0
  120. package/template/components/tools/SinewaveProgress.tsx +140 -135
  121. package/template/components/tools/badge/Badge 2.tsx +28 -0
  122. package/template/components/tools/badge/Badge.tsx +28 -28
  123. package/template/components/tools/dropdown/drop.module.css +196 -0
  124. package/template/components/tools/dropdown/drop.tsx +568 -0
  125. package/template/components/tools/easing.ts +118 -0
  126. package/template/components/tools/flubber.d 2.ts +7 -0
  127. package/template/components/tools/flubber.d.ts +6 -6
  128. package/template/components/tools/footer/Footer.tsx +20 -0
  129. package/template/components/tools/input/Input 2.tsx +99 -0
  130. package/template/components/tools/input/Input.module 2.css +45 -0
  131. package/template/components/tools/input/Input.module.css +45 -0
  132. package/template/components/tools/input/Input.tsx +99 -0
  133. package/template/components/tools/label/Icon 2.tsx +39 -0
  134. package/template/components/tools/label/Icon.tsx +39 -0
  135. package/template/components/tools/label/Label 2.tsx +150 -0
  136. package/template/components/tools/label/Label.tsx +156 -0
  137. package/template/components/tools/mobileViewProvider 2.tsx +53 -0
  138. package/template/components/tools/mobileViewProvider.tsx +53 -58
  139. package/template/components/tools/ripple/ripple 2.css +38 -0
  140. package/template/components/tools/ripple/ripple 2.tsx +78 -0
  141. package/template/components/tools/ripple/ripple.css +38 -41
  142. package/template/components/tools/ripple/ripple.tsx +78 -53
  143. package/template/components/tools/shape/{ShapeMorph.tsx → Shape 2.tsx } +313 -190
  144. package/template/components/tools/shape/Shape.module 2.css +21 -0
  145. package/template/components/tools/shape/Shape.module.css +25 -0
  146. package/template/components/tools/shape/Shape.tsx +316 -0
  147. package/template/components/tools/shape/ShapeLoader 2.tsx +104 -0
  148. package/template/components/tools/shape/ShapeLoader.tsx +104 -101
  149. package/template/components/tools/shape/ShapePaths 2.ts +116 -0
  150. package/template/components/tools/shape/ShapePaths.ts +116 -116
  151. package/template/components/{layout/switch/Switch.tsx → tools/switch/Switch 2.tsx } +48 -48
  152. package/template/components/{layout/switch/Switch.module.css → tools/switch/Switch.module 2.css } +102 -102
  153. package/template/components/tools/switch/Switch.module.css +102 -102
  154. package/template/components/tools/switch/Switch.tsx +48 -48
  155. package/template/components/tools/useBodyScrollLock 2.tsx +27 -0
  156. package/template/components/tools/useBodyScrollLock.tsx +27 -27
  157. package/template/components/tools/useImageColor 2.ts +47 -0
  158. package/template/components/tools/useImageColor.ts +47 -47
  159. package/template/components/tools/useNavSheetDrag 2.tsx +196 -0
  160. package/template/components/tools/useNavSheetDrag.tsx +196 -196
  161. package/template/public/fonts/material-symbols/MaterialSymbolsRounded-VariableFont_FILL,GRAD,opsz,wght 2.woff2 +0 -0
  162. package/template/components/layout/accordion/Accordion.module.css +0 -149
  163. package/template/components/layout/accordion/Accordion.tsx +0 -114
  164. package/template/components/layout/button/button.tsx +0 -128
  165. package/template/components/layout/button/drop.module.css +0 -229
  166. package/template/components/layout/button/drop.tsx +0 -516
  167. package/template/components/layout/hero/v1/heroSlideshow.module.css +0 -107
  168. package/template/components/layout/hero/v1/heroSlideshow.tsx +0 -233
  169. package/template/components/layout/modals/accessibilityModal/AccessibilityModal.module.css +0 -126
  170. package/template/components/layout/modals/accessibilityModal/AccessibilityModal.tsx +0 -290
  171. package/template/components/layout/modals/alert/Alert.tsx +0 -188
  172. package/template/components/layout/navigation/MioCard.module.css +0 -88
  173. package/template/components/layout/navigation/MioCard.tsx +0 -266
  174. package/template/components/tools/ProgressiveBlur.tsx +0 -73
  175. package/template/components/tools/icon/icon.module.css +0 -0
  176. package/template/components/tools/icon/icon.tsx +0 -125
  177. package/template/components/tools/react-bits/ClickSpark.tsx +0 -177
  178. package/template/components/tools/react-bits/FadeContent.tsx +0 -90
  179. package/template/components/tools/react-bits/GlareHover.tsx +0 -73
  180. package/template/components/tools/react-bits/GradientText/GradientText.css +0 -70
  181. package/template/components/tools/react-bits/GradientText/GradientText.tsx +0 -44
  182. package/template/components/tools/react-bits/Magnet.tsx +0 -118
  183. package/template/components/tools/react-bits/Stepper/Stepper.css +0 -134
  184. package/template/components/tools/react-bits/Stepper/Stepper.tsx +0 -412
@@ -1,188 +0,0 @@
1
- "use client";
2
- import { AnimatePresence, motion, MotionConfig } from "framer-motion";
3
- import { useRef, useState, useEffect, useCallback, useMemo } from "react";
4
- import { createPortal } from "react-dom";
5
- import { useBodyScrollLock } from "@/components/tools/useBodyScrollLock";
6
- import Button from "../../button/button";
7
- import Icon from "@/components/tools/icon/icon";
8
- import { useReduceMotion } from "@/components/tools/ReduceMotionContext";
9
-
10
- interface alertProps {
11
- submit: { label: string; systemName?: string };
12
- cancel: { label: string; systemName?: string };
13
- onSubmit: () => void;
14
- onCancel: () => void;
15
- isPresented: boolean;
16
- padding?: number;
17
- title?: string;
18
- children?: React.ReactNode;
19
- style?: React.CSSProperties;
20
- }
21
-
22
- // Static style objects extracted outside the component so they are allocated
23
- // once rather than on every render.
24
- const overlayStyle: React.CSSProperties = {
25
- position: "fixed",
26
- top: 0,
27
- left: 0,
28
- width: "100%",
29
- height: "100%",
30
- backgroundColor: "rgba(0, 0, 0, 0.4)",
31
- backdropFilter: "blur(12px)",
32
- WebkitBackdropFilter: "blur(12px)",
33
- display: "flex",
34
- alignItems: "center",
35
- justifyContent: "center",
36
- zIndex: 100000,
37
- };
38
-
39
- const dialogStyle: React.CSSProperties = {
40
- display: "flex",
41
- flexDirection: "column",
42
- alignItems: "center",
43
- justifyContent: "space-between",
44
- gap: 12,
45
- padding: "8px",
46
- width: "min-content",
47
- height: "auto",
48
- minWidth: 360,
49
- minHeight: 200,
50
- maxWidth: "100dvw",
51
- maxHeight: "90dvh",
52
- margin: "5dvh 0",
53
- overflowX: "hidden",
54
- scrollBehavior: "smooth",
55
- overflowY: "auto",
56
- border: "1px solid var(--globalUIBorderCard)",
57
- borderRadius: 36,
58
- zIndex: 100002,
59
- backgroundColor: "var(--md-sys-color-surface-container-low)",
60
- };
61
-
62
- const titleStyle: React.CSSProperties = {
63
- width: "100%",
64
- padding: "12px 20px",
65
- fontWeight: 500,
66
- color: "var(--md-sys-color-on-surface)",
67
- };
68
-
69
- const actionsStyle: React.CSSProperties = {
70
- display: "flex",
71
- width: "100%",
72
- alignItems: "center",
73
- padding: 4,
74
- justifyContent: "space-between",
75
- };
76
-
77
- function Alert({
78
- submit = { label: "confirm", systemName: "send" },
79
- cancel = { label: "cancel" },
80
- onSubmit,
81
- onCancel,
82
- padding,
83
- style,
84
- isPresented,
85
- title = "Alert Title",
86
- children,
87
- }: alertProps) {
88
- const rm = useReduceMotion();
89
- useBodyScrollLock(isPresented);
90
- const [mounted, setMounted] = useState(false);
91
- useEffect(() => setMounted(true), []);
92
-
93
- const scrollRef = useRef<HTMLDivElement>(null);
94
- const [canScrollDown, setCanScrollDown] = useState(false);
95
-
96
- const checkScroll = useCallback(() => {
97
- const el = scrollRef.current;
98
- if (!el) return;
99
- setCanScrollDown(el.scrollHeight - el.scrollTop - el.clientHeight > 1);
100
- }, []);
101
-
102
- useEffect(() => {
103
- const el = scrollRef.current;
104
- if (!el || !isPresented) return;
105
- checkScroll();
106
- el.addEventListener("scroll", checkScroll, { passive: true });
107
- return () => el.removeEventListener("scroll", checkScroll);
108
- }, [checkScroll, isPresented]);
109
-
110
- const handleScrollDown = useCallback(() => {
111
- const el = scrollRef.current;
112
- if (!el) return;
113
- el.scrollTo({ top: el.scrollHeight, behavior: "smooth" });
114
- }, []);
115
-
116
- const scrollButtonStyle = useMemo<React.CSSProperties>(
117
- () => ({
118
- position: "sticky",
119
- bottom: 1,
120
- alignSelf: "center",
121
- opacity: canScrollDown ? 1 : 0,
122
- pointerEvents: canScrollDown ? "auto" : "none",
123
- transition: "opacity var(--transition-expressive-color)",
124
- zIndex: 1,
125
- margin: "-24px",
126
- }),
127
- [canScrollDown],
128
- );
129
- // but is memoised to avoid a new object reference on unrelated re-renders.
130
- const contentStyle = useMemo<React.CSSProperties>(
131
- () => ({
132
- display: "flex",
133
- alignItems: "flex-start",
134
- justifyContent: "flex-start",
135
- width: "100%",
136
- height: "fit-content",
137
- padding: padding ? `${padding}px` : "6px 20px",
138
- }),
139
- [padding],
140
- );
141
-
142
- if (!mounted) return null;
143
- return createPortal(
144
- <MotionConfig reducedMotion={rm ? "always" : "never"}>
145
- <AnimatePresence>
146
- {isPresented && (
147
- // A single animated overlay handles both the backdrop fade and the
148
- // centred dialog — the redundant fixed backdrop div has been removed.
149
- <motion.div
150
- initial={{ opacity: 0 }}
151
- animate={{ opacity: 1 }}
152
- exit={{ opacity: 0 }}
153
- style={overlayStyle}
154
- >
155
- <motion.div
156
- ref={scrollRef}
157
- initial={{ opacity: 0, scale: 1.1 }}
158
- animate={{ opacity: 1, scale: 1 }}
159
- exit={{ opacity: 0 }}
160
- transition={{ duration: 0.3, ease: [0.55, 0.57, 0, 1.58] }}
161
- style={{ ...dialogStyle, ...style }}
162
- className="elevated a11y-modal-surface"
163
- >
164
- {title && <h4 style={titleStyle}>{title}</h4>}
165
- <div style={contentStyle}>{children}</div>
166
- <div style={scrollButtonStyle}>
167
- <Button primary-bold onClick={handleScrollDown} elevated>
168
- <Icon systemName="keyboard_arrow_down" />
169
- </Button>
170
- </div>
171
- <div style={actionsStyle}>
172
- <Button text onClick={onCancel}>
173
- <Icon systemName={cancel.systemName} label={cancel.label} />
174
- </Button>
175
- <Button primary onClick={onSubmit}>
176
- <Icon systemName={submit.systemName} label={submit.label} />
177
- </Button>
178
- </div>
179
- </motion.div>
180
- </motion.div>
181
- )}
182
- </AnimatePresence>
183
- </MotionConfig>,
184
- document.body,
185
- );
186
- }
187
-
188
- export default Alert;
@@ -1,88 +0,0 @@
1
- .mioBody {
2
- position: relative;
3
- display: flex;
4
- flex-direction: column;
5
- min-height: 102px;
6
- padding: 0;
7
- border-radius: 24px;
8
- border: 1px solid var(--globalUIBorderCard);
9
- background-color: var(--md-sys-color-surface-container-lowest);
10
- transition:
11
- background-color var(--transition-expressive-color),
12
- border-radius var(--transition-expressive-fast);
13
- min-width: 102px;
14
- overflow: hidden;
15
- &:hover {
16
- border-radius: 48px;
17
- cursor: pointer;
18
- background-color: var(--md-sys-color-secondary-container);
19
- }
20
- &:active {
21
- border-radius: 24px;
22
- }
23
- }
24
-
25
- /* MD3 state layer — composited replacement for `filter: brightness`.
26
- Animating opacity stays on the GPU instead of repainting the image + SVG.
27
- Uses on-surface at spec opacities; swap to a brighten color if your old
28
- --filterBrightness was lightening rather than dimming. */
29
- .mioBody::after {
30
- content: "";
31
- position: absolute;
32
- inset: 0;
33
- z-index: 3;
34
- border-radius: inherit;
35
- background-color: var(--md-sys-color-on-surface);
36
- opacity: 0;
37
- pointer-events: none;
38
- transition: opacity var(--transition-expressive-color);
39
- }
40
- .mioBody:hover::after {
41
- opacity: 0.08;
42
- }
43
- .mioBody:active::after {
44
- opacity: 0.12;
45
- }
46
-
47
- /* ── Accessibility: Show Borders ──────────────────────────────────────────── */
48
- :global([data-show-borders="true"]) .mioBody {
49
- border: var(--a11y-border);
50
- }
51
-
52
- .mioBody :global(.ripple) {
53
- background-color: var(--globalUIBorderCard) !important;
54
- opacity: 1;
55
- animation: ripple-animation 1200ms linear;
56
- }
57
- @keyframes ripple-animation {
58
- to {
59
- transform: scale(4);
60
- opacity: 0;
61
- }
62
- }
63
-
64
- .mioContentWrapper {
65
- position: relative;
66
- display: flex;
67
- flex-direction: row;
68
- align-items: center;
69
- justify-content: space-between;
70
- width: auto;
71
- height: 100%;
72
- }
73
-
74
- .mioIconWrapper path {
75
- transition: fill var(--transition-expressive-color);
76
- }
77
-
78
- @media screen and (max-width: 812px) {
79
- .mioBody {
80
- border-radius: 36px;
81
- &:hover {
82
- border-radius: 60px;
83
- }
84
- &:active {
85
- border-radius: 36px;
86
- }
87
- }
88
- }
@@ -1,266 +0,0 @@
1
- "use client";
2
- import React, { useState, useRef, useCallback, useMemo } from "react";
3
- import Ripple, { RippleHandle } from "@/components/tools/ripple/ripple";
4
- import Icon from "@/components/tools/icon/icon";
5
- import styles from "./MioCard.module.css";
6
- import { useNavRail } from "./nav/NavContext";
7
- import Image from "next/image";
8
- import dynamic from "next/dynamic";
9
- import type { ShapeType } from "../../tools/shape/ShapePaths";
10
- import { useBreakpoints } from "@/components/tools/mobileViewProvider";
11
- const ShapeMorph = dynamic(() => import("../../tools/shape/ShapeMorph"), {
12
- ssr: false,
13
- });
14
-
15
- type MioCardProps = {
16
- title: string;
17
- withImage?:
18
- | {
19
- src: string;
20
- alt: string;
21
- }
22
- | undefined;
23
- onClick?: () => void;
24
- navigate?: "next" | "previous";
25
- withIcon?: {
26
- systemName: string;
27
- shape: ShapeType;
28
- toShape?: ShapeType;
29
- };
30
- type?: "primary" | "secondary" | "tertiary";
31
- style?: React.CSSProperties;
32
- children?: React.ReactNode;
33
- };
34
-
35
- // Static style objects extracted outside the component — never reallocated.
36
- const outerWrapperStyle: React.CSSProperties = {
37
- display: "flex",
38
- flexDirection: "row",
39
- flexWrap: "nowrap",
40
- gap: "16px",
41
- padding: "20px 24px",
42
- flex: 1,
43
- };
44
- const innerWrapperStyle: React.CSSProperties = {
45
- display: "flex",
46
- flexDirection: "column",
47
- justifyContent: "space-between",
48
- gap: "16px",
49
- width: "100%",
50
- height: "100%",
51
- position: "relative",
52
- };
53
-
54
- const headerGroupStyle: React.CSSProperties = {
55
- display: "flex",
56
- flexDirection: "column",
57
- gap: "0px",
58
- };
59
-
60
- const upNextStyle: React.CSSProperties = {
61
- display: "flex",
62
- alignItems: "center",
63
- gap: "4px",
64
- fontWeight: 600,
65
- };
66
-
67
- const previousStyle: React.CSSProperties = { fontWeight: 600 };
68
-
69
- const iconWrapperStyle: React.CSSProperties = {
70
- position: "relative",
71
- height: "100%",
72
- display: "flex",
73
- justifyContent: "flex-start",
74
- alignItems: "center",
75
- };
76
-
77
- function MioCard({
78
- title,
79
- withImage,
80
- withIcon,
81
- type,
82
- onClick,
83
- navigate,
84
- children,
85
- style,
86
- }: MioCardProps) {
87
- const rippleRef = useRef<RippleHandle>(null);
88
- const [isHoveringContainer, setIsHoveringContainer] = useState(false);
89
- const { isMobile, isTablet } = useBreakpoints();
90
-
91
- // Triggers the ripple effect at the pointer position, then calls the consumer's onClick handler.
92
- const handleMioClick = useCallback(
93
- (e: React.MouseEvent<HTMLDivElement>) => {
94
- rippleRef.current?.triggerRipple(e);
95
- onClick?.();
96
- },
97
- [onClick],
98
- );
99
-
100
- // Track hover state so ShapeMorph and the icon can switch colors on hover.
101
- const handleMouseEnter = useCallback(() => setIsHoveringContainer(true), []);
102
- const handleMouseLeave = useCallback(() => setIsHoveringContainer(false), []);
103
-
104
- // Body/title text color. Typed cards lock to on-{type}-container at all times
105
- // (the card bg is the matching {type}-container, so the text reads correctly
106
- // hover or not). Default cards keep the original hover/idle behavior.
107
- const contentColor = useMemo(
108
- () =>
109
- type
110
- ? `var(--md-sys-color-on-${type}-container)`
111
- : isHoveringContainer
112
- ? "var(--md-sys-color-on-primary-container)"
113
- : "var(--md-sys-color-on-surface-container)",
114
- [type, isHoveringContainer],
115
- );
116
-
117
- // The "Up next" / "Previous" label. Typed cards match the body text color.
118
- // Default cards sit as a muted outline at rest and pick up a 50% tint of
119
- // on-secondary-container on hover (matching the secondary-container bg the
120
- // card fades to).
121
- const navigateLabelStyle = useMemo<React.CSSProperties>(
122
- () => ({
123
- color: type
124
- ? `var(--md-sys-color-on-${type}-container)`
125
- : isHoveringContainer
126
- ? "color-mix(in srgb, var(--md-sys-color-on-primary-container) 50%, transparent)"
127
- : "var(--md-sys-color-outline)",
128
- position: "relative",
129
- height: navigate ? "24px" : "0px",
130
- }),
131
- [type, isHoveringContainer, navigate],
132
- );
133
-
134
- const titleStyle = useMemo<React.CSSProperties>(
135
- () => ({ color: contentColor }),
136
- [contentColor],
137
- );
138
-
139
- const textStyle = useMemo<React.CSSProperties>(
140
- () => ({
141
- color: `var(--md-sys-color-on-surface)`,
142
- }),
143
- [],
144
- );
145
-
146
- // Renders the full-width image pinned to the bottom of the card when withImage is provided.
147
- const imageElement = useMemo(() => {
148
- if (!withImage) return null;
149
- return (
150
- <div
151
- style={{
152
- position: "relative",
153
- width: "100%",
154
- height: 280,
155
- borderRadius: isMobile ? "0 0 36px 36px" : "0 0 24px 24px",
156
- overflow: "hidden",
157
- flexShrink: 0,
158
- }}
159
- >
160
- <Image
161
- src={withImage.src}
162
- alt={withImage.alt}
163
- loading="eager"
164
- fill
165
- style={{ objectFit: "cover" }}
166
- />
167
- </div>
168
- );
169
- }, [withImage, isMobile]);
170
- // Positions the icon over the ShapeMorph bubble and switches its color on hover.
171
- const iconStyle = useMemo<React.CSSProperties>(
172
- () => ({
173
- position: "absolute",
174
- transform: "translate(132.5%, 0)",
175
- fontVariationSettings: "'wght' 400",
176
- transformOrigin: "center",
177
- zIndex: 2,
178
- pointerEvents: "none",
179
- scale: 1,
180
- color: isHoveringContainer
181
- ? type
182
- ? `var(--md-sys-color-on-${type})`
183
- : "var(--md-sys-color-on-primary)"
184
- : "var(--md-sys-color-on-surface-container)",
185
- }),
186
- [isHoveringContainer, type],
187
- );
188
-
189
- // Returns the fill color for the ShapeMorph bubble: primary/type on hover, surface on idle.
190
- const shapeColorValue = useMemo(
191
- () =>
192
- isHoveringContainer
193
- ? type
194
- ? `var(--md-sys-color-${type})`
195
- : "var(--md-sys-color-primary)"
196
- : type || isMobile
197
- ? "var(--md-sys-color-surface-container-lowest)"
198
- : "var(--md-sys-color-surface-container-low)",
199
- [isHoveringContainer, type, isMobile],
200
- );
201
-
202
- // Outer wrapper owns hover/click and keeps a CONSTANT border-radius, so its
203
- // hit area never moves. The inner body animates its radius purely for looks.
204
- // (Listening on the body directly caused an enter/leave flicker loop: its
205
- // growing radius clipped the corner out from under the cursor.)
206
- return (
207
- <div
208
- className={styles.mioWrapper}
209
- style={style}
210
- onClick={handleMioClick}
211
- onMouseEnter={handleMouseEnter}
212
- onMouseLeave={handleMouseLeave}
213
- >
214
- <div
215
- className={styles.mioBody}
216
- style={{
217
- backgroundColor: type
218
- ? `var(--md-sys-color-${type}-container)`
219
- : isMobile && !type
220
- ? "var(--md-sys-color-surface-container-low)"
221
- : undefined,
222
- }}
223
- >
224
- {imageElement}
225
- <div style={outerWrapperStyle}>
226
- <div style={innerWrapperStyle}>
227
- <div style={headerGroupStyle}>
228
- <span style={navigateLabelStyle}>
229
- {navigate === "next" ? (
230
- <span style={upNextStyle}>
231
- <p>Up next</p>
232
- <Icon systemName="arrow_right_alt" />
233
- </span>
234
- ) : navigate === "previous" ? (
235
- <span style={previousStyle}>
236
- <Icon systemName="arrow_left_alt" label="Previous" />
237
- </span>
238
- ) : null}
239
- </span>
240
- <h3 style={titleStyle}>{title}</h3>
241
- </div>
242
- {children && (
243
- <div className={styles.mioContentWrapper} style={textStyle}>
244
- {children}
245
- </div>
246
- )}
247
- </div>
248
- {withIcon && (
249
- <div className={styles.mioIconWrapper} style={iconWrapperStyle}>
250
- <Icon iconStyle={iconStyle} systemName={withIcon.systemName} />
251
- <ShapeMorph
252
- shape={withIcon.shape}
253
- isHovered={isHoveringContainer}
254
- color={shapeColorValue}
255
- size={62}
256
- />
257
- </div>
258
- )}
259
- </div>
260
- <Ripple ref={rippleRef} />
261
- </div>
262
- </div>
263
- );
264
- }
265
-
266
- export default React.memo(MioCard);
@@ -1,73 +0,0 @@
1
- import type { CSSProperties } from 'react';
2
-
3
- type SnapDirection = 'top' | 'right' | 'bottom' | 'left';
4
-
5
- const DIRECTIONS: Record<SnapDirection, string> = {
6
- top: 'to top',
7
- right: 'to right',
8
- bottom: 'to bottom',
9
- left: 'to left',
10
- };
11
-
12
- interface ProgressiveBlurProps {
13
- /** Edge the max blur snaps to; fades to 0 at the opposite side. */
14
- snapTo?: SnapDirection;
15
- /** Max blur radius in px. */
16
- blur?: number;
17
- /** Number of stacked layers — higher = smoother ramp. */
18
- definition?: number;
19
- className?: string;
20
- style?: CSSProperties;
21
- }
22
-
23
- /**
24
- * Gradual/progressive blur via stacked variable-blur layers with
25
- * overlapping gradient masks (no native CSS support yet).
26
- *
27
- * Drop inside a `position: relative` container:
28
- * <div style={{ position: 'relative', width: 500, height: 200 }}>
29
- * <ProgressiveBlur snapTo="bottom" blur={12} definition={8} />
30
- * </div>
31
- */
32
- export default function ProgressiveBlur({
33
- snapTo = 'bottom',
34
- blur = 8,
35
- definition = 8,
36
- className,
37
- style,
38
- }: ProgressiveBlurProps) {
39
- const direction = DIRECTIONS[snapTo] ?? DIRECTIONS.bottom;
40
-
41
- return (
42
- <div
43
- className={className}
44
- style={{ position: 'absolute', inset: 0, pointerEvents: 'none', ...style }}
45
- >
46
- {Array.from({ length: definition }).map((_, i) => {
47
- const seg = 100 / definition;
48
- // exponential ramp, normalized so the strongest layer ≈ `blur`px
49
- const blurValue = (blur * 2 ** i) / 2 ** (definition - 1);
50
- // overlapping trapezoid window per layer -> smooth blend
51
- const mask = `linear-gradient(${direction},
52
- transparent ${(i - 1) * seg}%,
53
- black ${i * seg}%,
54
- black ${(i + 1) * seg}%,
55
- transparent ${(i + 2) * seg}%)`;
56
- return (
57
- <div
58
- key={i}
59
- style={{
60
- position: 'absolute',
61
- inset: 0,
62
- zIndex: i, // lowest blur = lowest z, highest = highest
63
- backdropFilter: `blur(${blurValue}px)`,
64
- WebkitBackdropFilter: `blur(${blurValue}px)`,
65
- maskImage: mask,
66
- WebkitMaskImage: mask,
67
- }}
68
- />
69
- );
70
- })}
71
- </div>
72
- );
73
- }
File without changes