mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-18 03:30:39 +09:00
Make worktree banner name clickable to copy to clipboard
Clicking the worktree name in the banner now copies it to clipboard and shows "Copied\!" feedback for 1.5 seconds. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
30dd2b78e5
commit
db1279dc12
1 changed files with 19 additions and 1 deletions
|
|
@ -1,7 +1,18 @@
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
import { getWorktreeUiBranding } from "../lib/worktree-branding";
|
import { getWorktreeUiBranding } from "../lib/worktree-branding";
|
||||||
|
|
||||||
export function WorktreeBanner() {
|
export function WorktreeBanner() {
|
||||||
const branding = getWorktreeUiBranding();
|
const branding = getWorktreeUiBranding();
|
||||||
|
const [copied, setCopied] = useState(false);
|
||||||
|
|
||||||
|
const handleCopyName = useCallback(() => {
|
||||||
|
if (!branding) return;
|
||||||
|
navigator.clipboard.writeText(branding.name).then(() => {
|
||||||
|
setCopied(true);
|
||||||
|
setTimeout(() => setCopied(false), 1500);
|
||||||
|
});
|
||||||
|
}, [branding]);
|
||||||
|
|
||||||
if (!branding) return null;
|
if (!branding) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -18,7 +29,14 @@ export function WorktreeBanner() {
|
||||||
<div className="flex items-center gap-2 overflow-hidden whitespace-nowrap">
|
<div className="flex items-center gap-2 overflow-hidden whitespace-nowrap">
|
||||||
<span className="shrink-0 opacity-70">Worktree</span>
|
<span className="shrink-0 opacity-70">Worktree</span>
|
||||||
<span className="h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-70" aria-hidden="true" />
|
<span className="h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-70" aria-hidden="true" />
|
||||||
<span className="truncate font-semibold tracking-[0.12em]">{branding.name}</span>
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={handleCopyName}
|
||||||
|
title="Click to copy worktree name"
|
||||||
|
className="truncate font-semibold tracking-[0.12em] cursor-pointer hover:opacity-80 transition-opacity bg-transparent border-none p-0 text-current uppercase text-[11px]"
|
||||||
|
>
|
||||||
|
{copied ? "Copied!" : branding.name}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue