mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
16 lines
749 B
JavaScript
16 lines
749 B
JavaScript
import { useTheme } from '@/lib/theme'
|
|
import localStorage from 'localStorage'
|
|
|
|
const DarkModeButton = () => {
|
|
const { theme, changeTheme } = useTheme()
|
|
const handleChangeDarkMode = () => {
|
|
const newTheme = (theme === 'light' ? 'dark' : 'light')
|
|
changeTheme(newTheme)
|
|
localStorage.setItem('theme', newTheme)
|
|
}
|
|
return <div className='z-10 p-1 border dark:border-gray-500 mr-2 h-12 my-2 bg-white dark:bg-gray-600 dark:bg-opacity-70 bg-opacity-70 dark:hover:bg-gray-100 text-xl cursor-pointer dark:text-gray-300 dark:hover:text-black'>
|
|
<i className={'fa p-2.5 hover:scale-125 transform duration-200 ' + (theme === 'dark' ? ' fa-sun-o' : ' fa-moon-o') } onClick={handleChangeDarkMode} />
|
|
</div>
|
|
}
|
|
export default DarkModeButton
|