| // src/components/settings/ThemeSelector.tsx | |
| import { useTheme } from "@/hooks/useTheme"; | |
| import type { ThemeMode, AccentColor } from "@/hooks/useTheme"; | |
| import { Sun, Moon, Monitor, Palette, Check } from "lucide-react"; | |
| import { motion } from "framer-motion"; | |
| const MODE_OPTIONS: { value: ThemeMode; label: string; icon: typeof Sun }[] = [ | |
| { value: "light", label: "Light", icon: Sun }, | |
| { value: "dark", label: "Dark", icon: Moon }, | |
| { value: "system", label: "System", icon: Monitor }, | |
| ]; | |
| const ACCENT_OPTIONS: { value: AccentColor; label: string; colorClass: string }[] = [ | |
| { value: "default", label: "Teal", colorClass: "bg-teal-500" }, | |
| { value: "blue", label: "Blue", colorClass: "bg-blue-500" }, | |
| { value: "green", label: "Green", colorClass: "bg-green-500" }, | |
| { value: "purple", label: "Purple", colorClass: "bg-purple-500" }, | |
| { value: "orange", label: "Orange", colorClass: "bg-orange-500" }, | |
| { value: "rose", label: "Rose", colorClass: "bg-rose-500" }, | |
| { value: "amber", label: "Amber", colorClass: "bg-amber-500" }, | |
| ]; | |
| export function ThemeSelector() { | |
| const { mode, setMode, accent, setAccent, resolvedMode } = useTheme(); | |
| return ( | |
| <div className="space-y-6"> | |
| {/* Theme mode switcher */} | |
| <div> | |
| <h3 className="mb-3 text-sm font-semibold text-gray-700 dark:text-gray-300"> | |
| Theme Mode | |
| </h3> | |
| <div className="grid grid-cols-3 gap-2"> | |
| {MODE_OPTIONS.map((opt) => ( | |
| <motion.button | |
| key={opt.value} | |
| onClick={() => setMode(opt.value)} | |
| whileTap={{ scale: 0.97 }} | |
| className={`flex flex-col items-center gap-1.5 rounded-xl border-2 p-3 transition-all ${ | |
| mode === opt.value | |
| ? "border-primary bg-primary/5 text-primary" | |
| : "border-gray-200 text-gray-500 hover:border-gray-300 dark:border-gray-700 dark:hover:border-gray-600" | |
| }`} | |
| > | |
| <opt.icon className="h-5 w-5" /> | |
| <span className="text-xs font-medium">{opt.label}</span> | |
| </motion.button> | |
| ))} | |
| </div> | |
| </div> | |
| {/* Accent color picker */} | |
| <div> | |
| <h3 className="mb-3 text-sm font-semibold text-gray-700 dark:text-gray-300"> | |
| Accent Color | |
| </h3> | |
| <div className="grid grid-cols-4 gap-2 sm:grid-cols-7"> | |
| {ACCENT_OPTIONS.map((opt) => ( | |
| <motion.button | |
| key={opt.value} | |
| onClick={() => setAccent(opt.value)} | |
| whileTap={{ scale: 0.95 }} | |
| className={`relative flex h-10 w-10 items-center justify-center rounded-full ${opt.colorClass} transition-transform hover:scale-110 ${ | |
| accent === opt.value | |
| ? "ring-2 ring-offset-2 ring-gray-400 dark:ring-offset-gray-800" | |
| : "" | |
| }`} | |
| title={opt.label} | |
| > | |
| {accent === opt.value && <Check className="h-4 w-4 text-white" />} | |
| </motion.button> | |
| ))} | |
| </div> | |
| </div> | |
| {/* Live preview card */} | |
| <div | |
| className={`rounded-xl p-4 transition-colors ${ | |
| resolvedMode === "dark" ? "bg-gray-800" : "bg-gray-50" | |
| }`} | |
| > | |
| <p className="mb-2 text-xs text-gray-400">Preview</p> | |
| <div className="space-y-2"> | |
| <div className="h-2 w-24 rounded-full bg-primary" /> | |
| <div className="h-2 w-32 rounded-full bg-gray-300 dark:bg-gray-600" /> | |
| <div className="flex gap-2"> | |
| <div className="h-8 w-16 rounded-lg bg-primary" /> | |
| <div className="h-8 w-16 rounded-lg bg-gray-200 dark:bg-gray-700" /> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| } |
Xet Storage Details
- Size:
- 3.75 kB
- Xet hash:
- 662638e6ff979f63eb2f7353a63ca75ef29aeb017bce0918943ea15b716f6bf5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.