mirror of
https://github.com/kremalicious/portfolio.git
synced 2024-12-22 09:13:19 +01:00
dark mode fix
This commit is contained in:
parent
4bed995812
commit
23b0f8dcc7
@ -10,7 +10,7 @@ const MetaFavicons = () => {
|
||||
<link rel="icon" href="/favicon.ico" sizes="any" />
|
||||
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
||||
<link rel="manifest" href="/favicon/manifest.webmanifest"></link>
|
||||
<link rel="manifest" href="/manifest/manifest.webmanifest"></link>
|
||||
</Head>
|
||||
)
|
||||
}
|
||||
|
@ -12,11 +12,6 @@ export default function ThemeSwitch() {
|
||||
<Head>
|
||||
<meta name="theme-color" content={themeColor} />
|
||||
<meta name="msapplication-TileColor" content={themeColor} />
|
||||
{/* <link
|
||||
rel="mask-icon"
|
||||
href="/favicon/safari-pinned-tab.svg"
|
||||
color={themeColor}
|
||||
/> */}
|
||||
<meta
|
||||
name="apple-mobile-web-app-status-bar-style"
|
||||
content="black-translucent"
|
||||
|
@ -25,18 +25,26 @@ function getDarkMode() {
|
||||
}
|
||||
|
||||
export default function useDarkMode() {
|
||||
const [darkMode, setDarkMode] = useState(getDarkMode())
|
||||
const [darkMode, setDarkMode] = useState<boolean>()
|
||||
const [themeColor, setThemeColor] = useState<string>()
|
||||
|
||||
const toggleDarkMode = useCallback(() => {
|
||||
setDarkMode(!darkMode)
|
||||
}, [darkMode])
|
||||
|
||||
//
|
||||
// Init
|
||||
//
|
||||
useEffect(() => {
|
||||
const prefersDark = getDarkMode()
|
||||
setDarkMode(prefersDark)
|
||||
}, [])
|
||||
|
||||
//
|
||||
// Do things when darkMode changes
|
||||
//
|
||||
useEffect(() => {
|
||||
const bodyClassList = document.body.classList
|
||||
const bodyClassList = document.querySelector('body').classList
|
||||
bodyClassList.toggle('dark')
|
||||
bodyClassList.toggle('light')
|
||||
setThemeColor(darkMode === true ? '#1d2224' : '#e7eef4')
|
||||
|
Loading…
Reference in New Issue
Block a user