@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.
- package/LICENSE +201 -0
- package/README.md +101 -0
- package/package.json +49 -0
- package/scripts/postinstall.js +105 -0
- package/template/app/ClientNav.tsx +310 -0
- package/template/app/globals.css +167 -0
- package/template/app/layout.tsx +128 -0
- package/template/app/themes/dark-mc.css +51 -0
- package/template/app/themes/dark.css +51 -0
- package/template/app/themes/light-mc.css +51 -0
- package/template/app/themes/light.css +51 -0
- package/template/app/themes/theme.css +82 -0
- package/template/components/layout/Lightbox/LightboxCard.tsx +100 -0
- package/template/components/layout/Lightbox/LightboxGallery.module.css +249 -0
- package/template/components/layout/Lightbox/LightboxGallery.tsx +72 -0
- package/template/components/layout/Lightbox/LightboxGrid.tsx +186 -0
- package/template/components/layout/Lightbox/LightboxModal.module.css +395 -0
- package/template/components/layout/Lightbox/LightboxModal.tsx +500 -0
- package/template/components/layout/Lightbox/demo.tsx +412 -0
- package/template/components/layout/Lightbox/index.ts +30 -0
- package/template/components/layout/Lightbox/types.ts +113 -0
- package/template/components/layout/Lightbox/useLightboxFilters.ts +140 -0
- package/template/components/layout/accordion/Accordion.module.css +149 -0
- package/template/components/layout/accordion/Accordion.tsx +114 -0
- package/template/components/layout/button/Button.module.css +305 -0
- package/template/components/layout/button/ButtonGroup.tsx +503 -0
- package/template/components/layout/button/FAB.tsx +118 -0
- package/template/components/layout/button/button.tsx +128 -0
- package/template/components/layout/button/drop.module.css +229 -0
- package/template/components/layout/button/drop.tsx +516 -0
- package/template/components/layout/hero/v1/heroSlideshow.module.css +107 -0
- package/template/components/layout/hero/v1/heroSlideshow.tsx +233 -0
- package/template/components/layout/modals/accessibilityModal/AccessibilityModal.module.css +126 -0
- package/template/components/layout/modals/accessibilityModal/AccessibilityModal.tsx +290 -0
- package/template/components/layout/modals/alert/Alert.tsx +188 -0
- package/template/components/layout/navigation/MioCard.module.css +88 -0
- package/template/components/layout/navigation/MioCard.tsx +266 -0
- package/template/components/layout/navigation/Wrap.tsx +41 -0
- package/template/components/layout/navigation/nav/Nav.module.css +508 -0
- package/template/components/layout/navigation/nav/Nav.tsx +167 -0
- package/template/components/layout/navigation/nav/NavBar.tsx +419 -0
- package/template/components/layout/navigation/nav/NavContext.tsx +259 -0
- package/template/components/layout/navigation/nav/NavItem.tsx +173 -0
- package/template/components/layout/navigation/nav/NavNew.module.css +373 -0
- package/template/components/layout/navigation/nav/NavRail.tsx +315 -0
- package/template/components/layout/navigation/nav/NavSection.tsx +102 -0
- package/template/components/layout/navigation/nav/NavTab.tsx +25 -0
- package/template/components/layout/navigation/nav/navftb/NavFTB.module.css +252 -0
- package/template/components/layout/navigation/nav/navftb/NavFTB.tsx +399 -0
- package/template/components/layout/navigation/nav/navftb/useTabIndicator.ts +484 -0
- package/template/components/layout/navigation/nav/navheader/NavHeader.module.css +59 -0
- package/template/components/layout/navigation/nav/navheader/NavHeader.tsx +478 -0
- package/template/components/layout/pages/loadingScreen.tsx +102 -0
- package/template/components/layout/pages/maintenance/Maintenance.tsx +53 -0
- package/template/components/layout/pages/maintenance/maintenance.module.css +163 -0
- package/template/components/layout/switch/Switch.module.css +102 -0
- package/template/components/layout/switch/Switch.tsx +48 -0
- package/template/components/tools/Divider.tsx +11 -0
- package/template/components/tools/ProgressiveBlur.tsx +73 -0
- package/template/components/tools/ReduceMotionContext.tsx +5 -0
- package/template/components/tools/Sinewave.tsx +199 -0
- package/template/components/tools/SinewaveProgress.tsx +135 -0
- package/template/components/tools/badge/Badge.tsx +28 -0
- package/template/components/tools/flubber.d.ts +7 -0
- package/template/components/tools/icon/SocialIcons.tsx +88 -0
- package/template/components/tools/icon/icon.module.css +0 -0
- package/template/components/tools/icon/icon.tsx +125 -0
- package/template/components/tools/mobileViewProvider.tsx +58 -0
- package/template/components/tools/react-bits/ClickSpark.tsx +177 -0
- package/template/components/tools/react-bits/FadeContent.tsx +90 -0
- package/template/components/tools/react-bits/GlareHover.tsx +73 -0
- package/template/components/tools/react-bits/GradientText/GradientText.css +70 -0
- package/template/components/tools/react-bits/GradientText/GradientText.tsx +44 -0
- package/template/components/tools/react-bits/Magnet.tsx +118 -0
- package/template/components/tools/react-bits/Stepper/Stepper.css +134 -0
- package/template/components/tools/react-bits/Stepper/Stepper.tsx +412 -0
- package/template/components/tools/ripple/ripple.css +41 -0
- package/template/components/tools/ripple/ripple.tsx +53 -0
- package/template/components/tools/shape/ShapeLoader.tsx +101 -0
- package/template/components/tools/shape/ShapeMorph.tsx +190 -0
- package/template/components/tools/shape/ShapePaths.ts +116 -0
- package/template/components/tools/switch/Switch.module.css +102 -0
- package/template/components/tools/switch/Switch.tsx +48 -0
- package/template/components/tools/useBodyScrollLock.tsx +27 -0
- package/template/components/tools/useImageColor.ts +47 -0
- package/template/components/tools/useNavSheetDrag.tsx +196 -0
- package/template/public/fonts/material-symbols/MaterialSymbolsRounded-VariableFont_FILL,GRAD,opsz,wght.woff2 +0 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
position: fixed;
|
|
3
|
+
inset: 0;
|
|
4
|
+
z-index: 1000;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
background: black;
|
|
7
|
+
color: var(--md-sys-color-on-background);
|
|
8
|
+
}
|
|
9
|
+
.root *, .root *::before { box-sizing: border-box; }
|
|
10
|
+
|
|
11
|
+
/* ── background: soft drifting orbs + grain ───────────────── */
|
|
12
|
+
.bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
|
|
13
|
+
|
|
14
|
+
.orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .62; }
|
|
15
|
+
.orbA {
|
|
16
|
+
width: 42vmax; height: 42vmax; top: -12vmax; left: -8vmax;
|
|
17
|
+
background: var(--md-sys-color-primary-container);
|
|
18
|
+
animation: drift-a 24s ease-in-out infinite alternate;
|
|
19
|
+
}
|
|
20
|
+
.orbB {
|
|
21
|
+
width: 34vmax; height: 34vmax; bottom: -12vmax; right: -8vmax;
|
|
22
|
+
background: var(--md-sys-color-tertiary-container);
|
|
23
|
+
animation: drift-b 28s ease-in-out infinite alternate;
|
|
24
|
+
}
|
|
25
|
+
.orbC {
|
|
26
|
+
width: 26vmax; height: 26vmax; top: 38%; left: 52%;
|
|
27
|
+
background: var(--md-sys-color-secondary-container);
|
|
28
|
+
animation: drift-c 20s ease-in-out infinite alternate;
|
|
29
|
+
}
|
|
30
|
+
@keyframes drift-a { to { transform: translate(7vmax, 5vmax) scale(1.14); } }
|
|
31
|
+
@keyframes drift-b { to { transform: translate(-6vmax, -5vmax) scale(1.1); } }
|
|
32
|
+
@keyframes drift-c { to { transform: translate(-11vmax, 4vmax) scale(.82); } }
|
|
33
|
+
|
|
34
|
+
.grain {
|
|
35
|
+
position: absolute; inset: 0; z-index: 1; pointer-events: none;
|
|
36
|
+
opacity: .35; mix-blend-mode: overlay;
|
|
37
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* ── layout ───────────────────────────────────────────────── */
|
|
41
|
+
.wrap {
|
|
42
|
+
position: relative; z-index: 2;
|
|
43
|
+
min-height: 100svh;
|
|
44
|
+
max-width: 1080px; margin: 0 auto;
|
|
45
|
+
display: flex; align-items: center; justify-content: center;
|
|
46
|
+
gap: clamp(36px, 6vw, 64px);
|
|
47
|
+
padding: 48px 32px;
|
|
48
|
+
}
|
|
49
|
+
@media (max-width: 860px) {
|
|
50
|
+
.wrap { flex-direction: column; text-align: center; }
|
|
51
|
+
.copy { display: flex; flex-direction: column; align-items: center; }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* ── left: copy ───────────────────────────────────────────── */
|
|
55
|
+
.copy { max-width: 560px; animation: rise .8s cubic-bezier(.2, .85, .2, 1) both; }
|
|
56
|
+
|
|
57
|
+
.pill {
|
|
58
|
+
display: inline-flex; align-items: center; gap: 8px;
|
|
59
|
+
padding: 7px 14px; border-radius: 999px;
|
|
60
|
+
background: rgba(0, 0, 0, 0.4);
|
|
61
|
+
border: 1px solid var(--md-sys-color-secondary-container);
|
|
62
|
+
-webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
|
|
63
|
+
font-size: 12.5px; font-weight: 600; letter-spacing: .04em;
|
|
64
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
65
|
+
}
|
|
66
|
+
.dot {
|
|
67
|
+
width: 8px; height: 8px; border-radius: 50%;
|
|
68
|
+
background: var(--md-sys-color-primary);
|
|
69
|
+
animation: pulse 2s ease-in-out infinite;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.title {
|
|
73
|
+
font-family: var(--font-montserrat), sans-serif;
|
|
74
|
+
font-size: clamp(34px, 6.6vw, 66px);
|
|
75
|
+
font-weight: 600; line-height: .98; letter-spacing: -.03em;
|
|
76
|
+
margin: 20px 0 18px;
|
|
77
|
+
}
|
|
78
|
+
.title em { font-family: 'Montserrat', sans-serif; color: var(--md-sys-color-primary); }
|
|
79
|
+
|
|
80
|
+
.subtitle {
|
|
81
|
+
font-size: clamp(15px, 1.6vw, 17px); line-height: 1.6;
|
|
82
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
83
|
+
max-width: 42ch;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.sig {
|
|
87
|
+
margin-top: 24px; font-size: 13.5px; font-weight: 600;
|
|
88
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
89
|
+
letter-spacing: .02em;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* ── right: glass card + shape ────────────────────────────── */
|
|
93
|
+
.stage { flex-shrink: 0; animation: rise .9s cubic-bezier(.2, .85, .2, 1) .08s both; }
|
|
94
|
+
|
|
95
|
+
.card {
|
|
96
|
+
position: relative; overflow: hidden;
|
|
97
|
+
width: clamp(280px, 80vw, 340px);
|
|
98
|
+
padding: clamp(34px, 7vw, 48px);
|
|
99
|
+
border-radius: 40px;
|
|
100
|
+
display: grid; place-items: center;
|
|
101
|
+
background: rgba(0, 0, 0, 0.421);
|
|
102
|
+
border: 1px solid color-mix(in srgb, var(--md-sys-color-primary) 15%, transparent);
|
|
103
|
+
box-shadow:
|
|
104
|
+
0 28px 64px -28px color-mix(in srgb, var(--md-sys-color-shadow) 42%, transparent),
|
|
105
|
+
inset 1px 1px 1px var(--md-sys-color-primary-container);
|
|
106
|
+
}
|
|
107
|
+
.card::before {
|
|
108
|
+
content: ""; position: absolute; inset: 0; pointer-events: none;
|
|
109
|
+
background: linear-gradient(135deg, color-mix(in srgb, var(--md-sys-color-primary-container) 30%, transparent), transparent 80%);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/* the shape — placeholder for your mascot */
|
|
113
|
+
.blob {
|
|
114
|
+
position: relative;
|
|
115
|
+
width: clamp(150px, 42vw, 196px); aspect-ratio: 1;
|
|
116
|
+
display: grid; place-items: center;
|
|
117
|
+
background: linear-gradient(150deg,
|
|
118
|
+
var(--md-sys-color-primary-container),
|
|
119
|
+
var(--md-sys-color-primary));
|
|
120
|
+
border: 1px solid color-mix(in srgb, var(--md-sys-color-primary) 60%, transparent);
|
|
121
|
+
border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
|
|
122
|
+
box-shadow:
|
|
123
|
+
inset 0 8px 18px color-mix(in srgb, var(--md-sys-color-primary-container) 36%, transparent),
|
|
124
|
+
inset 0 -12px 22px color-mix(in srgb, var(--md-sys-color-primary) 20%, transparent);
|
|
125
|
+
animation: morph 8s ease-in-out infinite, bob 4.5s ease-in-out infinite;
|
|
126
|
+
}
|
|
127
|
+
.face { width: 58%; height: auto; overflow: visible; }
|
|
128
|
+
.eye {
|
|
129
|
+
fill: var(--md-sys-color-on-primary-container);
|
|
130
|
+
transform-box: fill-box; transform-origin: center;
|
|
131
|
+
animation: blink 5.5s infinite;
|
|
132
|
+
}
|
|
133
|
+
.mouth {
|
|
134
|
+
fill: none; stroke: var(--md-sys-color-on-primary-container);
|
|
135
|
+
stroke-width: 3; stroke-linecap: round;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/* ── keyframes ────────────────────────────────────────────── */
|
|
139
|
+
@keyframes rise {
|
|
140
|
+
from { opacity: 0; transform: translateY(22px); }
|
|
141
|
+
to { opacity: 1; transform: none; }
|
|
142
|
+
}
|
|
143
|
+
@keyframes morph {
|
|
144
|
+
0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
|
|
145
|
+
33% { border-radius: 30% 70% 70% 30% / 50% 60% 40% 50%; }
|
|
146
|
+
66% { border-radius: 70% 30% 52% 48% / 32% 52% 60% 68%; }
|
|
147
|
+
}
|
|
148
|
+
@keyframes bob {
|
|
149
|
+
0%, 100% { transform: translateY(0); }
|
|
150
|
+
50% { transform: translateY(-12px); }
|
|
151
|
+
}
|
|
152
|
+
@keyframes pulse {
|
|
153
|
+
0%, 100% { opacity: .3; transform: scale(.7); }
|
|
154
|
+
50% { opacity: 1; transform: scale(1); }
|
|
155
|
+
}
|
|
156
|
+
@keyframes blink {
|
|
157
|
+
0%, 93%, 100% { transform: scaleY(1); }
|
|
158
|
+
96% { transform: scaleY(.1); }
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@media (prefers-reduced-motion: reduce) {
|
|
162
|
+
.root * { animation: none !important; }
|
|
163
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
.switchContainer {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
position: relative;
|
|
5
|
+
margin: 0;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/* ── Accessibility: Show Borders ──────────────────────────────────────────── */
|
|
9
|
+
:global([data-show-borders="true"]) .switchBg,
|
|
10
|
+
:global([data-show-borders="true"]) .checked .switchBg {
|
|
11
|
+
border: var(--a11y-border) !important;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.switchBg {
|
|
15
|
+
position: relative;
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
border: 2px solid var(--md-sys-color-outline);
|
|
21
|
+
border-radius: 50px;
|
|
22
|
+
background-color: transparent;
|
|
23
|
+
width: 48px;
|
|
24
|
+
height: 28px;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
&:hover {
|
|
27
|
+
filter: var(--filterBrightness);
|
|
28
|
+
}
|
|
29
|
+
will-change: transform, background-color;
|
|
30
|
+
transition:
|
|
31
|
+
transform var(--transition-expressive),
|
|
32
|
+
background-color var(--transition-expressive-color),
|
|
33
|
+
filter var(--transition-expressive-color),
|
|
34
|
+
border var(--transition-expressive-color);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.switchBg::after {
|
|
38
|
+
content: "";
|
|
39
|
+
position: absolute;
|
|
40
|
+
transform: translate(-10px, 0px);
|
|
41
|
+
width: 12px;
|
|
42
|
+
height: 12px;
|
|
43
|
+
border-radius: 50%;
|
|
44
|
+
background-color: var(--md-sys-color-outline);
|
|
45
|
+
will-change: transform, width, height, background-color;
|
|
46
|
+
transition:
|
|
47
|
+
transform var(--transition-expressive),
|
|
48
|
+
width var(--transition-expressive-fast),
|
|
49
|
+
height var(--transition-expressive-fast),
|
|
50
|
+
background-color var(--transition-expressive-color),
|
|
51
|
+
border var(--transition-expressive-color),
|
|
52
|
+
left var(--transition-expressive),
|
|
53
|
+
right var(--transition-expressive);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.switchBg .switchIcon {
|
|
57
|
+
opacity: 0;
|
|
58
|
+
position: absolute;
|
|
59
|
+
scale: 0.5 !important;
|
|
60
|
+
z-index: 99;
|
|
61
|
+
transform: translate(-20px, 1px);
|
|
62
|
+
color: var(--md-sys-color-outline);
|
|
63
|
+
transform-origin: center;
|
|
64
|
+
padding: 0;
|
|
65
|
+
transition:
|
|
66
|
+
transform var(--transition-expressive),
|
|
67
|
+
padding var(--transition-expressive),
|
|
68
|
+
color var(--transition-expressive-color),
|
|
69
|
+
scale var(--transition-expressive),
|
|
70
|
+
opacity var(--transition-expressive-color);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.checked .switchBg {
|
|
74
|
+
background-color: var(--md-sys-color-primary);
|
|
75
|
+
border: 2px solid var(--md-sys-color-primary);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.checked .switchBg::after {
|
|
79
|
+
background-color: var(--md-sys-color-on-primary);
|
|
80
|
+
transform: translate(10px, 0px);
|
|
81
|
+
width: 22px;
|
|
82
|
+
height: 22px;
|
|
83
|
+
transition:
|
|
84
|
+
background-color var(--transition-expressive-color),
|
|
85
|
+
transform var(--transition-expressive);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.checked .switchIcon {
|
|
89
|
+
transform: translate(13px, 1px);
|
|
90
|
+
opacity: 1;
|
|
91
|
+
scale: 0.8 !important;
|
|
92
|
+
color: var(--md-sys-color-on-surface);
|
|
93
|
+
transition:
|
|
94
|
+
color var(--transition-expressive-color),
|
|
95
|
+
scale var(--transition-expressive),
|
|
96
|
+
transform var(--transition-expressive),
|
|
97
|
+
opacity var(--transition-expressive-color);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.switchContainer input[type="checkbox"] {
|
|
101
|
+
display: none;
|
|
102
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import styles from "./Switch.module.css";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import Icon from "../../tools/icon/icon";
|
|
5
|
+
|
|
6
|
+
export default function Switch({
|
|
7
|
+
id,
|
|
8
|
+
onClick,
|
|
9
|
+
systemIcon = false,
|
|
10
|
+
checked: controlledChecked,
|
|
11
|
+
onChange,
|
|
12
|
+
}: {
|
|
13
|
+
id?: string;
|
|
14
|
+
onClick?: () => void;
|
|
15
|
+
systemIcon?: boolean;
|
|
16
|
+
/** If provided the Switch runs in controlled mode */
|
|
17
|
+
checked?: boolean;
|
|
18
|
+
onChange?: (checked: boolean) => void;
|
|
19
|
+
}) {
|
|
20
|
+
const [internalChecked, setInternalChecked] = useState(false);
|
|
21
|
+
const isControlled = controlledChecked !== undefined;
|
|
22
|
+
const isChecked = isControlled ? controlledChecked : internalChecked;
|
|
23
|
+
|
|
24
|
+
const handleChange = () => {
|
|
25
|
+
const next = !isChecked;
|
|
26
|
+
if (!isControlled) setInternalChecked(next);
|
|
27
|
+
onChange?.(next);
|
|
28
|
+
onClick?.();
|
|
29
|
+
};
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
<label
|
|
33
|
+
className={`${styles.switchContainer} ${isChecked ? styles.checked : ""}`}
|
|
34
|
+
>
|
|
35
|
+
<input type="checkbox" checked={isChecked} onChange={handleChange} />
|
|
36
|
+
<span className={styles.switchBg}>
|
|
37
|
+
<Icon
|
|
38
|
+
id={`switch-icon md-18${id}`}
|
|
39
|
+
label=""
|
|
40
|
+
className={styles.switchIcon}
|
|
41
|
+
systemName={isChecked ? "check" : "close"}
|
|
42
|
+
iconStyle={systemIcon == false ? { opacity: 0 } : {}}
|
|
43
|
+
/>
|
|
44
|
+
</span>
|
|
45
|
+
</label>
|
|
46
|
+
</>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
type SinewaveProps = {
|
|
5
|
+
/** Fixed pixel width. Ignored when `fluid` (the container's width is measured each frame instead). */
|
|
6
|
+
width?: number;
|
|
7
|
+
/** Fit to the container's current width, re-fitting every frame so an animating container width drives the wave. */
|
|
8
|
+
fluid?: boolean;
|
|
9
|
+
height?: number;
|
|
10
|
+
frequency?: number;
|
|
11
|
+
/** If set, frequency = currentWidth * freqPerPx — holds wavelength constant as width changes. Overrides `frequency`. */
|
|
12
|
+
freqPerPx?: number;
|
|
13
|
+
amplitude?: number;
|
|
14
|
+
stroke?: string;
|
|
15
|
+
strokeWidth?: number;
|
|
16
|
+
/** Continuously shifts the wave's phase from right to left. */
|
|
17
|
+
animate?: boolean;
|
|
18
|
+
/** Seconds for the wave to shift exactly one full period. */
|
|
19
|
+
duration?: number;
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
className?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const useIsoLayoutEffect =
|
|
25
|
+
typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
26
|
+
|
|
27
|
+
function buildPath(
|
|
28
|
+
width: number,
|
|
29
|
+
height: number,
|
|
30
|
+
frequency: number,
|
|
31
|
+
amplitude: number,
|
|
32
|
+
phase: number,
|
|
33
|
+
) {
|
|
34
|
+
const points: string[] = [];
|
|
35
|
+
const step = 2;
|
|
36
|
+
for (let x = 0; x <= width; x += step) {
|
|
37
|
+
const y =
|
|
38
|
+
height / 2 +
|
|
39
|
+
amplitude * Math.sin((x / width) * frequency * 2 * Math.PI + phase);
|
|
40
|
+
points.push(`${x},${y}`);
|
|
41
|
+
}
|
|
42
|
+
return "M" + points.join(" L ");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const Sinewave: React.FC<SinewaveProps> = ({
|
|
46
|
+
width = 400,
|
|
47
|
+
fluid = false,
|
|
48
|
+
height = 20,
|
|
49
|
+
frequency = width * 0.04,
|
|
50
|
+
freqPerPx,
|
|
51
|
+
amplitude = 4,
|
|
52
|
+
stroke = "var(--md-sys-color-primary-container)",
|
|
53
|
+
strokeWidth = 2,
|
|
54
|
+
animate = false,
|
|
55
|
+
duration = 1.6,
|
|
56
|
+
style,
|
|
57
|
+
className,
|
|
58
|
+
}) => {
|
|
59
|
+
const rootRef = React.useRef<HTMLDivElement>(null);
|
|
60
|
+
const svgRef = React.useRef<SVGSVGElement>(null);
|
|
61
|
+
const pathRef = React.useRef<SVGPathElement>(null);
|
|
62
|
+
const phaseRef = React.useRef(0);
|
|
63
|
+
const lastTimeRef = React.useRef<number | null>(null);
|
|
64
|
+
const dispAmpRef = React.useRef(amplitude); // eased toward liveRef target
|
|
65
|
+
|
|
66
|
+
// Geometry the rAF loop reads each frame. Refreshed on every render (not via
|
|
67
|
+
// effect deps) so width/frequency/amplitude changes never restart the loop's
|
|
68
|
+
// clock — phase keeps advancing while the width is being animated.
|
|
69
|
+
const liveRef = React.useRef({
|
|
70
|
+
width,
|
|
71
|
+
fluid,
|
|
72
|
+
height,
|
|
73
|
+
frequency,
|
|
74
|
+
freqPerPx,
|
|
75
|
+
amplitude,
|
|
76
|
+
duration,
|
|
77
|
+
});
|
|
78
|
+
liveRef.current = {
|
|
79
|
+
width,
|
|
80
|
+
fluid,
|
|
81
|
+
height,
|
|
82
|
+
frequency,
|
|
83
|
+
freqPerPx,
|
|
84
|
+
amplitude,
|
|
85
|
+
duration,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// Resolve "now": measured width when fluid, derived freq when freqPerPx is
|
|
89
|
+
// set, eased amplitude.
|
|
90
|
+
const measure = React.useCallback(() => {
|
|
91
|
+
const l = liveRef.current;
|
|
92
|
+
const measured = rootRef.current?.clientWidth; // 0 is valid (progress 0)
|
|
93
|
+
const w = l.fluid ? (measured ?? l.width) : l.width;
|
|
94
|
+
const f = l.freqPerPx != null ? w * l.freqPerPx : l.frequency;
|
|
95
|
+
return { w, f, h: l.height, a: dispAmpRef.current };
|
|
96
|
+
}, []);
|
|
97
|
+
|
|
98
|
+
const draw = React.useCallback(() => {
|
|
99
|
+
const { w, f, h, a } = measure();
|
|
100
|
+
svgRef.current?.setAttribute("width", String(w));
|
|
101
|
+
svgRef.current?.setAttribute("viewBox", `0 0 ${w} ${h}`);
|
|
102
|
+
pathRef.current?.setAttribute("d", buildPath(w, h, f, a, phaseRef.current));
|
|
103
|
+
}, [measure]);
|
|
104
|
+
|
|
105
|
+
// Animated phase + per-frame re-fit + amplitude easing.
|
|
106
|
+
React.useEffect(() => {
|
|
107
|
+
if (!animate) {
|
|
108
|
+
lastTimeRef.current = null;
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
let frame: number;
|
|
112
|
+
const tick = (now: number) => {
|
|
113
|
+
if (lastTimeRef.current != null) {
|
|
114
|
+
const dt = (now - lastTimeRef.current) / 1000;
|
|
115
|
+
phaseRef.current =
|
|
116
|
+
(phaseRef.current + (dt / liveRef.current.duration) * Math.PI * 2) %
|
|
117
|
+
(Math.PI * 2);
|
|
118
|
+
// ease amplitude toward target (drops to 0 at ≥98%)
|
|
119
|
+
dispAmpRef.current +=
|
|
120
|
+
(liveRef.current.amplitude - dispAmpRef.current) *
|
|
121
|
+
(1 - Math.exp(-dt * 8));
|
|
122
|
+
}
|
|
123
|
+
lastTimeRef.current = now;
|
|
124
|
+
draw();
|
|
125
|
+
frame = requestAnimationFrame(tick);
|
|
126
|
+
};
|
|
127
|
+
frame = requestAnimationFrame(tick);
|
|
128
|
+
return () => cancelAnimationFrame(frame);
|
|
129
|
+
}, [animate, draw]);
|
|
130
|
+
|
|
131
|
+
// Initial fit (pre-paint) + static/resize fit when not animating.
|
|
132
|
+
useIsoLayoutEffect(() => {
|
|
133
|
+
if (!animate) dispAmpRef.current = amplitude; // frozen frame is exact
|
|
134
|
+
draw();
|
|
135
|
+
if (animate || !fluid) return;
|
|
136
|
+
const el = rootRef.current;
|
|
137
|
+
if (!el) return;
|
|
138
|
+
const ro = new ResizeObserver(() => draw());
|
|
139
|
+
ro.observe(el);
|
|
140
|
+
return () => ro.disconnect();
|
|
141
|
+
}, [draw, animate, fluid, width, height, frequency, freqPerPx, amplitude]);
|
|
142
|
+
|
|
143
|
+
// Fluid starts at 0 so nothing flashes full-width before the first fit.
|
|
144
|
+
const initialW = fluid ? 0 : width;
|
|
145
|
+
const initialFreq = freqPerPx != null ? initialW * freqPerPx : frequency;
|
|
146
|
+
const initialPath = React.useMemo(
|
|
147
|
+
() => buildPath(initialW, height, initialFreq, amplitude, 0),
|
|
148
|
+
[initialW, height, initialFreq, amplitude],
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<div
|
|
153
|
+
ref={rootRef}
|
|
154
|
+
className="sinewave-container"
|
|
155
|
+
style={{
|
|
156
|
+
minHeight: "20px",
|
|
157
|
+
margin: "24px 0",
|
|
158
|
+
display: "flex",
|
|
159
|
+
justifyContent: "center",
|
|
160
|
+
alignItems: "center",
|
|
161
|
+
...(fluid ? { width: "100%" } : null),
|
|
162
|
+
...style,
|
|
163
|
+
}}
|
|
164
|
+
>
|
|
165
|
+
<svg
|
|
166
|
+
ref={svgRef}
|
|
167
|
+
width={initialW}
|
|
168
|
+
height={height}
|
|
169
|
+
viewBox={`0 0 ${initialW} ${height}`}
|
|
170
|
+
fill="none"
|
|
171
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
172
|
+
style={{
|
|
173
|
+
stroke,
|
|
174
|
+
transition: "stroke var(--transition-expressive-color)",
|
|
175
|
+
position: "relative",
|
|
176
|
+
margin: 0,
|
|
177
|
+
padding: 0,
|
|
178
|
+
overflow: "visible",
|
|
179
|
+
}}
|
|
180
|
+
className={className}
|
|
181
|
+
>
|
|
182
|
+
<path
|
|
183
|
+
ref={pathRef}
|
|
184
|
+
d={initialPath}
|
|
185
|
+
stroke={stroke}
|
|
186
|
+
strokeLinecap="round"
|
|
187
|
+
fill="none"
|
|
188
|
+
suppressHydrationWarning
|
|
189
|
+
style={{
|
|
190
|
+
strokeWidth,
|
|
191
|
+
transition: "stroke-width var(--transition-expressive-color)",
|
|
192
|
+
}}
|
|
193
|
+
/>
|
|
194
|
+
</svg>
|
|
195
|
+
</div>
|
|
196
|
+
);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export default Sinewave;
|