mirror of
https://github.com/r-freeman/portfolio.git
synced 2024-11-22 03:35:41 +00:00
Update ThemeButton
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 2m22s
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 2m22s
This commit is contained in:
parent
f5146f4b06
commit
cf6423bbf8
@ -8,7 +8,7 @@ export function Providers({children}: {
|
||||
}) {
|
||||
|
||||
return (
|
||||
<ThemeProvider attribute="class">
|
||||
<ThemeProvider attribute="class" disableTransitionOnChange>
|
||||
{children}
|
||||
</ThemeProvider>
|
||||
)
|
||||
|
@ -14,16 +14,7 @@ export function ThemeButton() {
|
||||
return () => clearTimeout(timeout)
|
||||
}, [])
|
||||
|
||||
function disableTransitionsTemporarily() {
|
||||
document.documentElement.classList.add('[&_*]:!transition-none')
|
||||
window.setTimeout(() => {
|
||||
document.documentElement.classList.remove('[&_*]:!transition-none')
|
||||
}, 0)
|
||||
}
|
||||
|
||||
function toggleTheme() {
|
||||
disableTransitionsTemporarily()
|
||||
|
||||
let darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)')
|
||||
let isSystemDarkMode = darkModeMediaQuery.matches
|
||||
let isDarkMode = theme === 'dark'
|
||||
|
Loading…
Reference in New Issue
Block a user