-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
135 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
.score-wrapper { | ||
align-items: center; | ||
border-bottom: 1px dashed var(--text-fg); | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
padding-bottom: 1rem; | ||
} | ||
|
||
.score-wrapper h3 { | ||
color: var(--text-fg); | ||
font-size: 1rem; | ||
margin: 0; | ||
} | ||
|
||
.score-wrapper span { | ||
color: var(--text-fg); | ||
font-size: 4rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
.status-wrapper { | ||
background-color: var(--text-bg); | ||
border: 1px solid var(--text-fg); | ||
border-radius: 5px; | ||
border-radius: 0 5px 5px 0; | ||
display: flex; | ||
flex-basis: 200px; | ||
flex-direction: column; | ||
flex-grow: 0; | ||
flex-shrink: 0; | ||
justify-content: space-evenly; | ||
padding: 1rem; | ||
} | ||
|
||
.status-wrapper hr { | ||
border: 0; | ||
border-bottom: 1px dashed var(--text-fg); | ||
width: 100%; | ||
} | ||
|
||
.status-wrapper span { | ||
color: var(--text-fg); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.theme-toggler-wrapper { | ||
position: fixed; | ||
right: 1rem; | ||
top: 0.5rem; | ||
} | ||
|
||
.theme-toggler-wrapper input { | ||
appearance: none; | ||
background-color: var(--text-fg); | ||
border: 1px solid var(--text-bg); | ||
border-radius: 1rem; | ||
cursor: pointer; | ||
display: block; | ||
height: 1rem; | ||
margin: 0; | ||
width: 2.5rem; | ||
} | ||
|
||
.theme-toggler-wrapper input::before { | ||
background-color: var(--text-bg); | ||
border: 1px solid var(--text-fg); | ||
border-radius: 50%; | ||
box-shadow: var(--text-bg) 0 1px 4px; | ||
content: ""; | ||
height: 1rem; | ||
left: 0; | ||
position: absolute; | ||
top: -1px; | ||
width: 1rem; | ||
} | ||
|
||
.theme-toggler-wrapper input:checked::before { | ||
background-color: var(--text-bg); | ||
box-shadow: var(--text-fg) 0 1px 4px; | ||
transform: translateX(1.5rem); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useEffect, useRef, useState } from 'react'; | ||
|
||
import './ThemeToggler.css'; | ||
|
||
type Props = { | ||
onToggle: () => void; | ||
}; | ||
|
||
const INPUT_NAME = 'theme-toggler'; | ||
const ENABLE_LIGHT_MODE_LABEL = 'Enable day mode'; | ||
const ENABLE_DARK_MODE_LABEL = 'Enable night mode'; | ||
|
||
function ThemeToggler({ onToggle }: Props) { | ||
const inputRef = useRef<HTMLInputElement>(null); | ||
const [inputLabel, setInputLabel] = useState(ENABLE_DARK_MODE_LABEL); | ||
|
||
useEffect(() => { | ||
if (!window?.matchMedia) { | ||
return; | ||
} | ||
|
||
const isSystemDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches; | ||
|
||
if (isSystemDarkMode) { | ||
inputRef.current?.click(); | ||
} | ||
}, []); | ||
|
||
function handleClick(): void { | ||
onToggle(); | ||
setInputLabel(inputLabel === ENABLE_LIGHT_MODE_LABEL ? ENABLE_DARK_MODE_LABEL : ENABLE_LIGHT_MODE_LABEL); | ||
} | ||
|
||
return ( | ||
<div className="theme-toggler-wrapper" role="button" tabIndex={0} onClick={handleClick}> | ||
<label htmlFor={INPUT_NAME} aria-label={inputLabel} title={inputLabel}> | ||
<input type="checkbox" id={INPUT_NAME} name={INPUT_NAME} ref={inputRef} /> | ||
</label> | ||
</div> | ||
); | ||
} | ||
|
||
export default ThemeToggler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './ThemeToggler' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters