mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-11 16:07:15 +02:00
refactor: redesign settings UI with shadcn Tabs and cleaner layout
Simplified the settings UI to be more minimal and follow Grimoire patterns: Changes: - Use shadcn Tabs component instead of custom sidebar navigation - Remove non-working theme selector (no theme system implemented yet) - Use regular <label> elements with htmlFor instead of custom Label component - Shorter, cleaner copy throughout - Properly remove unused theme-related imports from user menu - Follow Grimoire UI patterns (similar to SettingsDialog) Settings sections: - Post: Include client tag setting - Appearance: Show client tags setting The UI is now cleaner, uses proper form semantics, and matches the rest of Grimoire's design system.
This commit is contained in:
@@ -1,153 +1,86 @@
|
||||
import { useState } from "react";
|
||||
import { Settings, Palette } from "lucide-react";
|
||||
import { Label } from "./ui/label";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./ui/tabs";
|
||||
import { Checkbox } from "./ui/checkbox";
|
||||
import { Button } from "./ui/button";
|
||||
import { useSettings } from "@/hooks/useSettings";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type SettingsTab = "post" | "appearance";
|
||||
|
||||
interface TabConfig {
|
||||
id: SettingsTab;
|
||||
label: string;
|
||||
icon: React.ReactNode;
|
||||
}
|
||||
|
||||
const TABS: TabConfig[] = [
|
||||
{
|
||||
id: "post",
|
||||
label: "Post",
|
||||
icon: <Settings className="h-4 w-4" />,
|
||||
},
|
||||
{
|
||||
id: "appearance",
|
||||
label: "Appearance",
|
||||
icon: <Palette className="h-4 w-4" />,
|
||||
},
|
||||
];
|
||||
|
||||
export function SettingsViewer() {
|
||||
const { settings, updateSetting } = useSettings();
|
||||
const [activeTab, setActiveTab] = useState<SettingsTab>("post");
|
||||
|
||||
return (
|
||||
<div className="h-full flex">
|
||||
{/* Sidebar */}
|
||||
<div className="w-48 border-r border-border bg-muted/20">
|
||||
<div className="p-4">
|
||||
<h2 className="text-lg font-semibold mb-4">Settings</h2>
|
||||
<div className="space-y-1">
|
||||
{TABS.map((tab) => (
|
||||
<button
|
||||
key={tab.id}
|
||||
onClick={() => setActiveTab(tab.id)}
|
||||
className={cn(
|
||||
"w-full flex items-center gap-3 px-3 py-2 rounded-md text-sm transition-colors",
|
||||
activeTab === tab.id
|
||||
? "bg-accent text-accent-foreground"
|
||||
: "hover:bg-accent/50 text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{tab.icon}
|
||||
<span>{tab.label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="h-full flex flex-col">
|
||||
<Tabs defaultValue="post" className="flex-1 flex flex-col">
|
||||
<div className="border-b px-6 py-3">
|
||||
<TabsList>
|
||||
<TabsTrigger value="post">Post</TabsTrigger>
|
||||
<TabsTrigger value="appearance">Appearance</TabsTrigger>
|
||||
</TabsList>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<div className="flex-1 overflow-y-auto">
|
||||
<div className="p-6 max-w-2xl">
|
||||
{activeTab === "post" && (
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold mb-4">Post Settings</h3>
|
||||
<p className="text-sm text-muted-foreground mb-6">
|
||||
Configure how your posts are published
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-start gap-3">
|
||||
<Checkbox
|
||||
id="client-tag"
|
||||
checked={settings?.post?.includeClientTag ?? true}
|
||||
onCheckedChange={(checked: boolean) =>
|
||||
updateSetting("post", "includeClientTag", checked)
|
||||
}
|
||||
/>
|
||||
<div className="space-y-0.5">
|
||||
<Label className="cursor-pointer">Include Client Tag</Label>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Add Grimoire client tag to your published events (kind 1
|
||||
posts, spells, deletions)
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex-1 overflow-y-auto">
|
||||
<TabsContent value="post" className="m-0 p-6 space-y-6">
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold mb-1">Post Settings</h3>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Configure event publishing
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === "appearance" && (
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold mb-4">
|
||||
Appearance Settings
|
||||
</h3>
|
||||
<p className="text-sm text-muted-foreground mb-6">
|
||||
Customize how Grimoire looks
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-6">
|
||||
<div className="space-y-3">
|
||||
<Label>Theme</Label>
|
||||
<div className="flex gap-2">
|
||||
{(["light", "dark", "system"] as const).map((theme) => (
|
||||
<Button
|
||||
key={theme}
|
||||
variant={
|
||||
(settings?.appearance?.theme ?? "dark") === theme
|
||||
? "default"
|
||||
: "outline"
|
||||
}
|
||||
size="sm"
|
||||
onClick={() =>
|
||||
updateSetting("appearance", "theme", theme)
|
||||
}
|
||||
className="capitalize"
|
||||
>
|
||||
{theme}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-start space-x-3">
|
||||
<Checkbox
|
||||
id="include-client-tag"
|
||||
checked={settings?.post?.includeClientTag ?? true}
|
||||
onCheckedChange={(checked: boolean) =>
|
||||
updateSetting("post", "includeClientTag", checked)
|
||||
}
|
||||
/>
|
||||
<div className="space-y-1">
|
||||
<label
|
||||
htmlFor="include-client-tag"
|
||||
className="text-sm cursor-pointer"
|
||||
>
|
||||
Include client tag
|
||||
</label>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Choose your preferred color scheme
|
||||
Add Grimoire tag to posts, spells, and deletions
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
<div className="flex items-start gap-3">
|
||||
<Checkbox
|
||||
id="show-client-tags"
|
||||
checked={settings?.appearance?.showClientTags ?? true}
|
||||
onCheckedChange={(checked: boolean) =>
|
||||
updateSetting("appearance", "showClientTags", checked)
|
||||
}
|
||||
/>
|
||||
<div className="space-y-0.5">
|
||||
<Label className="cursor-pointer">Show Client Tags</Label>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Display "via Grimoire" and other client tags in event UI
|
||||
</p>
|
||||
</div>
|
||||
<TabsContent value="appearance" className="m-0 p-6 space-y-6">
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold mb-1">Appearance</h3>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Customize display preferences
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-start space-x-3">
|
||||
<Checkbox
|
||||
id="show-client-tags"
|
||||
checked={settings?.appearance?.showClientTags ?? true}
|
||||
onCheckedChange={(checked: boolean) =>
|
||||
updateSetting("appearance", "showClientTags", checked)
|
||||
}
|
||||
/>
|
||||
<div className="space-y-1">
|
||||
<label
|
||||
htmlFor="show-client-tags"
|
||||
className="text-sm cursor-pointer"
|
||||
>
|
||||
Show client tags
|
||||
</label>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Display "via Grimoire" and other client identifiers
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</TabsContent>
|
||||
</div>
|
||||
</div>
|
||||
</Tabs>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
User,
|
||||
Palette,
|
||||
Wallet,
|
||||
X,
|
||||
RefreshCw,
|
||||
@@ -27,9 +26,6 @@ import {
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
DropdownMenuSub,
|
||||
DropdownMenuSubTrigger,
|
||||
DropdownMenuSubContent,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Dialog,
|
||||
@@ -45,7 +41,6 @@ import SettingsDialog from "@/components/SettingsDialog";
|
||||
import LoginDialog from "./LoginDialog";
|
||||
import ConnectWalletDialog from "@/components/ConnectWalletDialog";
|
||||
import { useState } from "react";
|
||||
import { useTheme } from "@/lib/themes";
|
||||
import { toast } from "sonner";
|
||||
import { useWallet } from "@/hooks/useWallet";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
@@ -95,7 +90,6 @@ export default function UserMenu() {
|
||||
const [showLogin, setShowLogin] = useState(false);
|
||||
const [showConnectWallet, setShowConnectWallet] = useState(false);
|
||||
const [showWalletInfo, setShowWalletInfo] = useState(false);
|
||||
const { themeId, setTheme, availableThemes } = useTheme();
|
||||
|
||||
// Calculate monthly donations reactively from DB (last 30 days)
|
||||
const monthlyDonations =
|
||||
@@ -489,34 +483,8 @@ export default function UserMenu() {
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* App Preferences - Theme */}
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuSub>
|
||||
<DropdownMenuSubTrigger className="cursor-crosshair">
|
||||
<Palette className="size-4 text-muted-foreground mr-2" />
|
||||
Theme
|
||||
</DropdownMenuSubTrigger>
|
||||
<DropdownMenuSubContent>
|
||||
{availableThemes.map((theme) => (
|
||||
<DropdownMenuItem
|
||||
key={theme.id}
|
||||
className="cursor-crosshair"
|
||||
onClick={() => setTheme(theme.id)}
|
||||
>
|
||||
<span
|
||||
className={`size-2 rounded-full mr-2 ${
|
||||
themeId === theme.id
|
||||
? "bg-primary"
|
||||
: "bg-muted-foreground/30"
|
||||
}`}
|
||||
/>
|
||||
{theme.name}
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
</DropdownMenuSubContent>
|
||||
</DropdownMenuSub>
|
||||
|
||||
{/* Settings */}
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem
|
||||
className="cursor-crosshair"
|
||||
onClick={() => addWindow("settings", {}, "Settings")}
|
||||
|
||||
Reference in New Issue
Block a user