mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-02 07:59:56 -04:00
23 lines
607 B
TypeScript
23 lines
607 B
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { useEffect } from 'react'
|
|
import { useIsDarkModeActivated } from './use-is-dark-mode-activated'
|
|
|
|
export const useApplyDarkMode = (): void => {
|
|
const darkModeActivated = useIsDarkModeActivated()
|
|
|
|
useEffect(() => {
|
|
if (darkModeActivated) {
|
|
window.document.body.classList.add('dark')
|
|
} else {
|
|
window.document.body.classList.remove('dark')
|
|
}
|
|
return () => {
|
|
window.document.body.classList.remove('dark')
|
|
}
|
|
}, [darkModeActivated])
|
|
}
|