jan/web/screens/Settings/Appearance/TogglePrimary.tsx
Faisal Amir 635435fbb8
Revert feat: temporary remove dark mode (#2221)
* Revert "feat: temporary remove dark mode :(  (#2168)"

This reverts commit 222b4ad897c275dab0eaec3c8a8472bf3df7afc4.

* fix: revert darkmode and fix darkmode for import model

* fix: prettier format import model

---------

Co-authored-by: Louis <louis@jan.ai>
2024-03-04 14:46:10 +07:00

58 lines
1.4 KiB
TypeScript

import { motion as m } from 'framer-motion'
import { twMerge } from 'tailwind-merge'
import { useUserConfigs } from '@/hooks/useUserConfigs'
type PrimaryColorOption = {
value: PrimaryColor
class: string
}
const primaryColorOptions: PrimaryColorOption[] = [
{
value: 'primary-blue',
class: 'bg-blue-500',
},
{
value: 'primary-purple',
class: 'bg-purple-500',
},
{
value: 'primary-green',
class: 'bg-green-500',
},
]
export default function TogglePrimary() {
const [config, setUserConfig] = useUserConfigs()
const handleChangeAccent = (primaryColor: PrimaryColor) => {
setUserConfig({ ...config, primaryColor })
}
return (
<div className="flex items-center">
{primaryColorOptions.map((option, i) => {
const isActive = config.primaryColor === option.value
return (
<div
className="relative flex h-6 w-6 items-center justify-center"
key={i}
>
<button
className={twMerge('h-3.5 w-3.5 rounded-full', option.class)}
onClick={() => handleChangeAccent(option.value)}
/>
{isActive ? (
<m.div
className="absolute inset-0 h-full w-full rounded-full border border-primary/50 bg-primary/20"
layoutId="active-primary-menu"
/>
) : null}
</div>
)
})}
</div>
)
}