|
1 | 1 | import classNames from 'classnames'; |
2 | | -import { Link } from 'react-router-dom'; |
3 | 2 | import { Container } from '@/components/Container'; |
4 | 3 | import { useCompetitionRemoteControl } from '@/hooks/useCompetitionRemoteControl'; |
5 | 4 | import { useNow } from '@/hooks/useNow'; |
6 | 5 | import { |
7 | 6 | formatElapsedMMSS, |
8 | | - formatUntilNextActivity, |
| 7 | + formatNextActivityOffset, |
9 | 8 | getActiveGroupStartTime, |
10 | 9 | getRemoteBarProgress, |
11 | 10 | } from './remoteBarProgress'; |
@@ -34,7 +33,7 @@ export function NotifyCompRemoteBar({ competitionId }: NotifyCompRemoteBarProps) |
34 | 33 | const currentTitle = activeNames.length > 0 ? activeNames.join(', ') : 'No active activity'; |
35 | 34 | const nextTitle = remote.nextGroup?.name || 'No next activity'; |
36 | 35 | const elapsed = formatElapsedMMSS(getActiveGroupStartTime(remote.activeGroups), now); |
37 | | - const nextStatus = formatUntilNextActivity(remote.nextGroup, now); |
| 36 | + const nextOffset = formatNextActivityOffset(remote.nextGroup, now); |
38 | 37 | const progress = getRemoteBarProgress({ |
39 | 38 | activeGroups: remote.activeGroups, |
40 | 39 | nextGroup: remote.nextGroup, |
@@ -76,81 +75,70 @@ export function NotifyCompRemoteBar({ competitionId }: NotifyCompRemoteBarProps) |
76 | 75 | <Container |
77 | 76 | fullWidth |
78 | 77 | className="relative flex-row min-h-16 items-center justify-center px-2 py-2"> |
79 | | - <div className="w-full max-w-xl space-y-1"> |
80 | | - <Link |
81 | | - to={`/competitions/${competitionId}/remote`} |
82 | | - className={classNames( |
83 | | - 'grid grid-cols-2 gap-2 rounded px-1 py-1 hover-transition hover:bg-gray-100 dark:hover:bg-gray-700', |
84 | | - { |
85 | | - 'opacity-60': remote.isLoading, |
86 | | - }, |
87 | | - )}> |
88 | | - <span className="min-w-0 space-y-0.5"> |
89 | | - <span className="block text-[0.625rem] font-medium uppercase leading-none text-muted"> |
90 | | - Current |
91 | | - </span> |
92 | | - <span className="block truncate text-xs font-medium text-default"> |
93 | | - {currentTitle} |
94 | | - </span> |
95 | | - </span> |
96 | | - <span className="min-w-0 space-y-0.5 text-right"> |
97 | | - <span className="block text-[0.625rem] font-medium uppercase leading-none text-muted"> |
98 | | - Next |
99 | | - </span> |
100 | | - <span className="block truncate text-xs font-medium text-default">{nextTitle}</span> |
101 | | - </span> |
102 | | - </Link> |
103 | | - |
104 | | - <div className="flex items-center justify-center gap-2"> |
105 | | - <button |
106 | | - type="button" |
107 | | - className={iconButtonClassName} |
108 | | - disabled={remote.isSaving || !remote.previousGroup} |
109 | | - aria-label="Go back to previous remote activity" |
110 | | - onClick={() => runSwitch('previous')}> |
111 | | - <span className="fa fa-arrow-left" aria-hidden="true" /> |
112 | | - </button> |
113 | | - |
114 | | - <button |
115 | | - type="button" |
116 | | - className={primaryButtonClassName} |
117 | | - disabled={remote.isSaving || (remote.activeGroups.length === 0 && !remote.nextGroup)} |
118 | | - aria-label={ |
119 | | - remote.activeGroups.length > 0 |
120 | | - ? 'Stop current remote activities' |
121 | | - : 'Start next remote activity' |
122 | | - } |
123 | | - onClick={togglePlayback}> |
124 | | - {remote.activeGroups.length > 0 ? <>■</> : <>▶</>} |
125 | | - </button> |
126 | | - |
127 | | - <button |
128 | | - type="button" |
129 | | - className={iconButtonClassName} |
130 | | - disabled={remote.isSaving || !remote.nextGroup} |
131 | | - aria-label="Go to next remote activity" |
132 | | - onClick={() => runSwitch('next')}> |
133 | | - <span className="fa fa-arrow-right" aria-hidden="true" /> |
134 | | - </button> |
| 78 | + <div |
| 79 | + className={classNames( |
| 80 | + 'grid w-full max-w-4xl grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 md:gap-4', |
| 81 | + { |
| 82 | + 'opacity-60': remote.isLoading, |
| 83 | + }, |
| 84 | + )}> |
| 85 | + <div className="min-w-0 space-y-0.5 text-left"> |
| 86 | + <div className="text-xs font-medium uppercase leading-none text-muted">Current</div> |
| 87 | + <div className="truncate text-sm font-medium text-default">{currentTitle}</div> |
| 88 | + <div className="text-sm tabular-nums text-muted">{elapsed}</div> |
135 | 89 | </div> |
136 | 90 |
|
137 | | - <Link |
138 | | - to={`/competitions/${competitionId}/remote`} |
139 | | - className={classNames( |
140 | | - 'grid grid-cols-[44px_minmax(0,1fr)_minmax(88px,1.5fr)] items-center gap-2 rounded px-1 py-1 hover-transition hover:bg-gray-100 dark:hover:bg-gray-700', |
141 | | - { |
142 | | - 'opacity-60': remote.isLoading, |
143 | | - }, |
144 | | - )}> |
145 | | - <span className="text-right text-xs tabular-nums text-muted">{elapsed}</span> |
146 | | - <span className="h-1 overflow-hidden rounded-full bg-tertiary"> |
147 | | - <span |
148 | | - className="block h-full rounded-full bg-blue-500 dark:bg-blue-400" |
149 | | - style={{ width: `${progress}%` }} |
150 | | - /> |
151 | | - </span> |
152 | | - <span className="truncate text-xs text-muted">{nextStatus}</span> |
153 | | - </Link> |
| 91 | + <div className="flex w-28 flex-col justify-center space-y-1 sm:w-40 md:w-64"> |
| 92 | + <div className="flex items-center justify-center gap-2"> |
| 93 | + <button |
| 94 | + type="button" |
| 95 | + className={iconButtonClassName} |
| 96 | + disabled={remote.isSaving || !remote.previousGroup} |
| 97 | + aria-label="Go back to previous remote activity" |
| 98 | + onClick={() => runSwitch('previous')}> |
| 99 | + <span className="fa fa-arrow-left" aria-hidden="true" /> |
| 100 | + </button> |
| 101 | + |
| 102 | + <button |
| 103 | + type="button" |
| 104 | + className={primaryButtonClassName} |
| 105 | + disabled={ |
| 106 | + remote.isSaving || (remote.activeGroups.length === 0 && !remote.nextGroup) |
| 107 | + } |
| 108 | + aria-label={ |
| 109 | + remote.activeGroups.length > 0 |
| 110 | + ? 'Stop current remote activities' |
| 111 | + : 'Start next remote activity' |
| 112 | + } |
| 113 | + onClick={togglePlayback}> |
| 114 | + {remote.activeGroups.length > 0 ? <>■</> : <>▶</>} |
| 115 | + </button> |
| 116 | + |
| 117 | + <button |
| 118 | + type="button" |
| 119 | + className={iconButtonClassName} |
| 120 | + disabled={remote.isSaving || !remote.nextGroup} |
| 121 | + aria-label="Go to next remote activity" |
| 122 | + onClick={() => runSwitch('next')}> |
| 123 | + <span className="fa fa-arrow-right" aria-hidden="true" /> |
| 124 | + </button> |
| 125 | + </div> |
| 126 | + |
| 127 | + <div className="flex h-4 items-center"> |
| 128 | + <div className="h-1 w-full overflow-hidden rounded-full bg-tertiary"> |
| 129 | + <span |
| 130 | + className="block h-full rounded-full bg-blue-500 dark:bg-blue-400" |
| 131 | + style={{ width: `${progress}%` }} |
| 132 | + /> |
| 133 | + </div> |
| 134 | + </div> |
| 135 | + </div> |
| 136 | + |
| 137 | + <div className="min-w-0 space-y-0.5 text-right"> |
| 138 | + <div className="text-xs font-medium uppercase leading-none text-muted">Next</div> |
| 139 | + <div className="truncate text-sm font-medium text-default">{nextTitle}</div> |
| 140 | + <div className="truncate text-sm text-muted">{nextOffset}</div> |
| 141 | + </div> |
154 | 142 | </div> |
155 | 143 | </Container> |
156 | 144 | </nav> |
|
0 commit comments