mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-12 08:27:27 +02:00
refactor: use Button component and remove misleading shortcuts
- Replace native button elements with Button component from shadcn/ui - Use variant="ghost" and size="icon" for consistent styling - Apply h-8 w-8 classes for uniform button sizing - Remove manual className styling in favor of component variants - Remove misleading keyboard shortcut hints from button titles - Changed "Edit command (Cmd+E)" to "Edit command" - Changed "Close window (Cmd+W)" to "Close window" - These shortcuts don't actually work, so they were misleading - Clean up imports and formatting - Format lucide-react imports across multiple lines - Add Button component import - Run prettier for consistent code style
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
import { X, Pencil, MoreVertical, WandSparkles, Copy, CopyCheck } from "lucide-react";
|
||||
import {
|
||||
X,
|
||||
Pencil,
|
||||
MoreVertical,
|
||||
WandSparkles,
|
||||
Copy,
|
||||
CopyCheck,
|
||||
} from "lucide-react";
|
||||
import { useSetAtom } from "jotai";
|
||||
import { useState } from "react";
|
||||
import { WindowInstance } from "@/types/app";
|
||||
@@ -10,6 +17,7 @@ import {
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { SpellDialog } from "@/components/nostr/SpellDialog";
|
||||
import { reconstructCommand as reconstructReqCommand } from "@/lib/spell-conversion";
|
||||
import { toast } from "sonner";
|
||||
@@ -66,7 +74,7 @@ export function WindowToolbar({
|
||||
|
||||
// Fetch NIP content for regular NIPs
|
||||
const { content: nipContent } = useNip(
|
||||
isNipWindow && window?.props?.number ? window.props.number : ""
|
||||
isNipWindow && window?.props?.number ? window.props.number : "",
|
||||
);
|
||||
|
||||
const handleCopyNip = () => {
|
||||
@@ -96,44 +104,46 @@ export function WindowToolbar({
|
||||
<>
|
||||
{window && (
|
||||
<>
|
||||
{/* Edit button with keyboard shortcut hint */}
|
||||
<button
|
||||
className="p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors"
|
||||
{/* Edit button */}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8"
|
||||
onClick={handleEdit}
|
||||
title="Edit command (Cmd+E)"
|
||||
title="Edit command"
|
||||
aria-label="Edit command"
|
||||
>
|
||||
<Pencil className="size-4" />
|
||||
</button>
|
||||
</Button>
|
||||
|
||||
{/* Copy button for NIPs */}
|
||||
{isNipWindow && (
|
||||
<button
|
||||
className="p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors"
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8"
|
||||
onClick={handleCopyNip}
|
||||
title="Copy NIP markdown"
|
||||
aria-label="Copy NIP markdown"
|
||||
disabled={!nipContent}
|
||||
>
|
||||
{copied ? (
|
||||
<CopyCheck className="size-4" />
|
||||
) : (
|
||||
<Copy className="size-4" />
|
||||
)}
|
||||
</button>
|
||||
{copied ? <CopyCheck /> : <Copy />}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{/* More actions menu - only for REQ windows for now */}
|
||||
{isReqWindow && (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button
|
||||
className="p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors"
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8"
|
||||
title="More actions"
|
||||
aria-label="More actions"
|
||||
>
|
||||
<MoreVertical className="size-4" />
|
||||
</button>
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem onClick={handleTurnIntoSpell}>
|
||||
@@ -159,14 +169,16 @@ export function WindowToolbar({
|
||||
</>
|
||||
)}
|
||||
{onClose && (
|
||||
<button
|
||||
className="p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors"
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8"
|
||||
onClick={onClose}
|
||||
title="Close window (Cmd+W)"
|
||||
title="Close window"
|
||||
aria-label="Close window"
|
||||
>
|
||||
<X className="size-4" />
|
||||
</button>
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Copy, CopyCheck } from "lucide-react";
|
||||
import { getTagValue } from "applesauce-core/helpers";
|
||||
import { UserName } from "../UserName";
|
||||
import { MarkdownContent } from "../MarkdownContent";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useCopy } from "@/hooks/useCopy";
|
||||
import { toast } from "sonner";
|
||||
import type { NostrEvent } from "@/types/nostr";
|
||||
@@ -46,18 +47,15 @@ export function CommunityNIPDetailRenderer({ event }: { event: NostrEvent }) {
|
||||
{/* Title with Copy Button */}
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<h1 className="text-3xl font-bold">{title}</h1>
|
||||
<button
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={handleCopy}
|
||||
className="p-2 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors shrink-0"
|
||||
title="Copy NIP markdown"
|
||||
aria-label="Copy NIP markdown"
|
||||
>
|
||||
{copied ? (
|
||||
<CopyCheck className="size-5" />
|
||||
) : (
|
||||
<Copy className="size-5" />
|
||||
)}
|
||||
</button>
|
||||
{copied ? <CopyCheck /> : <Copy />}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Metadata */}
|
||||
|
||||
Reference in New Issue
Block a user