@patternmode/status 0.1.0 → 0.2.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/dist/index.mjs +19 -11
- package/dist/index.mjs.map +1 -1
- package/dist/status-mark-types.d.ts.map +1 -1
- package/dist/status-mark.d.ts +1 -1
- package/dist/status-mark.d.ts.map +1 -1
- package/package.json +23 -24
package/dist/index.mjs
CHANGED
|
@@ -46,7 +46,13 @@ const PROGRESS_STEP = {
|
|
|
46
46
|
};
|
|
47
47
|
const snapProgress = (value) => {
|
|
48
48
|
if (value === void 0 || Number.isNaN(value)) return 0;
|
|
49
|
-
|
|
49
|
+
switch (Math.round(Math.min(100, Math.max(0, value)) / 25) * 25) {
|
|
50
|
+
case 25: return 25;
|
|
51
|
+
case 50: return 50;
|
|
52
|
+
case 75: return 75;
|
|
53
|
+
case 100: return 100;
|
|
54
|
+
default: return 0;
|
|
55
|
+
}
|
|
50
56
|
};
|
|
51
57
|
/** Resolves named or numeric progress input into a discrete StatusMark step. */
|
|
52
58
|
const resolveStatusProgress = ({ status, value }) => {
|
|
@@ -54,7 +60,7 @@ const resolveStatusProgress = ({ status, value }) => {
|
|
|
54
60
|
progress: null,
|
|
55
61
|
status
|
|
56
62
|
};
|
|
57
|
-
if (status) return {
|
|
63
|
+
if (status !== void 0) return {
|
|
58
64
|
progress: STEP_PROGRESS[status],
|
|
59
65
|
status
|
|
60
66
|
};
|
|
@@ -129,8 +135,8 @@ const getRootStyle = ({ color, size = "base", style, trackColor }) => {
|
|
|
129
135
|
...getSizeVariableStyle(size, "--patternmode-status-size"),
|
|
130
136
|
...style
|
|
131
137
|
};
|
|
132
|
-
if (color) rootStyle["--patternmode-status-color"] = color;
|
|
133
|
-
if (trackColor) rootStyle["--patternmode-status-track"] = trackColor;
|
|
138
|
+
if (color !== void 0 && color !== "") rootStyle["--patternmode-status-color"] = color;
|
|
139
|
+
if (trackColor !== void 0 && trackColor !== "") rootStyle["--patternmode-status-track"] = trackColor;
|
|
134
140
|
return rootStyle;
|
|
135
141
|
};
|
|
136
142
|
const StatusFillSweep = ({ hasReducedMotion, motion, progress, radius }) => {
|
|
@@ -138,14 +144,17 @@ const StatusFillSweep = ({ hasReducedMotion, motion, progress, radius }) => {
|
|
|
138
144
|
const renderedProgressRef = useRef(progress);
|
|
139
145
|
const [renderedProgress, setRenderedProgress] = useReducer(setProgress, progress);
|
|
140
146
|
useEffect(() => {
|
|
147
|
+
const cancelFillAnimation = () => {
|
|
148
|
+
if (animationFrameRef.current !== null) cancelAnimationFrame(animationFrameRef.current);
|
|
149
|
+
};
|
|
141
150
|
const duration = getFillMotionDuration(motion, hasReducedMotion);
|
|
142
151
|
const startProgress = renderedProgressRef.current;
|
|
143
152
|
const progressDelta = progress - startProgress;
|
|
144
|
-
|
|
153
|
+
cancelFillAnimation();
|
|
145
154
|
if (duration === 0 || progressDelta === 0) {
|
|
146
155
|
renderedProgressRef.current = progress;
|
|
147
156
|
setRenderedProgress(progress);
|
|
148
|
-
return;
|
|
157
|
+
return cancelFillAnimation;
|
|
149
158
|
}
|
|
150
159
|
const startTime = performance.now();
|
|
151
160
|
const tick = (now) => {
|
|
@@ -161,9 +170,7 @@ const StatusFillSweep = ({ hasReducedMotion, motion, progress, radius }) => {
|
|
|
161
170
|
animationFrameRef.current = null;
|
|
162
171
|
};
|
|
163
172
|
animationFrameRef.current = requestAnimationFrame(tick);
|
|
164
|
-
return
|
|
165
|
-
if (animationFrameRef.current !== null) cancelAnimationFrame(animationFrameRef.current);
|
|
166
|
-
};
|
|
173
|
+
return cancelFillAnimation;
|
|
167
174
|
}, [
|
|
168
175
|
hasReducedMotion,
|
|
169
176
|
motion,
|
|
@@ -239,9 +246,10 @@ const StatusMark = ({ className, color, label, motion = "smooth", size = "base",
|
|
|
239
246
|
style,
|
|
240
247
|
trackColor
|
|
241
248
|
});
|
|
249
|
+
const hasLabel = label !== void 0 && label !== "";
|
|
242
250
|
return /* @__PURE__ */ jsx("span", {
|
|
243
251
|
...props,
|
|
244
|
-
"aria-hidden":
|
|
252
|
+
"aria-hidden": hasLabel ? void 0 : true,
|
|
245
253
|
"aria-label": label,
|
|
246
254
|
className: joinClassNames("patternmode-status-mark", className),
|
|
247
255
|
"data-motion": motion === false ? "false" : motion,
|
|
@@ -250,7 +258,7 @@ const StatusMark = ({ className, color, label, motion = "smooth", size = "base",
|
|
|
250
258
|
"data-status": state.status,
|
|
251
259
|
"data-tone": tone,
|
|
252
260
|
"data-variant": variant,
|
|
253
|
-
role:
|
|
261
|
+
role: hasLabel ? "img" : void 0,
|
|
254
262
|
style: rootStyle,
|
|
255
263
|
children: /* @__PURE__ */ jsx(LazyMotion, {
|
|
256
264
|
features: domMax,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/status-mark-types.ts","../src/status-mark.tsx"],"sourcesContent":["import type { HTMLAttributes } from \"react\";\n\nexport const STATUS_MARK_PROGRESS_STEPS = [\n \"null\",\n \"empty\",\n \"quarter\",\n \"half\",\n \"three-quarter\",\n \"full\",\n] as const;\n\nexport const STATUS_MARK_STATUSES = STATUS_MARK_PROGRESS_STEPS;\nexport const STATUS_MARK_PROGRESS_VALUES = [0, 25, 50, 75, 100] as const;\nexport const STATUS_MARK_TONES = [\"neutral\", \"accent\", \"muted\"] as const;\nexport const STATUS_MARK_VARIANTS = [\"fill\", \"border\"] as const;\nexport const STATUS_MARK_MOTIONS = [\"smooth\", \"snap\", \"reduced\"] as const;\n\nexport type StatusMarkMotion = (typeof STATUS_MARK_MOTIONS)[number] | false;\nexport type StatusMarkProgressStep = (typeof STATUS_MARK_PROGRESS_STEPS)[number];\nexport type StatusMarkProgressValue = (typeof STATUS_MARK_PROGRESS_VALUES)[number];\nexport type StatusMarkStatus = StatusMarkProgressStep;\nexport type StatusMarkTone = (typeof STATUS_MARK_TONES)[number];\nexport type StatusMarkVariant = (typeof STATUS_MARK_VARIANTS)[number];\n\nexport type ResolvedStatusProgress =\n | {\n progress: null;\n status: \"null\";\n }\n | {\n progress: StatusMarkProgressValue;\n status: Exclude<StatusMarkProgressStep, \"null\">;\n };\n\nexport interface StatusMarkProps extends Omit<HTMLAttributes<HTMLSpanElement>, \"children\"> {\n /**\n * Active progress color. Overrides the selected visual `tone` when supplied.\n */\n color?: string;\n /**\n * Accessible label for the visual state. Omit only when adjacent text already\n * names the same progress and the mark should be decorative.\n */\n label?: string;\n /**\n * Transition preset for movement between progress steps.\n *\n * Default `\"smooth\"`.\n */\n motion?: StatusMarkMotion;\n /**\n * Named discrete progress step. Use `\"null\"` only when progress is explicitly\n * not yet known or measured.\n */\n status?: StatusMarkProgressStep;\n /**\n * Size token used for the mark dimensions.\n *\n * Default `\"base\"`.\n */\n size?: \"2xl\" | \"2xs\" | \"3xl\" | \"base\" | \"lg\" | \"sm\" | \"xl\" | \"xs\";\n /**\n * Visual emphasis treatment. Tone changes color only; progress shape carries\n * meaning.\n *\n * Default `\"neutral\"`.\n */\n tone?: StatusMarkTone;\n /**\n * Color used for inactive track or placeholder structure.\n */\n trackColor?: string;\n /**\n * Numeric progress input. Values are clamped from 0 to 100 and snapped to the\n * nearest discrete visual step: 0, 25, 50, 75, or 100.\n */\n value?: number;\n /**\n * Visual treatment for known progress. Null progress renders the same dashed\n * placeholder in every variant.\n *\n * Default `\"fill\"`.\n */\n variant?: StatusMarkVariant;\n}\n\nconst STEP_PROGRESS: Record<Exclude<StatusMarkProgressStep, \"null\">, StatusMarkProgressValue> = {\n empty: 0,\n full: 100,\n half: 50,\n quarter: 25,\n \"three-quarter\": 75,\n};\n\nconst PROGRESS_STEP: Record<StatusMarkProgressValue, Exclude<StatusMarkProgressStep, \"null\">> = {\n 0: \"empty\",\n 100: \"full\",\n 25: \"quarter\",\n 50: \"half\",\n 75: \"three-quarter\",\n};\n\nconst snapProgress = (value: number | undefined): StatusMarkProgressValue => {\n if (value === undefined || Number.isNaN(value)) {\n return 0;\n }\n\n const clamped = Math.min(100, Math.max(0, value));\n return (Math.round(clamped / 25) * 25) as StatusMarkProgressValue;\n};\n\n/** Resolves named or numeric progress input into a discrete StatusMark step. */\nexport const resolveStatusProgress = ({\n status,\n value,\n}: Pick<StatusMarkProps, \"status\" | \"value\">): ResolvedStatusProgress => {\n if (status === \"null\") {\n return {\n progress: null,\n status,\n };\n }\n\n if (status) {\n return {\n progress: STEP_PROGRESS[status],\n status,\n };\n }\n\n const progress = snapProgress(value);\n return {\n progress,\n status: PROGRESS_STEP[progress],\n };\n};\n","\"use client\";\n\nimport { getSizeVariableStyle, joinClassNames } from \"@patternmode/system\";\nimport { useEffect, useReducer, useRef } from \"react\";\nimport type { CSSProperties } from \"react\";\nimport { domMax, LazyMotion, m, useReducedMotion } from \"motion/react\";\nimport type { Transition } from \"motion/react\";\n\nimport { resolveStatusProgress } from \"./status-mark-types\";\nimport type {\n ResolvedStatusProgress,\n StatusMarkMotion,\n StatusMarkProgressValue,\n StatusMarkProps,\n} from \"./status-mark-types\";\n\ntype StatusMarkStyle = CSSProperties & Record<`--${string}`, string | number | undefined>;\ninterface MotionPartProps {\n hasReducedMotion: boolean;\n motion: StatusMarkMotion;\n}\n\nconst STATUS_MARK_RADIUS = 8;\nconst STATUS_MARK_STROKE_WIDTH = 1.8;\nconst BORDERLESS_STATUS_MARK_RADIUS = STATUS_MARK_RADIUS + STATUS_MARK_STROKE_WIDTH / 2;\nconst STATUS_MARK_CENTER = 12;\nconst STATUS_MARK_START_ANGLE = -90;\nconst STATUS_MARK_FULL_PROGRESS = 100;\nconst STATUS_SNAP_DURATION_MS = 160;\nconst STATUS_SMOOTH_DURATION_MS = 280;\n\nconst getTransition = (motion: StatusMarkMotion, reducedMotion: boolean): Transition => {\n if (motion === false || motion === \"reduced\" || reducedMotion) {\n return { duration: 0.01 };\n }\n\n if (motion === \"snap\") {\n return { duration: 0.16, ease: [0.22, 1, 0.36, 1] as const };\n }\n\n return { duration: 0.28, ease: [0.4, 0, 0.2, 1] as const };\n};\n\nconst getFillMotionDuration = (motion: StatusMarkMotion, reducedMotion: boolean) => {\n if (motion === false || motion === \"reduced\" || reducedMotion) {\n return 0;\n }\n\n return motion === \"snap\" ? STATUS_SNAP_DURATION_MS : STATUS_SMOOTH_DURATION_MS;\n};\n\nconst easeFillProgress = (progress: number) => {\n if (progress < 0.5) {\n return 4 * progress * progress * progress;\n }\n\n return 1 - (-2 * progress + 2) ** 3 / 2;\n};\n\nconst setProgress = (_current: number, next: number) => next;\n\nconst getFillPath = (progress: number, radius: number) => {\n if (progress <= 0) {\n return `M${STATUS_MARK_CENTER} ${STATUS_MARK_CENTER}`;\n }\n\n if (progress >= 99.9) {\n const diameter = radius * 2;\n\n return [\n `M${STATUS_MARK_CENTER - radius} ${STATUS_MARK_CENTER}`,\n `a${radius} ${radius} 0 1 0 ${diameter} 0`,\n `a${radius} ${radius} 0 1 0 -${diameter} 0`,\n ].join(\" \");\n }\n\n const endAngle = STATUS_MARK_START_ANGLE + (360 * progress) / STATUS_MARK_FULL_PROGRESS;\n const radians = (endAngle * Math.PI) / 180;\n const x = Number((STATUS_MARK_CENTER + radius * Math.cos(radians)).toFixed(3));\n const y = Number((STATUS_MARK_CENTER + radius * Math.sin(radians)).toFixed(3));\n const largeArcFlag = progress > 50 ? 1 : 0;\n\n return [\n `M${STATUS_MARK_CENTER} ${STATUS_MARK_CENTER}`,\n `L${STATUS_MARK_CENTER} ${STATUS_MARK_CENTER - radius}`,\n `A${radius} ${radius} 0 ${largeArcFlag} 1 ${x} ${y}`,\n \"Z\",\n ].join(\" \");\n};\n\nconst getRootStyle = ({\n color,\n size = \"base\",\n style,\n trackColor,\n}: Pick<StatusMarkProps, \"color\" | \"size\" | \"style\" | \"trackColor\">) => {\n const rootStyle: StatusMarkStyle = {\n ...getSizeVariableStyle(size, \"--patternmode-status-size\"),\n ...style,\n };\n\n if (color) {\n rootStyle[\"--patternmode-status-color\"] = color;\n }\n\n if (trackColor) {\n rootStyle[\"--patternmode-status-track\"] = trackColor;\n }\n\n return rootStyle;\n};\n\nconst StatusFillSweep = ({\n hasReducedMotion,\n motion,\n progress,\n radius,\n}: MotionPartProps & { progress: StatusMarkProgressValue; radius: number }) => {\n const animationFrameRef = useRef<number | null>(null);\n const renderedProgressRef = useRef<number>(progress);\n const [renderedProgress, setRenderedProgress] = useReducer(setProgress, progress);\n\n useEffect(() => {\n const duration = getFillMotionDuration(motion, hasReducedMotion);\n const startProgress = renderedProgressRef.current;\n const progressDelta = progress - startProgress;\n\n if (animationFrameRef.current !== null) {\n cancelAnimationFrame(animationFrameRef.current);\n }\n\n if (duration === 0 || progressDelta === 0) {\n renderedProgressRef.current = progress;\n setRenderedProgress(progress);\n return;\n }\n\n const startTime = performance.now();\n\n const tick = (now: number) => {\n const elapsed = Math.min((now - startTime) / duration, 1);\n const nextProgress = startProgress + progressDelta * easeFillProgress(elapsed);\n\n renderedProgressRef.current = nextProgress;\n setRenderedProgress(nextProgress);\n\n if (elapsed < 1) {\n animationFrameRef.current = requestAnimationFrame(tick);\n return;\n }\n\n renderedProgressRef.current = progress;\n animationFrameRef.current = null;\n };\n\n animationFrameRef.current = requestAnimationFrame(tick);\n\n return () => {\n if (animationFrameRef.current !== null) {\n cancelAnimationFrame(animationFrameRef.current);\n }\n };\n }, [hasReducedMotion, motion, progress]);\n\n return (\n <path\n className=\"patternmode-status-mark__fill-sweep\"\n d={getFillPath(renderedProgress, radius)}\n data-testid=\"status-mark-fill-sweep\"\n />\n );\n};\n\nconst StatusArc = ({\n hasReducedMotion,\n motion,\n progress,\n}: MotionPartProps & { progress: StatusMarkProgressValue }) => (\n <m.circle\n animate={{ opacity: progress > 0 ? 1 : 0, pathLength: progress / 100 }}\n className=\"patternmode-status-mark__arc\"\n cx=\"12\"\n cy=\"12\"\n initial={false}\n pathLength=\"1\"\n r=\"8\"\n transition={getTransition(motion, hasReducedMotion)}\n />\n);\n\nconst StatusMarkSvg = ({\n hasReducedMotion,\n motion,\n state,\n variant,\n}: MotionPartProps & {\n state: ResolvedStatusProgress;\n variant: NonNullable<StatusMarkProps[\"variant\"]>;\n}) => (\n <svg aria-hidden=\"true\" className=\"patternmode-status-mark__svg\" fill=\"none\" viewBox=\"0 0 24 24\">\n {state.status === \"null\" ? (\n <circle\n className=\"patternmode-status-mark__track patternmode-status-mark__track--null\"\n cx=\"12\"\n cy=\"12\"\n data-testid=\"status-mark-null\"\n r={STATUS_MARK_RADIUS}\n />\n ) : (\n <>\n {variant === \"fill\" ? (\n <>\n <circle\n className=\"patternmode-status-mark__disc\"\n cx=\"12\"\n cy=\"12\"\n data-testid=\"status-mark-fill\"\n r={BORDERLESS_STATUS_MARK_RADIUS}\n />\n <StatusFillSweep\n hasReducedMotion={hasReducedMotion}\n motion={motion}\n progress={state.progress}\n radius={BORDERLESS_STATUS_MARK_RADIUS}\n />\n </>\n ) : null}\n {variant === \"border\" ? (\n <circle\n className=\"patternmode-status-mark__track\"\n cx=\"12\"\n cy=\"12\"\n data-testid=\"status-mark-border\"\n r={STATUS_MARK_RADIUS}\n />\n ) : null}\n {variant === \"border\" ? (\n <StatusArc\n hasReducedMotion={hasReducedMotion}\n motion={motion}\n progress={state.progress}\n />\n ) : null}\n </>\n )}\n </svg>\n);\n\nexport const StatusMark = ({\n className,\n color,\n label,\n motion = \"smooth\",\n size = \"base\",\n status,\n style,\n tone = \"neutral\",\n trackColor,\n value,\n variant = \"fill\",\n ...props\n}: StatusMarkProps) => {\n const reducedMotion = useReducedMotion();\n const hasReducedMotion = Boolean(reducedMotion);\n const state = resolveStatusProgress({ status, value });\n const rootStyle = getRootStyle({ color, size, style, trackColor });\n\n return (\n <span\n {...props}\n aria-hidden={label ? undefined : true}\n aria-label={label}\n className={joinClassNames(\"patternmode-status-mark\", className)}\n data-motion={motion === false ? \"false\" : motion}\n data-progress={state.progress ?? \"null\"}\n data-slot=\"status-mark\"\n data-status={state.status}\n data-tone={tone}\n data-variant={variant}\n role={label ? \"img\" : undefined}\n style={rootStyle}\n >\n <LazyMotion features={domMax}>\n <StatusMarkSvg\n hasReducedMotion={hasReducedMotion}\n motion={motion}\n state={state}\n variant={variant}\n />\n </LazyMotion>\n </span>\n );\n};\n"],"mappings":";;;;;AAEA,MAAa,6BAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,uBAAuB;AACpC,MAAa,8BAA8B;CAAC;CAAG;CAAI;CAAI;CAAI;AAAG;AAC9D,MAAa,oBAAoB;CAAC;CAAW;CAAU;AAAO;AAC9D,MAAa,uBAAuB,CAAC,QAAQ,QAAQ;AACrD,MAAa,sBAAsB;CAAC;CAAU;CAAQ;AAAS;AAuE/D,MAAM,gBAA0F;CAC9F,OAAO;CACP,MAAM;CACN,MAAM;CACN,SAAS;CACT,iBAAiB;AACnB;AAEA,MAAM,gBAA0F;CAC9F,GAAG;CACH,KAAK;CACL,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,gBAAgB,UAAuD;CAC3E,IAAI,UAAU,KAAA,KAAa,OAAO,MAAM,KAAK,GAC3C,OAAO;CAIT,OAAQ,KAAK,MADG,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,CACtB,IAAI,EAAE,IAAI;AACrC;;AAGA,MAAa,yBAAyB,EACpC,QACA,YACuE;CACvE,IAAI,WAAW,QACb,OAAO;EACL,UAAU;EACV;CACF;CAGF,IAAI,QACF,OAAO;EACL,UAAU,cAAc;EACxB;CACF;CAGF,MAAM,WAAW,aAAa,KAAK;CACnC,OAAO;EACL;EACA,QAAQ,cAAc;CACxB;AACF;;;ACjHA,MAAM,qBAAqB;AAE3B,MAAM,gCAAgC;AACtC,MAAM,qBAAqB;AAC3B,MAAM,0BAA0B;AAChC,MAAM,4BAA4B;AAClC,MAAM,0BAA0B;AAChC,MAAM,4BAA4B;AAElC,MAAM,iBAAiB,QAA0B,kBAAuC;CACtF,IAAI,WAAW,SAAS,WAAW,aAAa,eAC9C,OAAO,EAAE,UAAU,IAAK;CAG1B,IAAI,WAAW,QACb,OA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Q,UAAU;EAC1C,iBAAe,MAAM,YAAY;EACjC,aAAU;EACV,eAAa,MAAM;EACnB,aAAW;EACX,gBAAc;EACd,MAAM,QAAQ,QAAQ,KAAA;EACtB,OAAO;YAEP,oBAAC,YAAD;GAAY,UAAU;aACpB,oBAAC,eAAD;IACoB;IACV;IACD;IACE;GACV,CAAA;EACS,CAAA;CACR,CAAA;AAEV"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/status-mark-types.ts","../src/status-mark.tsx"],"sourcesContent":["import type { HTMLAttributes } from \"react\";\n\nexport const STATUS_MARK_PROGRESS_STEPS = [\n \"null\",\n \"empty\",\n \"quarter\",\n \"half\",\n \"three-quarter\",\n \"full\",\n] as const;\n\nexport const STATUS_MARK_STATUSES = STATUS_MARK_PROGRESS_STEPS;\nexport const STATUS_MARK_PROGRESS_VALUES = [0, 25, 50, 75, 100] as const;\nexport const STATUS_MARK_TONES = [\"neutral\", \"accent\", \"muted\"] as const;\nexport const STATUS_MARK_VARIANTS = [\"fill\", \"border\"] as const;\nexport const STATUS_MARK_MOTIONS = [\"smooth\", \"snap\", \"reduced\"] as const;\n\nexport type StatusMarkMotion = (typeof STATUS_MARK_MOTIONS)[number] | false;\nexport type StatusMarkProgressStep = (typeof STATUS_MARK_PROGRESS_STEPS)[number];\nexport type StatusMarkProgressValue = (typeof STATUS_MARK_PROGRESS_VALUES)[number];\nexport type StatusMarkStatus = StatusMarkProgressStep;\nexport type StatusMarkTone = (typeof STATUS_MARK_TONES)[number];\nexport type StatusMarkVariant = (typeof STATUS_MARK_VARIANTS)[number];\n\nexport type ResolvedStatusProgress =\n | {\n progress: null;\n status: \"null\";\n }\n | {\n progress: StatusMarkProgressValue;\n status: Exclude<StatusMarkProgressStep, \"null\">;\n };\n\nexport interface StatusMarkProps extends Omit<HTMLAttributes<HTMLSpanElement>, \"children\"> {\n /**\n * Active progress color. Overrides the selected visual `tone` when supplied.\n */\n color?: string;\n /**\n * Accessible label for the visual state. Omit only when adjacent text already\n * names the same progress and the mark should be decorative.\n */\n label?: string;\n /**\n * Transition preset for movement between progress steps.\n *\n * Default `\"smooth\"`.\n */\n motion?: StatusMarkMotion;\n /**\n * Named discrete progress step. Use `\"null\"` only when progress is explicitly\n * not yet known or measured.\n */\n status?: StatusMarkProgressStep;\n /**\n * Size token used for the mark dimensions.\n *\n * Default `\"base\"`.\n */\n size?: \"2xl\" | \"2xs\" | \"3xl\" | \"base\" | \"lg\" | \"sm\" | \"xl\" | \"xs\";\n /**\n * Visual emphasis treatment. Tone changes color only; progress shape carries\n * meaning.\n *\n * Default `\"neutral\"`.\n */\n tone?: StatusMarkTone;\n /**\n * Color used for inactive track or placeholder structure.\n */\n trackColor?: string;\n /**\n * Numeric progress input. Values are clamped from 0 to 100 and snapped to the\n * nearest discrete visual step: 0, 25, 50, 75, or 100.\n */\n value?: number;\n /**\n * Visual treatment for known progress. Null progress renders the same dashed\n * placeholder in every variant.\n *\n * Default `\"fill\"`.\n */\n variant?: StatusMarkVariant;\n}\n\nconst STEP_PROGRESS: Record<Exclude<StatusMarkProgressStep, \"null\">, StatusMarkProgressValue> = {\n empty: 0,\n full: 100,\n half: 50,\n quarter: 25,\n \"three-quarter\": 75,\n};\n\nconst PROGRESS_STEP: Record<StatusMarkProgressValue, Exclude<StatusMarkProgressStep, \"null\">> = {\n 0: \"empty\",\n 100: \"full\",\n 25: \"quarter\",\n 50: \"half\",\n 75: \"three-quarter\",\n};\n\nconst snapProgress = (value: number | undefined): StatusMarkProgressValue => {\n if (value === undefined || Number.isNaN(value)) {\n return 0;\n }\n\n const clamped = Math.min(100, Math.max(0, value));\n const snapped = Math.round(clamped / 25) * 25;\n\n switch (snapped) {\n case 25: {\n return 25;\n }\n case 50: {\n return 50;\n }\n case 75: {\n return 75;\n }\n case 100: {\n return 100;\n }\n default: {\n return 0;\n }\n }\n};\n\n/** Resolves named or numeric progress input into a discrete StatusMark step. */\nexport const resolveStatusProgress = ({\n status,\n value,\n}: Pick<StatusMarkProps, \"status\" | \"value\">): ResolvedStatusProgress => {\n if (status === \"null\") {\n return {\n progress: null,\n status,\n };\n }\n\n if (status !== undefined) {\n return {\n progress: STEP_PROGRESS[status],\n status,\n };\n }\n\n const progress = snapProgress(value);\n return {\n progress,\n status: PROGRESS_STEP[progress],\n };\n};\n","\"use client\";\n\nimport { getSizeVariableStyle, joinClassNames } from \"@patternmode/system\";\nimport { useEffect, useReducer, useRef } from \"react\";\nimport type { CSSProperties } from \"react\";\nimport { domMax, LazyMotion, m, useReducedMotion } from \"motion/react\";\nimport type { Transition } from \"motion/react\";\n\nimport { resolveStatusProgress } from \"./status-mark-types\";\nimport type {\n ResolvedStatusProgress,\n StatusMarkMotion,\n StatusMarkProgressValue,\n StatusMarkProps,\n} from \"./status-mark-types\";\n\ntype StatusMarkStyle = CSSProperties & Record<`--${string}`, string | number | undefined>;\ninterface MotionPartProps {\n hasReducedMotion: boolean;\n motion: StatusMarkMotion;\n}\n\nconst STATUS_MARK_RADIUS = 8;\nconst STATUS_MARK_STROKE_WIDTH = 1.8;\nconst BORDERLESS_STATUS_MARK_RADIUS = STATUS_MARK_RADIUS + STATUS_MARK_STROKE_WIDTH / 2;\nconst STATUS_MARK_CENTER = 12;\nconst STATUS_MARK_START_ANGLE = -90;\nconst STATUS_MARK_FULL_PROGRESS = 100;\nconst STATUS_SNAP_DURATION_MS = 160;\nconst STATUS_SMOOTH_DURATION_MS = 280;\n\nconst getTransition = (motion: StatusMarkMotion, reducedMotion: boolean): Transition => {\n if (motion === false || motion === \"reduced\" || reducedMotion) {\n return { duration: 0.01 };\n }\n\n if (motion === \"snap\") {\n return { duration: 0.16, ease: [0.22, 1, 0.36, 1] as const };\n }\n\n return { duration: 0.28, ease: [0.4, 0, 0.2, 1] as const };\n};\n\nconst getFillMotionDuration = (motion: StatusMarkMotion, reducedMotion: boolean) => {\n if (motion === false || motion === \"reduced\" || reducedMotion) {\n return 0;\n }\n\n return motion === \"snap\" ? STATUS_SNAP_DURATION_MS : STATUS_SMOOTH_DURATION_MS;\n};\n\nconst easeFillProgress = (progress: number) => {\n if (progress < 0.5) {\n return 4 * progress * progress * progress;\n }\n\n return 1 - (-2 * progress + 2) ** 3 / 2;\n};\n\nconst setProgress = (_current: number, next: number) => next;\n\nconst getFillPath = (progress: number, radius: number) => {\n if (progress <= 0) {\n return `M${STATUS_MARK_CENTER} ${STATUS_MARK_CENTER}`;\n }\n\n if (progress >= 99.9) {\n const diameter = radius * 2;\n\n return [\n `M${STATUS_MARK_CENTER - radius} ${STATUS_MARK_CENTER}`,\n `a${radius} ${radius} 0 1 0 ${diameter} 0`,\n `a${radius} ${radius} 0 1 0 -${diameter} 0`,\n ].join(\" \");\n }\n\n const endAngle = STATUS_MARK_START_ANGLE + (360 * progress) / STATUS_MARK_FULL_PROGRESS;\n const radians = (endAngle * Math.PI) / 180;\n const x = Number((STATUS_MARK_CENTER + radius * Math.cos(radians)).toFixed(3));\n const y = Number((STATUS_MARK_CENTER + radius * Math.sin(radians)).toFixed(3));\n const largeArcFlag = progress > 50 ? 1 : 0;\n\n return [\n `M${STATUS_MARK_CENTER} ${STATUS_MARK_CENTER}`,\n `L${STATUS_MARK_CENTER} ${STATUS_MARK_CENTER - radius}`,\n `A${radius} ${radius} 0 ${largeArcFlag} 1 ${x} ${y}`,\n \"Z\",\n ].join(\" \");\n};\n\nconst getRootStyle = ({\n color,\n size = \"base\",\n style,\n trackColor,\n}: Pick<StatusMarkProps, \"color\" | \"size\" | \"style\" | \"trackColor\">) => {\n const rootStyle: StatusMarkStyle = {\n ...getSizeVariableStyle(size, \"--patternmode-status-size\"),\n ...style,\n };\n\n if (color !== undefined && color !== \"\") {\n rootStyle[\"--patternmode-status-color\"] = color;\n }\n\n if (trackColor !== undefined && trackColor !== \"\") {\n rootStyle[\"--patternmode-status-track\"] = trackColor;\n }\n\n return rootStyle;\n};\n\nconst StatusFillSweep = ({\n hasReducedMotion,\n motion,\n progress,\n radius,\n}: MotionPartProps & { progress: StatusMarkProgressValue; radius: number }) => {\n const animationFrameRef = useRef<number | null>(null);\n const renderedProgressRef = useRef<number>(progress);\n const [renderedProgress, setRenderedProgress] = useReducer(setProgress, progress);\n\n useEffect(() => {\n const cancelFillAnimation = () => {\n if (animationFrameRef.current !== null) {\n cancelAnimationFrame(animationFrameRef.current);\n }\n };\n const duration = getFillMotionDuration(motion, hasReducedMotion);\n const startProgress = renderedProgressRef.current;\n const progressDelta = progress - startProgress;\n\n cancelFillAnimation();\n\n if (duration === 0 || progressDelta === 0) {\n renderedProgressRef.current = progress;\n setRenderedProgress(progress);\n return cancelFillAnimation;\n }\n\n const startTime = performance.now();\n\n const tick = (now: number) => {\n const elapsed = Math.min((now - startTime) / duration, 1);\n const nextProgress = startProgress + progressDelta * easeFillProgress(elapsed);\n\n renderedProgressRef.current = nextProgress;\n setRenderedProgress(nextProgress);\n\n if (elapsed < 1) {\n animationFrameRef.current = requestAnimationFrame(tick);\n return;\n }\n\n renderedProgressRef.current = progress;\n animationFrameRef.current = null;\n };\n\n animationFrameRef.current = requestAnimationFrame(tick);\n\n return cancelFillAnimation;\n }, [hasReducedMotion, motion, progress]);\n\n return (\n <path\n className=\"patternmode-status-mark__fill-sweep\"\n d={getFillPath(renderedProgress, radius)}\n data-testid=\"status-mark-fill-sweep\"\n />\n );\n};\n\nconst StatusArc = ({\n hasReducedMotion,\n motion,\n progress,\n}: MotionPartProps & { progress: StatusMarkProgressValue }) => (\n <m.circle\n animate={{ opacity: progress > 0 ? 1 : 0, pathLength: progress / 100 }}\n className=\"patternmode-status-mark__arc\"\n cx=\"12\"\n cy=\"12\"\n initial={false}\n pathLength=\"1\"\n r=\"8\"\n transition={getTransition(motion, hasReducedMotion)}\n />\n);\n\nconst StatusMarkSvg = ({\n hasReducedMotion,\n motion,\n state,\n variant,\n}: MotionPartProps & {\n state: ResolvedStatusProgress;\n variant: NonNullable<StatusMarkProps[\"variant\"]>;\n}) => (\n <svg aria-hidden=\"true\" className=\"patternmode-status-mark__svg\" fill=\"none\" viewBox=\"0 0 24 24\">\n {state.status === \"null\" ? (\n <circle\n className=\"patternmode-status-mark__track patternmode-status-mark__track--null\"\n cx=\"12\"\n cy=\"12\"\n data-testid=\"status-mark-null\"\n r={STATUS_MARK_RADIUS}\n />\n ) : (\n <>\n {variant === \"fill\" ? (\n <>\n <circle\n className=\"patternmode-status-mark__disc\"\n cx=\"12\"\n cy=\"12\"\n data-testid=\"status-mark-fill\"\n r={BORDERLESS_STATUS_MARK_RADIUS}\n />\n <StatusFillSweep\n hasReducedMotion={hasReducedMotion}\n motion={motion}\n progress={state.progress}\n radius={BORDERLESS_STATUS_MARK_RADIUS}\n />\n </>\n ) : null}\n {variant === \"border\" ? (\n <circle\n className=\"patternmode-status-mark__track\"\n cx=\"12\"\n cy=\"12\"\n data-testid=\"status-mark-border\"\n r={STATUS_MARK_RADIUS}\n />\n ) : null}\n {variant === \"border\" ? (\n <StatusArc\n hasReducedMotion={hasReducedMotion}\n motion={motion}\n progress={state.progress}\n />\n ) : null}\n </>\n )}\n </svg>\n);\n\nexport const StatusMark = ({\n className,\n color,\n label,\n motion = \"smooth\",\n size = \"base\",\n status,\n style,\n tone = \"neutral\",\n trackColor,\n value,\n variant = \"fill\",\n ...props\n}: StatusMarkProps) => {\n const reducedMotion = useReducedMotion();\n const hasReducedMotion = Boolean(reducedMotion);\n const state = resolveStatusProgress({ status, value });\n const rootStyle = getRootStyle({ color, size, style, trackColor });\n const hasLabel = label !== undefined && label !== \"\";\n\n return (\n <span\n {...props}\n aria-hidden={hasLabel ? undefined : true}\n aria-label={label}\n className={joinClassNames(\"patternmode-status-mark\", className)}\n data-motion={motion === false ? \"false\" : motion}\n data-progress={state.progress ?? \"null\"}\n data-slot=\"status-mark\"\n data-status={state.status}\n data-tone={tone}\n data-variant={variant}\n role={hasLabel ? \"img\" : undefined}\n style={rootStyle}\n >\n <LazyMotion features={domMax}>\n <StatusMarkSvg\n hasReducedMotion={hasReducedMotion}\n motion={motion}\n state={state}\n variant={variant}\n />\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B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B;AA6CD,gFAAgF;AAChF,eAAO,MAAM,qBAAqB,GAAI,oBAGnC,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAG,sBAoB9C,CAAC"}
|
package/dist/status-mark.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { StatusMarkProps } from "./status-mark-types";
|
|
2
|
-
export declare const StatusMark: ({ className, color, label, motion, size, status, style, tone, trackColor, value, variant, ...props }: StatusMarkProps) => import("react
|
|
2
|
+
export declare const StatusMark: ({ className, color, label, motion, size, status, style, tone, trackColor, value, variant, ...props }: StatusMarkProps) => import("react").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=status-mark.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-mark.d.ts","sourceRoot":"","sources":["../src/status-mark.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAIV,eAAe,EAChB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"status-mark.d.ts","sourceRoot":"","sources":["../src/status-mark.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAIV,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAyO7B,eAAO,MAAM,UAAU,GAAI,sGAaxB,eAAe,gCAgCjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternmode/status",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Animated discrete status marks for Patternmode interfaces.",
|
|
6
6
|
"keywords": [
|
|
@@ -41,40 +41,26 @@
|
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
-
"scripts": {
|
|
45
|
-
"build": "tsdown && tsc --emitDeclarationOnly --declaration --declarationMap --outDir dist --noEmit false && pnpm build:styles",
|
|
46
|
-
"build:styles": "tailwindcss -i ./src/styles.css -o ./dist/styles.css --minify",
|
|
47
|
-
"clean": "rm -rf dist .turbo",
|
|
48
|
-
"dev": "concurrently \"pnpm dev:js\" \"pnpm dev:types\" \"pnpm dev:styles\"",
|
|
49
|
-
"dev:js": "tsdown --watch",
|
|
50
|
-
"dev:styles": "tailwindcss -i ./src/styles.css -o ./dist/styles.css --watch",
|
|
51
|
-
"dev:types": "tsc --emitDeclarationOnly --declaration --declarationMap --outDir dist --noEmit false --watch --preserveWatchOutput",
|
|
52
|
-
"lint": "howells-ox-check .",
|
|
53
|
-
"lint:fix": "howells-ox-fix .",
|
|
54
|
-
"prepack": "pnpm build",
|
|
55
|
-
"test": "vitest run",
|
|
56
|
-
"typecheck": "tsc --noEmit"
|
|
57
|
-
},
|
|
58
44
|
"dependencies": {
|
|
59
|
-
"
|
|
60
|
-
"
|
|
45
|
+
"motion": "^12.40.0",
|
|
46
|
+
"@patternmode/system": "0.2.3"
|
|
61
47
|
},
|
|
62
48
|
"devDependencies": {
|
|
63
|
-
"@howells/lint": "^0.
|
|
64
|
-
"@howells/typescript-config": "^0.1.
|
|
49
|
+
"@howells/lint": "^0.5.0",
|
|
50
|
+
"@howells/typescript-config": "^0.1.6",
|
|
65
51
|
"@tailwindcss/cli": "^4.3.0",
|
|
66
52
|
"@testing-library/jest-dom": "^6.9.1",
|
|
67
53
|
"@testing-library/react": "^16.3.2",
|
|
68
|
-
"@types/react": "^19.2.
|
|
54
|
+
"@types/react": "^19.2.17",
|
|
69
55
|
"@types/react-dom": "^19.2.3",
|
|
70
56
|
"concurrently": "^9.2.1",
|
|
71
57
|
"jsdom": "^29.1.1",
|
|
72
|
-
"react": "^19.2.
|
|
73
|
-
"react-dom": "^19.2.
|
|
58
|
+
"react": "^19.2.7",
|
|
59
|
+
"react-dom": "^19.2.7",
|
|
74
60
|
"tailwindcss": "^4.3.0",
|
|
75
61
|
"tsdown": "^0.22.0",
|
|
76
62
|
"typescript": "^6.0.3",
|
|
77
|
-
"vitest": "^4.1.
|
|
63
|
+
"vitest": "^4.1.8"
|
|
78
64
|
},
|
|
79
65
|
"peerDependencies": {
|
|
80
66
|
"react": "^19.0.0",
|
|
@@ -82,5 +68,18 @@
|
|
|
82
68
|
},
|
|
83
69
|
"engines": {
|
|
84
70
|
"node": ">=20"
|
|
71
|
+
},
|
|
72
|
+
"scripts": {
|
|
73
|
+
"build": "tsdown && tsc --emitDeclarationOnly --declaration --declarationMap --outDir dist --noEmit false && pnpm build:styles",
|
|
74
|
+
"build:styles": "tailwindcss -i ./src/styles.css -o ./dist/styles.css --minify",
|
|
75
|
+
"clean": "rm -rf dist .turbo",
|
|
76
|
+
"dev": "concurrently \"pnpm dev:js\" \"pnpm dev:types\" \"pnpm dev:styles\"",
|
|
77
|
+
"dev:js": "tsdown --watch",
|
|
78
|
+
"dev:styles": "tailwindcss -i ./src/styles.css -o ./dist/styles.css --watch",
|
|
79
|
+
"dev:types": "tsc --emitDeclarationOnly --declaration --declarationMap --outDir dist --noEmit false --watch --preserveWatchOutput",
|
|
80
|
+
"lint": "howells-check .",
|
|
81
|
+
"lint:fix": "howells-fix .",
|
|
82
|
+
"test": "vitest run",
|
|
83
|
+
"typecheck": "tsc --noEmit"
|
|
85
84
|
}
|
|
86
|
-
}
|
|
85
|
+
}
|