返回 DeepSeek-Reasonix
StateDot.tsx
1 // Ported from DeepSeek Harness c291e7961a (MIT).
2 const clsx = (...values: Array<string | false | undefined>) => values.filter(Boolean).join(' ')
3 import css from './StateDot.styles'
4
5 /**
6 * State semantic: green done / amber user-attention / blue running ring /
7 * red error / grey idle for a tracked subject with nothing in progress.
8 */
9 export type StateDotState = 'done' | 'warning' | 'ongoing' | 'error' | 'idle'
10
11 /** Outer 3x3 matrix cells (2px pixels on a 10px grid), clockwise from top-left. */
12 const MATRIX_CELLS: readonly (readonly [number, number])[] = [
13 [0, 0], [4, 0], [8, 0], [8, 4], [8, 8], [4, 8], [0, 8], [0, 4],
14 ]
15
16 /**
17 * Render a state dot.
18 * @param props.state - which of `done`, `warning`, `ongoing`, `error`, or `idle` to show.
19 * @param props.size - outer diameter in px (default 10, the figma size).
20 * @param props.className - extra class for layout placement.
21 * @returns the dot element (aria-hidden; pair with text for accessibility).
22 */
23 export function StateDot({ state, size = 10, className }: {
24 state: StateDotState
25 size?: number | undefined
26 className?: string | undefined
27 }) {
28 if (state === 'ongoing') {
29 return (
30 <svg
31 className={clsx(css.matrix, className)}
32 data-state="ongoing"
33 width={size}
34 height={size}
35 viewBox="0 0 10 10"
36 shapeRendering="crispEdges"
37 aria-hidden="true"
38 >
39 {MATRIX_CELLS.map(([x, y], index) => (
40 <rect
41 key={`${x}-${y}`}
42 className={css.cell}
43 x={x}
44 y={y}
45 width="2"
46 height="2"
47 /* Negative delay phases the chase so every cell animates from mount. */
48 style={{ animationDelay: `${(index - MATRIX_CELLS.length) * 125}ms` }}
49 />
50 ))}
51 </svg>
52 )
53 }
54 return (
55 <span
56 className={clsx(css.dot, className)}
57 data-state={state}
58 style={{ width: size, height: size }}
59 aria-hidden="true"
60 />
61 )
62 }
63
63 lines Plain Text