theming
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
import { Palette, Sun, Moon } from 'lucide-react';
|
||||
import { useTheme } from '@/components/ui/ThemeProvider';
|
||||
import { Card } from '@/components/Card';
|
||||
import { useSettings } from '@/state/useSettings';
|
||||
|
||||
export const Appearance = () => {
|
||||
const { settings, saveSettings } = useSettings();
|
||||
const { theme, setTheme } = useTheme();
|
||||
|
||||
const handleThemeChange = (newTheme: string) => {
|
||||
setTheme(newTheme);
|
||||
saveSettings({ ...settings, appearance: { ...settings.appearance, theme: newTheme } });
|
||||
};
|
||||
|
||||
return (
|
||||
<Card className="p-6 h-fit">
|
||||
<div className="flex items-center gap-3 mb-6">
|
||||
<Palette className="h-5 w-5 text-duck-forest" />
|
||||
<h2 className="text-xl font-bold text-duck-dark">Appearance</h2>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-3">
|
||||
<span className="text-duck-dark/70 text-sm">Theme</span>
|
||||
<div className="flex items-center border border-duck-dark/20 rounded-md overflow-hidden">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleThemeChange('light')}
|
||||
className={`flex-1 flex items-center justify-center gap-2 py-3 text-sm font-medium cursor-pointer transition-colors ${
|
||||
theme === 'light' ? 'bg-duck-teal text-duck-yellow' : 'text-duck-dark/50 hover:bg-duck-dark/5'
|
||||
}`}
|
||||
>
|
||||
<Sun className="h-4 w-4" />
|
||||
Light
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleThemeChange('dark')}
|
||||
className={`flex-1 flex items-center justify-center gap-2 py-3 text-sm font-medium cursor-pointer transition-colors ${
|
||||
theme === 'dark' ? 'bg-duck-teal text-duck-yellow' : 'text-duck-dark/50 hover:bg-duck-dark/5'
|
||||
}`}
|
||||
>
|
||||
<Moon className="h-4 w-4" />
|
||||
Dark
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
import { useSettings } from '@/state/useSettings';
|
||||
import { themes } from 'themes';
|
||||
|
||||
export const Appearance = () => {
|
||||
const { settings, saveSettings } = useSettings();
|
||||
|
||||
const handleColorThemeChange = (colorTheme: string) => {
|
||||
saveSettings({ ...settings, appearance: { ...settings.appearance, colorTheme } });
|
||||
};
|
||||
|
||||
const activeColorTheme = settings.appearance.colorTheme ?? 'DuckPond';
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 gap-2 pt-2">
|
||||
{themes.map((t) => (
|
||||
<button
|
||||
key={t.id}
|
||||
type="button"
|
||||
onClick={() => handleColorThemeChange(t.id)}
|
||||
className={`rounded-md px-3 py-2.5 text-sm font-medium cursor-pointer transition-colors ${
|
||||
activeColorTheme === t.id
|
||||
? 'bg-duck-teal text-white ring-2 ring-duck-teal/50'
|
||||
: 'bg-secondary text-secondary-foreground hover:bg-secondary/80'
|
||||
}`}
|
||||
>
|
||||
{t.name}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect, useRef, useMemo } from 'react';
|
||||
import { Search, User, Lock, Globe, ListChecks } from 'lucide-react';
|
||||
import { Search, User, Lock, Globe, ListChecks, Palette } from 'lucide-react';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from '@/components/ui/accordion';
|
||||
import { Card } from '@/components/Card';
|
||||
@@ -8,6 +8,7 @@ import { UserData } from './UserData';
|
||||
import { ChangePassword } from './ChangePassword';
|
||||
import { Languages } from './Languages';
|
||||
import { TaskDefaults } from './TaskDefaults';
|
||||
import { Appearance } from './Appearance';
|
||||
|
||||
const sections = [
|
||||
{
|
||||
@@ -17,6 +18,13 @@ const sections = [
|
||||
description: 'Update your name and avatar.',
|
||||
content: <UserData />,
|
||||
},
|
||||
{
|
||||
key: 'appearance',
|
||||
icon: Palette,
|
||||
title: 'Appearance',
|
||||
description: 'Color theme and light/dark mode.',
|
||||
content: <Appearance />,
|
||||
},
|
||||
{
|
||||
key: 'tasks',
|
||||
icon: ListChecks,
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Link } from 'react-router';
|
||||
import { Bot, ChevronRight } from 'lucide-react';
|
||||
import { Card } from '@/components/Card';
|
||||
import { DashboardLayout } from '../Layout';
|
||||
import { Appearance } from './Appearance';
|
||||
|
||||
export const Settings = () => {
|
||||
return (
|
||||
@@ -23,7 +22,6 @@ export const Settings = () => {
|
||||
</div>
|
||||
</Card>
|
||||
</Link>
|
||||
<Appearance />
|
||||
</div>
|
||||
</div>
|
||||
</DashboardLayout>
|
||||
|
||||
Reference in New Issue
Block a user