2022-05-12 02:45:43 +08:00
|
|
|
import { state } from '@/web/store'
|
|
|
|
import { changeAccentColor } from '@/web/utils/theme'
|
|
|
|
import { useSnapshot } from 'valtio'
|
|
|
|
import cx from 'classnames'
|
2022-04-17 12:46:06 +08:00
|
|
|
|
|
|
|
const AccentColor = () => {
|
|
|
|
const colors = {
|
|
|
|
red: 'bg-red-500',
|
|
|
|
orange: 'bg-orange-500',
|
|
|
|
amber: 'bg-amber-500',
|
|
|
|
yellow: 'bg-yellow-500',
|
|
|
|
lime: 'bg-lime-500',
|
|
|
|
green: 'bg-green-500',
|
|
|
|
emerald: 'bg-emerald-500',
|
|
|
|
teal: 'bg-teal-500',
|
|
|
|
cyan: 'bg-cyan-500',
|
|
|
|
sky: 'bg-sky-500',
|
|
|
|
blue: 'bg-blue-500',
|
|
|
|
indigo: 'bg-indigo-500',
|
|
|
|
violet: 'bg-violet-500',
|
|
|
|
purple: 'bg-purple-500',
|
|
|
|
fuchsia: 'bg-fuchsia-500',
|
|
|
|
pink: 'bg-pink-500',
|
|
|
|
rose: 'bg-rose-500',
|
|
|
|
}
|
|
|
|
|
|
|
|
const changeColor = (color: string) => {
|
|
|
|
state.settings.accentColor = color
|
|
|
|
changeAccentColor(color)
|
|
|
|
}
|
2022-04-29 19:16:34 +08:00
|
|
|
|
|
|
|
const accentColor = useSnapshot(state).settings.accentColor
|
2022-04-17 12:46:06 +08:00
|
|
|
return (
|
2022-04-29 19:16:34 +08:00
|
|
|
<div className='mt-4'>
|
|
|
|
<div className='mb-2 dark:text-white'>强调色</div>
|
|
|
|
<div className=' flex items-center'>
|
|
|
|
{Object.entries(colors).map(([color, bg]) => (
|
|
|
|
<div
|
|
|
|
key={color}
|
2022-05-12 02:45:43 +08:00
|
|
|
className={cx(
|
2022-05-01 19:53:25 +08:00
|
|
|
bg,
|
|
|
|
'mr-2.5 flex h-5 w-5 items-center justify-center rounded-full'
|
|
|
|
)}
|
2022-04-29 19:16:34 +08:00
|
|
|
onClick={() => changeColor(color)}
|
|
|
|
>
|
2022-05-01 19:53:25 +08:00
|
|
|
{color === accentColor && (
|
|
|
|
<div className='h-1.5 w-1.5 rounded-full bg-white'></div>
|
|
|
|
)}
|
2022-04-29 19:16:34 +08:00
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
2022-04-17 12:46:06 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-04-29 19:16:34 +08:00
|
|
|
const Theme = () => {
|
2022-05-01 19:53:25 +08:00
|
|
|
return (
|
|
|
|
<div className='mt-4'>
|
|
|
|
<div className='mb-2 dark:text-white'>主题</div>
|
|
|
|
<div></div>
|
2022-04-29 19:16:34 +08:00
|
|
|
</div>
|
2022-05-01 19:53:25 +08:00
|
|
|
)
|
2022-04-29 19:16:34 +08:00
|
|
|
}
|
|
|
|
|
2022-04-17 12:46:06 +08:00
|
|
|
const Appearance = () => {
|
|
|
|
return (
|
|
|
|
<div>
|
2022-04-29 19:16:34 +08:00
|
|
|
<div className='text-xl font-medium text-gray-800 dark:text-white/70'>
|
|
|
|
主题
|
|
|
|
</div>
|
|
|
|
<div className='mt-3 h-px w-full bg-black/5 dark:bg-white/10'></div>
|
2022-04-17 12:46:06 +08:00
|
|
|
|
|
|
|
<AccentColor />
|
2022-04-29 19:16:34 +08:00
|
|
|
<Theme />
|
2022-04-17 12:46:06 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Appearance
|