Files
hats-app/app/(dashboard)/profile/components/ChangeTheme.tsx
T
2025-12-19 13:57:55 +07:00

122 lines
7.6 KiB
TypeScript

'use client'
import { useTheme } from 'next-themes';
import { FC } from 'react';
type Props = {};
const ChangeTheme: FC<Props> = ({ }) => {
const { theme, setTheme } = useTheme()
return (
<>
<div className='hidden sm:flex flex-col sm:flex-row space-y-2 sm:space-y-0 sm sm:space-x-2 xl:space-x-4 font-medium'>
<div className='cursor-pointer' onClick={() => setTheme('light')}>
<div className={`items-center rounded-lg border-2 bg-popover p-1 hover:bg-accent hover:text-accent-foreground ${theme === 'light' ? 'border-his' : 'border-muted'}`}>
<div className="space-y-2 rounded-md bg-[#ecedef] p-2">
<div className="space-y-2 rounded-md bg-white p-2 shadow-sm">
<div className="h-2 w-20 rounded-lg bg-[#ecedef]" />
<div className="h-2 w-[100px] rounded-lg bg-[#ecedef]" />
</div>
<div className="flex items-center space-x-2 rounded-md bg-white p-2 shadow-sm">
<div className="h-4 w-4 rounded-full bg-[#ecedef]" />
<div className="h-2 w-[100px] rounded-lg bg-[#ecedef]" />
</div>
<div className="flex items-center space-x-2 rounded-md bg-white p-2 shadow-sm">
<div className="h-4 w-4 rounded-full bg-[#ecedef]" />
<div className="h-2 w-[100px] rounded-lg bg-[#ecedef]" />
</div>
</div>
</div>
<span className="block w-full p-2 text-center font-normal">
Light
</span>
</div>
<div className="[&:has([data-state=checked])>div]:border-primary cursor-pointer" onClick={() => setTheme('dark')}>
<div className={`items-center rounded-lg border-2 bg-popover p-1 hover:bg-accent hover:text-accent-foreground ${theme === 'dark' ? 'border-his' : 'border-muted'}`}>
<div className="space-y-2 rounded-md bg-slate-950 p-2">
<div className="space-y-2 rounded-md bg-slate-800 p-2 shadow-sm">
<div className="h-2 w-20 rounded-lg bg-slate-400" />
<div className="h-2 w-[100px] rounded-lg bg-slate-400" />
</div>
<div className="flex items-center space-x-2 rounded-md bg-slate-800 p-2 shadow-sm">
<div className="h-4 w-4 rounded-full bg-slate-400" />
<div className="h-2 w-[100px] rounded-lg bg-slate-400" />
</div>
<div className="flex items-center space-x-2 rounded-md bg-slate-800 p-2 shadow-sm">
<div className="h-4 w-4 rounded-full bg-slate-400" />
<div className="h-2 w-[100px] rounded-lg bg-slate-400" />
</div>
</div>
</div>
<span className="block w-full p-2 text-center font-normal">
Dark
</span>
</div>
<div className="[&:has([data-state=checked])>div]:border-primary cursor-pointer" onClick={() => setTheme('system')}>
<div className={`items-center rounded-lg border-2 bg-popover p-1 hover:bg-accent hover:text-accent-foreground ${theme === 'system' ? 'border-his' : 'border-muted'}`}>
<div className="space-y-2 rounded-md bg-zinc-950 p-2">
<div className="space-y-2 rounded-md bg-zinc-800 p-2 shadow-sm">
<div className="h-2 w-20 rounded-lg bg-zinc-400" />
<div className="h-2 w-[100px] rounded-lg bg-zinc-400" />
</div>
<div className="flex items-center space-x-2 rounded-md bg-zinc-800 p-2 shadow-sm">
<div className="h-4 w-4 rounded-full bg-zinc-400" />
<div className="h-2 w-[100px] rounded-lg bg-zinc-400" />
</div>
<div className="flex items-center space-x-2 rounded-md bg-zinc-800 p-2 shadow-sm">
<div className="h-4 w-4 rounded-full bg-zinc-400" />
<div className="h-2 w-[100px] rounded-lg bg-zinc-400" />
</div>
</div>
</div>
<span className="block w-full p-2 text-center font-normal">
System
</span>
</div>
</div>
<div className='sm:hidden flex flex-row space-x-2 font-medium'>
<div className='cursor-pointer' onClick={() => setTheme('light')}>
<div className={`items-center rounded-lg border-2 bg-popover p-1 hover:bg-accent hover:text-accent-foreground ${theme === 'light' ? 'border-his' : 'border-muted'}`}>
<div className="space-y-2 rounded-md bg-[#ecedef] p-2">
<div className="space-y-2 rounded-md bg-white p-2 shadow-sm">
<div className="h-2 w-5 rounded-lg bg-[#ecedef]" />
<div className="h-2 w-8 rounded-lg bg-[#ecedef]" />
</div>
</div>
</div>
<span className="block w-full p-2 text-center font-normal">
Light
</span>
</div>
<div className="[&:has([data-state=checked])>div]:border-primary cursor-pointer" onClick={() => setTheme('dark')}>
<div className={`items-center rounded-lg border-2 bg-popover p-1 hover:bg-accent hover:text-accent-foreground ${theme === 'dark' ? 'border-his' : 'border-muted'}`}>
<div className="space-y-2 rounded-md bg-slate-950 p-2">
<div className="space-y-2 rounded-md bg-slate-800 p-2 shadow-sm">
<div className="h-2 w-5 rounded-lg bg-slate-400" />
<div className="h-2 w-8 rounded-lg bg-slate-400" />
</div>
</div>
</div>
<span className="block w-full p-2 text-center font-normal">
Dark
</span>
</div>
<div className="[&:has([data-state=checked])>div]:border-primary cursor-pointer" onClick={() => setTheme('system')}>
<div className={`items-center rounded-lg border-2 bg-popover p-1 hover:bg-accent hover:text-accent-foreground ${theme === 'system' ? 'border-his' : 'border-muted'}`}>
<div className="space-y-2 rounded-md bg-zinc-950 p-2">
<div className="space-y-2 rounded-md bg-zinc-800 p-2 shadow-sm">
<div className="h-2 w-5 rounded-lg bg-zinc-400" />
<div className="h-2 w-8 rounded-lg bg-zinc-400" />
</div>
</div>
</div>
<span className="block w-full p-2 text-center font-normal">
System
</span>
</div>
</div>
</>
);
}
export default ChangeTheme;