-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoor.tsx
More file actions
86 lines (82 loc) · 3.19 KB
/
Door.tsx
File metadata and controls
86 lines (82 loc) · 3.19 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { BellIcon } from '@phosphor-icons/react';
import { TODO_OFF, isSoftTodo, hasTodo, type SessionStatus, type TodoState } from '../lib/terminal-registry';
export interface DoorProps {
doorId?: string;
title: string;
isActive?: boolean;
status?: SessionStatus;
todo?: TodoState;
onClick?: () => void;
}
export function Door({
doorId,
title,
isActive = false,
status = 'ALARM_DISABLED',
todo = TODO_OFF,
onClick,
}: DoorProps) {
// Doors can only be active in command mode (navigated to via arrow keys).
// Pressing Enter restores the door into a pane, so passthrough+active is impossible.
//
// Always use a 2px border on all sides to prevent layout shift when
// the dashed selection border appears. Inactive: bottom is transparent.
const alarmEnabled = status !== 'ALARM_DISABLED';
const alarmRinging = status === 'ALARM_RINGING';
return (
<button
data-door-id={doorId}
className={[
'relative flex h-6 max-w-[220px] min-w-[68px] items-center gap-2 overflow-hidden px-2.5',
'rounded-t-md',
alarmRinging
? 'bg-warning/10 motion-safe:animate-pulse motion-reduce:animate-none ring-1 ring-warning/60'
: 'bg-surface',
'text-[10px] font-medium font-mono tracking-[0.02em]',
'transition-colors hover:bg-surface-raised',
].join(' ')}
style={{
border: '2px solid var(--mt-border)',
borderBottom: '2px solid transparent',
}}
onClick={onClick}
title={title}
>
<span className={['min-w-0 flex-1 truncate', isActive ? 'text-foreground' : 'text-muted'].join(' ')}>
{title}
</span>
{(hasTodo(todo) || alarmEnabled) && (
<span className="flex shrink-0 items-center gap-1.5">
{hasTodo(todo) && (
<span
className={[
'rounded bg-surface-raised px-1 py-px text-[8px] font-semibold tracking-[0.08em] text-foreground',
isSoftTodo(todo) ? 'border border-dashed border-border' : 'border border-border',
].join(' ')}
style={isSoftTodo(todo) ? {
opacity: 0.3 + 0.7 * todo,
transform: `scale(${0.7 + 0.3 * todo})`,
transition: 'opacity 0.15s ease, transform 0.15s ease',
} : undefined}
>
TODO
</span>
)}
{alarmEnabled && (
<span className={['relative', alarmRinging ? 'text-warning' : isActive ? 'text-foreground' : 'text-muted'].join(' ')}>
<BellIcon size={11} weight="fill" />
{(status === 'MIGHT_BE_BUSY' || status === 'BUSY' || status === 'MIGHT_NEED_ATTENTION') && (
<span className={[
'absolute -top-0.5 -right-0.5 h-1 w-1 rounded-full',
status === 'MIGHT_BE_BUSY' && 'bg-foreground/40',
status === 'BUSY' && 'bg-accent motion-safe:animate-alarm-dot motion-reduce:animate-none',
status === 'MIGHT_NEED_ATTENTION' && 'bg-warning/60 motion-safe:animate-alarm-dot motion-reduce:animate-none',
].filter(Boolean).join(' ')} />
)}
</span>
)}
</span>
)}
</button>
);
}