Skip to content

Commit e39b897

Browse files
committed
fix(lint): restore ClipboardStream + drop unused ArrowUpRight + catch (_e)
1 parent b7e4d07 commit e39b897

1 file changed

Lines changed: 84 additions & 1 deletion

File tree

widgets/ClipboardStream.tsx

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,84 @@
1-
PLACEHOLDER
1+
import React, { useState } from 'react';
2+
import { Clipboard, Copy, Trash2, Plus, GripHorizontal, Check } from 'lucide-react';
3+
import { useAppStore } from '../store';
4+
5+
export const ClipboardStream: React.FC = () => {
6+
const { clipboardHistory, addToClipboardHistory, clearClipboardHistory } = useAppStore();
7+
const [justCopied, setJustCopied] = useState<number | null>(null);
8+
9+
const handleCopy = async (text: string, index: number) => {
10+
try {
11+
await navigator.clipboard.writeText(text);
12+
setJustCopied(index);
13+
setTimeout(() => setJustCopied(null), 1500);
14+
} catch (_e) {
15+
// ignore
16+
}
17+
};
18+
19+
const handlePaste = async () => {
20+
try {
21+
const text = await navigator.clipboard.readText();
22+
if (text) addToClipboardHistory(text);
23+
} catch (_e) {
24+
// ignore
25+
}
26+
};
27+
28+
return (
29+
<div className="h-full flex flex-col gap-2">
30+
<div className="flex items-center justify-between">
31+
<div className="flex items-center gap-2 text-xs font-bold text-indigo-400 uppercase">
32+
<Clipboard size={14} /> Stream
33+
</div>
34+
<button
35+
onClick={handlePaste}
36+
className="text-[10px] bg-slate-800 hover:bg-slate-700 px-2 py-1 rounded text-slate-300 flex items-center gap-1"
37+
>
38+
<Plus size={10} /> Capture
39+
</button>
40+
</div>
41+
42+
<div className="flex-1 overflow-y-auto space-y-1 min-h-0">
43+
{clipboardHistory.length === 0 && (
44+
<div className="text-center text-slate-600 text-xs py-8">No history yet</div>
45+
)}
46+
{clipboardHistory.map((item, i) => (
47+
<div
48+
key={i}
49+
className="group relative bg-slate-900 border border-slate-800 rounded p-2 text-xs text-slate-300 font-mono hover:border-indigo-500/40 transition-colors"
50+
draggable
51+
onDragStart={e => {
52+
e.dataTransfer.setData('text/plain', item);
53+
e.dataTransfer.effectAllowed = 'copy';
54+
}}
55+
>
56+
<div className="absolute top-1 left-1 opacity-0 group-hover:opacity-50">
57+
<GripHorizontal size={12} className="text-indigo-400" />
58+
</div>
59+
<div className="pr-6 pl-4 break-all line-clamp-3">{item}</div>
60+
<button
61+
onClick={() => handleCopy(item, i)}
62+
className="absolute top-1 right-1 p-1 rounded bg-slate-800 hover:bg-slate-700 text-slate-400 opacity-0 group-hover:opacity-100 transition-opacity"
63+
>
64+
{justCopied === i ? (
65+
<Check size={12} className="text-emerald-400" />
66+
) : (
67+
<Copy size={12} />
68+
)}
69+
</button>
70+
</div>
71+
))}
72+
</div>
73+
74+
{clipboardHistory.length > 0 && (
75+
<button
76+
onClick={clearClipboardHistory}
77+
className="text-[10px] text-slate-500 hover:text-red-400 flex items-center gap-1 self-end"
78+
>
79+
<Trash2 size={10} /> Clear Buffer
80+
</button>
81+
)}
82+
</div>
83+
);
84+
};

0 commit comments

Comments
 (0)