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(cards): folder opening on hover, textured cards, reliable hover, new open-stack view

Deepender25bdd21982eaa7
diff --git a/electron/main/ipc.ts b/electron/main/ipc.ts
index 6091432..ebdfd3b 100644
--- a/electron/main/ipc.ts
+++ b/electron/main/ipc.ts
@@ -7,13 +7,14 @@
*/
import { app, ipcMain, clipboard, nativeImage, shell, net } from 'electron'
import { existsSync } from 'node:fs'
-import { basename } from 'node:path'
+import { readFile } from 'node:fs/promises'
+import { basename, join } from 'node:path'
import { execFile } from 'node:child_process'
import { psHost, getSystemPowerShellPath, getWritableCwd } from './powershell'
import { filterValidPaths, isExistingFilePath } from './pathValidation'
import { type InvokeMap, type InvokeChannel, type SendMap, type SendChannel } from '../../shared/ipc'
import { getStore, loadSettings, saveSettings, pushState, addFiles, getWatcher } from './state'
-import { sendToMainWindow, setInteractive, setHeartbeatPaused, setHotZoneWidth, repositionWindow, getDisplayListOptions, popUpAndRetract, setWindowFocusable, captureExternalForeground, traceFg, resolvePasteTarget } from './window'
+import { resyncHover, sendToMainWindow, setInteractive, setHeartbeatPaused, setHotZoneWidth, repositionWindow, getDisplayListOptions, popUpAndRetract, setWindowFocusable, captureExternalForeground, traceFg, resolvePasteTarget } from './window'
import { registerGlobalHotkey } from './index'
import { getOnboardingWindow } from './onboardingWindow'
import { rebuildTrayMenu } from './tray'
@@ -26,7 +27,7 @@ import { isStoreBuild } from './config'
import { applyLaunchAtLogin, refreshLaunchAtLoginFromOs } from './loginItems'
import { toUnpackagedFilePath, toUnpackagedFilePaths } from '../store/paths'
import { isPasteableEmoji } from '../../shared/emoji'
-import { emojiAssetDir, readEmojiBatch } from './imageProtocol'
+import { emojiAssetDir, readEmojiBatch, resolveIconAsset } from './imageProtocol'
import { saveItemImages } from './saveImages'
export { isStoreBuild }
@@ -590,6 +591,17 @@ export function registerIpc(): void {
)
)
+ handle('icon:svg', async (kind) => {
+ if (typeof kind !== 'string') return null
+ const filePath = resolveIconAsset(join(app.getAppPath(), 'resources', 'file-icons'), `${kind}.svg`)
+ if (!filePath) return null
+ try {
+ return await readFile(filePath, 'utf8')
+ } catch {
+ return null
+ }
+ })
+
handle('emoji:paste', async (text) => {
if (!isPasteableEmoji(text)) return false
const now = Date.now()
@@ -852,6 +864,10 @@ function on<C extends SendChannel>(
}
export function registerSendListeners(): void {
+ on('window:resync-hover', () => {
+ resyncHover()
+ })
+
on('item:start-drag', (sender, req) => {
console.log('[IPC] item:start-drag req=', JSON.stringify(req))
const resolved = resolveDragData(req)
diff --git a/electron/main/window.ts b/electron/main/window.ts
index aa4755a..31a14ee 100644
--- a/electron/main/window.ts
+++ b/electron/main/window.ts
@@ -178,6 +178,24 @@ export function isInteractive(): boolean {
return interactive
}
+/**
+ * Re-check what the pointer is over after the cards moved under it.
+ * Chromium updates :hover (the card's action buttons) only on a mouse move,
+ * so a new item, a paste-to-top or a delete under a still pointer left the
+ * buttons on the card that moved away until the user wiggled the mouse.
+ * One real mouse-move at the cursor's current spot re-runs hit testing.
+ * Only while the shelf is open and the cursor is over this window.
+ */
+export function resyncHover(): void {
+ if (!mainWindow || mainWindow.isDestroyed() || !interactive) return
+ const pt = screen.getCursorScreenPoint()
+ const b = mainWindow.getContentBounds()
+ const x = pt.x - b.x
+ const y = pt.y - b.y
+ if (x < 0 || y < 0 || x >= b.width || y >= b.height) return
+ mainWindow.webContents.sendInputEvent({ type: 'mouseMove', x, y })
+}
+
/**
* Foreground memory for shelf search + paste.
*
diff --git a/electron/preload/index.ts b/electron/preload/index.ts
index bab9de7..7812c71 100644
--- a/electron/preload/index.ts
+++ b/electron/preload/index.ts
@@ -192,6 +192,7 @@ const api = {
pasteSubitem: (req: import('../../shared/types').DragRequest) => invoke('item:paste-subitem', req),
pasteEmoji: (text: string) => invoke('emoji:paste', text),
emojiGlyphs: (files: string[]) => invoke('emoji:glyphs', files),
+ iconSvg: (kind: string) => invoke('icon:svg', kind),
installUpdate: () => invoke('app:install-update'),
checkForUpdatesManual: () => invoke('updater:check-manual'),
startUpdateDownload: () => invoke('updater:start-download'),
@@ -219,6 +220,7 @@ const api = {
focusWindow: (focusable?: boolean) => invoke('window:focus', focusable),
setInternalDrag: (active: boolean) => { setInternalDragState(active) },
broadcastTutorialStep: (step: number) => send('tutorial:set-step', step),
+ resyncHover: () => send('window:resync-hover'),
/* Main -> Renderer */
onItems: (cb: (items: EventArgs<'state:items'>[0]) => void) => on('state:items', cb),
diff --git a/shared/bridge.ts b/shared/bridge.ts
index 99d9e51..b53c4c7 100644
--- a/shared/bridge.ts
+++ b/shared/bridge.ts
@@ -37,6 +37,8 @@ export interface EdgeApi {
pasteSubitem: (req: DragRequest) => Promise<boolean>
pasteEmoji: (text: string) => Promise<boolean>
emojiGlyphs: (files: string[]) => Promise<Record<string, string>>
+ /** A file-kind folder icon's SVG source, or null (see ipc 'icon:svg'). */
+ iconSvg: (kind: string) => Promise<string | null>
installUpdate: () => Promise<void>
checkForUpdatesManual: () => Promise<{ status: string; version?: string; error?: string }>
startUpdateDownload: () => Promise<void>
@@ -64,6 +66,8 @@ export interface EdgeApi {
updateSettings: (patch: Partial<Settings>) => Promise<Settings>
refreshLaunchAtLogin: () => Promise<Settings>
setInteractive: (value: boolean) => Promise<void>
+ /** Re-check what the pointer is over after the cards moved under it (ipc 'window:resync-hover'). */
+ resyncHover: () => void
setPreviewMode: (active: boolean) => Promise<void>
pauseHotkey: (paused: boolean) => Promise<void>
revealFile: (path: string) => Promise<boolean>
diff --git a/shared/fileIconLayers.ts b/shared/fileIconLayers.ts
new file mode 100644
index 0000000..45a4b2e
--- /dev/null
+++ b/shared/fileIconLayers.ts
@@ -0,0 +1,82 @@
+/**
+ * Split a file-kind folder icon (resources/file-icons/<kind>.svg) into the
+ * layers its hover "opening" moves: the back panel, the three papers and the
+ * front glass pocket. Each layer is a standalone SVG with the icon's full
+ * <defs>, so its gradients and filters render exactly as in the whole icon,
+ * and stacking the five in order draws the original icon (measured: mean
+ * difference 0.013 of 255 at 136px).
+ *
+ * The art keeps its own structure (all 13 icons share it):
+ * <svg><defs>…</defs>
+ * <g transform="translate(0 14)">
+ * shadows, panel, panel light -> back
+ * <g id="<kind>-contents"> 3 papers </g> -> paper1 (back right),
+ * paper2 (middle), paper3 (front left)
+ * <g mask="url(#<kind>-mask)"> … </g> -> front (frosts the papers through
+ * <use>, so they stay in its <defs>)
+ * </g>
+ * </svg>
+ * Returns null when a file does not have that shape; the icon then simply
+ * does not open.
+ */
+
+export const ICON_LAYER_PARTS = ['back', 'paper1', 'paper2', 'paper3', 'front'] as const
+export type IconLayerPart = (typeof ICON_LAYER_PARTS)[number]
+
+const OUTER_OPEN = '<g transform="translate(0 14)">'
+
+/** The direct child <g>…</g> elements of a fragment, in order. */
+function childGroups(fragment: string): string[] {
+ const out: string[] = []
+ const tag = /<(\/?)g\b[^>]*?(\/?)>/g
+ let depth = 0
+ let start = -1
+ for (let m = tag.exec(fragment); m; m = tag.exec(fragment)) {
+ const closing = m[1] === '/'
+ const selfClosing = m[2] === '/'
+ if (selfClosing) continue
+ if (!closing) {
+ if (depth === 0) start = m.index
+ depth++
+ } else {
+ depth--
+ if (depth === 0 && start >= 0) {
+ out.push(fragment.slice(start, m.index + m[0].length))
+ start = -1
+ }
+ if (depth < 0) return []
+ }
+ }
+ return depth === 0 ? out : []
+}
+
+/** All five layers of an icon, in drawing order, or null. */
+export function fileIconLayers(svg: string): Record<IconLayerPart, string> | null {
+ const defsEnd = svg.indexOf('</defs>')
+ if (defsEnd < 0) return null
+ const head = svg.slice(0, defsEnd + '</defs>'.length)
+ const outerAt = svg.indexOf(OUTER_OPEN, defsEnd)
+ const contentsMatch = /<g id="[a-z]+-contents">/.exec(svg)
+ const maskMatch = /<g mask="url\(#[a-z]+-mask\)">/.exec(svg)
+ const outerClose = svg.lastIndexOf('</g>')
+ if (outerAt < 0 || !contentsMatch || !maskMatch || outerClose < 0) return null
+ const contentsAt = contentsMatch.index
+ const maskAt = maskMatch.index
+ if (!(outerAt < contentsAt && contentsAt < maskAt && maskAt < outerClose)) return null
+
+ const contents = svg.slice(contentsAt, maskAt).trim()
+ if (childGroups(contents).length !== 1) return null
+ const papers = childGroups(contents.slice(contentsMatch[0].length, contents.length - '</g>'.length))
+ if (papers.length !== 3) return null
+
+ const wrap = (body: string): string => `${head}\n ${OUTER_OPEN}\n ${body.trim()}\n </g>\n</svg>\n`
+ return {
+ back: wrap(svg.slice(outerAt + OUTER_OPEN.length, contentsAt)),
+ paper1: wrap(papers[0]),
+ paper2: wrap(papers[1]),
+ paper3: wrap(papers[2]),
+ // the pocket frosts the papers through <use href="#…-contents">: keep them
+ // defined, not drawn
+ front: wrap(`<defs>${contents}</defs>${svg.slice(maskAt, outerClose)}`)
+ }
+}
diff --git a/shared/ipc.ts b/shared/ipc.ts
index 03536c8..9f7198b 100644
--- a/shared/ipc.ts
+++ b/shared/ipc.ts
@@ -82,6 +82,13 @@ export interface InvokeMap {
*/
'emoji:glyphs': { args: [files: string[]]; result: Record<string, string> }
+ /**
+ * A file-kind folder icon's SVG source (resources/file-icons/<kind>.svg),
+ * for the window to cut into the layers its hover "opening" moves. Only the
+ * 13 icon names are served; anything else is null.
+ */
+ 'icon:svg': { args: [kind: string]; result: string | null }
+
/** Add local file paths dragged into the shelf. */
'item:add-files': { args: [paths: string[]]; result: ClipboardItemDto[] }
@@ -209,6 +216,12 @@ export interface SendMap {
'item:prestage-drag': { args: [req: DragRequest] }
/** Synchronize tutorial step */
'tutorial:set-step': { args: [step: number] }
+ /**
+ * The cards moved under a still pointer (new item, paste to top, delete,
+ * expand…): re-check what it is over. Chromium only updates :hover on a
+ * mouse move, so main sends one at the cursor's current spot.
+ */
+ 'window:resync-hover': { args: [] }
}
/* ------------------------------------------------------------------ */
diff --git a/src/App.tsx b/src/App.tsx
index 056a798..13a354c 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -14,6 +14,7 @@ import { useStore } from './store/appStore'
import { edge } from './lib/edge'
import { applyReduceMotion } from './lib/theme'
import { useEdgeHover } from './hooks/useEdgeHover'
+import { useHoverResync } from './hooks/useHoverResync'
export default function App() {
const hydrate = useStore((s) => s.hydrate)
@@ -28,6 +29,7 @@ export default function App() {
// Drive the edge open/close behavior.
useEdgeHover()
+ useHoverResync(typeof document !== 'undefined' ? document.body : null)
// Cold-start warmup (no visual / feature change).
// The first shelf open and first emoji open jank because one-time init
diff --git a/src/assets/grain.png b/src/assets/grain.png
new file mode 100644
index 0000000..4dd5a0c
Binary files /dev/null and b/src/assets/grain.png differ
diff --git a/src/components/ClipboardItem.tsx b/src/components/ClipboardItem.tsx
index dec02a5..fcc3c20 100644
--- a/src/components/ClipboardItem.tsx
+++ b/src/components/ClipboardItem.tsx
@@ -28,6 +28,7 @@ import { playButtonClickSound, playToggleSound, playDeleteSound, playCardExpandS
import { CopyIcon, FileKindIcon, FileStackPhoto, PinIcon, PinFillIcon, TrashIcon, MinusIcon, ChevronUpIcon, ChevronLeftIcon, ExpandIcon, ContractIcon, ExternalLinkIcon } from './icons'
import { LinkPreviewCard } from './LinkPreviewCard'
import { CodeBlock } from './CodeBlock'
+import { StackHeader, StackItems, fileStackEntries, imageCollectionEntries, stackOpenWidth } from './StackItems'
import { detectCode } from '../lib/codeDetect'
import '../styles/item.css'
import { tryPaste } from '../lib/tryPaste'
@@ -107,7 +108,7 @@ const ClipboardItemBase = forwardRef<HTMLDivElement, Props>(({ item }, ref) => {
const expandedWidth = expanded && isHorizontal
? (isImageFolderCard || isFileCard
- ? Math.max(210, 16 + bundleCount * 132)
+ ? stackOpenWidth(bundleCount, isImageStack)
: Math.max(300, 48 + bundleCount * 124))
: undefined
@@ -1217,166 +1218,6 @@ function getImageEntries(item: ClipboardItemDto): ImageCardEntry[] {
return []
}
-/* ------------------------------------------------------------------ */
-/* Mini Image Folder Card (For Expanded Collections / Stacks) */
-/* ------------------------------------------------------------------ */
-
-function MiniImageFolderCard({
- item,
- img,
- onDragStart
-}: {
- item: ClipboardItemDto
- img: ImageCardEntry
- isHorizontal?: boolean
- onDragStart?: (e: React.DragEvent, req: DragRequest) => void
-}) {
- const { t } = useTranslation()
- const [copied, setCopied] = useState(false)
- const isImgCol = item.data.kind === 'image-collection'
- const subReq = isImgCol ? { id: item.id, imageId: img.id } : { id: item.id, paths: [img.id] }
- const dims = img.width && img.height ? `${img.width}×${img.height}` : ''
- const size = img.bytes ? formatBytes(img.bytes) : ''
- const displayName = img.name && img.name !== 'clipboard' && !img.name.startsWith('image-') ? img.name : dims || 'image'
-
- const handleCopy = (e: React.MouseEvent<HTMLButtonElement>) => {
- e.stopPropagation()
- e.currentTarget.blur()
- playButtonClickSound()
- if (isImgCol) {
- useStore.getState().copySubitem({ id: item.id, imageId: img.id })
- } else {
- useStore.getState().copySubitem({ id: item.id, paths: [img.id] })
- }
- setCopied(true)
- setTimeout(() => setCopied(false), 900)
- }
-
- const handleUngroup = (e: React.MouseEvent<HTMLButtonElement>) => {
- e.stopPropagation()
- e.currentTarget.blur()
- playDeleteSound()
- if (isImgCol) {
- window.edge.splitItem({ id: item.id, imageId: img.id, splitPlacement: 'after' })
- } else {
- window.edge.splitItem({ id: item.id, paths: [img.id], splitPlacement: 'after' })
- }
- }
-
- const handlePaste = (e: React.MouseEvent) => {
- e.stopPropagation()
- tryPaste(() => {
- if (isImgCol) {
- window.edge.pasteSubitem({ id: item.id, imageId: img.id })
- } else {
- window.edge.pasteSubitem({ id: item.id, paths: [img.id] })
- }
- })
- }
-
- return (
- <motion.div
- className="mini-image-folder-card"
- variants={rowVariants}
- draggable
- onMouseEnter={() => window.edge.prestageDrag(subReq)}
- onPointerDown={() => window.edge.prestageDrag(subReq)}
- onDragStartCapture={(e: any) => {
- e.stopPropagation()
- onDragStart?.(e, subReq)
- }}
- onClick={handlePaste}
- >
- {copied && (
- <motion.div
- key="copy-ripple"
- initial={{ opacity: 0.75, scale: 0.2 }}
- animate={{ opacity: 0, scale: 1.6 }}
- transition={{ duration: 0.45, ease: [0.16, 1, 0.3, 1] }}
- style={{
- position: 'absolute',
- inset: 0,
- borderRadius: 12,
- background: 'radial-gradient(circle at center, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.08) 45%, transparent 75%)',
- pointerEvents: 'none',
- zIndex: 15
- }}
- />
- )}
- <div className="mini-image-folder-card-inner">
- {/* Blue Gradient Viewport */}
- <div className="mini-image-folder-viewport">
- <img
- className="mini-image-folder-thumb"
- src={img.src}
- onError={(e) => {
- if (img.fallbackSrc && e.currentTarget.src !== img.fallbackSrc) {
- e.currentTarget.src = img.fallbackSrc
- }
- }}
- alt=""
- loading="lazy"
- decoding="async"
- draggable={false}
- />
- </div>
-
- {/* Solid Black Curved Flap */}
- <div className="mini-image-folder-flap-wrap">
- <svg
- className="mini-image-folder-flap-svg"
- viewBox="0 0 240 74"
- preserveAspectRatio="none"
- >
- <path
- d="M 0,74 L 0,6 Q 0,0 6,0 L 64,0 C 74,0 80,6 85,12 C 90,18 96,24 106,24 L 234,24 Q 240,24 240,30 L 240,74 Z"
- />
- </svg>
-
- <div className="mini-image-folder-flap-content">
- <div className="mini-image-folder-flap-header">
- <span className="kind-badge file-elevated-badge" style={{ color: '#06B6D4' }}>
- {t('filters.images').toLowerCase().slice(0, -1) || t('filters.images').toLowerCase()}
- </span>
- </div>
- <div className="mini-image-folder-flap-footer">
- <div className="mini-image-folder-meta">
- {displayName && (
- <span className="mini-image-folder-source-name" title={displayName}>
- {displayName}
- </span>
- )}
- {copied && <span className="meta-copied">{(displayName ? ' · ' : '') + t('item.copied')}</span>}
- </div>
- {size && <span className="mini-image-folder-size">{size}</span>}
- </div>
- </div>
- </div>
-
- {/* Hover Action Buttons (Copy, Ungroup) */}
- <div className="mini-image-folder-actions" onPointerDown={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}>
- <button
- className="act"
- title={isImgCol ? t('item.copy') : t('item.copyFilePath')}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={handleCopy}
- >
- <CopyIcon width={11} height={11} />
- </button>
- <button
- className="act danger"
- title={t('item.ungroup')}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={handleUngroup}
- >
- <MinusIcon width={11} height={11} />
- </button>
- </div>
- </div>
- </motion.div>
- )
-}
-
function ImageFolderCard({
item,
copied = false,
@@ -1397,7 +1238,6 @@ function ImageFolderCard({
onCollapse?: (e?: React.MouseEvent) => void
}) {
const { t } = useTranslation()
- const isPreviewing = useStore((s) => s.previewItemId) === item.id
const images = getImageEntries(item)
const count = images.length
@@ -1427,7 +1267,7 @@ function ImageFolderCard({
return (
<div className={`image-folder-card-inner${expanded && isStack ? ' is-expanded-folder' : ''}`}>
- <div className={`image-folder-viewport${expanded && isStack ? ' is-expanded-viewport' : ''}`}>
+ <div className={`image-folder-viewport is-textured${expanded && isStack ? ' is-expanded-viewport' : ''}`}>
{!isStack ? (
displayImages[0].src ? (
<img
@@ -1476,117 +1316,16 @@ function ImageFolderCard({
}
panel={
<div className="image-folder-expanded-content">
- {/* Top Header inside Expanded Blue Viewport */}
- <div
- className="image-folder-expanded-top-bar"
- title={t('item.collapsePinned')}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={(e) => {
- e.stopPropagation()
- onCollapse?.(e)
- }}
- >
- <button
- type="button"
- className="image-folder-collapse-btn"
- title={t('item.collapsePinned')}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={(e) => {
- e.stopPropagation()
- e.currentTarget.blur()
- onCollapse?.(e)
- }}
- >
- {isHorizontal ? <ChevronLeftIcon width={13} height={13} /> : <ChevronUpIcon width={13} height={13} />}
- </button>
- <span className="image-folder-expanded-title">
- {count} {t('filters.images').toLowerCase()}
- </span>
- <div className="actions-pill" onPointerDown={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}>
- <button
- className={`act${item.pinned ? ' active' : ''}`}
- title={item.pinned ? t('item.unpin') : t('item.pin')}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={(e) => {
- e.stopPropagation()
- e.currentTarget.blur()
- playToggleSound(!item.pinned)
- useStore.getState().togglePin(item.id, !item.pinned)
- }}
- >
- {item.pinned ? <PinFillIcon width={12} height={12} /> : <PinIcon width={12} height={12} />}
- </button>
- <button
- className={`act${isPreviewing ? ' preview-contract active' : ' preview-expand'}`}
- title={isPreviewing ? t('header.close') : t('item.expand')}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={(e) => {
- e.stopPropagation()
- e.preventDefault()
- e.currentTarget.blur()
- playCardExpandSound(!isPreviewing)
- const rect = e.currentTarget.closest('.item-main, .item')?.getBoundingClientRect()
- const rectData = rect ? { x: rect.x, y: rect.y, width: rect.width, height: rect.height } : undefined
- useStore.getState().setPreviewItemId(isPreviewing ? null : item.id, rectData)
- }}
- >
- {isPreviewing ? <ContractIcon width={12} height={12} /> : <ExpandIcon width={12} height={12} />}
- </button>
- <button
- className="act"
- title={t('item.copy')}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={(e) => {
- e.stopPropagation()
- e.currentTarget.blur()
- onCopy?.(e)
- }}
- >
- <CopyIcon width={12} height={12} />
- </button>
- <button
- className="act danger"
- title={t('item.delete')}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={(e) => {
- e.stopPropagation()
- e.currentTarget.blur()
- playDeleteSound()
- onRemove?.()
- }}
- >
- <TrashIcon width={12} height={12} />
- </button>
- </div>
- </div>
-
- {/* List / Track of Mini Image Folder Cards */}
- {isHorizontal ? (
- <div className="image-stack-expanded-track" onClick={(e) => e.stopPropagation()}>
- {images.map((img) => (
- <MiniImageFolderCard
- key={img.id}
- item={item}
- img={img}
- isHorizontal={isHorizontal}
- onDragStart={onDragStart}
- />
- ))}
- </div>
- ) : (
- <div className="image-stack-expanded-list" onClick={(e) => e.stopPropagation()}>
- {images.map((img) => (
- <MiniImageFolderCard
- key={img.id}
- item={item}
- img={img}
- isHorizontal={isHorizontal}
- onDragStart={onDragStart}
- />
- ))}
- </div>
- )}
- </div>
+ <StackHeader
+ item={item}
+ title={`${count} ${t('filters.images').toLowerCase()}`}
+ isHorizontal={isHorizontal}
+ onCollapse={onCollapse}
+ onCopy={onCopy}
+ onRemove={onRemove}
+ />
+ <StackItems entries={item.data.kind === 'image-collection' ? imageCollectionEntries(item, t) : fileStackEntries(item, t)} isHorizontal={isHorizontal} onDragStart={onDragStart} />
+ </div>
}
/>
)}
@@ -1643,10 +1382,6 @@ function ImageFolderCard({
)
}
-/* ------------------------------------------------------------------ */
-/* Mini File Folder Card (For Expanded File Stacks) */
-/* ------------------------------------------------------------------ */
-
/* ------------------------------------------------------------------ */
/* Stack expand/collapse swap */
/* ------------------------------------------------------------------ */
@@ -1692,168 +1427,6 @@ function StackExpandSwap({
)
}
-function MiniFileFolderCard({
- item,
- filePath,
- subEntry,
- isHorizontal,
- onDragStart
-}: {
- item: ClipboardItemDto
- filePath: string
- subEntry?: any
- isHorizontal?: boolean
- onDragStart?: (e: React.DragEvent, req: DragRequest) => void
-}) {
- const { t } = useTranslation()
- const [copied, setCopied] = useState(false)
- const subReq = { id: item.id, paths: [filePath] }
- const name = formatImageDisplayName(subEntry?.name ?? filePath, item.capturedAt) || basename(filePath)
- const subInfo = getFileKind(filePath, subEntry?.isDirectory)
- const isImage = !subEntry?.isDirectory && (subEntry?.isImage || subInfo.kind === 'image')
- const imgSrc = subEntry?.preview || `edgelocal://file/${encodeURIComponent(filePath.replace(/\\/g, '/'))}`
- const dims = subEntry?.width && subEntry?.height ? `${subEntry.width}×${subEntry.height}` : ''
- const size = !subEntry?.isDirectory && subEntry?.size ? formatBytes(subEntry.size) : ''
- const displayFooterName = isImage ? (name && name !== 'clipboard' && !name.startsWith('image-') ? name : dims || 'image') : name
-
- const handleCopy = (e: React.MouseEvent<HTMLButtonElement>) => {
- e.stopPropagation()
- e.currentTarget.blur()
- playButtonClickSound()
- useStore.getState().copySubitem(subReq)
- setCopied(true)
- setTimeout(() => setCopied(false), 900)
- }
-
- const handleUngroup = (e: React.MouseEvent<HTMLButtonElement>) => {
- e.stopPropagation()
- e.currentTarget.blur()
- playDeleteSound()
- window.edge.splitItem({ id: item.id, paths: [filePath], splitPlacement: 'after' })
- }
-
- const handlePaste = (e: React.MouseEvent) => {
- e.stopPropagation()
- tryPaste(() => {
- window.edge.pasteSubitem(subReq)
- })
- }
-
- return (
- <motion.div
- className="mini-image-folder-card"
- variants={rowVariants}
- draggable
- onMouseEnter={() => window.edge.prestageDrag(subReq)}
- onPointerDown={() => window.edge.prestageDrag(subReq)}
- onDragStartCapture={(e: any) => {
- e.stopPropagation()
- onDragStart?.(e, subReq)
- }}
- onClick={handlePaste}
- >
- {copied && (
- <motion.div
- key="copy-ripple"
- initial={{ opacity: 0.75, scale: 0.2 }}
- animate={{ opacity: 0, scale: 1.6 }}
- transition={{ duration: 0.45, ease: [0.16, 1, 0.3, 1] }}
- style={{
- position: 'absolute',
- inset: 0,
- borderRadius: 12,
- background: 'radial-gradient(circle at center, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.08) 45%, transparent 75%)',
- pointerEvents: 'none',
- zIndex: 15
- }}
- />
- )}
- <div className="mini-image-folder-card-inner">
- {/* Blue Gradient Viewport */}
- <div className="mini-image-folder-viewport">
- {isImage ? (
- <img
- className="mini-image-folder-thumb"
- src={imgSrc}
- onError={(e) => {
- const fallback = `edgelocal://file/${encodeURIComponent(filePath.replace(/\\/g, '/'))}`
- if (e.currentTarget.src !== fallback) {
- e.currentTarget.src = fallback
- }
- }}
- alt=""
- loading="lazy"
- decoding="async"
- draggable={false}
- />
- ) : (
- <div className="single-file-hero" style={{ color: subInfo.color, width: '100%', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
- <FileKindIcon
- path={filePath}
- isDirectory={subEntry?.isDirectory}
- width={isHorizontal ? 58 : 128}
- height={isHorizontal ? 58 : 128}
- />
- </div>
- )}
- </div>
-
- {/* Solid Black Curved Flap */}
- <div className="mini-image-folder-flap-wrap">
- <svg
- className="mini-image-folder-flap-svg"
- viewBox="0 0 240 74"
- preserveAspectRatio="none"
- >
- <path
- d="M 0,74 L 0,6 Q 0,0 6,0 L 64,0 C 74,0 80,6 85,12 C 90,18 96,24 106,24 L 234,24 Q 240,24 240,30 L 240,74 Z"
- />
- </svg>
-
- <div className="mini-image-folder-flap-content">
- <div className="mini-image-folder-flap-header">
- <span className="kind-badge file-elevated-badge" style={{ color: isImage ? '#06B6D4' : subInfo.color }}>
- {isImage ? (t('filters.images').toLowerCase().slice(0, -1) || 'image') : subInfo.label.toLowerCase()}
- </span>
- </div>
- <div className="mini-image-folder-flap-footer">
- <div className="mini-image-folder-meta">
- {displayFooterName && (
- <span className="mini-image-folder-source-name" title={displayFooterName}>
- {displayFooterName}
- </span>
- )}
- {copied && <span className="meta-copied">{(displayFooterName ? ' · ' : '') + t('item.copied')}</span>}
- </div>
- {size && <span className="mini-image-folder-size">{size}</span>}
- </div>
- </div>
- </div>
-
- {/* Hover Action Buttons (Copy, Ungroup) */}
- <div className="mini-image-folder-actions" onPointerDown={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}>
- <button
- className="act"
- title={t('item.copyFilePath')}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={handleCopy}
- >
- <CopyIcon width={11} height={11} />
- </button>
- <button
- className="act danger"
- title={t('item.ungroup')}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={handleUngroup}
- >
- <MinusIcon width={11} height={11} />
- </button>
- </div>
- </div>
- </motion.div>
- )
-}
-
/* ------------------------------------------------------------------ */
/* File Folder Card (Framed File / Folder / Stack in Blue Folder Card) */
/* ------------------------------------------------------------------ */
@@ -1878,7 +1451,6 @@ function FileFolderCard({
onCollapse?: (e?: React.MouseEvent) => void
}) {
const { t } = useTranslation()
- const isPreviewing = useStore((s) => s.previewItemId) === item.id
if (item.data.kind !== 'files') return null
const paths = item.data.paths
@@ -1895,7 +1467,7 @@ function FileFolderCard({
return (
<div className={`image-folder-card-inner${expanded && isStack ? ' is-expanded-folder' : ''}`}>
- <div className={`image-folder-viewport${expanded && isStack ? ' is-expanded-viewport' : ''}`}>
+ <div className={`image-folder-viewport is-textured${expanded && isStack ? ' is-expanded-viewport' : ''}`}>
{!isStack ? (
(!entry?.isDirectory && (entry?.isImage || info.kind === 'image')) ? (
<img
@@ -1914,7 +1486,7 @@ function FileFolderCard({
/>
) : (
<div className="single-file-hero" style={{ color: info.color }}>
- <FileKindIcon path={first} isDirectory={entry?.isDirectory} width={isHorizontal ? 100 : 136} height={isHorizontal ? 100 : 136} />
+ <FileKindIcon path={first} isDirectory={entry?.isDirectory} width={isHorizontal ? 94 : 136} height={isHorizontal ? 94 : 136} layered />
</div>
)
) : (
@@ -1930,7 +1502,7 @@ function FileFolderCard({
const isImg = !fileEntry?.isDirectory && (fileEntry?.isImage || fileInfo.kind === 'image')
// Front folder art is ~65% of the icon tall; sized so the cascade
// fits the viewport above the label flap in each dock.
- const iconSize = isHorizontal ? 100 : 148
+ const iconSize = isHorizontal ? 94 : 148
const imgSrc = fileEntry?.preview || `edgelocal://file/${encodeURIComponent(filePath.replace(/\\/g, '/'))}`
return (
<div
@@ -1953,7 +1525,7 @@ function FileFolderCard({
draggable={false}
/>
) : (
- <FileKindIcon path={filePath} isDirectory={fileEntry?.isDirectory} width={iconSize} height={iconSize} />
+ <FileKindIcon path={filePath} isDirectory={fileEntry?.isDirectory} width={iconSize} height={iconSize} layered={idx === 0} />
)}
</div>
)
@@ -1962,119 +1534,16 @@ function FileFolderCard({
}
panel={
<div className="image-folder-expanded-content">
- {/* Top Header inside Expanded Blue Viewport */}
- <div
- className="image-folder-expanded-top-bar"
- title={t('item.collapsePinned')}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={(e) => {
- e.stopPropagation()
- onCollapse?.(e)
- }}
- >
- <button
- type="button"
- className="image-folder-collapse-btn"
- title={t('item.collapsePinned')}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={(e) => {
- e.stopPropagation()
- e.currentTarget.blur()
- onCollapse?.(e)
- }}
- >
- {isHorizontal ? <ChevronLeftIcon width={13} height={13} /> : <ChevronUpIcon width={13} height={13} />}
- </button>
- <span className="image-folder-expanded-title">
- {count} {t('filters.files').toLowerCase()}
- </span>
- <div className="actions-pill" onPointerDown={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}>
- <button
- className={`act${item.pinned ? ' active' : ''}`}
- title={item.pinned ? t('item.unpin') : t('item.pin')}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={(e) => {
- e.stopPropagation()
- e.currentTarget.blur()
- playToggleSound(!item.pinned)
- useStore.getState().togglePin(item.id, !item.pinned)
- }}
- >
- {item.pinned ? <PinFillIcon width={12} height={12} /> : <PinIcon width={12} height={12} />}
- </button>
- <button
- className={`act${isPreviewing ? ' preview-contract active' : ' preview-expand'}`}
- title={isPreviewing ? t('header.close') : t('item.expand')}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={(e) => {
- e.stopPropagation()
- e.preventDefault()
- e.currentTarget.blur()
- playCardExpandSound(!isPreviewing)
- const rect = e.currentTarget.closest('.item-main, .item')?.getBoundingClientRect()
- const rectData = rect ? { x: rect.x, y: rect.y, width: rect.width, height: rect.height } : undefined
- useStore.getState().setPreviewItemId(isPreviewing ? null : item.id, rectData)
- }}
- >
- {isPreviewing ? <ContractIcon width={12} height={12} /> : <ExpandIcon width={12} height={12} />}
- </button>
- <button
- className="act"
- title={t('item.copy')}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={(e) => {
- e.stopPropagation()
- e.currentTarget.blur()
- onCopy?.(e)
- }}
- >
- <CopyIcon width={12} height={12} />
- </button>
- <button
- className="act danger"
- title={t('item.delete')}
- onPointerDown={(e) => e.stopPropagation()}
- onClick={(e) => {
- e.stopPropagation()
- e.currentTarget.blur()
- playDeleteSound()
- onRemove?.()
- }}
- >
- <TrashIcon width={12} height={12} />
- </button>
- </div>
- </div>
-
- {/* List / Track of Subitems */}
- {isHorizontal ? (
- <div className="image-stack-expanded-track" onClick={(e) => e.stopPropagation()}>
- {paths.map((filePath, index) => (
- <MiniFileFolderCard
- key={`${item.id}-${filePath}-${index}`}
- item={item}
- filePath={filePath}
- subEntry={entries?.[index]}
- isHorizontal={isHorizontal}
- onDragStart={onDragStart}
- />
- ))}
- </div>
- ) : (
- <div className="image-stack-expanded-list" onClick={(e) => e.stopPropagation()}>
- {paths.map((filePath, index) => (
- <MiniFileFolderCard
- key={`${item.id}-${filePath}-${index}`}
- item={item}
- filePath={filePath}
- subEntry={entries?.[index]}
- isHorizontal={isHorizontal}
- onDragStart={onDragStart}
- />
- ))}
- </div>
- )}
- </div>
+ <StackHeader
+ item={item}
+ title={`${count} ${t('filters.files').toLowerCase()}`}
+ isHorizontal={isHorizontal}
+ onCollapse={onCollapse}
+ onCopy={onCopy}
+ onRemove={onRemove}
+ />
+ <StackItems entries={fileStackEntries(item, t)} isHorizontal={isHorizontal} onDragStart={onDragStart} />
+ </div>
}
/>
)}
diff --git a/src/components/CustomFileIcon.tsx b/src/components/CustomFileIcon.tsx
index 63dd5f9..e963d0b 100644
--- a/src/components/CustomFileIcon.tsx
+++ b/src/components/CustomFileIcon.tsx
@@ -1,5 +1,7 @@
-import { useState, type ImgHTMLAttributes, type SVGProps, type JSX } from 'react'
+import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ImgHTMLAttributes, type SVGProps, type JSX } from 'react'
import { getFileKind, getFileKindByExt, extOf, fileIconUrl, type FileKind } from '../lib/fileType'
+import { useIconLayers } from '../lib/iconLayers'
+import { ICON_LAYER_PARTS } from '../../shared/fileIconLayers'
export interface CustomFileIconProps extends ImgHTMLAttributes<HTMLImageElement> {
ext?: string
@@ -9,6 +11,12 @@ export interface CustomFileIconProps extends ImgHTMLAttributes<HTMLImageElement>
isFolder?: boolean
width?: number | string
height?: number | string
+ /**
+ * Let hovering its card open the folder: the pocket tips forward, the
+ * papers rise and fan out (item.css, .file-kind-opening). At rest it is the
+ * plain icon; the moving layers are pre-rendered bitmaps (lib/iconLayers).
+ */
+ layered?: boolean
}
/** Micro-mode simplified icons for tiny sizes (width <= 16px) */
@@ -109,6 +117,7 @@ export function CustomFileIcon({
kind: explicitKind,
isDirectory,
isFolder,
+ layered = false,
width = 32,
height,
style,
@@ -157,6 +166,10 @@ export function CustomFileIcon({
)
}
+ if (layered) {
+ return <OpeningFileIcon kind={kind} width={width} height={resolvedHeight} className={className} style={style} alt={alt} />
+ }
+
return (
<img
src={fileIconUrl(kind)}
@@ -184,6 +197,76 @@ export function CustomFileIcon({
* SVGs in resources/file-icons) in the same cropped frame, so a photo
* masked with it lines up with the file icons next to it in a stack.
*/
+/**
+ * A folder icon that opens when its card is hovered. At rest it shows the
+ * plain icon; next to it sit the five layer bitmaps (back, three papers,
+ * front pocket) drawn once at this exact size, hidden until hover, when CSS
+ * swaps them in and moves them (see .file-kind-opening in item.css). The
+ * bitmaps are built the first time its card is hovered; until they are ready
+ * the icon simply stays closed.
+ */
+function OpeningFileIcon({
+ kind,
+ width,
+ height,
+ className,
+ style,
+ alt
+}: {
+ kind: FileKind
+ width: number | string
+ height: number | string
+ className?: string
+ style?: CSSProperties
+ alt: string
+}): JSX.Element {
+ const ref = useRef<HTMLSpanElement>(null)
+ // The size it is really shown at (CSS may override the prop, e.g. in the flyout).
+ const [cssSize, setCssSize] = useState<number | null>(null)
+ useLayoutEffect(() => {
+ const w = ref.current?.offsetWidth
+ if (w) setCssSize(w)
+ }, [width, height])
+ // Build on the first hover of the card it sits in (the hover that opens it).
+ const [wanted, setWanted] = useState(false)
+ useEffect(() => {
+ if (wanted) return
+ const card = ref.current?.closest('.item-main, .flyout-subitem')
+ if (!card) return
+ const onEnter = (): void => setWanted(true)
+ card.addEventListener('pointerenter', onEnter, { once: true })
+ return () => card.removeEventListener('pointerenter', onEnter)
+ }, [wanted])
+ const layers = useIconLayers(kind, cssSize, wanted)
+ // Layers that appear while the card is already hovered must first take
+ // their closed style, or they would jump open with no motion: style them,
+ // then arm the opening rules (CSS keys them on .is-armed).
+ const [armed, setArmed] = useState(false)
+ useEffect(() => {
+ if (!layers || armed) return
+ const el = ref.current?.querySelector('.fko-layers')
+ if (el) void getComputedStyle(el).visibility
+ setArmed(true)
+ }, [layers, armed])
+
+ return (
+ <span
+ ref={ref}
+ className={['file-kind-img', 'file-kind-opening', armed ? 'is-armed' : '', className].filter(Boolean).join(' ')}
+ style={{ width, height, flexShrink: 0, ...style }}
+ >
+ <img className="fko-plain" src={fileIconUrl(kind)} alt={alt} draggable={false} />
+ {layers && (
+ <span className="fko-layers" aria-hidden="true">
+ {ICON_LAYER_PARTS.map((part) => (
+ <img key={part} className={`fil fil-${part}`} src={layers[part]} alt="" draggable={false} />
+ ))}
+ </span>
+ )}
+ </span>
+ )
+}
+
const FOLDER_MASK_SHAPES =
"<g transform='translate(0 14)' fill='black'>" +
"<rect x='120' y='118' width='272' height='246' rx='24'/>" +
diff --git a/src/components/PreviewFlyout.tsx b/src/components/PreviewFlyout.tsx
index 3ecbc51..677945e 100644
--- a/src/components/PreviewFlyout.tsx
+++ b/src/components/PreviewFlyout.tsx
@@ -1016,7 +1016,7 @@ function PreviewContent({
<div className="item-content" style={{ padding: '24px 20px 12px 20px' }}>
<div className="single-file-preview">
<div className="single-file-hero" style={{ color: info.color }}>
- <FileKindIcon path={p} width={154} height={154} isDirectory={entry?.isDirectory} />
+ <FileKindIcon path={p} width={154} height={154} isDirectory={entry?.isDirectory} layered />
</div>
<div className="single-file-meta" style={{ marginTop: 8 }}>
<div className="preview single single-file-name" title={fileName} style={{ fontSize: 15, WebkitLineClamp: 3, whiteSpace: 'normal', lineHeight: 1.4 }}>
@@ -1177,7 +1177,7 @@ function PreviewContent({
<div className="item-content">
<div className="single-file-preview">
<div className="single-file-hero" style={{ color: info.color }}>
- <FileKindIcon path={p} width={120} height={120} isDirectory={entry?.isDirectory} />
+ <FileKindIcon path={p} width={120} height={120} isDirectory={entry?.isDirectory} layered />
</div>
<div className="single-file-meta">
<div className="preview single single-file-name" title={fileName}>
diff --git a/src/components/StackItems.tsx b/src/components/StackItems.tsx
new file mode 100644
index 0000000..b1f5771
--- /dev/null
+++ b/src/components/StackItems.tsx
@@ -0,0 +1,339 @@
+/**
+ * The open view of a stack (several files or images in one card).
+ *
+ * Laid out by content instead of repeating a whole mini card per entry:
+ * - only pictures -> a photo grid (2 columns in a side dock, one strip of
+ * larger thumbnails in the top dock);
+ * - files or mixed -> a list: small icon or thumbnail, the full name (up to
+ * 2 lines in a side dock), then "kind · size". In the top
+ * dock rows flow down two lines, then across.
+ * Each entry pastes on click, drags out on its own and shows copy / ungroup on
+ * hover, like the mini cards it replaces. Rows are plain DOM (no texture,
+ * flap or opening icon layers), so a big stack stays cheap to draw.
+ */
+import { memo, useState } from 'react'
+import type { ClipboardItemDto, DragRequest } from '../../shared/types'
+import { useStore } from '../store/appStore'
+import { basename, formatBytes, formatImageDisplayName } from '../lib/format'
+import { extOf, getFileKind } from '../lib/fileType'
+import { playButtonClickSound, playDeleteSound, playToggleSound, playCardExpandSound } from '../lib/soundEffects'
+import { tryPaste } from '../lib/tryPaste'
+import { useTranslation } from '../i18n'
+import { CopyIcon, FileKindIcon, MinusIcon, PinIcon, PinFillIcon, TrashIcon, ChevronUpIcon, ChevronLeftIcon, ExpandIcon, ContractIcon } from './icons'
+import '../styles/stack.css'
+
+/** Same accent the shelf uses for image badges. */
+const IMAGE_COLOR = '#06B6D4'
+
+export interface StackEntry {
+ key: string
+ req: DragRequest
+ name: string
+ kindLabel: string
+ kindColor?: string
+ /** "1920×1080 · 470.7 KB", "2.0 MB", or '' */
+ detail: string
+ thumb?: { src: string; fallbackSrc?: string }
+ icon?: { path: string; isDirectory?: boolean }
+ copyTitle: string
+}
+
+function fileUrl(filePath: string): string {
+ return `edgelocal://file/${encodeURIComponent(filePath.replace(/\\/g, '/'))}`
+}
+
+const join = (...parts: Array<string | false | undefined>): string => parts.filter(Boolean).join(' · ')
+
+/** Entries of a files stack (files, folders and image files, in order). */
+export function fileStackEntries(item: ClipboardItemDto, t: (k: string) => string): StackEntry[] {
+ if (item.data.kind !== 'files') return []
+ const { paths, entries } = item.data
+ const imageWord = t('filters.images').toLowerCase().slice(0, -1) || 'image'
+ return paths.map((p, i) => {
+ const e = entries?.[i]
+ const info = getFileKind(p, e?.isDirectory)
+ const isImage = !e?.isDirectory && (e?.isImage || info.kind === 'image')
+ // the real extension ("csv", "pptx") reads better than the family ("excel", "slides")
+ const ext = e?.isDirectory ? '' : (e?.ext || extOf(basename(p))).toLowerCase()
+ return {
+ key: `${p}-${i}`,
+ req: { id: item.id, paths: [p] },
+ name: formatImageDisplayName(e?.name ?? p, item.capturedAt) || basename(p),
+ kindLabel: ext || (isImage ? imageWord : info.label.toLowerCase()),
+ kindColor: isImage ? IMAGE_COLOR : info.color,
+ detail: !e?.isDirectory && e?.size ? formatBytes(e.size) : '',
+ thumb: isImage ? { src: e?.preview || fileUrl(p), fallbackSrc: fileUrl(p) } : undefined,
+ icon: isImage ? undefined : { path: p, isDirectory: e?.isDirectory },
+ copyTitle: t('item.copyFilePath')
+ }
+ })
+}
+
+/** Entries of a clipboard image collection. */
+export function imageCollectionEntries(item: ClipboardItemDto, t: (k: string) => string): StackEntry[] {
+ if (item.data.kind !== 'image-collection') return []
+ const imageWord = t('filters.images').toLowerCase().slice(0, -1) || 'image'
+ return item.data.images.map((img, i) => {
+ const dims = img.width && img.height ? `${img.width}×${img.height}` : ''
+ return {
+ key: img.imageId || `${item.id}-${i}`,
+ req: { id: item.id, imageId: img.imageId || `${item.id}-${i}` },
+ name: img.fileName || dims || `${imageWord} ${i + 1}`,
+ kindLabel: imageWord,
+ kindColor: IMAGE_COLOR,
+ detail: join(img.fileName ? dims : '', img.bytes ? formatBytes(img.bytes) : ''),
+ thumb: { src: img.preview },
+ copyTitle: t('item.copy')
+ }
+ })
+}
+
+/** Total size of a stack for its header ('' when unknown). */
+export function stackTotalSize(item: ClipboardItemDto): string {
+ let total = 0
+ if (item.data.kind === 'files') for (const e of item.data.entries ?? []) total += e?.isDirectory ? 0 : e?.size || 0
+ else if (item.data.kind === 'image-collection') for (const img of item.data.images) total += img.bytes || 0
+ return total > 0 ? formatBytes(total) : ''
+}
+
+/**
+ * Width of an open stack card in the top dock, matching stack.css: photos sit
+ * in one strip of 128px tiles (inset 4px each side); files fill 232px
+ * columns two rows tall. Gaps are 6px, plus 22px of card and viewport padding.
+ */
+export function stackOpenWidth(count: number, gallery: boolean): number {
+ const cols = gallery ? count : Math.ceil(count / 2)
+ const track = cols * (gallery ? 128 : 232) + Math.max(0, cols - 1) * 6 + (gallery ? 8 : 0)
+ return Math.max(240, track + 22) // room for the header: title, size and actions
+}
+
+const stop = (e: React.SyntheticEvent): void => e.stopPropagation()
+
+export function StackItems({
+ entries,
+ isHorizontal,
+ onDragStart
+}: {
+ entries: StackEntry[]
+ isHorizontal: boolean
+ onDragStart?: (e: React.DragEvent, req: DragRequest) => void
+}) {
+ const gallery = entries.length > 0 && entries.every((e) => e.thumb)
+ return (
+ <div className={`stack-items ${gallery ? 'is-gallery' : 'is-list'}`} data-count={entries.length} onClick={stop}>
+ {entries.map((entry) => (
+ <StackEntryView key={entry.key} entry={entry} tile={gallery} iconSize={isHorizontal ? 30 : 36} onDragStart={onDragStart} />
+ ))}
+ </div>
+ )
+}
+
+const StackEntryView = memo(function StackEntryView({
+ entry,
+ tile,
+ iconSize,
+ onDragStart
+}: {
+ entry: StackEntry
+ tile: boolean
+ iconSize: number
+ onDragStart?: (e: React.DragEvent, req: DragRequest) => void
+}) {
+ const { t } = useTranslation()
+ const [copied, setCopied] = useState(false)
+ const { req } = entry
+
+ const handleCopy = (e: React.MouseEvent<HTMLButtonElement>) => {
+ e.stopPropagation()
+ e.currentTarget.blur()
+ playButtonClickSound()
+ useStore.getState().copySubitem(req)
+ setCopied(true)
+ setTimeout(() => setCopied(false), 900)
+ }
+ const handleUngroup = (e: React.MouseEvent<HTMLButtonElement>) => {
+ e.stopPropagation()
+ e.currentTarget.blur()
+ playDeleteSound()
+ window.edge.splitItem({ ...req, splitPlacement: 'after' })
+ }
+ const handlePaste = (e: React.MouseEvent) => {
+ e.stopPropagation()
+ tryPaste(() => window.edge.pasteSubitem(req))
+ }
+
+ const thumb = entry.thumb && (
+ <img
+ className={tile ? 'stack-tile-img' : 'stack-row-thumb'}
+ src={entry.thumb.src}
+ onError={(e) => {
+ const fb = entry.thumb?.fallbackSrc
+ if (fb && e.currentTarget.src !== fb) e.currentTarget.src = fb
+ }}
+ alt=""
+ loading="lazy"
+ decoding="async"
+ draggable={false}
+ />
+ )
+ const meta = copied ? (
+ <span className="meta-copied">{t('item.copied')}</span>
+ ) : (
+ <>
+ <span className="stack-row-kind" style={{ color: entry.kindColor }}>{entry.kindLabel}</span>
+ {entry.detail && <span className="stack-row-detail">{` · ${entry.detail}`}</span>}
+ </>
+ )
+
+ return (
+ <div
+ className={tile ? 'stack-tile' : 'stack-row'}
+ data-stack-row=""
+ draggable
+ title={entry.name}
+ onMouseEnter={() => window.edge.prestageDrag(req)}
+ onPointerDown={() => window.edge.prestageDrag(req)}
+ onDragStartCapture={(e) => {
+ e.stopPropagation()
+ onDragStart?.(e, req)
+ }}
+ onClick={handlePaste}
+ >
+ {tile ? (
+ <>
+ {thumb}
+ <div className="stack-tile-caption">
+ <span className="stack-row-name" data-row-name="">{entry.name}</span>
+ <span className="stack-row-meta">{copied ? meta : entry.detail}</span>
+ </div>
+ </>
+ ) : (
+ <>
+ <div className="stack-row-art">
+ {thumb ?? (entry.icon && <FileKindIcon path={entry.icon.path} isDirectory={entry.icon.isDirectory} width={iconSize} height={iconSize} />)}
+ </div>
+ <div className="stack-row-text">
+ <span className="stack-row-name" data-row-name="">{entry.name}</span>
+ <span className="stack-row-meta">{meta}</span>
+ </div>
+ </>
+ )}
+ <div className="stack-row-actions" onPointerDown={stop} onClick={stop}>
+ <button className="act" title={entry.copyTitle} onPointerDown={stop} onClick={handleCopy}>
+ <CopyIcon width={11} height={11} />
+ </button>
+ <button className="act danger" title={t('item.ungroup')} onPointerDown={stop} onClick={handleUngroup}>
+ <MinusIcon width={11} height={11} />
+ </button>
+ </div>
+ </div>
+ )
+})
+
+/** Header of an open stack: collapse, "N files · total size", and the card's actions. */
+export function StackHeader({
+ item,
+ title,
+ isHorizontal,
+ onCollapse,
+ onCopy,
+ onRemove
+}: {
+ item: ClipboardItemDto
+ title: string
+ isHorizontal: boolean
+ onCollapse?: (e?: React.MouseEvent) => void
+ onCopy?: (e: React.MouseEvent) => void
+ onRemove?: () => void
+}) {
+ const { t } = useTranslation()
+ const isPreviewing = useStore((s) => s.previewItemId) === item.id
+ const total = stackTotalSize(item)
+ return (
+ <div
+ className="image-folder-expanded-top-bar"
+ title={t('item.collapsePinned')}
+ onPointerDown={stop}
+ onClick={(e) => {
+ e.stopPropagation()
+ onCollapse?.(e)
+ }}
+ >
+ <div className="stack-head-lead">
+ <button
+ type="button"
+ className="image-folder-collapse-btn"
+ title={t('item.collapsePinned')}
+ onPointerDown={stop}
+ onClick={(e) => {
+ e.stopPropagation()
+ e.currentTarget.blur()
+ onCollapse?.(e)
+ }}
+ >
+ {isHorizontal ? <ChevronLeftIcon width={13} height={13} /> : <ChevronUpIcon width={13} height={13} />}
+ </button>
+ <span className="stack-head-text">
+ <span className="image-folder-expanded-title">{title}</span>
+ {total && <span className="image-folder-expanded-sub">{total}</span>}
+ </span>
+ </div>
+ <div className="actions-pill" onPointerDown={stop} onClick={stop}>
+ <button
+ className={`act${item.pinned ? ' active' : ''}`}
+ title={item.pinned ? t('item.unpin') : t('item.pin')}
+ onPointerDown={stop}
+ onClick={(e) => {
+ e.stopPropagation()
+ e.currentTarget.blur()
+ playToggleSound(!item.pinned)
+ useStore.getState().togglePin(item.id, !item.pinned)
+ }}
+ >
+ {item.pinned ? <PinFillIcon width={12} height={12} /> : <PinIcon width={12} height={12} />}
+ </button>
+ <button
+ className={`act${isPreviewing ? ' preview-contract active' : ' preview-expand'}`}
+ title={isPreviewing ? t('header.close') : t('item.expand')}
+ onPointerDown={stop}
+ onClick={(e) => {
+ e.stopPropagation()
+ e.preventDefault()
+ e.currentTarget.blur()
+ playCardExpandSound(!isPreviewing)
+ const rect = e.currentTarget.closest('.item-main, .item')?.getBoundingClientRect()
+ const rectData = rect ? { x: rect.x, y: rect.y, width: rect.width, height: rect.height } : undefined
+ useStore.getState().setPreviewItemId(isPreviewing ? null : item.id, rectData)
+ }}
+ >
+ {isPreviewing ? <ContractIcon width={12} height={12} /> : <ExpandIcon width={12} height={12} />}
+ </button>
+ <button
+ className="act"
+ title={t('item.copy')}
+ onPointerDown={stop}
+ onClick={(e) => {
+ e.stopPropagation()
+ e.currentTarget.blur()
+ onCopy?.(e)
+ }}
+ >
+ <CopyIcon width={12} height={12} />
+ </button>
+ <button
+ className="act danger"
+ title={t('item.delete')}
+ onPointerDown={stop}
+ onClick={(e) => {
+ e.stopPropagation()
+ e.currentTarget.blur()
+ playDeleteSound()
+ onRemove?.()
+ }}
+ >
+ <TrashIcon width={12} height={12} />
+ </button>
+ </div>
+ </div>
+ )
+}
diff --git a/src/hooks/useHoverResync.ts b/src/hooks/useHoverResync.ts
new file mode 100644
index 0000000..a52aa67
--- /dev/null
+++ b/src/hooks/useHoverResync.ts
@@ -0,0 +1,80 @@
+import { useEffect } from 'react'
+import { useStore } from '../store/appStore'
+import { edge } from '../lib/edge'
+
+/** After a change, re-check soon, and again once card motion has settled. */
+const RESYNC_DELAYS_MS = [60, 400] as const
+/** A scroll counts as settled after this long without a scroll event. */
+const SCROLL_SETTLE_MS = 80
+
+/**
+ * Keep hover (the cards' action buttons) on the card that is really under
+ * the pointer. Chromium re-hit-tests only on a mouse move, so when cards
+ * are added, removed or reordered under a still pointer (a new copy, paste
+ * moving an item to the top, delete, expanding a stack, the shelf opening,
+ * scrolling with the wheel or trackpad) the buttons stayed on the card that
+ * moved away until the mouse moved.
+ * On such changes this asks main for one real mouse-move at the cursor's
+ * spot (main skips it when the cursor is not over the window).
+ *
+ * Skipped while a button is held or something is being dragged, so it can
+ * never interfere with a press, a drag or a slider.
+ */
+export function useHoverResync(root: HTMLElement | null): void {
+ useEffect(() => {
+ if (!root || typeof MutationObserver === 'undefined') return
+ let pressed = false
+ const timers: number[] = []
+ const onDown = (): void => { pressed = true }
+ const onUp = (): void => { pressed = false }
+ window.addEventListener('pointerdown', onDown, true)
+ window.addEventListener('pointerup', onUp, true)
+ window.addEventListener('pointercancel', onUp, true)
+
+ const fire = (): void => {
+ const s = useStore.getState()
+ if (!s.open || pressed || s.dragActive || s.internalDragReq) return
+ try {
+ edge.resyncHover?.()
+ } catch { /* ignore */ }
+ }
+ const schedule = (): void => {
+ if (timers.length > 0) return // one pending round covers a burst of changes
+ for (const ms of RESYNC_DELAYS_MS) {
+ timers.push(window.setTimeout(() => {
+ timers.shift()
+ fire()
+ }, ms))
+ }
+ }
+
+ const observer = new MutationObserver(schedule)
+ observer.observe(root, { childList: true, subtree: true })
+ // the list scrolling under a still pointer: once, when the scroll settles.
+ // Wheel, trackpad and smooth scrolls run as a stream of scroll events (the
+ // top dock turns each wheel step into its own instant scroll, so
+ // 'scrollend' would fire per step; a short quiet period covers both).
+ let scrollTimer = 0
+ const onScroll = (): void => {
+ window.clearTimeout(scrollTimer)
+ scrollTimer = window.setTimeout(fire, SCROLL_SETTLE_MS)
+ }
+ const doc = root.ownerDocument
+ doc.addEventListener('scroll', onScroll, { capture: true, passive: true })
+ // the shelf finishing its open under a still pointer
+ const unsubOpen = useStore.subscribe((s, prev) => {
+ if (s.open && !prev.open) schedule()
+ })
+
+ return () => {
+ observer.disconnect()
+ unsubOpen()
+ for (const t of timers) window.clearTimeout(t)
+ window.clearTimeout(scrollTimer)
+ doc.removeEventListener('scroll', onScroll, true)
+ window.removeEventListener('pointerdown', onDown, true)
+ window.removeEventListener('pointerup', onUp, true)
+ window.removeEventListener('pointercancel', onUp, true)
+ }
+ }, [root])
+}
diff --git a/src/lib/iconLayers.ts b/src/lib/iconLayers.ts
new file mode 100644
index 0000000..41cdfda
--- /dev/null
+++ b/src/lib/iconLayers.ts
@@ -0,0 +1,166 @@
+/**
+ * Pre-rendered layers for the folder icons' hover "opening".
+ *
+ * Each icon is cut into back panel, three papers and front pocket
+ * (shared/fileIconLayers.ts) and every layer is drawn ONCE, by this window's
+ * own renderer, into a bitmap at the exact device-pixel size it is shown at,
+ * then kept as a small PNG blob URL. A set is only built when a card with
+ * that icon is first hovered (building ahead for every card on screen held
+ * ~+29MB). Measured against the alternatives:
+ * - live SVG layers cost +27-53MB (one SVG document per layer) and redrew
+ * their blur/grain filters on every hover;
+ * - Resvg in main differs visibly from Chrome's rendering.
+ * A bitmap drawn by the same engine at the same size matches the SVG <img>
+ * (mean 0.05 of 255, same sharpness), costs ~15ms per layer once, ~20-40KB
+ * per layer, and moving it is a plain copy. One set per (kind, device size),
+ * re-drawn if the display scale changes.
+ */
+import { useEffect, useState, useSyncExternalStore } from 'react'
+import { edge } from './edge'
+import { fileIconLayers, ICON_LAYER_PARTS, type IconLayerPart } from '../../shared/fileIconLayers'
+
+export type IconLayerUrls = Record<IconLayerPart, string>
+
+/* ---------------------------- display scale ---------------------------- */
+
+let ratio = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1
+const ratioListeners = new Set<() => void>()
+
+function watchRatio(): void {
+ if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return
+ window.matchMedia(`(resolution: ${ratio}dppx)`).addEventListener(
+ 'change',
+ () => {
+ ratio = window.devicePixelRatio || 1
+ ratioListeners.forEach((l) => l())
+ watchRatio()
+ },
+ { once: true }
+ )
+}
+watchRatio()
+
+function subscribeRatio(l: () => void): () => void {
+ ratioListeners.add(l)
+ return () => ratioListeners.delete(l)
+}
+
+/* ------------------------------- building ------------------------------ */
+
+const sources = new Map<string, Promise<string | null>>()
+
+function sourceOf(kind: string): Promise<string | null> {
+ let p = sources.get(kind)
+ if (!p) {
+ p = Promise.resolve()
+ .then(() => edge.iconSvg?.(kind))
+ .then((s) => (typeof s === 'string' ? s : null))
+ .catch(() => null)
+ sources.set(kind, p)
+ }
+ return p
+}
+
+/** Yield between layers so building never holds a frame (~15ms each). */
+function nextTask(): Promise<void> {
+ return new Promise((resolve) => setTimeout(resolve, 0))
+}
+
+async function rasterize(svg: string, px: number): Promise<string | null> {
+ const src = URL.createObjectURL(new Blob([svg], { type: 'image/svg+xml' }))
+ try {
+ const img = new Image()
+ img.src = src
+ await img.decode()
+ const canvas = new OffscreenCanvas(px, px)
+ const g = canvas.getContext('2d')
+ if (!g) return null
+ g.drawImage(img, 0, 0, px, px)
+ return URL.createObjectURL(await canvas.convertToBlob({ type: 'image/png' }))
+ } catch {
+ return null
+ } finally {
+ URL.revokeObjectURL(src)
+ }
+}
+
+function revokeAll(urls: Partial<IconLayerUrls>): void {
+ for (const u of Object.values(urls)) if (u) URL.revokeObjectURL(u)
+}
+
+async function build(kind: string, px: number): Promise<IconLayerUrls | null> {
+ const svg = await sourceOf(kind)
+ const layers = svg ? fileIconLayers(svg) : null
+ if (!layers) return null
+ const out: Partial<IconLayerUrls> = {}
+ for (const part of ICON_LAYER_PARTS) {
+ await nextTask()
+ const url = await rasterize(layers[part], px)
+ if (!url) {
+ revokeAll(out)
+ return null
+ }
+ out[part] = url
+ }
+ return out as IconLayerUrls
+}
+
+/* -------------------------------- cache -------------------------------- */
+
+/** Sets kept (each ~100-200KB of PNG); the oldest is dropped past this. */
+const MAX_SETS = 32
+const pending = new Map<string, Promise<IconLayerUrls | null>>()
+const done = new Map<string, IconLayerUrls>()
+
+function request(kind: string, px: number): Promise<IconLayerUrls | null> {
+ const key = `${kind}|${px}`
+ const hit = pending.get(key)
+ if (hit) return hit
+ const p = build(kind, px).then((urls) => {
+ if (urls) {
+ done.set(key, urls)
+ while (done.size > MAX_SETS) {
+ const [oldKey, oldUrls] = done.entries().next().value as [string, IconLayerUrls]
+ done.delete(oldKey)
+ pending.delete(oldKey)
+ revokeAll(oldUrls)
+ }
+ } else {
+ pending.delete(key) // a failed build may be retried later
+ }
+ return urls
+ })
+ pending.set(key, p)
+ return p
+}
+
+/**
+ * The layer bitmaps for an icon kind shown `cssSize` CSS px wide: ready ones
+ * at once; otherwise built when `build` turns true (null until then, or when
+ * the icon cannot be layered).
+ */
+export function useIconLayers(kind: string, cssSize: number | null, build: boolean): IconLayerUrls | null {
+ const r = useSyncExternalStore(subscribeRatio, () => ratio, () => 1)
+ const px = cssSize && cssSize > 16 ? Math.round(cssSize * r) : 0
+ const key = px ? `${kind}|${px}` : ''
+ const [state, setState] = useState<{ key: string; urls: IconLayerUrls | null }>(() => ({ key, urls: (key && done.get(key)) || null }))
+
+ useEffect(() => {
+ if (!key) return
+ const hit = done.get(key)
+ if (hit) {
+ setState({ key, urls: hit })
+ return
+ }
+ if (!build) return
+ let live = true
+ void request(kind, px).then((urls) => {
+ if (live) setState({ key, urls })
+ })
+ return () => {
+ live = false
+ }
+ }, [key, kind, px, build])
+
+ return state.key === key ? state.urls : null
+}
diff --git a/src/styles/item.css b/src/styles/item.css
index b88b2d4..58361ec 100644
--- a/src/styles/item.css
+++ b/src/styles/item.css
@@ -505,9 +505,12 @@
transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
-/* The file art keeps one soft shadow; hover only grows it a touch around
- its center (no lift into the hover buttons, no animated shadow: changing
- a filter repaints the SVG every frame, a transform does not). */
+/* The file art keeps one soft shadow; hover lifts it 4px. It is its own
+ pre-rastered layer (will-change), so it must stay 1:1 to stay sharp: no
+ scaling, and moves only in multiples of 4px (whole device pixels at
+ 100-200% display scaling). Growing it 4% on hover measured 72% of the
+ sharpness of a direct render on a 1x screen; the 4px lift stays sharp.
+ No animated shadow either: changing a filter repaints the SVG every frame. */
.single-file-hero svg,
.single-file-hero img.file-kind-img {
display: block;
@@ -520,12 +523,7 @@
.item:not(.is-expanded) .item-main:hover .single-file-hero svg,
.item.is-image-folder-card:not(.is-expanded):hover .single-file-hero img.file-kind-img,
.item:not(.is-expanded) .item-main:hover .single-file-hero img.file-kind-img {
- transform: scale(1.04);
-}
-
-.mini-image-folder-card:hover .single-file-hero svg,
-.mini-image-folder-card:hover .single-file-hero img.file-kind-img {
- transform: scale(1.04);
+ transform: translateY(-4px);
}
html[data-motion='reduce'] .single-file-hero svg,
@@ -533,27 +531,158 @@ html[data-motion='reduce'] .single-file-hero img.file-kind-img {
transition: none;
}
-/* File cards: center the art in the part of the viewport the label flap
- (.image-folder-flap-wrap, pulled up 26px / 24px) leaves visible. */
+/* ------------------------------------------------------------------ */
+/* Folder icons that open on hover (CustomFileIcon layered) */
+/* ------------------------------------------------------------------ */
+/* At rest the plain icon shows (.fko-plain). Next to it sit its five
+ layers (back panel, three papers, front pocket) as bitmaps drawn once at
+ this exact device size (lib/iconLayers.ts), hidden: not painted, not even
+ decoded. Hovering the card swaps them in (same pixels as the plain icon)
+ and opens the folder: the pocket drops a step and tips forward on its
+ bottom edge, the papers rise a little and fan out. Leaving closes it, and
+ only then (after the motion) the plain icon takes over again. The opening
+ rules wait for .is-armed (set once the layers have their closed style),
+ so layers that arrive mid-hover still animate open instead of jumping.
+ Cost: moving bitmaps is a plain copy, no filter or SVG is redrawn; the
+ wrapper never gets a filter or transform (that would redraw everything
+ each frame). The papers move in multiples of --open-u (4px on large
+ icons, 2px on small ones), whole device pixels at 100-200% scaling, so
+ they stay sharp while open. */
+.file-kind-opening {
+ --open-u: 4px;
+ --open-time: 0.46s;
+ position: relative;
+ display: block;
+ filter: none !important;
+ transform: none !important;
+ will-change: auto !important;
+ transition: none !important;
+}
+/* Plain icon and every layer are pre-rastered layers (will-change): showing,
+ hiding and moving them is then compositor work, not a repaint of the card
+ under them (measured: ~3ms of raster per hover instead of ~12ms; memory
+ at rest unchanged, hidden layers hold no raster). */
+.file-kind-opening > .fko-plain,
+.fko-layers > .fil {
+ will-change: transform;
+}
+/* plain icon and pocket share the icon's one shadow */
+.file-kind-opening > .fko-plain,
+.fko-layers > .fil-front {
+ filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.45));
+}
+.file-kind-opening > .fko-plain {
+ display: block;
+ width: 100%;
+ height: 100%;
+ /* back to visible only once the closing motion has finished */
+ transition: visibility 0s linear var(--open-time);
+}
+.fko-layers {
+ position: absolute;
+ inset: 0;
+ visibility: hidden;
+ transition: visibility 0s linear var(--open-time);
+}
+.fko-layers > .fil {
+ position: absolute;
+ inset: 0;
+ display: block;
+ width: 100%;
+ height: 100%;
+ transition: translate var(--open-time) cubic-bezier(0.22, 1, 0.36, 1), transform var(--open-time) cubic-bezier(0.22, 1, 0.36, 1);
+}
+.fko-layers > .fil-front {
+ transform-origin: 50% 83%; /* the pocket's bottom edge */
+}
+/* papers leave one after another: the front one first */
+.fko-layers > .fil-paper2 {
+ transition-delay: 0.035s;
+}
+.fko-layers > .fil-paper1 {
+ transition-delay: 0.07s;
+}
+/* small icons move half as far */
+.flyout-subitem:not(.single-hero-card) .file-kind-opening {
+ --open-u: 2px;
+}
+
+/* open */
+.item:not(.is-expanded) .item-main:hover .file-kind-opening.is-armed > .fko-plain,
+.item.is-image-folder-card:not(.is-expanded):hover .file-kind-opening.is-armed > .fko-plain {
+ visibility: hidden;
+ transition-delay: 0s;
+}
+.item:not(.is-expanded) .item-main:hover .file-kind-opening.is-armed > .fko-layers,
+.item.is-image-folder-card:not(.is-expanded):hover .file-kind-opening.is-armed > .fko-layers {
+ visibility: visible;
+ transition-delay: 0s;
+}
+.item:not(.is-expanded) .item-main:hover .file-kind-opening.is-armed .fil-paper1,
+.item.is-image-folder-card:not(.is-expanded):hover .file-kind-opening.is-armed .fil-paper1 {
+ translate: var(--open-u) calc(var(--open-u) * -1);
+}
+.item:not(.is-expanded) .item-main:hover .file-kind-opening.is-armed .fil-paper2,
+.item.is-image-folder-card:not(.is-expanded):hover .file-kind-opening.is-armed .fil-paper2 {
+ translate: 0 calc(var(--open-u) * -2);
+}
+.item:not(.is-expanded) .item-main:hover .file-kind-opening.is-armed .fil-paper3,
+.item.is-image-folder-card:not(.is-expanded):hover .file-kind-opening.is-armed .fil-paper3 {
+ translate: calc(var(--open-u) * -1) calc(var(--open-u) * -1);
+}
+.item:not(.is-expanded) .item-main:hover .file-kind-opening.is-armed .fil-front,
+.item.is-image-folder-card:not(.is-expanded):hover .file-kind-opening.is-armed .fil-front {
+ transform: translateY(var(--open-u)) perspective(calc(var(--open-u) * 90)) rotateX(-26deg);
+}
+
+html[data-motion='reduce'] .fko-layers > .fil {
+ transition: none;
+}
+
+/* Cards showing an opening folder icon keep the same horizontal hover pill,
+ but dock it on the label flap's shoulder (right of the raised tab, between
+ the folder and the name) instead of the top corner, where the opening
+ papers rise. Measured clear of the open folder and of the text.
+ (`top: auto` sits in each dock's own rule: those outrank the top dock's
+ `.list.horizontal` pill offsets.) */
+.item.is-image-folder-card .item-main:has(.file-kind-opening) > .actions {
+ transform-origin: bottom right;
+}
+.item.is-image-folder-card .item-main:has(.file-kind-opening) > .actions {
+ top: auto;
+ bottom: 37px;
+}
+.list.horizontal .item.is-image-folder-card .item-main:has(.file-kind-opening) > .actions {
+ top: auto;
+ bottom: 28px;
+}
+
+/* The preview's cards have no flap: their pill stays in the top corner and
+ the folder sits a little lower so the open papers clear it. */
+.flyout-subitem:not(.single-hero-card) .item-content:has(.file-kind-opening) {
+ padding-top: 28px;
+}
+/* Grid cards: the pill centred on the select box's row (box 10-30px). */
+.flyout-subitem:has(.subitem-select-badge) .actions {
+ top: 5px;
+}
+
+/* File cards: the art sits in the part of the viewport the label flap
+ (.image-folder-flap-wrap, pulled up 26px / 24px) leaves visible, high
+ enough that the open folder clears the hover pill on the flap's shoulder
+ (top dock: 94px icon, measured >= 6px gaps to folder and name). */
.image-folder-viewport > .single-file-hero {
margin-top: 0;
padding-bottom: 26px;
box-sizing: border-box;
}
.list.horizontal .image-folder-viewport > .single-file-hero {
- padding-bottom: 24px;
-}
-/* Same for the mini cards of an expanded stack. Their flap covers 16px /
- 12px of the viewport (measured on the rendered cards). */
-.mini-image-folder-viewport > .single-file-hero {
- padding-bottom: 16px;
- box-sizing: border-box;
-}
-.list.horizontal .mini-image-folder-viewport > .single-file-hero {
- padding-bottom: 12px;
+ padding-bottom: 34px;
}
/* Single Image Folder Card (Framed image in folder card + borderless folder flap) */
+/* The hover background switches in one step (no fade): the textured viewport
+ paints with the card, so a fade redrew its grain and glow on every frame. */
.item.is-image-folder-card {
height: 205px;
background: var(--bg-card, #141414);
@@ -561,10 +690,8 @@ html[data-motion='reduce'] .single-file-hero img.file-kind-img {
overflow: hidden;
padding: 5px;
box-sizing: border-box;
- transition: background 0.16s ease;
}
-
.item.is-image-folder-card:not(.is-expanded):hover {
background: var(--bg-card-hover, #1c1c1c);
}
@@ -590,19 +717,18 @@ html[data-motion='reduce'] .single-file-hero img.file-kind-img {
border-radius: calc(var(--radius-card, 18px) - 5px);
overflow: hidden;
background: var(--bg-card, #141414);
- transition: background 0.16s ease;
}
-
.item.is-image-folder-card:not(.is-expanded):hover .image-folder-card-inner,
.item:not(.is-expanded) .item-main:hover .image-folder-card-inner {
background: var(--bg-card-hover, #1c1c1c);
}
-/* Lift the viewport with the flap on hover so the folder tab keeps its contrast. */
+/* Lift the viewport with the flap on hover so the folder tab keeps its contrast.
+ background-color only: the shorthand would also drop the glow and grain. */
.item.is-image-folder-card:not(.is-expanded):hover .image-folder-viewport,
.item:not(.is-expanded) .item-main:hover .image-folder-viewport {
- background: #222222;
+ background-color: #222222;
}
.image-folder-viewport {
@@ -859,7 +985,7 @@ html[data-motion='reduce'] .single-file-hero img.file-kind-img {
justify-content: space-between;
width: 100%;
height: 28px;
- padding: 0 4px;
+ padding: 0 0 0 4px; /* the actions sit flush right: room for the title */
margin-bottom: 10px;
flex-shrink: 0;
cursor: pointer;
@@ -868,8 +994,10 @@ html[data-motion='reduce'] .single-file-hero img.file-kind-img {
}
.list.horizontal .image-folder-expanded-top-bar {
- height: 20px;
- margin-bottom: 5px;
+ justify-content: flex-start;
+ gap: 12px;
+ height: 22px;
+ margin-bottom: 8px;
padding: 0 4px;
}
@@ -915,326 +1043,69 @@ html[data-motion='reduce'] .single-file-hero img.file-kind-img {
display: flex;
align-items: center;
}
-
-/* Horizontal Track (Horizontal Dock Mode - Naturally expanded across items) */
-.image-stack-expanded-track {
- display: flex;
- flex-direction: row;
- gap: 8px;
- flex: 1;
- min-height: 0;
- height: 104px;
- max-height: 104px;
- align-items: center;
- overflow: visible;
- scrollbar-width: none;
- -ms-overflow-style: none;
- padding: 4px 2px 5px 2px;
- box-sizing: border-box;
-}
-
-.image-stack-expanded-track::-webkit-scrollbar {
- display: none;
-}
-
-/* Vertical List (Vertical Dock Mode - No internal scroll, fully expanded) */
-.image-stack-expanded-list {
- display: flex;
- flex-direction: column;
- gap: 8px;
- width: 100%;
- height: auto;
- max-height: none;
- overflow: visible;
- padding: 2px 0 2px 0;
- box-sizing: border-box;
-}
-
-/* ------------------------------------------------------------------ */
-/* Mini Image Folder Card (Exact Same Look & Design as Single Image) */
-/* ------------------------------------------------------------------ */
-
-.mini-image-folder-card {
- position: relative;
- width: 100%;
- height: auto;
- aspect-ratio: 242 / 205;
- padding: 4px;
- box-sizing: border-box;
- flex-shrink: 0;
- cursor: grab;
- border-radius: 15px;
- overflow: hidden;
- background: var(--bg-card, #141414);
- box-shadow: none !important;
- border: none;
- transition: background 0.16s ease;
- user-select: none;
-}
-
-.mini-image-folder-card:active {
- cursor: grabbing;
-}
-
-.mini-image-folder-card:hover {
- background: var(--bg-card-hover, #1c1c1c);
- transform: none;
- box-shadow: none !important;
-}
-
-/* Horizontal Dock mini card sizing */
-.list.horizontal .mini-image-folder-card {
- width: 124px;
- min-width: 124px;
- max-width: 124px;
- height: 94px;
- max-height: 94px;
- aspect-ratio: 210 / 146;
- flex-shrink: 0;
- padding: 2px;
- border-radius: 9px;
- box-shadow: none !important;
-}
-
-.list.horizontal .mini-image-folder-card:hover {
- background: var(--bg-card-hover, #1c1c1c);
- transform: none;
- box-shadow: none !important;
-}
-
-.mini-image-folder-card-inner {
- position: relative;
- width: 100%;
- height: 100%;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- border-radius: 12px;
- overflow: hidden;
- background: var(--bg-card, #141414);
- transition: background 0.16s ease;
-}
-
-.mini-image-folder-card:hover .mini-image-folder-card-inner {
- background: var(--bg-card-hover, #1c1c1c);
-}
-
-.list.horizontal .mini-image-folder-card-inner {
- border-radius: 7px;
-}
-
-/* Mini Charcoal Viewport */
-.mini-image-folder-viewport {
- position: relative;
- width: 100%;
- flex: 1;
- min-height: 0;
- background: #1b1b1b;
- transition: background-color 0.16s ease;
- overflow: hidden;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 12px 12px 0 0;
-}
-
-.list.horizontal .mini-image-folder-viewport {
- border-radius: 7px 7px 0 0;
-}
-
-.mini-image-folder-thumb {
- position: relative;
- max-width: calc(100% - 20px);
- max-height: calc(100% - 20px);
- object-fit: contain;
- border-radius: 6px;
- z-index: 2;
- filter: none;
- transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
- pointer-events: none;
-}
-
-.list.horizontal .mini-image-folder-thumb {
- max-width: calc(100% - 12px);
- max-height: calc(100% - 10px);
- border-radius: 4px;
- filter: none;
-}
-
-.mini-image-folder-card:hover .mini-image-folder-thumb {
- transform: scale(1.02);
- filter: none;
-}
-
-.list.horizontal .mini-image-folder-card:hover .mini-image-folder-thumb {
- transform: scale(1.02);
- filter: none;
-}
-
-/* Mini Solid Black Curved Folder Flap */
-.mini-image-folder-flap-wrap {
- position: relative;
- width: 100%;
- flex-shrink: 0;
- margin-top: -22px;
- z-index: 5;
+/* The header sits in the card's flow, not over content: no drop shadows
+ (in the top dock they fell onto the first row). */
+.image-folder-expanded-top-bar .actions-pill,
+.image-folder-expanded-top-bar .image-folder-collapse-btn {
+ box-shadow: none;
}
-.list.horizontal .mini-image-folder-flap-wrap {
- margin-top: -18px;
- flex-shrink: 0;
-}
-.mini-image-folder-flap-svg {
+/* Textured card backgrounds (file and image cards):
+ a neutral, Apple-style dark surface, no color.
+ - Light: a faint white glow centered behind the art, a barely-there sheen
+ at the top and a soft darkening toward the bottom, like macOS's dark
+ widget materials.
+ - Grain: one static 128px seamless tile (assets/grain.png, soft Gaussian
+ luminance noise as light/dark specks with alpha; the light specks at half
+ strength so the grain darkens rather than greys the card).
+ All of it is background layers of one pseudo-element behind the content,
+ kept on its own layer (will-change): rastered once, so the card's hover
+ color change never redraws it (painted with the card it doubled the hover
+ raster work). No filter, blur or animation.
+ --glow-lift centers the glow on the art, which sits in the part the label
+ flap leaves visible (half the flap: 26/24px). */
+.image-folder-viewport.is-textured {
+ --glow-lift: 13px;
+ isolation: isolate;
+}
+.is-textured::before {
+ content: '';
position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
+ inset: 0;
+ z-index: -1;
+ border-radius: inherit;
pointer-events: none;
- z-index: 1;
-}
-
-.mini-image-folder-flap-svg path {
- fill: var(--bg-card, #141414);
- stroke: none;
- border: none;
- transition: fill 0.16s ease;
-}
-
-.mini-image-folder-card:hover .mini-image-folder-flap-svg path {
- fill: var(--bg-card-hover, #1c1c1c);
-}
-
-.mini-image-folder-card:hover .mini-image-folder-viewport {
- background: #222222;
-}
-
-.mini-image-folder-flap-content {
- position: relative;
- z-index: 2;
- width: 100%;
- display: flex;
- flex-direction: column;
-}
-
-.mini-image-folder-flap-header {
- height: 24px;
- display: flex;
- align-items: center;
- padding-left: 5px;
- padding-top: 1px;
- box-sizing: border-box;
- max-width: 110px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.list.horizontal .mini-image-folder-flap-header {
- height: 16px;
- padding-left: 3px;
- max-width: 80px;
-}
-
-.list.horizontal .mini-image-folder-flap-header .file-elevated-badge {
- font-size: 8px;
- padding: 0 1px;
- font-weight: 700;
- letter-spacing: 0.01em;
-}
-
-.mini-image-folder-flap-footer {
- padding: 2px 8px 5px 8px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 6px;
- min-width: 0;
-}
-
-.list.horizontal .mini-image-folder-flap-footer {
- padding: 2px 4.5px 3px 4.5px;
- gap: 3px;
- box-sizing: border-box;
-}
-
-.mini-image-folder-meta {
- display: flex;
- align-items: center;
- gap: 5px;
- min-width: 0;
- flex: 1;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.list.horizontal .mini-image-folder-meta {
- gap: 2px;
-}
-
-.mini-image-folder-meta .kind-badge {
- font-size: calc(10.5px * var(--font-scale, 1));
- padding: 1px 5px;
-}
-
-.list.horizontal .mini-image-folder-meta .kind-badge {
- font-size: 8px;
- padding: 0 2px;
-}
-
-.mini-image-folder-source-name {
- font-size: calc(11.5px * var(--font-scale, 1));
- color: rgba(255, 255, 255, 0.85);
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- font-weight: 500;
- min-width: 0;
- flex: 1;
- max-width: none;
-}
-
-.list.horizontal .mini-image-folder-source-name {
- font-size: 9px;
- line-height: 1.25;
- max-width: 74px;
-}
-
-.mini-image-folder-size {
- font-size: calc(10.5px * var(--font-scale, 1));
- color: rgba(255, 255, 255, 0.55);
- font-family: var(--font-mono);
- white-space: nowrap;
- flex-shrink: 0;
+ will-change: transform;
+ background-image:
+ url('../assets/grain.png'),
+ radial-gradient(
+ 60% 66% at 50% calc(50% - var(--glow-lift)),
+ rgba(255, 255, 255, 0.045) 0%,
+ rgba(255, 255, 255, 0.016) 50%,
+ transparent 80%
+ ),
+ linear-gradient(
+ 180deg,
+ rgba(255, 255, 255, 0.022) 0%,
+ transparent 38%,
+ rgba(0, 0, 0, 0.2) 100%
+ );
+ background-size: 128px 128px, 100% 100%, 100% 100%;
+ background-repeat: repeat, no-repeat, no-repeat;
}
-
-.list.horizontal .mini-image-folder-size {
- font-size: 8.5px;
- line-height: 1.25;
+.list.horizontal .image-folder-viewport.is-textured {
+ --glow-lift: 12px;
}
-
-/* Hover Action Pill for Mini Card (Expand, Copy, Ungroup) */
-.mini-image-folder-actions {
- position: absolute;
- top: 6px;
- right: 6px;
- opacity: 0;
- pointer-events: none;
- z-index: 10;
+/* Textured cards keep their base on hover: the lift to #222 would sit under
+ the texture for nothing, and the texture already sets the flap apart. */
+.item.is-image-folder-card:not(.is-expanded):hover .image-folder-viewport.is-textured,
+.item:not(.is-expanded) .item-main:hover .image-folder-viewport.is-textured {
+ background-color: #1b1b1b;
}
-
-.list.horizontal .mini-image-folder-actions {
- top: 4px;
- right: 4px;
-}
-
-.mini-image-folder-card:hover .mini-image-folder-actions,
-.mini-image-folder-card:focus-within .mini-image-folder-actions {
- opacity: 1;
- pointer-events: auto;
- scale: 1;
+/* An open stack shows its list of entries; keep its frame plain. */
+.image-folder-viewport.is-textured.is-expanded-viewport::before {
+ content: none;
}
/* Folder Flap Sleeve - completely borderless */
@@ -1260,7 +1131,6 @@ html[data-motion='reduce'] .single-file-hero img.file-kind-img {
fill: var(--bg-card, #141414);
stroke: none;
border: none;
- transition: fill 0.16s ease;
}
.item.is-image-folder-card:not(.is-expanded):hover .image-folder-flap-svg path,
@@ -1317,18 +1187,44 @@ html[data-motion='reduce'] .single-file-hero img.file-kind-img {
/* The folders have see-through fronts, so a tight fan of four (each with
its own heavy shadow) read as a smear. The front folder sits in full
color with the only shadow; the others peek out to the sides and behind,
- smaller and dimmed, so the glass reads as depth. Positions are % of the
- icon, so the same rules fit both docks. Hover spreads them a little with
- a small tilt. Only transform animates (each folder is its own layer,
- rastered once); the dimming and the shadow never change. Photo cards in
- a mixed stack keep the .image-folder-stack-item rules above. */
+ smaller and dimmed, so the glass reads as depth. Hover spreads them and
+ lifts the front one. Photo cards in a mixed stack keep the
+ .image-folder-stack-item rules above.
+
+ Pixel-sharp on every screen: each folder is its own pre-rastered layer
+ (will-change), and a layer stays sharp only while it is shown 1:1. So
+ - its size never changes (each position has one fixed scale, the same at
+ rest and on hover) and nothing is tilted;
+ - it only ever moves by multiples of 4px, a whole number of device pixels
+ at 100/125/150/175/200% display scaling.
+ Measured on a 1x screen this took the front folder from 62% to ~100% of
+ the sharpness of a direct render, with no extra raster work on hover. */
+
+.image-folder-stack-deck.is-file-deck {
+ --spread: 36px; /* side folders, at rest */
+ --spread-h: 44px; /* ... on hover */
+ --pair: 24px; /* second folder of a 2-stack */
+ --pair-h: 32px;
+ --pair-front: -12px; /* front folder of a 2-stack */
+ --back: -24px; /* fourth folder, behind */
+ --back-h: -32px;
+}
+.list.horizontal .image-folder-stack-deck.is-file-deck {
+ --spread: 24px;
+ --spread-h: 28px;
+ --pair: 16px;
+ --pair-h: 24px;
+ --pair-front: -8px;
+ --back: -16px;
+ --back-h: -20px;
+}
.file-stack-folder {
position: absolute;
display: block;
line-height: 0;
transform-origin: 50% 70%;
- transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
+ transition: translate 0.42s cubic-bezier(0.22, 1, 0.36, 1);
will-change: transform;
}
@@ -1362,88 +1258,108 @@ html[data-motion='reduce'] .single-file-hero img.file-kind-img {
/* 2 files: front a little left, the second behind on the right. */
.image-folder-stack-deck[data-count="2"] .file-stack-folder.pos-0 {
- transform: translate(-9%, 3%);
+ translate: var(--pair-front) 4px;
}
.image-folder-stack-deck[data-count="2"] .file-stack-folder.pos-1 {
- transform: translate(17%, -5%) rotate(3deg) scale(0.88);
+ translate: var(--pair) -4px;
+ scale: 0.88;
}
.item.is-image-folder-card:not(.is-expanded):hover .image-folder-stack-deck[data-count="2"] .file-stack-folder.pos-0,
.item-main:hover .image-folder-stack-deck[data-count="2"] .file-stack-folder.pos-0 {
- transform: translate(-12%, 2%) scale(1.03);
+ translate: var(--pair-front) 0;
}
.item.is-image-folder-card:not(.is-expanded):hover .image-folder-stack-deck[data-count="2"] .file-stack-folder.pos-1,
.item-main:hover .image-folder-stack-deck[data-count="2"] .file-stack-folder.pos-1 {
- transform: translate(23%, -7%) rotate(6deg) scale(0.9);
+ translate: var(--pair-h) -8px;
}
/* 3 files: front centered, one each side behind (right first, as the photo cards). */
.image-folder-stack-deck[data-count="3"] .file-stack-folder.pos-0 {
- transform: translate(0, 3%);
+ translate: 0 4px;
}
.image-folder-stack-deck[data-count="3"] .file-stack-folder.pos-1 {
- transform: translate(24%, -4%) rotate(3deg) scale(0.84);
+ translate: var(--spread) -4px;
+ scale: 0.84;
}
.image-folder-stack-deck[data-count="3"] .file-stack-folder.pos-2 {
- transform: translate(-24%, -4%) rotate(-3deg) scale(0.84);
+ translate: calc(-1 * var(--spread)) -4px;
+ scale: 0.84;
}
.item.is-image-folder-card:not(.is-expanded):hover .image-folder-stack-deck[data-count="3"] .file-stack-folder.pos-0,
.item-main:hover .image-folder-stack-deck[data-count="3"] .file-stack-folder.pos-0 {
- transform: translate(0, 2%) scale(1.03);
+ translate: 0 0;
}
.item.is-image-folder-card:not(.is-expanded):hover .image-folder-stack-deck[data-count="3"] .file-stack-folder.pos-1,
.item-main:hover .image-folder-stack-deck[data-count="3"] .file-stack-folder.pos-1 {
- transform: translate(30%, -6%) rotate(6deg) scale(0.86);
+ translate: var(--spread-h) -8px;
}
.item.is-image-folder-card:not(.is-expanded):hover .image-folder-stack-deck[data-count="3"] .file-stack-folder.pos-2,
.item-main:hover .image-folder-stack-deck[data-count="3"] .file-stack-folder.pos-2 {
- transform: translate(-30%, -6%) rotate(-6deg) scale(0.86);
+ translate: calc(-1 * var(--spread-h)) -8px;
}
/* 4+ files: front centered, left and right behind, a fourth further back. */
.image-folder-stack-deck[data-count="4"] .file-stack-folder.pos-0 {
- transform: translate(0, 4%);
+ translate: 0 4px;
}
.image-folder-stack-deck[data-count="4"] .file-stack-folder.pos-1 {
- transform: translate(-24%, -3%) rotate(-3deg) scale(0.84);
+ translate: calc(-1 * var(--spread)) -4px;
+ scale: 0.84;
}
.image-folder-stack-deck[data-count="4"] .file-stack-folder.pos-2 {
- transform: translate(24%, -3%) rotate(3deg) scale(0.84);
+ translate: var(--spread) -4px;
+ scale: 0.84;
}
.image-folder-stack-deck[data-count="4"] .file-stack-folder.pos-3 {
- transform: translate(0, -17%) scale(0.74);
+ translate: 0 var(--back);
+ scale: 0.74;
}
.item.is-image-folder-card:not(.is-expanded):hover .image-folder-stack-deck[data-count="4"] .file-stack-folder.pos-0,
.item-main:hover .image-folder-stack-deck[data-count="4"] .file-stack-folder.pos-0 {
- transform: translate(0, 3%) scale(1.03);
+ translate: 0 0;
}
.item.is-image-folder-card:not(.is-expanded):hover .image-folder-stack-deck[data-count="4"] .file-stack-folder.pos-1,
.item-main:hover .image-folder-stack-deck[data-count="4"] .file-stack-folder.pos-1 {
- transform: translate(-30%, -5%) rotate(-6deg) scale(0.86);
+ translate: calc(-1 * var(--spread-h)) -8px;
}
.item.is-image-folder-card:not(.is-expanded):hover .image-folder-stack-deck[data-count="4"] .file-stack-folder.pos-2,
.item-main:hover .image-folder-stack-deck[data-count="4"] .file-stack-folder.pos-2 {
- transform: translate(30%, -5%) rotate(6deg) scale(0.86);
+ translate: var(--spread-h) -8px;
}
.item.is-image-folder-card:not(.is-expanded):hover .image-folder-stack-deck[data-count="4"] .file-stack-folder.pos-3,
.item-main:hover .image-folder-stack-deck[data-count="4"] .file-stack-folder.pos-3 {
- transform: translate(0, -22%) scale(0.76);
+ translate: 0 var(--back-h);
}
html[data-motion='reduce'] .file-stack-folder {
transition: none;
}
-/* Center the cascade in the viewport above the label flap. The back
- folders rise above the front one, so the box is nudged down by about
- half that rise to keep the whole group optically centered. */
+/* The cascade sits above the label flap, raised so the open front folder
+ clears the hover pill on the flap's shoulder (the back folders rise above
+ the front one, so the group still keeps a top margin). */
.image-folder-viewport .image-folder-stack-deck.is-file-deck {
margin-top: 0;
- padding: 8px 0 26px;
+ padding: 0 0 36px;
box-sizing: border-box;
}
.list.horizontal .image-folder-viewport .image-folder-stack-deck.is-file-deck {
margin-top: 0;
- padding: 6px 0 24px;
+ padding: 0 0 34px;
+}
+/* A photo in a top-dock file stack scales with the folders (icon 94px), so
+ the group keeps its top margin. */
+/* ...and in any file stack its hover swing lifts 4px less, so its corner
+ stays clear of the card's top edge. */
+.image-folder-stack-deck.is-file-deck .image-folder-stack-item {
+ transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), translate 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s ease, opacity 0.28s ease;
+}
+.item-main:hover .image-folder-stack-deck.is-file-deck .image-folder-stack-item {
+ translate: 0 4px;
+}
+.list.horizontal .image-folder-stack-deck.is-file-deck .image-folder-stack-item {
+ width: 92px;
+ height: 60px;
}
.file-stack-expanded-track {
@@ -1974,7 +1890,7 @@ html[data-motion='reduce'] .file-stack-folder {
}
.flyout-subitem .single-file-hero svg,
-.flyout-subitem .single-file-hero img.file-kind-img {
+.flyout-subitem .single-file-hero .file-kind-img {
width: 88px;
height: 88px;
display: block;
@@ -1984,7 +1900,7 @@ html[data-motion='reduce'] .file-stack-folder {
.flyout-subitem:hover .single-file-hero svg,
.flyout-subitem:hover .single-file-hero img.file-kind-img {
- transform: translateY(-2px) scale(1.04);
+ transform: translateY(-4px);
}
.flyout-subitem .single-file-meta {
@@ -2100,7 +2016,7 @@ html[data-motion='reduce'] .file-stack-folder {
width: 100%;
}
.single-hero-card .single-file-hero svg,
-.single-hero-card .single-file-hero img.file-kind-img {
+.single-hero-card .single-file-hero .file-kind-img {
width: 120px;
height: 120px;
}
@@ -2579,7 +2495,6 @@ html[data-motion='reduce'] .file-stack-folder {
font-size: 9.5px;
}
-
/* ------------------------------------------------------------------ */
/* Horizontal Expanded Stack & Sub-Item Tile Styling */
/* ------------------------------------------------------------------ */
@@ -3051,9 +2966,9 @@ html[data-motion='reduce'] .file-stack-folder {
.actions,
.actions-pill,
.act-pill,
-.mini-image-folder-actions,
.fluid-row-actions,
-.horizontal-subitem-actions {
+.horizontal-subitem-actions,
+.stack-row-actions {
display: flex;
align-items: center;
gap: 0;
@@ -3066,16 +2981,17 @@ html[data-motion='reduce'] .file-stack-folder {
/* Hover pills grow in from their corner, then shrink back on leave. */
.actions,
-.mini-image-folder-actions,
.fluid-row-actions,
-.horizontal-subitem-actions {
+.horizontal-subitem-actions,
+.stack-row-actions {
scale: 0.94;
transform-origin: top right;
transition:
opacity 0.12s ease,
scale 0.18s cubic-bezier(0.2, 0.9, 0.3, 1);
}
-.fluid-row-actions {
+.fluid-row-actions,
+.stack-row .stack-row-actions {
transform-origin: right center;
}
diff --git a/src/styles/stack.css b/src/styles/stack.css
new file mode 100644
index 0000000..fc621e0
--- /dev/null
+++ b/src/styles/stack.css
@@ -0,0 +1,294 @@
+/* ------------------------------------------------------------------ */
+/* Open stack (StackItems.tsx): header, file list, photo grid */
+/* ------------------------------------------------------------------ */
+
+/* Header: collapse + "N files" over the total size on the left, card
+ actions on the right. The top dock puts title and size on one line and the
+ actions right after them (a long stack runs past the window edge). */
+.stack-head-lead {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ min-width: 0;
+}
+.stack-head-lead .image-folder-collapse-btn {
+ flex: none;
+}
+.stack-head-text {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+}
+.stack-head-text .image-folder-expanded-title {
+ line-height: 15px;
+ white-space: nowrap;
+}
+.image-folder-expanded-sub {
+ font-size: 10.5px;
+ line-height: 13px;
+ font-weight: 500;
+ color: rgba(255, 255, 255, 0.45);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.list.horizontal .stack-head-lead {
+ gap: 6px;
+}
+/* One left edge for every open stack: the header, the list's icons and the
+ photo grid all start 4px in, so the header never shifts between kinds. */
+.stack-head-lead {
+ flex: 1 1 auto;
+ margin-right: 6px;
+}
+.list.horizontal .stack-head-lead {
+ flex: 0 1 auto;
+ margin-right: 0;
+}
+.image-folder-expanded-top-bar .actions-pill {
+ flex: none;
+}
+/* 12.5px fits titles up to "128 images" (70px) beside the four actions. */
+.stack-head-text .image-folder-expanded-title {
+ font-size: 12.5px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.list.horizontal .stack-head-text {
+ flex-direction: row;
+ align-items: baseline;
+ gap: 6px;
+}
+
+/* ------------------------------ entries ------------------------------ */
+
+.stack-row,
+.stack-tile {
+ position: relative;
+ cursor: grab;
+ user-select: none;
+}
+.stack-row:active,
+.stack-tile:active {
+ cursor: grabbing;
+}
+
+.stack-row-actions {
+ position: absolute;
+ opacity: 0;
+ pointer-events: none;
+ z-index: 2;
+}
+.stack-row:hover .stack-row-actions,
+.stack-tile:hover .stack-row-actions,
+.stack-row:focus-within .stack-row-actions,
+.stack-tile:focus-within .stack-row-actions {
+ opacity: 1;
+ scale: 1;
+ pointer-events: auto;
+}
+
+/* File list: icon or thumbnail, name (2 lines), "kind · size". */
+.stack-items.is-list {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+}
+.stack-row {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ min-height: 52px;
+ padding: 6px 8px 6px 4px;
+ border-radius: 10px;
+ box-sizing: border-box;
+}
+.stack-row:hover {
+ background: rgba(255, 255, 255, 0.06);
+}
+.stack-row-art {
+ flex: none;
+ width: 36px;
+ height: 36px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+.stack-row-art .file-kind-img {
+ /* the frosted icons read pale at this size next to white text */
+ filter: saturate(1.8) contrast(1.06);
+}
+.stack-row-thumb {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ border-radius: 8px;
+ box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
+}
+.stack-row-text {
+ flex: 1;
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+}
+.stack-row-name {
+ font-size: 12.5px;
+ line-height: 16px;
+ font-weight: 500;
+ color: rgba(255, 255, 255, 0.92);
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 2;
+ overflow: hidden;
+ overflow-wrap: anywhere;
+}
+.stack-row-meta {
+ font-size: 10.5px;
+ line-height: 13px;
+ color: rgba(255, 255, 255, 0.45);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.stack-row-kind {
+ font-weight: 600;
+}
+.stack-row .stack-row-actions {
+ right: 6px;
+ top: 50%;
+ translate: 0 -50%;
+}
+/* The text fades out just before the hover pill instead of being cut. */
+.stack-row:is(:hover, :focus-within) .stack-row-text {
+ -webkit-mask-image: linear-gradient(to left, transparent 58px, #000 82px);
+ mask-image: linear-gradient(to left, transparent 58px, #000 82px);
+}
+
+/* Photo grid: two columns; an odd count lets the first photo span both. */
+.stack-items.is-gallery {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 6px;
+ padding: 0 4px;
+}
+.stack-tile {
+ aspect-ratio: 1;
+ border-radius: 10px;
+ overflow: hidden;
+ background: #18181b;
+}
+/* 7+ photos: three columns, so a full stack (10) stays about half as tall. */
+.stack-items.is-gallery:is([data-count="7"], [data-count="8"], [data-count="9"], [data-count="10"]) {
+ grid-template-columns: repeat(3, 1fr);
+}
+.stack-items.is-gallery > .stack-tile:first-child:nth-last-child(odd) {
+ grid-column: 1 / -1;
+ aspect-ratio: 16 / 9;
+}
+/* In three columns the grid ends flush too: 10 = wide + 3 rows, 8 = a double
+ first photo, 9 = plain 3 x 3 (7 = wide + 2 rows, from the rule above). */
+.stack-items.is-gallery[data-count="10"] > .stack-tile:first-child {
+ grid-column: 1 / -1;
+ aspect-ratio: 16 / 9;
+}
+.stack-items.is-gallery[data-count="8"] > .stack-tile:first-child {
+ grid-column: span 2;
+ aspect-ratio: auto;
+}
+.stack-items.is-gallery[data-count="9"] > .stack-tile:first-child {
+ grid-column: auto;
+ aspect-ratio: 1;
+}
+.stack-tile-img {
+ display: block;
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+}
+.stack-tile::after {
+ content: '';
+ position: absolute;
+ inset: 0;
+ border-radius: inherit;
+ box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
+ pointer-events: none;
+}
+.stack-tile:hover::after {
+ box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
+}
+.stack-tile-caption {
+ position: absolute;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 1px;
+ padding: 16px 8px 6px;
+ background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.72));
+ opacity: 0;
+ transition: opacity 0.12s ease;
+ pointer-events: none;
+}
+.stack-tile:hover .stack-tile-caption {
+ opacity: 1;
+}
+.stack-tile-caption .stack-row-name {
+ font-size: 11.5px;
+ line-height: 14px;
+ font-weight: 600;
+ color: #ffffff;
+ -webkit-line-clamp: 1;
+}
+.stack-tile-caption .stack-row-meta {
+ color: rgba(255, 255, 255, 0.72);
+}
+.stack-tile .stack-row-actions {
+ top: 6px;
+ right: 6px;
+}
+
+/* ----------------------------- top dock ------------------------------ */
+/* 96px of height under the header: files flow down two rows, then
+ across; photos sit in one strip. */
+
+.list.horizontal .stack-items.is-list {
+ display: grid;
+ grid-template-rows: repeat(2, 46px);
+ grid-auto-flow: column;
+ grid-auto-columns: minmax(232px, 1fr); /* stackOpenWidth() */
+ gap: 4px 6px;
+}
+.list.horizontal .stack-row {
+ min-height: 0;
+ height: 46px;
+ gap: 8px;
+ padding: 5px 8px 5px 4px;
+}
+.list.horizontal .stack-row-art {
+ width: 30px;
+ height: 30px;
+}
+.list.horizontal .stack-row-thumb {
+ border-radius: 7px;
+}
+.list.horizontal .stack-row-name {
+ font-size: 12px;
+ line-height: 15px;
+ -webkit-line-clamp: 1;
+}
+.list.horizontal .stack-items.is-gallery {
+ display: flex;
+ gap: 6px;
+ height: 96px;
+ padding: 0 4px;
+}
+.list.horizontal .stack-tile,
+.list.horizontal .stack-items.is-gallery > .stack-tile:first-child:nth-last-child(odd) {
+ flex: none;
+ width: 128px; /* stackOpenWidth() */
+ height: 100%;
+ aspect-ratio: auto;
+ border-radius: 9px;
+}
diff --git a/tests/actionPills.test.ts b/tests/actionPills.test.ts
index 84201fe..7fed980 100644
--- a/tests/actionPills.test.ts
+++ b/tests/actionPills.test.ts
@@ -20,7 +20,7 @@ describe('action pills share one look', () => {
})
it('every hover/quick-action container gets the same surface from one rule', () => {
- const shared = css.match(/\.actions,\n\.actions-pill,\n\.act-pill,\n\.mini-image-folder-actions,\n\.fluid-row-actions,\n\.horizontal-subitem-actions \{([^}]*)\}/)?.[1] ?? ''
+ const shared = css.match(/\.actions,\n\.actions-pill,\n\.act-pill,\n\.fluid-row-actions,\n\.horizontal-subitem-actions,\n\.stack-row-actions \{([^}]*)\}/)?.[1] ?? ''
expect(shared).toContain('background: var(--act-surface);')
expect(shared).toContain('border: none;')
expect(shared).toContain('border-radius: 999px;')
@@ -28,10 +28,14 @@ describe('action pills share one look', () => {
})
it('containers only position themselves: no own background, border or size', () => {
- for (const sel of ['.actions', '.mini-image-folder-actions', '.fluid-row-actions', '.flyout-subitem .actions', '.horizontal-subitem-actions', '.list.horizontal .actions']) {
+ for (const sel of ['.actions', '.fluid-row-actions', '.flyout-subitem .actions', '.horizontal-subitem-actions', '.list.horizontal .actions']) {
const body = rule(sel)
expect(body, sel).not.toMatch(/background|border:|box-shadow|padding|will-change/)
}
+ // an open stack's row pill (stack.css) too
+ const row = read('src/styles/stack.css').match(/\n\.stack-row-actions \{([^}]*)\}/)?.[1] ?? ''
+ expect(row).toContain('position: absolute;')
+ expect(row).not.toMatch(/background|border:|box-shadow|padding|will-change/)
})
it('buttons are sized and coloured only through the shared values', () => {
diff --git a/tests/fileIconOpening.test.ts b/tests/fileIconOpening.test.ts
new file mode 100644
index 0000000..3281400
--- /dev/null
+++ b/tests/fileIconOpening.test.ts
@@ -0,0 +1,110 @@
+import { describe, expect, it } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { join } from 'node:path'
+import { fileIconLayers, ICON_LAYER_PARTS } from '../shared/fileIconLayers'
+
+const root = join(__dirname, '..')
+const read = (p: string) => readFileSync(join(root, p), 'utf8')
+const KINDS = ['pdf', 'word', 'excel', 'powerpoint', 'archive', 'text', 'code', 'audio', 'video', 'image', 'executable', 'folder', 'file']
+
+describe('folder icon layers (shared/fileIconLayers)', () => {
+ it('every icon splits into back, three papers and the front pocket', () => {
+ for (const kind of KINDS) {
+ const svg = read(`resources/file-icons/${kind}.svg`)
+ const layers = fileIconLayers(svg)
+ expect(layers, kind).not.toBeNull()
+ const defs = svg.slice(svg.indexOf('<defs>'), svg.indexOf('</defs>') + 7)
+ for (const part of ICON_LAYER_PARTS) {
+ const l = layers![part]
+ expect(l.startsWith(svg.slice(0, svg.indexOf('<defs>'))), `${kind} ${part} keeps the root`).toBe(true)
+ expect(l, `${kind} ${part} keeps every def`).toContain(defs)
+ expect(l.trim().endsWith('</svg>'), `${kind} ${part}`).toBe(true)
+ // balanced groups
+ expect((l.match(/<g\b/g) ?? []).length, `${kind} ${part}`).toBe((l.match(/<\/g>/g) ?? []).length)
+ }
+ // each paper is one rotated sheet; nothing else is drawn with it
+ for (const part of ['paper1', 'paper2', 'paper3'] as const) {
+ const body = layers![part].slice(layers![part].indexOf('</defs>'))
+ expect(body.match(/<g transform="rotate\(/g)?.length, `${kind} ${part}`).toBe(1)
+ expect(body, `${kind} ${part}`).not.toMatch(/mask=|ellipse/)
+ }
+ expect(layers!.back).toMatch(/<use href="#[a-z]+-panel"/)
+ expect(layers!.back.slice(layers!.back.indexOf('</defs>'))).not.toMatch(/mask=|rotate\(/)
+ // the pocket keeps the papers defined (it frosts them through <use>) but does not draw them
+ expect(layers!.front).toMatch(/<defs><g id="[a-z]+-contents">/)
+ expect(layers!.front).toMatch(/<g mask="url\(#[a-z]+-mask\)">/)
+ // together the five draw what the icon draws: same papers, once each
+ const papers = (svg.match(/<g transform="rotate\(/g) ?? []).length
+ expect(papers).toBe(3)
+ }
+ })
+
+ it('an icon without that structure does not split', () => {
+ expect(fileIconLayers('<svg><defs></defs><rect/></svg>')).toBeNull()
+ expect(fileIconLayers('')).toBeNull()
+ })
+})
+
+describe('folder icons open on hover', () => {
+ const css = read('src/styles/item.css').replace(/\/\*[\s\S]*?\*\//g, '')
+ const icon = read('src/components/CustomFileIcon.tsx')
+ const layersLib = read('src/lib/iconLayers.ts')
+
+ it('the opening rules only apply once the layers are armed, and only move them', () => {
+ const open = [...css.matchAll(/([^{}]*:hover[^{}]*\.file-kind-opening[^{}]*)\{([^}]*)\}/g)]
+ expect(open.length).toBeGreaterThanOrEqual(6)
+ for (const [, sel, body] of open) {
+ for (const s of sel.split(',')) expect(s.trim(), s).toContain('.file-kind-opening.is-armed')
+ expect(body, sel).not.toMatch(/filter|opacity|width|height/)
+ }
+ })
+
+ it('papers move in whole --open-u steps; the pocket tips on its bottom edge', () => {
+ expect(css).toMatch(/\.fil-paper1 \{\n translate: var\(--open-u\) calc\(var\(--open-u\) \* -1\);/)
+ expect(css).toMatch(/\.fil-paper2 \{\n translate: 0 calc\(var\(--open-u\) \* -2\);/)
+ expect(css).toMatch(/\.fil-paper3 \{\n translate: calc\(var\(--open-u\) \* -1\) calc\(var\(--open-u\) \* -1\);/)
+ expect(css).toContain('.fil-front {\n transform: translateY(var(--open-u)) perspective(calc(var(--open-u) * 90)) rotateX(-26deg);')
+ expect(css).toMatch(/\.fko-layers > \.fil-front \{\n transform-origin: 50% 83%;/)
+ expect(css).toMatch(/\.file-kind-opening \{\n --open-u: 4px;/)
+ })
+
+ it('at rest the layers are hidden, and they hand back to the plain icon only after closing', () => {
+ expect(css).toMatch(/\.fko-layers \{[^}]*visibility: hidden;[^}]*transition: visibility 0s linear var\(--open-time\);/)
+ expect(css).toMatch(/\.file-kind-opening > \.fko-plain \{[^}]*transition: visibility 0s linear var\(--open-time\);/)
+ })
+
+ it('cheap to show and move: pre-rastered layers, no filter or transform on the wrapper', () => {
+ expect(css).toMatch(/\.file-kind-opening > \.fko-plain,\n\.fko-layers > \.fil \{\n will-change: transform;/)
+ expect(css).toMatch(/\.file-kind-opening \{[^}]*filter: none !important;[^}]*transform: none !important;/)
+ expect(css).toContain("html[data-motion='reduce'] .fko-layers > .fil {\n transition: none;")
+ })
+
+ it('layers are built on the first hover of the card, armed before opening', () => {
+ expect(icon).toContain("card.addEventListener('pointerenter', onEnter, { once: true })")
+ expect(icon).toContain('useIconLayers(kind, cssSize, wanted)')
+ expect(icon).toMatch(/getComputedStyle\(el\)\.visibility\s+setArmed\(true\)/)
+ expect(layersLib).toContain('if (!build) return')
+ // bitmaps drawn by this window at the exact device size
+ expect(layersLib).toContain('new OffscreenCanvas(px, px)')
+ expect(layersLib).toMatch(/Math\.round\(cssSize \* r\)/)
+ })
+
+ it('hover buttons stay a horizontal pill, docked off the opening folder', () => {
+ // never turned into a column: same pill as every other card
+ expect(css).not.toMatch(/actions[^{]*\{[^}]*flex-direction: column/)
+ // shelf and expanded-stack folder cards: on the flap's shoulder, in each dock
+ for (const [sel, bottom] of [
+ ['.item.is-image-folder-card .item-main:has(.file-kind-opening) > .actions', '37px'],
+ ['.list.horizontal .item.is-image-folder-card .item-main:has(.file-kind-opening) > .actions', '28px'],
+ ]) {
+ expect(css, sel).toContain(`\n${sel} {\n top: auto;\n bottom: ${bottom};`)
+ }
+ // the preview keeps the pill in the corner and lowers its grid folders instead
+ expect(css).toContain('.flyout-subitem:not(.single-hero-card) .item-content:has(.file-kind-opening) {\n padding-top: 28px;')
+ })
+
+ it('the window gets icon sources only for the 13 known names', () => {
+ const ipc = read('electron/main/ipc.ts')
+ expect(ipc).toMatch(/handle\('icon:svg', async \(kind\) => \{[\s\S]*?resolveIconAsset\(join\(app\.getAppPath\(\), 'resources', 'file-icons'\), `\$\{kind\}\.svg`\)/)
+ })
+})
diff --git a/tests/fileStacks.test.ts b/tests/fileStacks.test.ts
index 2c58dca..38e774c 100644
--- a/tests/fileStacks.test.ts
+++ b/tests/fileStacks.test.ts
@@ -25,20 +25,35 @@ describe('file icon stacks and hover', () => {
const hover = [...rules('.file-stack-folder'), ...rules('.single-file-hero')].filter(([sel]) => sel.includes(':hover'))
expect(hover.length).toBeGreaterThan(8)
for (const [sel, body] of hover) {
- // the flyout's own hover rules are separate and already transform-only
expect(body, sel).not.toMatch(/filter|box-shadow|opacity/)
- expect(body, sel).toMatch(/transform:/)
+ expect(body, sel).toMatch(/transform:|translate:/)
}
})
- it('only transform is transitioned, and each folder is its own layer', () => {
+ it('pixel-sharp on every screen: layered icons never resize or tilt, and move in whole 4px steps', () => {
+ // hover states only translate: no scale or rotate on a pre-rastered layer
+ const layered = [...rules('.file-stack-folder'), ...rules('.single-file-hero img'), ...rules('.single-file-hero svg')]
+ for (const [sel, body] of layered.filter(([s]) => s.includes(':hover'))) {
+ expect(body, sel).not.toMatch(/scale|rotate/)
+ }
+ for (const [sel, body] of rules('.file-stack-folder')) expect(body, sel).not.toMatch(/rotate/)
+ // every length used to move them is a multiple of 4px
+ const moves = [...rules('.file-stack-folder'), ...rules('.is-file-deck'), ...rules('.single-file-hero')]
+ .flatMap(([, body]) => [...body.matchAll(/(?:translate(?:Y)?\(|translate:|--[a-z-]+:)\s*([^;]*)/g)].map((m) => m[1]))
+ const lengths = moves.flatMap((v) => [...v.matchAll(/(-?\d+(?:\.\d+)?)px/g)].map((m) => Number(m[1])))
+ expect(lengths.length).toBeGreaterThan(20)
+ for (const n of lengths) expect(Math.abs(n % 4), `${n}px`).toBe(0)
+ // no percentages (they land between pixels)
+ for (const v of moves) expect(v, v).not.toMatch(/%/)
+ })
+
+ it('only one property is transitioned, and each folder is its own layer', () => {
const base = rules('.file-stack-folder').find(([sel]) => sel === '.file-stack-folder')![1]
// one property only: the curve's commas are inside cubic-bezier( )
- const onlyTransform = /transition: transform [\d.]+s cubic-bezier\([^)]*\);/
- expect(base).toMatch(onlyTransform)
+ expect(base).toMatch(/transition: translate [\d.]+s cubic-bezier\([^)]*\);/)
expect(base).toContain('will-change: transform')
const hero = rules('.single-file-hero img.file-kind-img').find(([sel]) => sel.startsWith('.single-file-hero svg'))![1]
- expect(hero).toMatch(onlyTransform)
+ expect(hero).toMatch(/transition: transform [\d.]+s cubic-bezier\([^)]*\);/)
expect(hero).toContain('will-change: transform')
})
@@ -52,11 +67,51 @@ describe('file icon stacks and hover', () => {
}
})
- it('file art is centered above the label flap in cards and mini cards', () => {
+ it('file art sits above the flap, leaving the shoulder band for the hover pill', () => {
expect(css).toMatch(/\.image-folder-viewport > \.single-file-hero \{[^}]*padding-bottom: 26px/)
- expect(css).toMatch(/\.list\.horizontal \.image-folder-viewport > \.single-file-hero \{[^}]*padding-bottom: 24px/)
- expect(css).toMatch(/\.mini-image-folder-viewport > \.single-file-hero \{[^}]*padding-bottom: 16px/)
- expect(css).toMatch(/\.image-folder-viewport \.image-folder-stack-deck\.is-file-deck \{[^}]*padding: 8px 0 26px/)
+ expect(css).toMatch(/\.list\.horizontal \.image-folder-viewport > \.single-file-hero \{[^}]*padding-bottom: 34px/)
+ expect(css).toMatch(/\.image-folder-viewport \.image-folder-stack-deck\.is-file-deck \{[^}]*padding: 0 0 36px/)
+ expect(css).toMatch(/\.list\.horizontal \.image-folder-viewport \.image-folder-stack-deck\.is-file-deck \{[^}]*padding: 0 0 34px/)
+ })
+
+ it('file and image cards carry a neutral grain + light on their own pre-rastered layer', () => {
+ const base = rules('.is-textured').find(([sel]) => sel === '.image-folder-viewport.is-textured')!
+ expect(base[1]).toContain('isolation: isolate')
+ const layer = rules('.is-textured::before').find(([sel]) => sel === '.is-textured::before')![1]
+ expect(layer).toContain("url('../assets/grain.png')")
+ expect(layer).toContain('radial-gradient(')
+ expect(layer).toContain('will-change: transform')
+ expect(layer).toContain('z-index: -1')
+ expect(layer).toContain('pointer-events: none')
+ expect(layer).not.toMatch(/filter|animation|transition/)
+ // neutral: only white / black light, never a color
+ for (const m of layer.matchAll(/rgba\((\d+), (\d+), (\d+)/g)) {
+ expect(m[1] === m[2] && m[2] === m[3], m[0]).toBe(true)
+ }
+ expect(css).not.toMatch(/--tint|is-photo|is-mixed/)
+ expect(card.match(/ is-textured/g)?.length).toBe(2)
+ })
+
+ it('hovering a textured card never repaints its texture', () => {
+ // card, inner and flap colors switch in one step (a fade redrew the card every frame)
+ for (const sel of ['.item.is-image-folder-card', '.image-folder-card-inner', '.image-folder-flap-svg path']) {
+ const body = rules(sel).find(([s]) => s === sel)?.[1]
+ expect(body, sel).toBeDefined()
+ expect(body, sel).not.toMatch(/transition/)
+ }
+ // the viewport keeps its base color on hover, and never uses the shorthand
+ expect(css).toContain('.item:not(.is-expanded) .item-main:hover .image-folder-viewport.is-textured {\n background-color: #1b1b1b;')
+ for (const [sel, body] of rules('.image-folder-viewport')) {
+ if (sel.includes(':hover')) expect(body, sel).not.toMatch(/(^|\s)background:/)
+ }
+ })
+
+ it('the grain tile is a small seamless 128px PNG', () => {
+ const png = readFileSync(join(__dirname, '..', 'src', 'assets', 'grain.png'))
+ expect(png.subarray(1, 4).toString()).toBe('PNG')
+ expect(png.readUInt32BE(16)).toBe(128) // width
+ expect(png.readUInt32BE(20)).toBe(128) // height
+ expect(png.length).toBeLessThan(32 * 1024)
})
it('reduced motion turns the stack and hero motion off', () => {
diff --git a/tests/hoverResync.test.ts b/tests/hoverResync.test.ts
new file mode 100644
index 0000000..6d84e7d
--- /dev/null
+++ b/tests/hoverResync.test.ts
@@ -0,0 +1,49 @@
+import { describe, expect, it } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { join } from 'node:path'
+
+const read = (p: string) => readFileSync(join(__dirname, '..', p), 'utf8')
+
+describe('hover follows cards that move under a still pointer', () => {
+ const hook = read('src/hooks/useHoverResync.ts')
+ const win = read('electron/main/window.ts')
+
+ it('re-checks after cards are added, removed or reordered, and when the shelf opens', () => {
+ expect(hook).toContain('observer.observe(root, { childList: true, subtree: true })')
+ expect(hook).toContain('if (s.open && !prev.open) schedule()')
+ expect(hook).toMatch(/RESYNC_DELAYS_MS = \[60, 400\] as const/)
+ // one pending round covers a burst of changes
+ expect(hook).toContain('if (timers.length > 0) return')
+ expect(read('src/App.tsx')).toMatch(/useHoverResync\(/)
+ })
+
+ it('re-checks once a wheel or trackpad scroll settles, not on every scroll step', () => {
+ expect(hook).toContain("doc.addEventListener('scroll', onScroll, { capture: true, passive: true })")
+ expect(hook).toMatch(/window\.clearTimeout\(scrollTimer\)\s+scrollTimer = window\.setTimeout\(fire, SCROLL_SETTLE_MS\)/)
+ expect(hook).toMatch(/SCROLL_SETTLE_MS = 80\b/)
+ expect(hook).toContain("doc.removeEventListener('scroll', onScroll, true)")
+ })
+
+ it('never fires while closed, pressing or dragging', () => {
+ expect(hook).toContain('if (!s.open || pressed || s.dragActive || s.internalDragReq) return')
+ for (const ev of ['pointerdown', 'pointerup', 'pointercancel']) {
+ expect(hook).toContain(`window.addEventListener('${ev}'`)
+ expect(hook).toContain(`window.removeEventListener('${ev}'`)
+ }
+ expect(hook).toContain('observer.disconnect()')
+ })
+
+ it('main sends one mouse move at the cursor, only when it is over the clickable window', () => {
+ const fn = win.match(/export function resyncHover\(\)[\s\S]*?\r?\n\}\r?\n/)?.[0] ?? ''
+ expect(fn).toContain('!interactive) return')
+ expect(fn).toContain('if (x < 0 || y < 0 || x >= b.width || y >= b.height) return')
+ expect(fn).toContain("sendInputEvent({ type: 'mouseMove', x, y })")
+ expect(fn).not.toMatch(/mouseDown|mouseUp|click/)
+ })
+
+ it('is wired through one send channel', () => {
+ expect(read('shared/ipc.ts')).toContain("'window:resync-hover': { args: [] }")
+ expect(read('electron/preload/index.ts')).toContain("resyncHover: () => send('window:resync-hover')")
+ expect(read('electron/main/ipc.ts')).toMatch(/on\('window:resync-hover', \(\) => \{\s+resyncHover\(\)/)
+ })
+})
diff --git a/tests/stackItems.test.ts b/tests/stackItems.test.ts
new file mode 100644
index 0000000..3e6959f
--- /dev/null
+++ b/tests/stackItems.test.ts
@@ -0,0 +1,130 @@
+import { describe, expect, it } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { join } from 'node:path'
+import type { ClipboardItemDto } from '../shared/types'
+import { fileStackEntries, imageCollectionEntries, stackOpenWidth, stackTotalSize } from '../src/components/StackItems'
+import { getFileKind } from '../src/lib/fileType'
+
+const read = (p: string) => readFileSync(join(__dirname, '..', p), 'utf8')
+const t = (k: string) => ({ 'filters.images': 'Images', 'item.copyFilePath': 'Copy file path', 'item.copy': 'Copy' } as Record<string, string>)[k] ?? k
+
+const files = {
+ id: 'f1',
+ capturedAt: Date.now(),
+ hitCount: 1,
+ pinned: false,
+ data: {
+ kind: 'files',
+ paths: ['C:/Docs/Report.pdf', 'C:/Pics/Beach day.png', 'C:/Work/Projects'],
+ entries: [
+ { name: 'Report.pdf', ext: 'pdf', size: 2_000_000, isImage: false },
+ { name: 'Beach day.png', ext: 'png', size: 820_000, isImage: true, preview: 'data:image/png;base64,AA' },
+ { name: 'Projects', ext: '', size: 0, isImage: false, isDirectory: true }
+ ]
+ }
+} as unknown as ClipboardItemDto
+
+const images = {
+ id: 'c1',
+ capturedAt: Date.now(),
+ hitCount: 1,
+ pinned: false,
+ data: {
+ kind: 'image-collection',
+ images: [
+ { imageId: 'a', width: 1920, height: 1080, bytes: 480_000, preview: 'data:a' },
+ { imageId: 'b', width: 800, height: 600, bytes: 20_000, fileName: 'logo.png', preview: 'data:b' }
+ ]
+ }
+} as unknown as ClipboardItemDto
+
+describe('open stack entries', () => {
+ it('every file entry acts on its own real path', () => {
+ const e = fileStackEntries(files, t)
+ expect(e.map((x) => x.req)).toEqual([
+ { id: 'f1', paths: ['C:/Docs/Report.pdf'] },
+ { id: 'f1', paths: ['C:/Pics/Beach day.png'] },
+ { id: 'f1', paths: ['C:/Work/Projects'] }
+ ])
+ })
+
+ it('files show an icon and "kind · size"; pictures a thumbnail; folders no size', () => {
+ const [pdf, photo, folder] = fileStackEntries(files, t)
+ expect(pdf.icon).toEqual({ path: 'C:/Docs/Report.pdf', isDirectory: undefined })
+ expect(pdf.thumb).toBeUndefined()
+ expect(pdf.kindLabel).toBe(getFileKind('C:/Docs/Report.pdf').label.toLowerCase())
+ expect(pdf.detail).toBe('1.9 MB')
+ expect(photo.thumb?.src).toBe('data:image/png;base64,AA')
+ expect(photo.thumb?.fallbackSrc).toBe('edgelocal://file/C%3A%2FPics%2FBeach%20day.png')
+ expect(photo.kindLabel).toBe('png') // the real extension, not the family
+ expect(folder.icon?.isDirectory).toBe(true)
+ expect(folder.detail).toBe('')
+ })
+
+ it('clipboard images act by image id and are named by file name, else size in pixels', () => {
+ const [a, b] = imageCollectionEntries(images, t)
+ expect(a.req).toEqual({ id: 'c1', imageId: 'a' })
+ expect(a.name).toBe('1920×1080')
+ expect(b.name).toBe('logo.png')
+ expect(b.detail).toBe('800×600 · 19.5 KB')
+ expect(a.thumb?.src).toBe('data:a')
+ })
+
+ it('the header shows the total size', () => {
+ expect(stackTotalSize(files)).toBe('2.7 MB')
+ expect(stackTotalSize(images)).toBe('488.3 KB')
+ })
+})
+
+describe('open stack layout', () => {
+ const css = read('src/styles/stack.css')
+ const view = read('src/components/StackItems.tsx')
+
+ it('pictures only -> photo grid, anything else -> list', () => {
+ expect(view).toContain('const gallery = entries.length > 0 && entries.every((e) => e.thumb)')
+ expect(view).toContain("className={`stack-items ${gallery ? 'is-gallery' : 'is-list'}`}")
+ })
+
+ it('top dock width matches the CSS: 128px photo tiles, 232px file columns two rows tall', () => {
+ expect(stackOpenWidth(6, true)).toBe(6 * 128 + 5 * 6 + 8 + 22)
+ expect(stackOpenWidth(9, false)).toBe(5 * 232 + 4 * 6 + 22)
+ expect(stackOpenWidth(4, false)).toBe(2 * 232 + 6 + 22)
+ expect(stackOpenWidth(2, false)).toBe(232 + 22)
+ expect(stackOpenWidth(1, true)).toBe(240) // never narrower than the header needs
+ expect(css).toContain('width: 128px; /* stackOpenWidth() */')
+ expect(css).toContain('grid-auto-columns: minmax(232px, 1fr); /* stackOpenWidth() */')
+ expect(css).toMatch(/\.list\.horizontal \.stack-items\.is-list \{[^}]*grid-template-rows: repeat\(2, 46px\);[^}]*grid-auto-flow: column;/)
+ expect(read('src/components/ClipboardItem.tsx')).toContain('? stackOpenWidth(bundleCount, isImageStack)')
+ })
+
+ it('one left edge: header, list icons and photo grid all start 4px in', () => {
+ expect(css).not.toContain(':has(> .stack-items.is-list) > .image-folder-expanded-top-bar')
+ expect(css).toMatch(/\n\.stack-row \{[^}]*padding: 6px 8px 6px 4px;/)
+ expect(css).toMatch(/\n\.stack-items\.is-gallery \{[^}]*padding: 0 4px;/)
+ expect(read('src/styles/item.css')).toMatch(/\n\.image-folder-expanded-top-bar \{[^}]*padding: 0 0 0 4px;/)
+ })
+
+ it('side dock: names get two lines; an odd photo count lets the first photo span the row', () => {
+ expect(css).toMatch(/\.stack-row-name \{[^}]*-webkit-line-clamp: 2;/)
+ expect(css).toContain('.stack-items.is-gallery > .stack-tile:first-child:nth-last-child(odd) {\n grid-column: 1 / -1;')
+ })
+
+ it('7+ photos use three columns and the grid always ends flush', () => {
+ expect(css).toContain('.stack-items.is-gallery:is([data-count="7"], [data-count="8"], [data-count="9"], [data-count="10"]) {\n grid-template-columns: repeat(3, 1fr);')
+ expect(css).toContain('.stack-items.is-gallery[data-count="10"] > .stack-tile:first-child {\n grid-column: 1 / -1;')
+ expect(css).toContain('.stack-items.is-gallery[data-count="8"] > .stack-tile:first-child {\n grid-column: span 2;')
+ expect(css).toContain('.stack-items.is-gallery[data-count="9"] > .stack-tile:first-child {\n grid-column: auto;')
+ })
+
+ it('hovered rows fade their text before the pill instead of cutting it', () => {
+ expect(css).toMatch(/\.stack-row:is\(:hover, :focus-within\) \.stack-row-text \{[^}]*mask-image: linear-gradient\(to left, transparent 58px, #000 82px\);/)
+ })
+
+ it('the mini cards are gone', () => {
+ const card = read('src/components/ClipboardItem.tsx')
+ expect(card).not.toMatch(/MiniImageFolderCard|MiniFileFolderCard|mini-image-folder/)
+ expect(read('src/styles/item.css')).not.toContain('mini-image-folder')
+ expect(card.match(/<StackHeader/g)?.length).toBe(2)
+ expect(card.match(/<StackItems /g)?.length).toBe(2)
+ })
+})