@@ -229,33 +229,21 @@ const NavBarSearchBox = styled(SearchBox)`
229229` ;
230230
231231const ToggleTrack = styled . label `
232- display: flex;
233- align-items: center;
234- width: 44px;
232+ display: block;
233+ width: 40px;
235234 height: 22px;
236235 border-radius: 11px;
237- background-color: #d1d5db;
236+ border: 1px solid var(--group-border);
237+ background-color: var(--group-members);
238238 cursor: pointer;
239239 position: relative;
240- transition: background-color 0.2s;
240+ transition:
241+ border-color 0.25s,
242+ background-color 0.25s;
241243 flex-shrink: 0;
242244
243- [data-theme="dark"] & {
244- background-color: #2a2d33;
245- }
246-
247- .theme-icon-dark {
248- display: none;
249- }
250- .theme-icon-light {
251- display: block;
252- }
253-
254- [data-theme="dark"] & .theme-icon-dark {
255- display: block;
256- }
257- [data-theme="dark"] & .theme-icon-light {
258- display: none;
245+ &:hover {
246+ border-color: var(--text-dim);
259247 }
260248
261249 input {
@@ -268,34 +256,54 @@ const ToggleTrack = styled.label`
268256
269257const ToggleThumb = styled . span `
270258 position: absolute;
271- left: 2px;
272- width: 18px;
273- height: 18px;
259+ top: 0;
260+ left: 0;
261+ width: 20px;
262+ height: 20px;
274263 border-radius: 50%;
275- background-color: #ffffff;
276- transition:
277- left 0.2s,
278- background-color 0.2s;
264+ background-color: var(--sidebar);
265+ box-shadow:
266+ 0 1px 2px rgba(0, 0, 0, 0.04),
267+ 0 1px 2px rgba(0, 0, 0, 0.06);
268+ transition: transform 0.25s;
269+ overflow: hidden;
279270
280271 [data-theme="dark"] & {
281- left: 24px;
282- background-color: #7a7f88;
272+ transform: translateX(18px);
283273 }
284274` ;
285275
286- const ToggleLabel = styled . span `
287- font-size: 14px;
288- user-select: none;
276+ const ToggleIcon = styled . span `
289277 position: absolute;
290- line-height: 1;
291- ` ;
278+ top: 3px;
279+ left: 3px;
280+ width: 14px;
281+ height: 14px;
282+ opacity: 1;
283+ transition: opacity 0.25s;
284+
285+ &.sun {
286+ background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='%23f5a623' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41'/%3E%3C/g%3E%3C/svg%3E")
287+ no-repeat center / contain;
288+ }
292289
293- const ToggleLabelLeft = styled ( ToggleLabel ) `
294- left: 5px;
295- ` ;
290+ &.moon {
291+ background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 3a6 6 0 0 0 9 9a9 9 0 1 1-9-9'/%3E%3C/svg%3E")
292+ no-repeat center / contain;
293+ }
296294
297- const ToggleLabelRight = styled ( ToggleLabel ) `
298- right: 5px;
295+ &.sun {
296+ opacity: 1;
297+ }
298+ &.moon {
299+ opacity: 0;
300+ }
301+ [data-theme="dark"] &.sun {
302+ opacity: 0;
303+ }
304+ [data-theme="dark"] &.moon {
305+ opacity: 1;
306+ }
299307` ;
300308
301309export function S2VLogo ( ) {
@@ -310,16 +318,17 @@ function NavBarThemeSwitcher() {
310318 const appContext = React . useContext ( AppContext ) ;
311319
312320 return (
313- < ToggleTrack >
321+ < ToggleTrack title = { appContext . darkmode ? "Switch to light theme" : "Switch to dark theme" } >
314322 < input
315323 type = "checkbox"
316324 checked = { appContext . darkmode }
317325 onChange = { ( e ) => appContext . setDarkmode ( e . target . checked ) }
318326 aria-label = "Dark Mode Toggle"
319327 />
320- < ToggleLabelLeft className = "theme-icon-dark" > { "\u{1F31C}" } </ ToggleLabelLeft >
321- < ToggleLabelRight className = "theme-icon-light" > { "\u{1F31E}" } </ ToggleLabelRight >
322- < ToggleThumb />
328+ < ToggleThumb >
329+ < ToggleIcon className = "sun" />
330+ < ToggleIcon className = "moon" />
331+ </ ToggleThumb >
323332 </ ToggleTrack >
324333 ) ;
325334}
0 commit comments