feat(07-02): add theme picker section to InstanceGeneralSettings
- Import useTheme, THEME_META, type Theme from ThemeContext - Add ORDERED_THEMES constant with three theme IDs - Add theme picker section as first section in General Settings - Color swatches use inline backgroundColor (hardcoded hex, not CSS vars) - Active theme highlighted with border-primary bg-primary/10
This commit is contained in:
parent
868eb8a0ba
commit
076a29dc61
1 changed files with 35 additions and 0 deletions
|
|
@ -3,13 +3,17 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { SlidersHorizontal } from "lucide-react";
|
import { SlidersHorizontal } from "lucide-react";
|
||||||
import { instanceSettingsApi } from "@/api/instanceSettings";
|
import { instanceSettingsApi } from "@/api/instanceSettings";
|
||||||
import { useBreadcrumbs } from "../context/BreadcrumbContext";
|
import { useBreadcrumbs } from "../context/BreadcrumbContext";
|
||||||
|
import { useTheme, THEME_META, type Theme } from "../context/ThemeContext";
|
||||||
import { queryKeys } from "../lib/queryKeys";
|
import { queryKeys } from "../lib/queryKeys";
|
||||||
import { cn } from "../lib/utils";
|
import { cn } from "../lib/utils";
|
||||||
|
|
||||||
|
const ORDERED_THEMES: Theme[] = ["catppuccin-mocha", "tokyo-night", "catppuccin-latte"];
|
||||||
|
|
||||||
export function InstanceGeneralSettings() {
|
export function InstanceGeneralSettings() {
|
||||||
const { setBreadcrumbs } = useBreadcrumbs();
|
const { setBreadcrumbs } = useBreadcrumbs();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [actionError, setActionError] = useState<string | null>(null);
|
const [actionError, setActionError] = useState<string | null>(null);
|
||||||
|
const { theme, setTheme } = useTheme();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setBreadcrumbs([
|
setBreadcrumbs([
|
||||||
|
|
@ -69,6 +73,37 @@ export function InstanceGeneralSettings() {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<section className="rounded-xl border border-border bg-card p-5">
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
<h2 className="text-sm font-semibold">Theme</h2>
|
||||||
|
<p className="text-sm text-muted-foreground">Choose the visual theme for Nexus.</p>
|
||||||
|
</div>
|
||||||
|
<div className="mt-4 flex flex-wrap gap-3">
|
||||||
|
{ORDERED_THEMES.map((id) => {
|
||||||
|
const meta = THEME_META[id];
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={id}
|
||||||
|
type="button"
|
||||||
|
onClick={() => setTheme(id)}
|
||||||
|
className={cn(
|
||||||
|
"flex items-center gap-2.5 rounded-lg border px-3 py-2 text-sm transition-colors",
|
||||||
|
theme === id
|
||||||
|
? "border-primary bg-primary/10 text-primary"
|
||||||
|
: "border-border bg-card text-foreground hover:border-ring",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="h-4 w-4 rounded-full border border-border/50 shrink-0"
|
||||||
|
style={{ backgroundColor: meta.primary }}
|
||||||
|
/>
|
||||||
|
{meta.label}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section className="rounded-xl border border-border bg-card p-5">
|
<section className="rounded-xl border border-border bg-card p-5">
|
||||||
<div className="flex items-start justify-between gap-4">
|
<div className="flex items-start justify-between gap-4">
|
||||||
<div className="space-y-1.5">
|
<div className="space-y-1.5">
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue