Contextual Bottom Action Tray & Multi-Select Bar
File & media grid where multi-selection summons a floating bottom contextual action bar with batch operations and undo.
Inspired by Tresorit ↗
WHY THIS AESTHETIC IS UNIQUE
Keeps the default interface calm and clutter-free by revealing bulk management controls only while items are actively selected, anchored right in the thumb zone.
BEST FOR
TAGS
COLOR PALETTE (CLICK TO COPY HEX)
TYPOGRAPHY
- Display
- Plus Jakarta Sans
- Body
- Inter
- Mono
- JetBrains Mono
- Scale
- Clear 14px file titles, 12px mono file sizes, and high-contrast badge counters inside the dark floating action tray.
ARCHITECTURE & MOBILE NOTES
LAYOUT
Responsive 2-column mobile / 4-column desktop media grid with a floating high-contrast dark bottom action bar that slides up smoothly on first selection.
INTERACTION
Tap checkboxes or long-press cards to toggle selection; Select All, Clear, Move, Share, Encrypt, and Delete update state immediately with a reversible Undo toast.
MOBILE
Every action button in the bottom tray is >=44px tall and reachable with one thumb; Escape key clears selection on desktop.
AI AGENT GUARDRAILS
DO
- Display the exact selected count and a quick Clear/Select All control in the contextual bar
- Pair destructive batch actions like Delete with an immediate non-blocking Undo toast
- Provide a clear visual selected ring and checkmark state on every chosen card
DON'T
- Do not hide selection checkboxes entirely on touch devices where hover does not exist
- Do not let the floating action tray cover the bottom row of items without extra scroll padding
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>VaultKeep — Encrypted Cloud Vault & Contextual Multi-Select Tray</title>
<style>
:root {
--canvas: #F4F3F9;
--surface: #FFFFFF;
--ink: #1C162E;
--accent: #6D4AFF;
--accent-hover: #5A36F2;
--accent-soft: #EFEAFF;
--muted: #6B6580;
--border: #E5E1F2;
--tray-bg: #1C162E;
--tray-surface: #2B2344;
--danger: #F43F5E;
--success: #10B981;
--radius: 16px;
--font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
background: var(--canvas);
color: var(--ink);
font-family: var(--font);
line-height: 1.45;
-webkit-font-smoothing: antialiased;
overflow-x: clip;
user-select: none;
-webkit-user-select: none;
}
.vault-shell {
max-width: 1180px;
margin: 0 auto;
padding: 16px 14px 120px;
}
@media (min-width: 768px) {
.vault-shell {
padding: 26px 28px 128px;
}
}
/* Top Bar */
.vault-header {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 18px;
}
.vault-brand {
display: flex;
align-items: center;
gap: 11px;
}
.shield-badge {
width: 40px;
height: 40px;
border-radius: 12px;
background: linear-gradient(145deg, #7C5CFF, #5632E8);
display: grid;
place-items: center;
box-shadow: 0 6px 16px rgba(109, 74, 255, 0.28);
flex-shrink: 0;
}
.vault-brand h1 {
font-size: 1.18rem;
font-weight: 750;
letter-spacing: -0.02em;
}
.vault-brand p {
font-size: 0.78rem;
color: var(--muted);
}
.header-actions {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.folder-pills {
display: flex;
gap: 6px;
overflow-x: auto;
scrollbar-width: none;
margin-bottom: 16px;
padding-bottom: 2px;
}
.folder-pills::-webkit-scrollbar { display: none; }
.folder-pill {
min-height: 44px;
padding: 0 14px;
border-radius: 999px;
border: 1px solid var(--border);
background: var(--surface);
color: var(--muted);
font-size: 0.82rem;
font-weight: 600;
cursor: pointer;
white-space: nowrap;
display: inline-flex;
align-items: center;
gap: 6px;
transition: all 0.16s;
}
.folder-pill.active {
background: var(--accent);
border-color: var(--accent);
color: #FFFFFF;
box-shadow: 0 4px 12px rgba(109, 74, 255, 0.25);
}
.folder-pill .count-tag {
font-size: 0.72rem;
opacity: 0.85;
}
.btn-ghost {
min-height: 44px;
padding: 0 14px;
border-radius: 11px;
border: 1px solid var(--border);
background: var(--surface);
color: var(--ink);
font-size: 0.83rem;
font-weight: 600;
font-family: inherit;
cursor: pointer;
display: inline-flex;
align-items: center;
gap: 7px;
transition: background 0.15s, border-color 0.15s;
}
.btn-ghost:hover {
border-color: #CFC7E8;
background: #FAF9FE;
}
.hint-banner {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
padding: 10px 14px;
border-radius: 12px;
background: var(--accent-soft);
color: #492DC4;
font-size: 0.8rem;
font-weight: 500;
margin-bottom: 16px;
}
/* File Grid */
.vault-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
}
@media (min-width: 640px) {
.vault-grid {
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 14px;
}
}
@media (min-width: 980px) {
.vault-grid {
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 16px;
}
}
.file-card {
background: var(--surface);
border: 2px solid transparent;
border-radius: var(--radius);
overflow: hidden;
box-shadow: 0 2px 10px rgba(28, 22, 46, 0.05);
cursor: pointer;
position: relative;
transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
-webkit-tap-highlight-color: transparent;
}
.file-card:hover {
box-shadow: 0 8px 22px rgba(28, 22, 46, 0.09);
}
.file-card.pressing {
transform: scale(0.96);
}
.file-card.selected {
border-color: var(--accent);
background: #FBF9FF;
box-shadow: 0 6px 20px rgba(109, 74, 255, 0.18);
}
.thumb-area {
position: relative;
aspect-ratio: 4 / 3;
background: #F8F7FC;
display: grid;
place-items: center;
overflow: hidden;
border-bottom: 1px solid var(--border);
}
.thumb-area svg.artwork {
width: 100%;
height: 100%;
display: block;
}
/* 44px Checkbox Hit Area */
.check-hit {
position: absolute;
top: 4px;
left: 4px;
width: 44px;
height: 44px;
border: none;
background: transparent;
cursor: pointer;
display: grid;
place-items: center;
z-index: 2;
}
.check-box {
width: 24px;
height: 24px;
border-radius: 8px;
border: 2px solid rgba(28, 22, 46, 0.28);
background: rgba(255, 255, 255, 0.92);
display: grid;
place-items: center;
color: #FFFFFF;
transition: all 0.15s;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.file-card.selected .check-box {
background: var(--accent);
border-color: var(--accent);
transform: scale(1.06);
}
.lock-chip {
position: absolute;
top: 10px;
right: 10px;
padding: 4px 8px;
border-radius: 999px;
font-size: 0.68rem;
font-weight: 700;
display: inline-flex;
align-items: center;
gap: 4px;
background: rgba(28, 22, 46, 0.78);
color: #FFFFFF;
backdrop-filter: blur(4px);
}
.lock-chip.e2e {
background: rgba(109, 74, 255, 0.92);
}
.file-info {
padding: 11px 12px 13px;
}
.file-name {
font-size: 0.87rem;
font-weight: 700;
color: var(--ink);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-bottom: 3px;
}
.file-meta {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 0.74rem;
color: var(--muted);
}
.folder-tag {
font-size: 0.7rem;
font-weight: 600;
color: #5C4B8A;
background: var(--canvas);
padding: 2px 7px;
border-radius: 6px;
}
/* Floating Dark Contextual Bottom Action Tray */
.action-tray {
position: fixed;
left: 50%;
bottom: 16px;
transform: translate(-50%, 140%);
width: calc(100% - 24px);
max-width: 760px;
background: var(--tray-bg);
color: #FFFFFF;
border-radius: 18px;
padding: 10px 12px;
box-shadow: 0 18px 42px rgba(28, 22, 46, 0.38), 0 0 0 1px rgba(255, 255, 255, 0.08);
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 8px;
z-index: 40;
transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s;
opacity: 0;
pointer-events: none;
}
.action-tray.visible {
transform: translate(-50%, 0);
opacity: 1;
pointer-events: auto;
}
.tray-left {
display: flex;
align-items: center;
gap: 8px;
}
.tray-count {
background: var(--accent);
color: #FFFFFF;
font-size: 0.82rem;
font-weight: 700;
padding: 6px 11px;
border-radius: 10px;
white-space: nowrap;
}
.tray-actions {
display: flex;
align-items: center;
gap: 6px;
flex-wrap: wrap;
}
.tray-btn {
min-height: 44px;
padding: 0 12px;
border: none;
border-radius: 11px;
background: var(--tray-surface);
color: #F4F3F9;
font-size: 0.8rem;
font-weight: 600;
font-family: inherit;
cursor: pointer;
display: inline-flex;
align-items: center;
gap: 6px;
transition: background 0.15s, transform 0.12s;
}
.tray-btn:hover {
background: #3A3059;
}
.tray-btn:active {
transform: scale(0.96);
}
.tray-btn.danger {
background: rgba(244, 63, 94, 0.18);
color: #FDA4AF;
}
.tray-btn.danger:hover {
background: rgba(244, 63, 94, 0.32);
color: #FFFFFF;
}
.tray-close {
min-width: 44px;
min-height: 44px;
padding: 0;
justify-content: center;
background: transparent;
color: #B4ADC9;
}
.tray-close:hover {
background: rgba(255, 255, 255, 0.08);
color: #FFFFFF;
}
/* Toast with Undo */
.toast {
position: fixed;
left: 50%;
bottom: 92px;
transform: translate(-50%, 30px);
background: #141022;
color: #FFFFFF;
padding: 10px 14px;
border-radius: 13px;
box-shadow: 0 12px 28px rgba(15, 10, 30, 0.35);
display: flex;
align-items: center;
gap: 12px;
font-size: 0.84rem;
z-index: 50;
opacity: 0;
pointer-events: none;
transition: opacity 0.2s, transform 0.22s;
max-width: calc(100% - 28px);
}
.toast.show {
opacity: 1;
transform: translate(-50%, 0);
pointer-events: auto;
}
.toast-undo {
min-height: 36px;
padding: 0 12px;
border: none;
border-radius: 8px;
background: var(--accent);
color: #FFFFFF;
font-weight: 700;
font-size: 0.8rem;
cursor: pointer;
}
/* Modal Dialog (Move / Share) */
.modal-backdrop {
position: fixed;
inset: 0;
background: rgba(28, 22, 46, 0.48);
backdrop-filter: blur(3px);
display: none;
place-items: center;
padding: 16px;
z-index: 60;
}
.modal-backdrop.open {
display: grid;
}
.modal-card {
width: 100%;
max-width: 400px;
background: var(--surface);
border-radius: 18px;
padding: 20px;
box-shadow: 0 22px 48px rgba(28, 22, 46, 0.28);
}
.modal-card h2 {
font-size: 1.04rem;
margin-bottom: 6px;
}
.modal-card p {
font-size: 0.84rem;
color: var(--muted);
margin-bottom: 14px;
}
.modal-list {
display: flex;
flex-direction: column;
gap: 8px;
margin-bottom: 14px;
}
.modal-option {
min-height: 46px;
padding: 0 14px;
border-radius: 11px;
border: 1px solid var(--border);
background: var(--canvas);
color: var(--ink);
font-size: 0.88rem;
font-weight: 600;
font-family: inherit;
text-align: left;
cursor: pointer;
display: flex;
align-items: center;
justify-content: space-between;
}
.modal-option:hover {
border-color: var(--accent);
background: var(--accent-soft);
}
.share-box {
display: flex;
gap: 8px;
margin-bottom: 14px;
}
.share-input {
flex: 1;
min-height: 44px;
padding: 0 11px;
border-radius: 10px;
border: 1px solid var(--border);
background: var(--canvas);
font-size: 0.8rem;
color: var(--ink);
font-family: ui-monospace, monospace;
}
.btn-primary {
min-height: 44px;
padding: 0 16px;
border: none;
border-radius: 10px;
background: var(--accent);
color: #FFFFFF;
font-weight: 700;
font-size: 0.84rem;
cursor: pointer;
}
.btn-primary:hover { background: var(--accent-hover); }
.empty-vault {
grid-column: 1 / -1;
text-align: center;
padding: 48px 18px;
background: var(--surface);
border-radius: var(--radius);
border: 1px dashed var(--border);
color: var(--muted);
}
</style>
</head>
<body>
<div class="vault-shell">
<header class="vault-header">
<div class="vault-brand">
<div class="shield-badge" aria-hidden="true">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#FFFFFF" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"></path>
<rect x="9" y="10" width="6" height="5" rx="1"></rect>
<path d="M10 10V8.5a2 2 0 1 1 4 0V10"></path>
</svg>
</div>
<div>
<h1>VaultKeep Drive</h1>
<p>Zero-knowledge encrypted vault · 14.2 GB / 500 GB used</p>
</div>
</div>
<div class="header-actions">
<button id="selectAllTop" class="btn-ghost" type="button">Select All</button>
</div>
</header>
<nav class="folder-pills" id="folderPills" aria-label="Vault folders"></nav>
<div class="hint-banner">
<span>Tap any checkbox or <strong>long-press</strong> a file card to open the contextual action tray.</span>
<span id="selectionSummary">0 selected</span>
</div>
<main id="vaultGrid" class="vault-grid" aria-label="Encrypted files"></main>
</div>
<!-- Floating Dark Contextual Bottom Action Bar -->
<aside id="actionTray" class="action-tray" role="region" aria-label="Bulk actions for selected files">
<div class="tray-left">
<button id="trayClear" class="tray-btn tray-close" type="button" aria-label="Clear selection">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.3" stroke-linecap="round">
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</button>
<span id="trayCount" class="tray-count">0 selected</span>
</div>
<div class="tray-actions">
<button id="actSelectAll" class="tray-btn" type="button">All</button>
<button id="actMove" class="tray-btn" type="button">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/></svg>
Move
</button>
<button id="actShare" class="tray-btn" type="button">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>
Share
</button>
<button id="actEncrypt" class="tray-btn" type="button">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>
<span id="encryptLabel">Lock E2E</span>
</button>
<button id="actDelete" class="tray-btn danger" type="button">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6M14 11v6"/></svg>
Delete
</button>
</div>
</aside>
<!-- Undo Toast -->
<div id="toast" class="toast" role="status" aria-live="polite">
<span id="toastText"></span>
<button id="toastUndo" class="toast-undo" type="button" style="display:none">Undo</button>
</div>
<!-- Move / Share Modal -->
<div id="modalBackdrop" class="modal-backdrop" role="dialog" aria-modal="true">
<div class="modal-card" id="modalContent"></div>
</div>
<script>
(function () {
const FOLDERS = ["All Files", "Personal", "Finance", "Photos", "Keys"];
let files = [
{ id: "f1", name: "Passport_Scan_2026.pdf", folder: "Personal", size: "2.4 MB", date: "Today", encrypted: true, art: "doc-id" },
{ id: "f2", name: "Zurich_Studio_RAW.dng", folder: "Photos", size: "18.6 MB", date: "Yesterday", encrypted: false, art: "photo-mtn" },
{ id: "f3", name: "Q4_Tax_Ledger.xlsx", folder: "Finance", size: "840 KB", date: "May 14", encrypted: true, art: "sheet" },
{ id: "f4", name: "PGP_Master_Backup.asc", folder: "Keys", size: "12 KB", date: "May 10", encrypted: true, art: "key" },
{ id: "f5", name: "Kyoto_Lanterns_04.heic", folder: "Photos", size: "4.1 MB", date: "May 08", encrypted: false, art: "photo-sunset" },
{ id: "f6", name: "Apartment_Lease_Signed.pdf", folder: "Personal", size: "3.2 MB", date: "May 02", encrypted: true, art: "doc-contract" },
{ id: "f7", name: "Hardware_Wallet_Notes.md", folder: "Keys", size: "6 KB", date: "Apr 27", encrypted: true, art: "key" },
{ id: "f8", name: "Equity_Cap_Table.csv", folder: "Finance", size: "194 KB", date: "Apr 19", encrypted: false, art: "sheet" }
];
let activeFolder = "All Files";
const selected = new Set();
let lastDeleted = null;
let toastTimer = null;
const els = {
grid: document.getElementById("vaultGrid"),
folderPills: document.getElementById("folderPills"),
selectAllTop: document.getElementById("selectAllTop"),
selectionSummary: document.getElementById("selectionSummary"),
actionTray: document.getElementById("actionTray"),
trayCount: document.getElementById("trayCount"),
trayClear: document.getElementById("trayClear"),
actSelectAll: document.getElementById("actSelectAll"),
actMove: document.getElementById("actMove"),
actShare: document.getElementById("actShare"),
actEncrypt: document.getElementById("actEncrypt"),
encryptLabel: document.getElementById("encryptLabel"),
actDelete: document.getElementById("actDelete"),
toast: document.getElementById("toast"),
toastText: document.getElementById("toastText"),
toastUndo: document.getElementById("toastUndo"),
modalBackdrop: document.getElementById("modalBackdrop"),
modalContent: document.getElementById("modalContent")
};
function thumbSvg(kind) {
if (kind === "photo-mtn") {
return `<svg class="artwork" viewBox="0 0 240 180" preserveAspectRatio="xMidYMid slice">
<defs><linearGradient id="sky1" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#C7D2FE"/><stop offset="100%" stop-color="#EDE9FE"/></linearGradient></defs>
<rect width="240" height="180" fill="url(#sky1)"/>
<circle cx="182" cy="48" r="18" fill="#FEF3C7"/>
<path d="M0 140 L68 72 L126 128 L168 88 L240 145 L240 180 L0 180 Z" fill="#6D4AFF" opacity="0.28"/>
<path d="M0 154 L88 94 L152 146 L202 110 L240 142 L240 180 L0 180 Z" fill="#4C2DC7" opacity="0.55"/>
</svg>`;
}
if (kind === "photo-sunset") {
return `<svg class="artwork" viewBox="0 0 240 180" preserveAspectRatio="xMidYMid slice">
<defs><linearGradient id="sky2" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#FDE68A"/><stop offset="55%" stop-color="#FCA5A5"/><stop offset="100%" stop-color="#A78BFA"/></linearGradient></defs>
<rect width="240" height="180" fill="url(#sky2)"/>
<circle cx="120" cy="94" r="32" fill="#FFFBEB" opacity="0.9"/>
<rect x="0" y="128" width="240" height="52" fill="#2E1065" opacity="0.45"/>
<rect x="52" y="88" width="18" height="40" rx="2" fill="#1C162E" opacity="0.65"/>
<rect x="166" y="76" width="22" height="52" rx="2" fill="#1C162E" opacity="0.65"/>
</svg>`;
}
if (kind === "sheet") {
return `<svg class="artwork" viewBox="0 0 240 180">
<rect width="240" height="180" fill="#F5F3FF"/>
<rect x="34" y="26" width="172" height="128" rx="10" fill="#FFFFFF" stroke="#DDD6FE" stroke-width="2"/>
<rect x="34" y="26" width="172" height="28" rx="10" fill="#6D4AFF"/>
<rect x="50" y="68" width="44" height="10" rx="3" fill="#C4B5FD"/>
<rect x="104" y="68" width="84" height="10" rx="3" fill="#EDE9FE"/>
<rect x="50" y="92" width="44" height="10" rx="3" fill="#A78BFA"/>
<rect x="104" y="92" width="64" height="10" rx="3" fill="#DDD6FE"/>
<rect x="50" y="116" width="44" height="10" rx="3" fill="#10B981" opacity="0.7"/>
<rect x="104" y="116" width="76" height="10" rx="3" fill="#D1FAE5"/>
</svg>`;
}
if (kind === "key") {
return `<svg class="artwork" viewBox="0 0 240 180">
<rect width="240" height="180" fill="#1E1736"/>
<circle cx="120" cy="90" r="54" fill="#6D4AFF" opacity="0.22"/>
<circle cx="96" cy="90" r="20" fill="none" stroke="#C4B5FD" stroke-width="5"/>
<line x1="116" y1="90" x2="170" y2="90" stroke="#C4B5FD" stroke-width="5" stroke-linecap="round"/>
<line x1="150" y1="90" x2="150" y2="106" stroke="#C4B5FD" stroke-width="5" stroke-linecap="round"/>
<line x1="164" y1="90" x2="164" y2="102" stroke="#C4B5FD" stroke-width="5" stroke-linecap="round"/>
</svg>`;
}
return `<svg class="artwork" viewBox="0 0 240 180">
<rect width="240" height="180" fill="#F4F1FF"/>
<rect x="54" y="22" width="132" height="136" rx="10" fill="#FFFFFF" stroke="#DDD6FE" stroke-width="2"/>
<circle cx="84" cy="54" r="14" fill="#DDD6FE"/>
<rect x="108" y="45" width="56" height="8" rx="4" fill="#6D4AFF"/>
<rect x="108" y="59" width="40" height="6" rx="3" fill="#C4B5FD"/>
<rect x="70" y="86" width="100" height="7" rx="3.5" fill="#E5E1F2"/>
<rect x="70" y="102" width="88" height="7" rx="3.5" fill="#E5E1F2"/>
<rect x="70" y="118" width="68" height="7" rx="3.5" fill="#E5E1F2"/>
</svg>`;
}
function visibleFiles() {
return activeFolder === "All Files" ? files : files.filter((f) => f.folder === activeFolder);
}
function showToast(msg, allowUndo) {
clearTimeout(toastTimer);
els.toastText.textContent = msg;
els.toastUndo.style.display = allowUndo ? "inline-block" : "none";
els.toast.classList.add("show");
toastTimer = setTimeout(() => {
els.toast.classList.remove("show");
}, allowUndo ? 5500 : 3200);
}
function renderFolders() {
els.folderPills.innerHTML = FOLDERS.map((folder) => {
const count = folder === "All Files" ? files.length : files.filter((f) => f.folder === folder).length;
const active = folder === activeFolder;
return `<button class="folder-pill ${active ? "active" : ""}" data-folder="${folder}" type="button">${folder} <span class="count-tag">${count}</span></button>`;
}).join("");
}
function renderTray() {
const count = selected.size;
els.selectionSummary.textContent = count > 0 ? `${count} selected` : "0 selected";
els.trayCount.textContent = `${count} selected`;
els.actionTray.classList.toggle("visible", count > 0);
const vis = visibleFiles();
const allSelected = vis.length > 0 && vis.every((f) => selected.has(f.id));
els.selectAllTop.textContent = allSelected ? "Clear Selection" : "Select All";
els.actSelectAll.textContent = allSelected ? "None" : "All";
// Dynamic lock/unlock label
const selItems = files.filter((f) => selected.has(f.id));
const allLocked = selItems.length > 0 && selItems.every((f) => f.encrypted);
els.encryptLabel.textContent = allLocked ? "Unlock" : "Lock E2E";
}
function renderGrid() {
const list = visibleFiles();
if (list.length === 0) {
els.grid.innerHTML = `<div class="empty-vault"><strong>This folder is empty</strong>Switch folders or restore deleted items via Undo.</div>`;
renderTray();
return;
}
els.grid.innerHTML = list.map((f) => {
const isSel = selected.has(f.id);
return `
<article class="file-card ${isSel ? "selected" : ""}" data-id="${f.id}" tabindex="0" aria-selected="${isSel}">
<div class="thumb-area">
${thumbSvg(f.art)}
<button class="check-hit" data-check="${f.id}" type="button" aria-label="Select ${f.name}">
<span class="check-box">
${isSel ? `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>` : ""}
</span>
</button>
<span class="lock-chip ${f.encrypted ? "e2e" : ""}">
${f.encrypted ? "E2E Locked" : "Standard"}
</span>
</div>
<div class="file-info">
<div class="file-name" title="${f.name}">${f.name}</div>
<div class="file-meta">
<span>${f.size} · ${f.date}</span>
<span class="folder-tag">${f.folder}</span>
</div>
</div>
</article>
`;
}).join("");
renderTray();
}
function toggleSelect(id) {
if (selected.has(id)) selected.delete(id);
else selected.add(id);
renderGrid();
}
function toggleAllVisible() {
const vis = visibleFiles();
const allSelected = vis.length > 0 && vis.every((f) => selected.has(f.id));
if (allSelected) {
vis.forEach((f) => selected.delete(f.id));
} else {
vis.forEach((f) => selected.add(f.id));
}
renderGrid();
}
// Long-press + tap mechanics
let pressTimer = null;
let longPressed = false;
els.grid.addEventListener("pointerdown", (e) => {
const card = e.target.closest(".file-card");
if (!card || e.target.closest(".check-hit")) return;
longPressed = false;
card.classList.add("pressing");
pressTimer = setTimeout(() => {
longPressed = true;
card.classList.remove("pressing");
toggleSelect(card.dataset.id);
if (navigator.vibrate) navigator.vibrate(18);
}, 420);
});
function cancelPress() {
clearTimeout(pressTimer);
document.querySelectorAll(".file-card.pressing").forEach((c) => c.classList.remove("pressing"));
}
els.grid.addEventListener("pointerup", cancelPress);
els.grid.addEventListener("pointerleave", cancelPress);
els.grid.addEventListener("pointercancel", cancelPress);
els.grid.addEventListener("click", (e) => {
const checkBtn = e.target.closest("[data-check]");
if (checkBtn) {
e.stopPropagation();
toggleSelect(checkBtn.dataset.check);
return;
}
const card = e.target.closest(".file-card");
if (!card) return;
if (longPressed) {
longPressed = false;
return;
}
if (selected.size > 0) {
toggleSelect(card.dataset.id);
} else {
const f = files.find((item) => item.id === card.dataset.id);
showToast(`Previewing ${f.name} (${f.encrypted ? "E2E decrypted in memory" : f.size})`, false);
}
});
// Folder filter
els.folderPills.addEventListener("click", (e) => {
const btn = e.target.closest("[data-folder]");
if (!btn) return;
activeFolder = btn.dataset.folder;
renderFolders();
renderGrid();
});
els.selectAllTop.addEventListener("click", toggleAllVisible);
els.actSelectAll.addEventListener("click", toggleAllVisible);
els.trayClear.addEventListener("click", () => {
selected.clear();
renderGrid();
});
// Encrypt / Lock toggle
els.actEncrypt.addEventListener("click", () => {
const selItems = files.filter((f) => selected.has(f.id));
const allLocked = selItems.every((f) => f.encrypted);
selItems.forEach((f) => { f.encrypted = !allLocked; });
showToast(`${selItems.length} item${selItems.length > 1 ? "s" : ""} ${allLocked ? "unlocked" : "sealed with E2E encryption"}`, false);
renderGrid();
});
// Move modal
els.actMove.addEventListener("click", () => {
const count = selected.size;
const targets = FOLDERS.filter((f) => f !== "All Files");
els.modalContent.innerHTML = `
<h2>Move ${count} item${count > 1 ? "s" : ""}</h2>
<p>Choose a destination vault folder:</p>
<div class="modal-list">
${targets.map((t) => `<button class="modal-option" data-dest="${t}" type="button"><span>${t}</span><span>→</span></button>`).join("")}
</div>
<button class="btn-ghost" id="closeModal" type="button" style="width:100%;justify-content:center">Cancel</button>
`;
els.modalBackdrop.classList.add("open");
});
// Share modal
els.actShare.addEventListener("click", () => {
const count = selected.size;
const token = Math.random().toString(36).slice(2, 10).toUpperCase();
const link = `https://vaultkeep.local/s/${token}#k=${Math.random().toString(36).slice(2, 8)}`;
els.modalContent.innerHTML = `
<h2>Encrypted Share Link</h2>
<p>Zero-knowledge link for ${count} selected item${count > 1 ? "s" : ""}. Key stays in the URL hash.</p>
<div class="share-box">
<input class="share-input" id="shareUrl" type="text" readonly value="${link}">
<button class="btn-primary" id="copyShare" type="button">Copy</button>
</div>
<button class="btn-ghost" id="closeModal" type="button" style="width:100%;justify-content:center">Done</button>
`;
els.modalBackdrop.classList.add("open");
});
els.modalBackdrop.addEventListener("click", (e) => {
if (e.target === els.modalBackdrop || e.target.id === "closeModal") {
els.modalBackdrop.classList.remove("open");
return;
}
const destBtn = e.target.closest("[data-dest]");
if (destBtn) {
const dest = destBtn.dataset.dest;
const count = selected.size;
files.forEach((f) => { if (selected.has(f.id)) f.folder = dest; });
selected.clear();
els.modalBackdrop.classList.remove("open");
renderFolders();
renderGrid();
showToast(`Moved ${count} item${count > 1 ? "s" : ""} to ${dest}`, false);
return;
}
if (e.target.id === "copyShare") {
const inp = document.getElementById("shareUrl");
inp.select();
if (navigator.clipboard) navigator.clipboard.writeText(inp.value).catch(() => {});
els.modalBackdrop.classList.remove("open");
showToast("Encrypted share link copied to clipboard", false);
}
});
// Delete + Undo
els.actDelete.addEventListener("click", () => {
const removed = files.filter((f) => selected.has(f.id));
lastDeleted = removed;
files = files.filter((f) => !selected.has(f.id));
selected.clear();
renderFolders();
renderGrid();
showToast(`Deleted ${removed.length} item${removed.length > 1 ? "s" : ""} from vault`, true);
});
els.toastUndo.addEventListener("click", () => {
if (!lastDeleted) return;
files = [...lastDeleted, ...files];
lastDeleted = null;
els.toast.classList.remove("show");
renderFolders();
renderGrid();
showToast("Items restored to vault", false);
});
// Keyboard shortcuts
document.addEventListener("keydown", (e) => {
if (e.key === "Escape") {
els.modalBackdrop.classList.remove("open");
if (selected.size > 0) {
selected.clear();
renderGrid();
}
}
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "a") {
e.preventDefault();
toggleAllVisible();
}
});
renderFolders();
renderGrid();
})();
</script>
</body>
</html>