forked from koshikraj/ottopus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtentacle-ring.tsx
More file actions
61 lines (57 loc) · 1.8 KB
/
Copy pathtentacle-ring.tsx
File metadata and controls
61 lines (57 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { cn } from '@/lib/cn'
/**
* Eight dots, one per arm. The design is explicit: never six, never twelve.
* They sit on a circle, so the positions are computed rather than transcribed —
* transcribed pixel offsets only hold at the size they were drawn for.
*/
const ARMS = 8
export interface TentacleRingProps {
/** 16–40px is the design's range. Larger than that wants Otto instead. */
size?: number
/** Inherits currentColor so it can sit on a coloured button. */
tone?: 'plan' | 'current'
label?: string
className?: string
}
/**
* L1 · Tentacle ring — the default spinner.
*
* Buttons, table cells, icon slots: anywhere Otto himself would be too loud.
* Geometry only, no mascot, because an inline wait does not block the screen.
*/
export function TentacleRing({
size = 24,
tone = 'plan',
label,
className,
}: TentacleRingProps) {
const dot = Math.max(3, Math.round(size * 0.15))
const radius = size / 2 - dot / 2
return (
<span
role={label ? 'status' : undefined}
aria-label={label}
aria-hidden={label ? undefined : true}
className={cn('ot-ring relative inline-block shrink-0', className)}
style={{ width: size, height: size }}
>
{Array.from({ length: ARMS }, (_, i) => {
const angle = (i / ARMS) * 2 * Math.PI - Math.PI / 2
return (
<span
key={i}
className="ot-ring-dot absolute rounded-full"
style={{
width: dot,
height: dot,
left: size / 2 + radius * Math.cos(angle) - dot / 2,
top: size / 2 + radius * Math.sin(angle) - dot / 2,
background: tone === 'plan' ? 'var(--ot-plan)' : 'currentColor',
animationDelay: `${i * 0.2}s`,
}}
/>
)
})}
</span>
)
}