fix: theme switch on system theme
This commit is contained in:
parent
f4b3fb54a9
commit
5c9bc7d6d7
@ -25,7 +25,7 @@ export function ThemeSwitch({
|
|||||||
}: Props) {
|
}: Props) {
|
||||||
let REACT_TOGGLE_DARK_MODE_GLOBAL_ID = starterId
|
let REACT_TOGGLE_DARK_MODE_GLOBAL_ID = starterId
|
||||||
|
|
||||||
const { theme, setTheme } = useTheme()
|
const { theme, systemTheme, setTheme } = useTheme()
|
||||||
|
|
||||||
const [id, setId] = useState(REACT_TOGGLE_DARK_MODE_GLOBAL_ID)
|
const [id, setId] = useState(REACT_TOGGLE_DARK_MODE_GLOBAL_ID)
|
||||||
|
|
||||||
@ -34,6 +34,13 @@ export function ThemeSwitch({
|
|||||||
setId(REACT_TOGGLE_DARK_MODE_GLOBAL_ID)
|
setId(REACT_TOGGLE_DARK_MODE_GLOBAL_ID)
|
||||||
}, [setId])
|
}, [setId])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// If the theme is currently using system theme, set the theme according to the system theme value.
|
||||||
|
if (theme === 'system') {
|
||||||
|
setTheme(systemTheme as 'dark' | 'light')
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
const properties = {
|
const properties = {
|
||||||
circle: {
|
circle: {
|
||||||
r: theme === 'dark' ? 9 : 5,
|
r: theme === 'dark' ? 9 : 5,
|
||||||
|
Loading…
Reference in New Issue
Block a user