Skip to content

Edge-Drop is a clipboard shelf on the edge of your screen. Hover to open it. Drag files and images into any app, click to copy text and links. Free and open-source for Windows.

feat: integrate unified preview toggle into clipboard cards

Deepender2568034b99d305
diff --git a/src/components/ClipboardItem.tsx b/src/components/ClipboardItem.tsx
index f167252..e5df854 100644
--- a/src/components/ClipboardItem.tsx
+++ b/src/components/ClipboardItem.tsx
@@ -23,7 +23,7 @@ import { useStore } from '../store/appStore'
import { useDragOut } from '../hooks/useDragOut'
import { basename, formatBytes, previewText, relativeTime } from '../lib/format'
import { getFileKind } from '../lib/fileType'
-import { CopyIcon, FileKindIcon, ImageIcon, LinkIcon, PinIcon, PinFillIcon, TrashIcon, MinusIcon, ChevronUpIcon, EyeIcon, EyeOffIcon } from './icons'
+import { CopyIcon, FileKindIcon, ImageIcon, LinkIcon, PinIcon, PinFillIcon, TrashIcon, MinusIcon, ChevronUpIcon, ExpandIcon, ContractIcon } from './icons'
import '../styles/item.css'
/**
@@ -129,7 +129,7 @@ function ClipboardItemBase({ item }: Props) {
className={`item${item.pinned ? ' pinned' : ''}${isBundle ? ' bundle' : ''}`}
>
<div
- className={`item-main${isPreviewing ? ' force-actions' : ''}`}
+ className={`item-main${isPreviewing ? ' force-actions previewing' : ''}`}
data-id={item.id}
draggable={item.data.kind !== 'text' && (!isBundle || !expanded)}
onDragStart={(e) => handleDragStart(e, { id: item.id })}
@@ -210,8 +210,8 @@ function ClipboardItemBase({ item }: Props) {
<CopyIcon />
</button>
<button
- className="act"
- title={isPreviewing ? "Close Preview" : "Preview"}
+ className={`act${isPreviewing ? ' preview-contract active' : ' preview-expand'}`}
+ title={isPreviewing ? 'Close Preview' : 'Expand Preview'}
onClick={(e) => {
e.stopPropagation()
e.currentTarget.blur()
@@ -220,7 +220,7 @@ function ClipboardItemBase({ item }: Props) {
useStore.getState().setPreviewItemId(isPreviewing ? null : item.id, rectData)
}}
>
- {isPreviewing ? <EyeIcon /> : <EyeOffIcon />}
+ {isPreviewing ? <ContractIcon /> : <ExpandIcon />}
</button>
<button
className="act danger"
diff --git a/src/components/PreviewFlyout.tsx b/src/components/PreviewFlyout.tsx
index c1981be..e13838e 100644
--- a/src/components/PreviewFlyout.tsx
+++ b/src/components/PreviewFlyout.tsx
@@ -2,14 +2,13 @@ import { motion, AnimatePresence } from 'framer-motion'
import { useStore } from '../store/appStore'
import { formatBytes } from '../lib/format'
import { getFileKind } from '../lib/fileType'
-import { FileKindIcon, CloseIcon } from './icons'
+import { FileKindIcon } from './icons'
import { createPortal } from 'react-dom'
export function PreviewFlyout({ isRight }: { isRight: boolean }) {
const previewItemId = useStore((s) => s.previewItemId)
const items = useStore((s) => s.items)
const previewItemRect = useStore((s) => s.previewItemRect)
- const setPreviewItemId = useStore((s) => s.setPreviewItemId)
const settings = useStore((s) => s.settings)
const item = previewItemId ? items.find((i) => i.id === previewItemId) : null
@@ -72,21 +71,8 @@ export function PreviewFlyout({ isRight }: { isRight: boolean }) {
transformOrigin: `${isRight ? '100%' : '0%'} ${originY}`,
}}
>
- {/* Header */}
- <div style={{ padding: '16px', borderBottom: '1px solid rgba(255,255,255,0.05)', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
- <h3 style={{ margin: 0, fontSize: 14, fontWeight: 500, color: 'rgba(255,255,255,0.9)' }}>Preview</h3>
- <button
- className="act"
- title="Close Preview"
- onClick={() => setPreviewItemId(null)}
- style={{ background: 'rgba(255, 255, 255, 0.08)', border: 'none', color: '#fff', cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '6px', borderRadius: '50%' }}
- >
- <CloseIcon width={16} height={16} />
- </button>
- </div>
-
- {/* Content */}
- <div style={{ padding: '16px', overflowY: 'auto', flex: 1, minHeight: 0 }}>
+ {/* Content — even bezels, no header chrome */}
+ <div style={{ padding: '20px', overflowY: 'auto', flex: 1, minHeight: 0 }}>
<PreviewContent item={item} />
</div>
</motion.div>
diff --git a/src/components/icons.tsx b/src/components/icons.tsx
index 468a440..59b472b 100644
--- a/src/components/icons.tsx
+++ b/src/components/icons.tsx
@@ -111,15 +111,17 @@ export const ChevronDownIcon = (p: P) => (
</svg>
)
-export const EyeIcon = (p: P) => (
+/** Expand — four arrows pointing outward to corners (video player "enter fullscreen") */
+export const ExpandIcon = (p: P) => (
<svg {...base(p)}>
- <path fill="currentColor" fillRule="evenodd" d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z" clipRule="evenodd" />
+ <path fill="currentColor" d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/>
</svg>
)
-export const EyeOffIcon = (p: P) => (
+/** Contract — four arrows pointing inward from corners (video player "exit fullscreen") */
+export const ContractIcon = (p: P) => (
<svg {...base(p)}>
- <path fill="currentColor" d="M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z" />
+ <path fill="currentColor" d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"/>
</svg>
)
diff --git a/src/hooks/useEdgeHover.ts b/src/hooks/useEdgeHover.ts
index a9b7925..b27ce41 100644
--- a/src/hooks/useEdgeHover.ts
+++ b/src/hooks/useEdgeHover.ts
@@ -42,6 +42,30 @@ const PREVIEW_WIDE = 740 // Extended width when preview flyout is ac
export const PANEL_LEAVE_EVENT = 'panel:leave'
export const PANEL_ENTER_EVENT = 'panel:enter'
+// How long to keep the panel alive after the user explicitly closes the preview
+// via the X button. This prevents the jarring simultaneous collapse of both
+// the preview and the clipboard.
+const PREVIEW_CLOSE_STAY_MS = 2500
+
+// Module-level flag set by the X button click. useEdgeHover reads this to
+// extend the close grace period without needing React state or store updates.
+let _previewClosedByUser = false
+let _previewClosedTimer: number | undefined
+
+/**
+ * Call this from the preview flyout's X button to signal that the user
+ * deliberately closed the preview — the clipboard should stay open for a
+ * while so they can keep browsing.
+ */
+export function notifyPreviewClosedByUser(): void {
+ _previewClosedByUser = true
+ if (_previewClosedTimer !== undefined) window.clearTimeout(_previewClosedTimer)
+ _previewClosedTimer = window.setTimeout(() => {
+ _previewClosedByUser = false
+ _previewClosedTimer = undefined
+ }, PREVIEW_CLOSE_STAY_MS)
+}
+
export function useEdgeHover(): void {
const open = useStore((s) => s.open)
const setOpen = useStore((s) => s.setOpen)
@@ -141,7 +165,10 @@ export function useEdgeHover(): void {
const scheduleClose = (delay = GRACE_MS) => {
if (dragActiveRef.current && !internalDragRef.current) return
if (graceTimer !== undefined) return // already closing
- graceTimer = window.setTimeout(closePanel, delay)
+ // If the user just closed the preview via X, give them extra time before
+ // the clipboard collapses so they can keep using it.
+ const effectiveDelay = _previewClosedByUser ? PREVIEW_CLOSE_STAY_MS : delay
+ graceTimer = window.setTimeout(closePanel, effectiveDelay)
}
const cancelClose = () => {
@@ -153,6 +180,16 @@ export function useEdgeHover(): void {
window.clearTimeout(interactiveTimer)
interactiveTimer = undefined
}
+ // User re-entered the clipboard — clear the grace period flag so the
+ // next time they leave, the panel retracts at normal speed instead of
+ // waiting the full 2.5s safety net.
+ if (_previewClosedByUser) {
+ _previewClosedByUser = false
+ if (_previewClosedTimer !== undefined) {
+ window.clearTimeout(_previewClosedTimer)
+ _previewClosedTimer = undefined
+ }
+ }
}
const openPanel = () => {
diff --git a/src/styles/item.css b/src/styles/item.css
index 80ffe02..49644ff 100644
--- a/src/styles/item.css
+++ b/src/styles/item.css
@@ -244,6 +244,73 @@
background: rgba(255, 255, 255, 0.25);
}
+/* ------------------------------------------------------------------ */
+/* Preview expand / contract button states */
+/* ------------------------------------------------------------------ */
+
+/* Card is actively being previewed — dim body so flyout takes focus */
+.item-main.previewing .body {
+ opacity: 0.45;
+ filter: blur(2px);
+ transition: opacity 0.3s ease, filter 0.3s ease;
+}
+
+/* In preview mode: center the pill horizontally over the card and enlarge everything */
+.item-main.previewing .actions {
+ right: 50%;
+ transform: translateY(-50%) translateX(50%);
+ padding: 6px;
+ gap: 6px;
+}
+
+/* All buttons in the pill get bigger when previewing */
+.item-main.previewing .act {
+ width: 38px;
+ height: 38px;
+}
+
+/* Icons inside also scale up to match the larger buttons */
+.item-main.previewing .act svg {
+ width: 20px;
+ height: 20px;
+}
+
+/* Hide the delete button while preview is active — prevents accidental deletion
+ when the pill repositions and the cursor lands on the trash icon.
+ User can close preview first if they want to delete. */
+.item-main.previewing .act.danger {
+ display: none;
+}
+
+/* Brief pointer-events freeze on the pill right after preview opens,
+ so a rapid second click on the repositioned pill doesn't misfire. */
+.item-main.previewing .actions {
+ animation: preview-pill-appear 0.35s ease forwards;
+}
+
+@keyframes preview-pill-appear {
+ 0%, 80% { pointer-events: none; }
+ 100% { pointer-events: auto; }
+}
+
+/* Contract (close preview) button — accented with a pulsing glow ring */
+.act.preview-contract {
+ color: #fff;
+ background: rgba(255, 255, 255, 0.12);
+ box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22);
+ animation: preview-pulse 2s ease-in-out infinite;
+}
+.act.preview-contract:hover {
+ background: rgba(255, 255, 255, 0.22);
+ box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
+ animation: none;
+}
+
+@keyframes preview-pulse {
+ 0%, 100% { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22); }
+ 50% { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1), 0 0 14px rgba(255, 255, 255, 0.08); }
+}
+
/* ------------------------------------------------------------------ */
/* Bundle-specific styles */
/* ------------------------------------------------------------------ */