mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 18:36:21 +00:00
ref(global) update project structure
This commit is contained in:
32 files changed
+67
-42
No files matched your search
@@ -0,0 +1,42 @@
|
||||
'use client';
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useTheme } from 'next-themes';
|
||||
import { Switch } from '@nextui-org/react';
|
||||
import { MdOutlineDarkMode, MdOutlineLightMode } from 'react-icons/md';
|
||||
|
||||
function ThemeSwitcher() {
|
||||
const [ mounted, setMounted ] = useState(false);
|
||||
const { setTheme } = useTheme();
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true);
|
||||
}, []);
|
||||
|
||||
if (!mounted) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={ `` }>
|
||||
<div className={ `flex flex-row items-center` }>
|
||||
<Switch
|
||||
color={ 'default' }
|
||||
aria-label={ `theme switch` }
|
||||
startContent={ <MdOutlineLightMode /> }
|
||||
endContent={ <MdOutlineDarkMode /> }
|
||||
onValueChange={ (isSelected) => {
|
||||
if (isSelected) {
|
||||
setTheme('light');
|
||||
} else {
|
||||
setTheme('dark');
|
||||
}
|
||||
} }
|
||||
></Switch>
|
||||
<p className={ `font-bold hidden md:block` }>{ `Toggle Theme` }</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ThemeSwitcher;
|
||||
Reference in new issue
Block a user