-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f41fa8
commit 3d5ac89
Showing
4 changed files
with
36 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,39 @@ | ||
"use client"; | ||
'use client' | ||
|
||
import { Button } from "@ui/components/ui/button"; | ||
import { useToolStore } from '@/store/toolStore' | ||
import { ColorMode } from '@/types/app' | ||
import { Button } from '@ui/components/ui/button' | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuRadioGroup, | ||
DropdownMenuRadioItem, | ||
DropdownMenuTrigger, | ||
} from "@ui/components/ui/dropdown-menu"; | ||
import { useColorStore } from "@/store/store"; | ||
import { ColorMode } from "@/types/app"; | ||
} from '@ui/components/ui/dropdown-menu' | ||
function ColorModeDropdownMenu() { | ||
const { colorMode, setColorMode } = useColorStore(); | ||
const handleChangeColorMode = async (mode: ColorMode) => { | ||
setColorMode(mode); | ||
// call server to set colormode cookie | ||
await fetch("/api/color-mode", { | ||
method: "POST", | ||
body: JSON.stringify({ mode }), | ||
}); | ||
}; | ||
const { colorMode, setColorMode } = useToolStore() | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button | ||
variant="outline" | ||
className="flex items-center justify-center gap-1.5 text-sm uppercase" | ||
> | ||
<Button className="flex items-center justify-center gap-1.5 text-sm uppercase" variant="outline"> | ||
<span>{colorMode}</span> | ||
{/* <ChevronDownIcon className="h-3.5 w-3.5" /> */} | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent align="start" className="w-[8.75rem]"> | ||
<DropdownMenuRadioGroup | ||
value={colorMode} | ||
onValueChange={handleChangeColorMode} | ||
> | ||
<DropdownMenuRadioGroup onValueChange={setColorMode} value={colorMode}> | ||
{Object.values(ColorMode).map((mode) => { | ||
return ( | ||
<DropdownMenuRadioItem | ||
value={mode} | ||
key={mode} | ||
className="uppercase" | ||
> | ||
<DropdownMenuRadioItem className="uppercase" key={mode} value={mode}> | ||
{mode} | ||
</DropdownMenuRadioItem> | ||
); | ||
) | ||
})} | ||
</DropdownMenuRadioGroup> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
) | ||
} | ||
|
||
export default ColorModeDropdownMenu; | ||
export default ColorModeDropdownMenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters