mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-06 09:31:35 -04:00
Add dark mode (#554)
This commit is contained in:
parent
be2428f22c
commit
44637c753e
80 changed files with 2474 additions and 178 deletions
20
src/components/common/apply-dark-mode/apply-dark-mode.tsx
Normal file
20
src/components/common/apply-dark-mode/apply-dark-mode.tsx
Normal file
|
@ -0,0 +1,20 @@
|
|||
import React, { useEffect } from 'react'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { ApplicationState } from '../../../redux'
|
||||
|
||||
export const ApplyDarkMode: React.FC = () => {
|
||||
const darkModeActivated = useSelector((state: ApplicationState) => state.darkMode.darkMode)
|
||||
|
||||
useEffect(() => {
|
||||
if (darkModeActivated) {
|
||||
window.document.body.classList.add('dark')
|
||||
} else {
|
||||
window.document.body.classList.remove('dark')
|
||||
}
|
||||
return () => {
|
||||
window.document.body.classList.remove('dark')
|
||||
}
|
||||
}, [darkModeActivated])
|
||||
|
||||
return null
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue