@yamatozhen/design_system 1.1.0 → 1.2.1

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 (29) hide show
  1. package/package.json +1 -1
  2. package/template/app/themes/dark-mc 2.css +0 -51
  3. package/template/app/themes/light 2.css +0 -51
  4. package/template/app/themes/light-mc 2.css +0 -51
  5. package/template/app/themes/theme 2.css +0 -272
  6. package/template/components/tools/CustomScrollbar 2.tsx +0 -107
  7. package/template/components/tools/Divider 2.tsx +0 -11
  8. package/template/components/tools/ReduceMotionContext 2.tsx +0 -5
  9. package/template/components/tools/Sinewave 2.tsx +0 -206
  10. package/template/components/tools/SinewaveProgress 2.tsx +0 -140
  11. package/template/components/tools/badge/Badge 2.tsx +0 -28
  12. package/template/components/tools/flubber.d 2.ts +0 -7
  13. package/template/components/tools/input/Input 2.tsx +0 -99
  14. package/template/components/tools/input/Input.module 2.css +0 -45
  15. package/template/components/tools/label/Icon 2.tsx +0 -39
  16. package/template/components/tools/label/Label 2.tsx +0 -150
  17. package/template/components/tools/mobileViewProvider 2.tsx +0 -53
  18. package/template/components/tools/ripple/ripple 2.css +0 -38
  19. package/template/components/tools/ripple/ripple 2.tsx +0 -78
  20. package/template/components/tools/shape/Shape 2.tsx +0 -313
  21. package/template/components/tools/shape/Shape.module 2.css +0 -21
  22. package/template/components/tools/shape/ShapeLoader 2.tsx +0 -104
  23. package/template/components/tools/shape/ShapePaths 2.ts +0 -116
  24. package/template/components/tools/switch/Switch 2.tsx +0 -48
  25. package/template/components/tools/switch/Switch.module 2.css +0 -102
  26. package/template/components/tools/useBodyScrollLock 2.tsx +0 -27
  27. package/template/components/tools/useImageColor 2.ts +0 -47
  28. package/template/components/tools/useNavSheetDrag 2.tsx +0 -196
  29. package/template/public/fonts/material-symbols/MaterialSymbolsRounded-VariableFont_FILL,GRAD,opsz,wght 2.woff2 +0 -0
@@ -1,206 +0,0 @@
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
- // width === 0 is a valid, intentional state (fluid mode starts at 0 before
35
- // the first measurement) — but x / width would be 0 / 0 = NaN, poisoning
36
- // the whole path string. Short-circuit to a degenerate flat point instead.
37
- if (width <= 0) return `M0,${height / 2}`;
38
- const points: string[] = [];
39
- const step = 2;
40
- for (let x = 0; x <= width; x += step) {
41
- const y =
42
- height / 2 +
43
- amplitude * Math.sin((x / width) * frequency * 2 * Math.PI + phase);
44
- points.push(`${x},${y}`);
45
- }
46
- return "M" + points.join(" L ");
47
- }
48
-
49
- const Sinewave: React.FC<SinewaveProps> = ({
50
- width = 400,
51
- fluid = false,
52
- height = 20,
53
- frequency = width * 0.04,
54
- freqPerPx,
55
- amplitude = 4,
56
- stroke = "var(--md-sys-color-primary-container)",
57
- strokeWidth = 2,
58
- animate = false,
59
- duration = 1.6,
60
- style,
61
- className,
62
- }) => {
63
- const rootRef = React.useRef<HTMLDivElement>(null);
64
- const svgRef = React.useRef<SVGSVGElement>(null);
65
- const pathRef = React.useRef<SVGPathElement>(null);
66
- const phaseRef = React.useRef(0);
67
- const lastTimeRef = React.useRef<number | null>(null);
68
- const dispAmpRef = React.useRef(amplitude); // eased toward liveRef target
69
-
70
- // Geometry the rAF loop reads each frame. Refreshed every commit (via a
71
- // no-deps layout effect, before paint — not during render, since ref
72
- // writes aren't render-pure) so width/frequency/amplitude changes never
73
- // restart the loop's clock — phase keeps advancing while width animates.
74
- const liveRef = React.useRef({
75
- width,
76
- fluid,
77
- height,
78
- frequency,
79
- freqPerPx,
80
- amplitude,
81
- duration,
82
- });
83
- useIsoLayoutEffect(() => {
84
- liveRef.current = {
85
- width,
86
- fluid,
87
- height,
88
- frequency,
89
- freqPerPx,
90
- amplitude,
91
- duration,
92
- };
93
- });
94
-
95
- // Resolve "now": measured width when fluid, derived freq when freqPerPx is
96
- // set, eased amplitude.
97
- const measure = React.useCallback(() => {
98
- const l = liveRef.current;
99
- const measured = rootRef.current?.clientWidth; // 0 is valid (progress 0)
100
- const w = l.fluid ? (measured ?? l.width) : l.width;
101
- const f = l.freqPerPx != null ? w * l.freqPerPx : l.frequency;
102
- return { w, f, h: l.height, a: dispAmpRef.current };
103
- }, []);
104
-
105
- const draw = React.useCallback(() => {
106
- const { w, f, h, a } = measure();
107
- svgRef.current?.setAttribute("width", String(w));
108
- svgRef.current?.setAttribute("viewBox", `0 0 ${w} ${h}`);
109
- pathRef.current?.setAttribute("d", buildPath(w, h, f, a, phaseRef.current));
110
- }, [measure]);
111
-
112
- // Animated phase + per-frame re-fit + amplitude easing.
113
- React.useEffect(() => {
114
- if (!animate) {
115
- lastTimeRef.current = null;
116
- return;
117
- }
118
- let frame: number;
119
- const tick = (now: number) => {
120
- if (lastTimeRef.current != null) {
121
- const dt = (now - lastTimeRef.current) / 1000;
122
- phaseRef.current =
123
- (phaseRef.current + (dt / liveRef.current.duration) * Math.PI * 2) %
124
- (Math.PI * 2);
125
- // ease amplitude toward target (drops to 0 at ≥98%)
126
- dispAmpRef.current +=
127
- (liveRef.current.amplitude - dispAmpRef.current) *
128
- (1 - Math.exp(-dt * 8));
129
- }
130
- lastTimeRef.current = now;
131
- draw();
132
- frame = requestAnimationFrame(tick);
133
- };
134
- frame = requestAnimationFrame(tick);
135
- return () => cancelAnimationFrame(frame);
136
- }, [animate, draw]);
137
-
138
- // Initial fit (pre-paint) + static/resize fit when not animating.
139
- useIsoLayoutEffect(() => {
140
- if (!animate) dispAmpRef.current = amplitude; // frozen frame is exact
141
- draw();
142
- if (animate || !fluid) return;
143
- const el = rootRef.current;
144
- if (!el) return;
145
- const ro = new ResizeObserver(() => draw());
146
- ro.observe(el);
147
- return () => ro.disconnect();
148
- }, [draw, animate, fluid, width, height, frequency, freqPerPx, amplitude]);
149
-
150
- // Fluid starts at 0 so nothing flashes full-width before the first fit.
151
- const initialW = fluid ? 0 : width;
152
- const initialFreq = freqPerPx != null ? initialW * freqPerPx : frequency;
153
- const initialPath = React.useMemo(
154
- () => buildPath(initialW, height, initialFreq, amplitude, 0),
155
- [initialW, height, initialFreq, amplitude],
156
- );
157
-
158
- return (
159
- <div
160
- ref={rootRef}
161
- className="sinewave-container"
162
- style={{
163
- minHeight: "20px",
164
- margin: "24px 0",
165
- display: "flex",
166
- justifyContent: "center",
167
- alignItems: "center",
168
- ...(fluid ? { width: "100%" } : null),
169
- ...style,
170
- }}
171
- >
172
- <svg
173
- ref={svgRef}
174
- width={initialW}
175
- height={height}
176
- viewBox={`0 0 ${initialW} ${height}`}
177
- fill="none"
178
- xmlns="http://www.w3.org/2000/svg"
179
- style={{
180
- stroke,
181
- transition: "stroke var(--transition-expressive-color)",
182
- position: "relative",
183
- margin: 0,
184
- padding: 0,
185
- overflow: "visible",
186
- }}
187
- className={className}
188
- >
189
- <path
190
- ref={pathRef}
191
- d={initialPath}
192
- stroke={stroke}
193
- strokeLinecap="round"
194
- fill="none"
195
- suppressHydrationWarning
196
- style={{
197
- strokeWidth,
198
- transition: "stroke-width var(--transition-expressive-color)",
199
- }}
200
- />
201
- </svg>
202
- </div>
203
- );
204
- };
205
-
206
- export default Sinewave;
@@ -1,140 +0,0 @@
1
- "use client";
2
- import React from "react";
3
- import Sinewave from "@/components/tools/Sinewave";
4
-
5
- type SinewaveProgressProps = {
6
- /** 0-100 task progress. The wave covers the loaded portion, the line covers the rest. */
7
- progress: number;
8
- width?: number;
9
- height?: number;
10
- /** Frequency at full width. Wavelength is held constant as the wave grows. */
11
- frequency?: number;
12
- amplitude?: number;
13
- strokeWidth?: number;
14
- accentColor?: string;
15
- trackColor?: string;
16
- duration?: number;
17
- progressDuration?: number;
18
- progressEasing?: string;
19
- /** Seconds to hold at 100% before the whole bar collapses (thickness → 0). */
20
- onCollapsed?: () => void;
21
- shrinkDelay?: number;
22
- className?: string;
23
- style?: React.CSSProperties;
24
- };
25
-
26
- const SinewaveProgress: React.FC<SinewaveProgressProps> = ({
27
- progress,
28
- width = 400,
29
- height = 20,
30
- frequency = width * 0.04,
31
- amplitude = 2,
32
- strokeWidth = 4,
33
- accentColor = "var(--md-sys-color-primary, #d9ff1f)",
34
- trackColor = "var(--md-sys-color-secondary-container, #2e4a3d)",
35
- duration = 1,
36
- progressDuration = 1,
37
- progressEasing = "cubic-bezier(0.5,0,0.5,1)",
38
- shrinkDelay = 1,
39
- onCollapsed,
40
- className,
41
- style,
42
- }) => {
43
- const clamped = Math.min(100, Math.max(0, progress));
44
- const loadedWidth = (clamped / 100) * width;
45
- const computedWidth = width - loadedWidth;
46
- const remainingWidth = Math.max(0, computedWidth);
47
- const freqPerPx = frequency / width; // 12 / 400 = 0.03 — constant wavelength
48
- const progressTransition = `${progressDuration}s ${progressEasing}`;
49
-
50
- const complete = clamped >= 100;
51
-
52
- // Reach 100% → hold shrinkDelay seconds → collapse everything at once. The
53
- // immediate reset and the delayed-collapse timer are one state machine —
54
- // splitting the reset out to render time would still leave the timer
55
- // scheduling in an effect, for no real gain.
56
- const [collapsed, setCollapsed] = React.useState(false);
57
- /* eslint-disable react-hooks/set-state-in-effect */
58
- React.useEffect(() => {
59
- if (!complete) {
60
- setCollapsed(false);
61
- return;
62
- }
63
- const t = setTimeout(() => setCollapsed(true), shrinkDelay * 1000);
64
- return () => clearTimeout(t);
65
- }, [complete, shrinkDelay]);
66
- /* eslint-enable react-hooks/set-state-in-effect */
67
-
68
- // One thickness drives the wave stroke, the track height and the dot, so all
69
- // three thin to nothing together when `collapsed` flips. amplitude goes with them.
70
- const thickness = collapsed ? 0 : strokeWidth;
71
- const waveAmplitude = collapsed ? 0 : amplitude;
72
- const sizeTween = "var(--transition-expressive-color)"; // shared → all shrink in sync
73
-
74
- return (
75
- <div
76
- className={className}
77
- style={{
78
- display: "flex",
79
- alignItems: "center",
80
- width,
81
- height,
82
- ...style,
83
- }}
84
- >
85
- <div
86
- style={{
87
- width: loadedWidth,
88
- marginRight: !complete ? 8 : 0,
89
- height,
90
- flexShrink: 0,
91
- transition: `width ${progressTransition}, margin ${progressTransition}`,
92
- }}
93
- >
94
- <Sinewave
95
- fluid
96
- freqPerPx={freqPerPx}
97
- height={height}
98
- amplitude={waveAmplitude}
99
- strokeWidth={thickness}
100
- stroke={accentColor}
101
- animate={true}
102
- duration={duration}
103
- style={{ margin: 0, minHeight: height, width: "100%" }}
104
- />
105
- </div>
106
- <div
107
- onTransitionEnd={(e) => {
108
- if (collapsed && e.propertyName === "height") onCollapsed?.();
109
- }}
110
- style={{
111
- flexGrow: 0,
112
- flexShrink: 0,
113
- flexBasis: remainingWidth,
114
- opacity: !complete ? 1 : 0,
115
- minWidth: 0,
116
- height: thickness,
117
- background: trackColor,
118
- borderRadius: thickness,
119
- transition: `flex-basis ${progressTransition}, height ${sizeTween}, border-radius ${sizeTween}, background ${sizeTween}, opacity 2s ${sizeTween}`,
120
- }}
121
- />
122
- <span
123
- aria-hidden
124
- style={{
125
- flexShrink: 0,
126
- width: thickness,
127
- height: thickness,
128
- borderRadius: "50%",
129
- position: "absolute",
130
- opacity: !complete ? 1 : 0,
131
- marginLeft: width - thickness + 8,
132
- background: accentColor,
133
- transition: `width ${sizeTween}, height ${sizeTween}, margin 2s ${sizeTween}, background ${sizeTween}, opacity 2s ${sizeTween}`,
134
- }}
135
- />
136
- </div>
137
- );
138
- };
139
-
140
- export default SinewaveProgress;
@@ -1,28 +0,0 @@
1
- function Badge({
2
- children,
3
- badgeVariant = "error",
4
- }: {
5
- badgeVariant?: "error" | "primary" | "secondary" | "tertiary" | "success";
6
- children?: React.ReactNode;
7
- }) {
8
- return (
9
- <span
10
- style={{
11
- display: "inline-block",
12
- backgroundColor: `var(--md-sys-color-${badgeVariant}-container)`,
13
- color: `var(--md-sys-color-on-${badgeVariant}-container)`,
14
- borderRadius: "var(--borderRadius-sm)",
15
- padding: "4px 8px",
16
- scale: 1,
17
- fontSize: "0.6rem",
18
- fontWeight: 600,
19
- textTransform: "uppercase",
20
- transition: "all var(--transition-expressive-color)",
21
- }}
22
- >
23
- {children}
24
- </span>
25
- );
26
- }
27
-
28
- export { Badge };
@@ -1,7 +0,0 @@
1
- declare module "flubber" {
2
- export function interpolate(
3
- from: string,
4
- to: string,
5
- options?: { maxSegmentLength?: number },
6
- ): (t: number) => string;
7
- }
@@ -1,99 +0,0 @@
1
- "use client";
2
-
3
- import styles from "./Input.module.css";
4
-
5
- type RadioVariant = "primary" | "secondary" | "tertiary" | "error";
6
-
7
- type RadioProps = {
8
- checked: boolean;
9
- onChange?: (checked: boolean) => void;
10
- // variant booleans — first truthy one wins; defaults to "primary"
11
- primary?: boolean;
12
- secondary?: boolean;
13
- tertiary?: boolean;
14
- error?: boolean;
15
- disabled?: boolean;
16
- className?: string;
17
- style?: React.CSSProperties;
18
- };
19
-
20
- function resolveVariant({
21
- primary,
22
- secondary,
23
- tertiary,
24
- error,
25
- }: Pick<
26
- RadioProps,
27
- "primary" | "secondary" | "tertiary" | "error"
28
- >): RadioVariant {
29
- if (primary) return "primary";
30
- if (secondary) return "secondary";
31
- if (tertiary) return "tertiary";
32
- if (error) return "error";
33
- return "primary";
34
- }
35
-
36
- function Radio({
37
- checked,
38
- onChange,
39
- primary,
40
- secondary,
41
- tertiary,
42
- error,
43
- disabled,
44
- className,
45
- style,
46
- }: RadioProps) {
47
- if (process.env.NODE_ENV !== "production") {
48
- const variantCount = [primary, secondary, tertiary, error].filter(
49
- Boolean,
50
- ).length;
51
- if (variantCount === 0) {
52
- console.warn(
53
- "<Input.Radio>: No variant prop provided. Specify one of: primary, secondary, tertiary, error.",
54
- );
55
- } else if (variantCount > 1) {
56
- console.warn(
57
- "<Input.Radio>: Multiple variant props provided — only the first truthy one is used. Remove the extras.",
58
- );
59
- }
60
- }
61
-
62
- const variant = resolveVariant({ primary, secondary, tertiary, error });
63
- const activeColor = `var(--md-sys-color-${variant})`;
64
- const restColor = "var(--md-sys-color-outline)";
65
-
66
- return (
67
- <button
68
- type="button"
69
- role="radio"
70
- aria-checked={checked}
71
- disabled={disabled}
72
- onClick={() => onChange?.(!checked)}
73
- className={className ? `${className} ${styles.radio}` : styles.radio}
74
- style={style}
75
- >
76
- <span
77
- className={styles.ring}
78
- style={{
79
- borderColor: checked ? activeColor : restColor,
80
- borderWidth: checked ? 2 : 2,
81
- width: checked ? 18 : 18,
82
- height: checked ? 18 : 18,
83
- }}
84
- />
85
- <span
86
- className={styles.dot}
87
- style={{
88
- background: checked ? activeColor : restColor,
89
- opacity: checked ? 1 : 0,
90
- width: checked ? 10 : 4,
91
- height: checked ? 10 : 4,
92
- }}
93
- />
94
- </button>
95
- );
96
- }
97
-
98
- const Input = { Radio };
99
- export default Input;
@@ -1,45 +0,0 @@
1
- .radio {
2
- position: relative;
3
- width: 24px;
4
- height: 24px;
5
- margin: 8px;
6
- padding: 0;
7
- border: none;
8
- background: transparent;
9
- cursor: pointer;
10
- flex-shrink: 0;
11
- display: inline-block;
12
- }
13
-
14
- .radio:disabled {
15
- cursor: not-allowed;
16
- opacity: 0.38;
17
- }
18
-
19
- .ring {
20
- position: absolute;
21
- top: 50%;
22
- left: 50%;
23
- box-sizing: border-box;
24
- border-radius: 50%;
25
- border-style: solid;
26
- transform: translate(-50%, -50%);
27
- transition:
28
- width var(--transition-expressive-slow),
29
- height var(--transition-expressive-slow),
30
- border-color var(--transition-expressive-color),
31
- border-width var(--transition-expressive-slow);
32
- }
33
-
34
- .dot {
35
- position: absolute;
36
- top: 50%;
37
- left: 50%;
38
- border-radius: 50%;
39
- transform: translate(-50%, -50%);
40
- transition:
41
- width var(--transition-expressive-slow),
42
- height var(--transition-expressive-slow),
43
- background-color var(--transition-expressive-color),
44
- opacity var(--transition-expressive-color);
45
- }
@@ -1,39 +0,0 @@
1
- "use client";
2
- import React from "react";
3
- import { motion, AnimatePresence, easeInOut } from "framer-motion";
4
-
5
- type IconProps = {
6
- systemName: string;
7
- style?: React.CSSProperties;
8
- };
9
-
10
- // Old value shrinks+blurs out over 200ms, then the new value grows+unblurs
11
- // in over 200ms (AnimatePresence mode="wait" sequences the two — 400ms
12
- // total) whenever systemName changes. Keyed on systemName itself, which is
13
- // also what keeps the outgoing value mounted long enough to animate out.
14
- const SWAP_TRANSITION = { duration: 0.225, ease: easeInOut };
15
-
16
- export default function Icon({ systemName, style }: IconProps) {
17
- return (
18
- <AnimatePresence mode="wait" initial={false}>
19
- <motion.span
20
- key={systemName}
21
- className="material-symbols-rounded"
22
- aria-hidden="true"
23
- style={{
24
- minHeight: 28,
25
- minWidth: 24,
26
- padding: "0 2px",
27
- userSelect: "none",
28
- ...style,
29
- }}
30
- initial={{ scale: 0.8, filter: "blur(4px)" }}
31
- animate={{ scale: 1, filter: "blur(0px)" }}
32
- exit={{ scale: 0.96, filter: "blur(6px)" }}
33
- transition={SWAP_TRANSITION}
34
- >
35
- {systemName}
36
- </motion.span>
37
- </AnimatePresence>
38
- );
39
- }