Skip to content

Commit 75e7268

Browse files
committed
Replace auto advance button with toggle
1 parent b5a2f4e commit 75e7268

3 files changed

Lines changed: 41 additions & 15 deletions

File tree

src/components/NotifyCompRemoteBar/NotifyCompRemoteBar.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,7 @@ export function NotifyCompRemoteBar({ competitionId }: NotifyCompRemoteBarProps)
122122
</Link>
123123
</div>
124124

125-
<div className="flex min-w-0 items-center justify-end gap-3">
126-
<div className="hidden min-w-0 text-right sm:block">
127-
<div className="truncate text-sm font-medium text-default">Remote</div>
128-
<div className="truncate text-xs text-muted">
129-
{remote.error ? remote.error : remote.isSaving ? 'Syncing' : 'Ready'}
130-
</div>
131-
</div>
132-
</div>
125+
<div />
133126
</Container>
134127
</nav>
135128
);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import classNames from 'classnames';
2+
3+
interface RemoteAutoAdvanceToggleProps {
4+
checked: boolean;
5+
disabled?: boolean;
6+
onToggle: () => void;
7+
}
8+
9+
export function RemoteAutoAdvanceToggle({
10+
checked,
11+
disabled,
12+
onToggle,
13+
}: RemoteAutoAdvanceToggleProps) {
14+
return (
15+
<button
16+
type="button"
17+
role="switch"
18+
aria-checked={checked}
19+
aria-label="Auto-advance"
20+
disabled={disabled}
21+
className={classNames(
22+
'relative h-6 w-12 rounded-full shadow-sm hover-transition disabled:cursor-not-allowed disabled:opacity-50',
23+
checked ? 'bg-blue-400' : 'bg-gray-300 dark:bg-gray-600',
24+
)}
25+
onClick={onToggle}>
26+
<span
27+
className={classNames(
28+
'absolute top-0 h-6 w-6 rounded-full bg-blue-600 shadow-md transition-transform',
29+
checked ? 'translate-x-6' : 'translate-x-0 bg-gray-50 dark:bg-gray-300',
30+
)}
31+
/>
32+
</button>
33+
);
34+
}

src/pages/Competition/Remote/index.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useNotifyCompRemoteAuth } from '@/providers/NotifyCompRemoteAuthProvide
99
import { useWCIF } from '@/providers/WCIFProvider';
1010
import { RemoteAction, RemoteActionDialog } from './RemoteActionDialog';
1111
import { RemoteGroupList } from './RemoteActivityList';
12+
import { RemoteAutoAdvanceToggle } from './RemoteAutoAdvanceToggle';
1213

1314
const confirmAction = (message: string) => window.confirm(message);
1415

@@ -109,21 +110,19 @@ export default function CompetitionRemote() {
109110
<div className="space-y-4">
110111
<div className="flex flex-col gap-4 md:flex-row md:items-end md:justify-between">
111112
<h2 className="type-heading">All rooms</h2>
112-
<Button
113-
type="button"
114-
variant={remote.autoAdvance ? 'green' : 'light'}
113+
<RemoteAutoAdvanceToggle
114+
checked={Boolean(remote.autoAdvance)}
115115
disabled={remote.isSaving}
116-
onClick={() => {
116+
onToggle={() => {
117117
if (
118118
confirmAction(
119119
`${remote.autoAdvance ? 'Disable' : 'Enable'} auto-advance for this competition?`,
120120
)
121121
) {
122122
void remote.updateAutoAdvance(!remote.autoAdvance);
123123
}
124-
}}>
125-
{remote.autoAdvance ? 'Auto-advance on' : 'Auto-advance off'}
126-
</Button>
124+
}}
125+
/>
127126
</div>
128127

129128
<div

0 commit comments

Comments
 (0)