BlueGit

timfa filemanager

Merge branch 'fix/preview-redesign'

timfa Tim Falken · pushed by timfa

Authored 2026-05-04 · 6 months ago

Hash
7e179f05d6aa1efed51840c6b641abcc5316eafd
5 files changed +29 −359
public/app.js +9 −237
@@ -1546,165 +1546,6 @@ function fileAccentColor (name)
1546 1546 return '#7880a0';
1547 1547 }
1548 1548
1549 function animatePreviewOpen (sourceSvgEl, sheetEl)
1550 {
1551 if (!sourceSvgEl || !sheetEl || !sourceSvgEl.isConnected) return Promise.resolve({ startScale: 0.12 });
1552
1553 const start = sourceSvgEl.getBoundingClientRect();
1554 const end = sheetEl.getBoundingClientRect();
1555 if (!start.width || !start.height || !end.width || !end.height) return Promise.resolve({ startScale: 0.12 });
1556
1557 const ghost = document.createElement('div');
1558 ghost.className = 'preview-ghost';
1559 ghost.style.left = `${start.left}px`;
1560 ghost.style.top = `${start.top}px`;
1561 ghost.style.width = `${start.width}px`;
1562 ghost.style.height = `${start.height}px`;
1563
1564 // Clone before hiding so the ghost is a visible copy
1565 const clone = sourceSvgEl.cloneNode(true);
1566 // Hide source icon for the duration of the preview
1567 sourceSvgEl.style.visibility = 'hidden';
1568 clone.style.width = '100%';
1569 clone.style.height = '100%';
1570 clone.style.display = 'block';
1571 ghost.appendChild(clone);
1572 document.body.appendChild(ghost);
1573
1574 // Bézier path: random control points in viewport space
1575 const vw = window.innerWidth;
1576 const vh = window.innerHeight;
1577 const startCx = start.left + start.width / 2;
1578 const startCy = start.top + start.height / 2;
1579 const endCx = end.left + end.width / 2;
1580 const endCy = end.top + end.height / 2;
1581 const cp1x = startCx + (Math.random() - 0.5) * vw * 0.8;
1582 const cp1y = startCy + (Math.random() - 0.5) * vh * 0.8;
1583 const cp2x = endCx + (Math.random() - 0.5) * vw * 0.6;
1584 const cp2y = endCy + (Math.random() - 0.5) * vh * 0.6;
1585
1586 // Random full rotations: -3 to +3
1587 const totalDeg = (Math.random() * 6 - 3) * 360;
1588 const duration = 640;
1589 const startTime = performance.now();
1590 const startScale = start.width / end.width;
1591
1592 function easeInOut (t) { return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2; }
1593 function bezier1D (p0, p1, p2, p3, t)
1594 {
1595 const u = 1 - t;
1596 return u * u * u * p0 + 3 * u * u * t * p1 + 3 * u * t * t * p2 + t * t * t * p3;
1597 }
1598
1599 return new Promise((resolve) =>
1600 {
1601 function frame (now)
1602 {
1603 const raw = Math.min((now - startTime) / duration, 1);
1604 const t = easeInOut(raw);
1605
1606 const cx = bezier1D(startCx, cp1x, cp2x, endCx, t);
1607 const cy = bezier1D(startCy, cp1y, cp2y, endCy, t);
1608 const w = start.width + (end.width - start.width) * t;
1609 const h = start.height + (end.height - start.height) * t;
1610 const angle = t * totalDeg;
1611 const opacity = raw > 0.82 ? 1 - (raw - 0.82) / 0.18 : 1;
1612
1613 ghost.style.left = `${cx - w / 2}px`;
1614 ghost.style.top = `${cy - h / 2}px`;
1615 ghost.style.width = `${w}px`;
1616 ghost.style.height = `${h}px`;
1617 ghost.style.transform = `rotate(${angle}deg)`;
1618 ghost.style.opacity = opacity;
1619
1620 if (raw < 1)
1621 {
1622 requestAnimationFrame(frame);
1623 } else
1624 {
1625 ghost.remove();
1626 resolve({ startScale });
1627 }
1628 }
1629 requestAnimationFrame(frame);
1630 });
1631 }
1632
1633 function animatePreviewClose (sourceSvgEl, sheetEl)
1634 {
1635 if (!sourceSvgEl || !sheetEl || !sourceSvgEl.isConnected) return Promise.resolve();
1636
1637 const sheetRect = sheetEl.getBoundingClientRect();
1638 const iconRect = sourceSvgEl.getBoundingClientRect();
1639 if (!sheetRect.width || !iconRect.width) return Promise.resolve();
1640
1641 // Ghost starts at sheet center, icon-sized, then flies back to icon
1642 const ghost = document.createElement('div');
1643 ghost.className = 'preview-ghost';
1644
1645 const clone = sourceSvgEl.cloneNode(true);
1646 clone.style.width = '100%';
1647 clone.style.height = '100%';
1648 clone.style.display = 'block';
1649 ghost.appendChild(clone);
1650 document.body.appendChild(ghost);
1651
1652 const vw = window.innerWidth;
1653 const vh = window.innerHeight;
1654 const startCx = sheetRect.left + sheetRect.width / 2;
1655 const startCy = sheetRect.top + sheetRect.height / 2;
1656 const endCx = iconRect.left + iconRect.width / 2;
1657 const endCy = iconRect.top + iconRect.height / 2;
1658
1659 const cp1x = startCx + (Math.random() - 0.5) * vw * 0.6;
1660 const cp1y = startCy + (Math.random() - 0.5) * vh * 0.6;
1661 const cp2x = endCx + (Math.random() - 0.5) * vw * 0.5;
1662 const cp2y = endCy + (Math.random() - 0.5) * vh * 0.5;
1663
1664 const totalDeg = (Math.random() * 6 - 3) * 360;
1665 const duration = 580;
1666 const startTime = performance.now();
1667
1668 function easeInOut (t) { return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2; }
1669 function bezier1D (p0, p1, p2, p3, t)
1670 {
1671 const u = 1 - t;
1672 return u * u * u * p0 + 3 * u * u * t * p1 + 3 * u * t * t * p2 + t * t * t * p3;
1673 }
1674
1675 return new Promise((resolve) =>
1676 {
1677 function frame (now)
1678 {
1679 const raw = Math.min((now - startTime) / duration, 1);
1680 const t = easeInOut(raw);
1681
1682 const cx = bezier1D(startCx, cp1x, cp2x, endCx, t);
1683 const cy = bezier1D(startCy, cp1y, cp2y, endCy, t);
1684 const angle = t * totalDeg;
1685 const opacity = raw < 0.85 ? 1 : 1 - (raw - 0.85) / 0.15;
1686
1687 ghost.style.left = `${cx - iconRect.width / 2}px`;
1688 ghost.style.top = `${cy - iconRect.height / 2}px`;
1689 ghost.style.width = `${iconRect.width}px`;
1690 ghost.style.height = `${iconRect.height}px`;
1691 ghost.style.transform = `rotate(${angle}deg)`;
1692 ghost.style.opacity = opacity;
1693
1694 if (raw < 1)
1695 {
1696 requestAnimationFrame(frame);
1697 } else
1698 {
1699 ghost.remove();
1700 sourceSvgEl.style.visibility = '';
1701 resolve();
1702 }
1703 }
1704 requestAnimationFrame(frame);
1705 });
1706 }
1707
1708 1549 function animateRect (el, fromRect, toRect, opts = {})
1709 1550 {
1710 1551 const duration = opts.duration == null ? 260 : opts.duration;
@@ -1782,6 +1623,7 @@ async function openExpandedTilePreview (item, tileEl, sourceSvgEl, blob, objectU
1782 1623 tileEl.remove();
1783 1624 document.body.appendChild(tileEl);
1784 1625 tileEl.classList.add('file-item--preview');
1626 tileEl.style.setProperty('--preview-accent', fileAccentColor(item.name));
1785 1627 tileEl.style.position = 'fixed';
1786 1628 tileEl.style.left = `${startRect.left}px`;
1787 1629 tileEl.style.top = `${startRect.top}px`;
@@ -1825,7 +1667,10 @@ async function openExpandedTilePreview (item, tileEl, sourceSvgEl, blob, objectU
1825 1667 previewMount.className = 'preview-expand-content';
1826 1668 iconEl.appendChild(previewMount);
1827 1669
1828 await renderPreviewBody(item, blob, objectUrl, previewMount);
1670 // Show spinner during expansion animation; content loads after it finishes
1671 const spinner = document.createElement('div');
1672 spinner.className = 'preview-loading-spinner';
1673 previewMount.appendChild(spinner);
1829 1674
1830 1675 tileEl.insertBefore(titleEl, tileEl.firstChild);
1831 1676 tileEl.appendChild(closeBtn);
@@ -1866,6 +1711,9 @@ async function openExpandedTilePreview (item, tileEl, sourceSvgEl, blob, objectU
1866 1711 tileEl.style.width = `${targetRect.width}px`;
1867 1712 tileEl.style.height = `${targetRect.height}px`;
1868 1713
1714 previewMount.innerHTML = '';
1715 await renderPreviewBody(item, blob, objectUrl, previewMount);
1716
1869 1717 return true;
1870 1718 }
1871 1719
@@ -1918,45 +1766,7 @@ async function closePreview ()
1918 1766 await closeExpandedTilePreview();
1919 1767 clearPreviewObjectUrl();
1920 1768 STATE.previewSourceEl = null;
1921 return;
1922 }
1923
1924 const overlay = document.getElementById('preview-overlay');
1925 const body = document.getElementById('preview-body');
1926 if (!overlay || !body) return;
1927 if (overlay.classList.contains('hidden')) return;
1928 if (STATE.previewClosing) return;
1929 STATE.previewClosing = true;
1930
1931 const sourceSvgEl = STATE.previewSourceEl;
1932 if (sourceSvgEl && sourceSvgEl.isConnected)
1933 {
1934 const sheet = document.getElementById('preview-sheet');
1935 // Shrink the sheet first, then fly ghost back
1936 await new Promise((res) =>
1937 {
1938 const a = sheet.animate(
1939 [{ transform: 'scale(1)', opacity: 1 }, { transform: 'scale(0.06)', opacity: 0 }],
1940 { duration: 180, easing: 'cubic-bezier(0.4, 0, 1, 1)', fill: 'forwards' }
1941 );
1942 a.onfinish = res;
1943 a.oncancel = res;
1944 });
1945 overlay.classList.add('preview-prep');
1946 sheet.style.transform = '';
1947 sheet.style.opacity = '';
1948 await animatePreviewClose(sourceSvgEl, sheet);
1949 } else if (sourceSvgEl)
1950 {
1951 sourceSvgEl.style.visibility = '';
1952 1769 }
1953
1954 overlay.classList.add('hidden');
1955 overlay.classList.remove('preview-prep');
1956 body.innerHTML = '';
1957 clearPreviewObjectUrl();
1958 STATE.previewSourceEl = null;
1959 STATE.previewClosing = false;
1960 1770 }
1961 1771
1962 1772 async function fetchFileBlob (item)
@@ -2088,30 +1898,7 @@ async function downloadOrView (item, sourceSvgEl = null)
2088 1898 if (expanded) return;
2089 1899 }
2090 1900
2091 const overlay = document.getElementById('preview-overlay');
2092 const sheet = document.getElementById('preview-sheet');
2093 const title = document.getElementById('preview-title');
2094 const dlBtn = document.getElementById('preview-download');
2095
2096 sheet.style.setProperty('--preview-accent', fileAccentColor(item.name));
2097 title.textContent = item.name;
2098 dlBtn.onclick = () => triggerDownload(item.name, objectUrl);
2099 await renderPreviewBody(item, blob, objectUrl);
2100
2101 STATE.previewSourceEl = sourceSvgEl || null;
2102 overlay.classList.add('preview-prep');
2103 overlay.classList.remove('hidden');
2104 const { startScale } = await animatePreviewOpen(sourceSvgEl, sheet);
2105 overlay.classList.remove('preview-prep');
2106
2107 // Scale sheet up from the icon's apparent size, driven by JS so the start
2108 // scale matches the actual icon-to-sheet ratio for this specific invocation
2109 const s = (startScale > 0 && startScale < 1) ? startScale : 0.12;
2110 const scaleAnim = sheet.animate(
2111 [{ transform: `scale(${s})`, opacity: 0 }, { transform: 'scale(1)', opacity: 1 }],
2112 { duration: 220, easing: 'cubic-bezier(0.2, 0.9, 0.2, 1.05)', fill: 'forwards' }
2113 );
2114 scaleAnim.onfinish = () => { sheet.style.transform = ''; sheet.style.opacity = ''; };
1901 toast('Preview unavailable — no source tile found.', 'err');
2115 1902 }
2116 1903
2117 1904 // ───────────────────────────────────────────────────────────────────────────
@@ -3162,21 +2949,6 @@ function wireEvents ()
3162 2949 document.getElementById('rename-modal-close').addEventListener('click', () =>
3163 2950 document.getElementById('rename-modal').classList.add('hidden'));
3164 2951
3165 // Preview close
3166 document.getElementById('preview-close').addEventListener('click', closePreview);
3167 document.getElementById('preview-overlay').addEventListener('click', (e) =>
3168 {
3169 if (e.target.id === 'preview-overlay') closePreview();
3170 });
3171
3172 document.addEventListener('keydown', (e) =>
3173 {
3174 if (e.key === 'Escape' && !document.getElementById('preview-overlay').classList.contains('hidden'))
3175 {
3176 closePreview();
3177 }
3178 });
3179
3180 2952 // Close modals on backdrop click
3181 2953 document.querySelectorAll('.modal-overlay').forEach(overlay =>
3182 2954 {
@@ -1546,165 +1546,6 @@ function fileAccentColor (name)
1546 return '#7880a0';
1546 return '#7880a0';
1547}
1547}
1548
1548
1549function animatePreviewOpen (sourceSvgEl, sheetEl)
1550{
1551 if (!sourceSvgEl || !sheetEl || !sourceSvgEl.isConnected) return Promise.resolve({ startScale: 0.12 });
1552
1553 const start = sourceSvgEl.getBoundingClientRect();
1554 const end = sheetEl.getBoundingClientRect();
1555 if (!start.width || !start.height || !end.width || !end.height) return Promise.resolve({ startScale: 0.12 });
1556
1557 const ghost = document.createElement('div');
1558 ghost.className = 'preview-ghost';
1559 ghost.style.left = `${start.left}px`;
1560 ghost.style.top = `${start.top}px`;
1561 ghost.style.width = `${start.width}px`;
1562 ghost.style.height = `${start.height}px`;
1563
1564 // Clone before hiding so the ghost is a visible copy
1565 const clone = sourceSvgEl.cloneNode(true);
1566 // Hide source icon for the duration of the preview
1567 sourceSvgEl.style.visibility = 'hidden';
1568 clone.style.width = '100%';
1569 clone.style.height = '100%';
1570 clone.style.display = 'block';
1571 ghost.appendChild(clone);
1572 document.body.appendChild(ghost);
1573
1574 // Bézier path: random control points in viewport space
1575 const vw = window.innerWidth;
1576 const vh = window.innerHeight;
1577 const startCx = start.left + start.width / 2;
1578 const startCy = start.top + start.height / 2;
1579 const endCx = end.left + end.width / 2;
1580 const endCy = end.top + end.height / 2;
1581 const cp1x = startCx + (Math.random() - 0.5) * vw * 0.8;
1582 const cp1y = startCy + (Math.random() - 0.5) * vh * 0.8;
1583 const cp2x = endCx + (Math.random() - 0.5) * vw * 0.6;
1584 const cp2y = endCy + (Math.random() - 0.5) * vh * 0.6;
1585
1586 // Random full rotations: -3 to +3
1587 const totalDeg = (Math.random() * 6 - 3) * 360;
1588 const duration = 640;
1589 const startTime = performance.now();
1590 const startScale = start.width / end.width;
1591
1592 function easeInOut (t) { return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2; }
1593 function bezier1D (p0, p1, p2, p3, t)
1594 {
1595 const u = 1 - t;
1596 return u * u * u * p0 + 3 * u * u * t * p1 + 3 * u * t * t * p2 + t * t * t * p3;
1597 }
1598
1599 return new Promise((resolve) =>
1600 {
1601 function frame (now)
1602 {
1603 const raw = Math.min((now - startTime) / duration, 1);
1604 const t = easeInOut(raw);
1605
1606 const cx = bezier1D(startCx, cp1x, cp2x, endCx, t);
1607 const cy = bezier1D(startCy, cp1y, cp2y, endCy, t);
1608 const w = start.width + (end.width - start.width) * t;
1609 const h = start.height + (end.height - start.height) * t;
1610 const angle = t * totalDeg;
1611 const opacity = raw > 0.82 ? 1 - (raw - 0.82) / 0.18 : 1;
1612
1613 ghost.style.left = `${cx - w / 2}px`;
1614 ghost.style.top = `${cy - h / 2}px`;
1615 ghost.style.width = `${w}px`;
1616 ghost.style.height = `${h}px`;
1617 ghost.style.transform = `rotate(${angle}deg)`;
1618 ghost.style.opacity = opacity;
1619
1620 if (raw < 1)
1621 {
1622 requestAnimationFrame(frame);
1623 } else
1624 {
1625 ghost.remove();
1626 resolve({ startScale });
1627 }
1628 }
1629 requestAnimationFrame(frame);
1630 });
1631}
1632
1633function animatePreviewClose (sourceSvgEl, sheetEl)
1634{
1635 if (!sourceSvgEl || !sheetEl || !sourceSvgEl.isConnected) return Promise.resolve();
1636
1637 const sheetRect = sheetEl.getBoundingClientRect();
1638 const iconRect = sourceSvgEl.getBoundingClientRect();
1639 if (!sheetRect.width || !iconRect.width) return Promise.resolve();
1640
1641 // Ghost starts at sheet center, icon-sized, then flies back to icon
1642 const ghost = document.createElement('div');
1643 ghost.className = 'preview-ghost';
1644
1645 const clone = sourceSvgEl.cloneNode(true);
1646 clone.style.width = '100%';
1647 clone.style.height = '100%';
1648 clone.style.display = 'block';
1649 ghost.appendChild(clone);
1650 document.body.appendChild(ghost);
1651
1652 const vw = window.innerWidth;
1653 const vh = window.innerHeight;
1654 const startCx = sheetRect.left + sheetRect.width / 2;
1655 const startCy = sheetRect.top + sheetRect.height / 2;
1656 const endCx = iconRect.left + iconRect.width / 2;
1657 const endCy = iconRect.top + iconRect.height / 2;
1658
1659 const cp1x = startCx + (Math.random() - 0.5) * vw * 0.6;
1660 const cp1y = startCy + (Math.random() - 0.5) * vh * 0.6;
1661 const cp2x = endCx + (Math.random() - 0.5) * vw * 0.5;
1662 const cp2y = endCy + (Math.random() - 0.5) * vh * 0.5;
1663
1664 const totalDeg = (Math.random() * 6 - 3) * 360;
1665 const duration = 580;
1666 const startTime = performance.now();
1667
1668 function easeInOut (t) { return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2; }
1669 function bezier1D (p0, p1, p2, p3, t)
1670 {
1671 const u = 1 - t;
1672 return u * u * u * p0 + 3 * u * u * t * p1 + 3 * u * t * t * p2 + t * t * t * p3;
1673 }
1674
1675 return new Promise((resolve) =>
1676 {
1677 function frame (now)
1678 {
1679 const raw = Math.min((now - startTime) / duration, 1);
1680 const t = easeInOut(raw);
1681
1682 const cx = bezier1D(startCx, cp1x, cp2x, endCx, t);
1683 const cy = bezier1D(startCy, cp1y, cp2y, endCy, t);
1684 const angle = t * totalDeg;
1685 const opacity = raw < 0.85 ? 1 : 1 - (raw - 0.85) / 0.15;
1686
1687 ghost.style.left = `${cx - iconRect.width / 2}px`;
1688 ghost.style.top = `${cy - iconRect.height / 2}px`;
1689 ghost.style.width = `${iconRect.width}px`;
1690 ghost.style.height = `${iconRect.height}px`;
1691 ghost.style.transform = `rotate(${angle}deg)`;
1692 ghost.style.opacity = opacity;
1693
1694 if (raw < 1)
1695 {
1696 requestAnimationFrame(frame);
1697 } else
1698 {
1699 ghost.remove();
1700 sourceSvgEl.style.visibility = '';
1701 resolve();
1702 }
1703 }
1704 requestAnimationFrame(frame);
1705 });
1706}
1707
1708function animateRect (el, fromRect, toRect, opts = {})
1549function animateRect (el, fromRect, toRect, opts = {})
1709{
1550{
1710 const duration = opts.duration == null ? 260 : opts.duration;
1551 const duration = opts.duration == null ? 260 : opts.duration;
@@ -1782,6 +1623,7 @@ async function openExpandedTilePreview (item, tileEl, sourceSvgEl, blob, objectU
1782 tileEl.remove();
1623 tileEl.remove();
1783 document.body.appendChild(tileEl);
1624 document.body.appendChild(tileEl);
1784 tileEl.classList.add('file-item--preview');
1625 tileEl.classList.add('file-item--preview');
1626 tileEl.style.setProperty('--preview-accent', fileAccentColor(item.name));
1785 tileEl.style.position = 'fixed';
1627 tileEl.style.position = 'fixed';
1786 tileEl.style.left = `${startRect.left}px`;
1628 tileEl.style.left = `${startRect.left}px`;
1787 tileEl.style.top = `${startRect.top}px`;
1629 tileEl.style.top = `${startRect.top}px`;
@@ -1825,7 +1667,10 @@ async function openExpandedTilePreview (item, tileEl, sourceSvgEl, blob, objectU
1825 previewMount.className = 'preview-expand-content';
1667 previewMount.className = 'preview-expand-content';
1826 iconEl.appendChild(previewMount);
1668 iconEl.appendChild(previewMount);
1827
1669
1828 await renderPreviewBody(item, blob, objectUrl, previewMount);
1670 // Show spinner during expansion animation; content loads after it finishes
1671 const spinner = document.createElement('div');
1672 spinner.className = 'preview-loading-spinner';
1673 previewMount.appendChild(spinner);
1829
1674
1830 tileEl.insertBefore(titleEl, tileEl.firstChild);
1675 tileEl.insertBefore(titleEl, tileEl.firstChild);
1831 tileEl.appendChild(closeBtn);
1676 tileEl.appendChild(closeBtn);
@@ -1866,6 +1711,9 @@ async function openExpandedTilePreview (item, tileEl, sourceSvgEl, blob, objectU
1866 tileEl.style.width = `${targetRect.width}px`;
1711 tileEl.style.width = `${targetRect.width}px`;
1867 tileEl.style.height = `${targetRect.height}px`;
1712 tileEl.style.height = `${targetRect.height}px`;
1868
1713
1714 previewMount.innerHTML = '';
1715 await renderPreviewBody(item, blob, objectUrl, previewMount);
1716
1869 return true;
1717 return true;
1870}
1718}
1871
1719
@@ -1918,45 +1766,7 @@ async function closePreview ()
1918 await closeExpandedTilePreview();
1766 await closeExpandedTilePreview();
1919 clearPreviewObjectUrl();
1767 clearPreviewObjectUrl();
1920 STATE.previewSourceEl = null;
1768 STATE.previewSourceEl = null;
1921 return;
1922 }
1923
1924 const overlay = document.getElementById('preview-overlay');
1925 const body = document.getElementById('preview-body');
1926 if (!overlay || !body) return;
1927 if (overlay.classList.contains('hidden')) return;
1928 if (STATE.previewClosing) return;
1929 STATE.previewClosing = true;
1930
1931 const sourceSvgEl = STATE.previewSourceEl;
1932 if (sourceSvgEl && sourceSvgEl.isConnected)
1933 {
1934 const sheet = document.getElementById('preview-sheet');
1935 // Shrink the sheet first, then fly ghost back
1936 await new Promise((res) =>
1937 {
1938 const a = sheet.animate(
1939 [{ transform: 'scale(1)', opacity: 1 }, { transform: 'scale(0.06)', opacity: 0 }],
1940 { duration: 180, easing: 'cubic-bezier(0.4, 0, 1, 1)', fill: 'forwards' }
1941 );
1942 a.onfinish = res;
1943 a.oncancel = res;
1944 });
1945 overlay.classList.add('preview-prep');
1946 sheet.style.transform = '';
1947 sheet.style.opacity = '';
1948 await animatePreviewClose(sourceSvgEl, sheet);
1949 } else if (sourceSvgEl)
1950 {
1951 sourceSvgEl.style.visibility = '';
1952 }
1769 }
1953
1954 overlay.classList.add('hidden');
1955 overlay.classList.remove('preview-prep');
1956 body.innerHTML = '';
1957 clearPreviewObjectUrl();
1958 STATE.previewSourceEl = null;
1959 STATE.previewClosing = false;
1960}
1770}
1961
1771
1962async function fetchFileBlob (item)
1772async function fetchFileBlob (item)
@@ -2088,30 +1898,7 @@ async function downloadOrView (item, sourceSvgEl = null)
2088 if (expanded) return;
1898 if (expanded) return;
2089 }
1899 }
2090
1900
2091 const overlay = document.getElementById('preview-overlay');
1901 toast('Preview unavailable — no source tile found.', 'err');
2092 const sheet = document.getElementById('preview-sheet');
2093 const title = document.getElementById('preview-title');
2094 const dlBtn = document.getElementById('preview-download');
2095
2096 sheet.style.setProperty('--preview-accent', fileAccentColor(item.name));
2097 title.textContent = item.name;
2098 dlBtn.onclick = () => triggerDownload(item.name, objectUrl);
2099 await renderPreviewBody(item, blob, objectUrl);
2100
2101 STATE.previewSourceEl = sourceSvgEl || null;
2102 overlay.classList.add('preview-prep');
2103 overlay.classList.remove('hidden');
2104 const { startScale } = await animatePreviewOpen(sourceSvgEl, sheet);
2105 overlay.classList.remove('preview-prep');
2106
2107 // Scale sheet up from the icon's apparent size, driven by JS so the start
2108 // scale matches the actual icon-to-sheet ratio for this specific invocation
2109 const s = (startScale > 0 && startScale < 1) ? startScale : 0.12;
2110 const scaleAnim = sheet.animate(
2111 [{ transform: `scale(${s})`, opacity: 0 }, { transform: 'scale(1)', opacity: 1 }],
2112 { duration: 220, easing: 'cubic-bezier(0.2, 0.9, 0.2, 1.05)', fill: 'forwards' }
2113 );
2114 scaleAnim.onfinish = () => { sheet.style.transform = ''; sheet.style.opacity = ''; };
2115}
1902}
2116
1903
2117// ───────────────────────────────────────────────────────────────────────────
1904// ───────────────────────────────────────────────────────────────────────────
@@ -3162,21 +2949,6 @@ function wireEvents ()
3162 document.getElementById('rename-modal-close').addEventListener('click', () =>
2949 document.getElementById('rename-modal-close').addEventListener('click', () =>
3163 document.getElementById('rename-modal').classList.add('hidden'));
2950 document.getElementById('rename-modal').classList.add('hidden'));
3164
2951
3165 // Preview close
3166 document.getElementById('preview-close').addEventListener('click', closePreview);
3167 document.getElementById('preview-overlay').addEventListener('click', (e) =>
3168 {
3169 if (e.target.id === 'preview-overlay') closePreview();
3170 });
3171
3172 document.addEventListener('keydown', (e) =>
3173 {
3174 if (e.key === 'Escape' && !document.getElementById('preview-overlay').classList.contains('hidden'))
3175 {
3176 closePreview();
3177 }
3178 });
3179
3180 // Close modals on backdrop click
2952 // Close modals on backdrop click
3181 document.querySelectorAll('.modal-overlay').forEach(overlay =>
2953 document.querySelectorAll('.modal-overlay').forEach(overlay =>
3182 {
2954 {
public/drag-move.css +17 −2
@@ -106,7 +106,7 @@
106 106 /* .file-item in expanded preview state */
107 107 .file-item.file-item--preview {
108 108 background: var(--surface, #1a1d27) !important;
109 border: 1px solid var(--border, #2e3247) !important;
109 border: 2px solid var(--preview-accent, var(--border, #2e3247)) !important;
110 110 border-radius: 12px !important;
111 111 cursor: default !important;
112 112 user-select: text;
@@ -139,9 +139,10 @@
139 139 width: min(72%, 640px);
140 140 height: min(72%, 640px);
141 141 transform: translate(-50%, -50%);
142 opacity: 0.22;
142 opacity: 0.18;
143 143 pointer-events: none;
144 144 z-index: 1;
145 filter: drop-shadow(0 0 10px var(--preview-accent, transparent));
145 146 }
146 147
147 148 .file-item.file-item--preview .icon .preview-expand-content {
@@ -249,6 +250,20 @@
249 250 opacity: 0.85;
250 251 }
251 252
253 /* Spinner shown inside the expanded tile while content is loading */
254 .preview-loading-spinner {
255 width: 40px;
256 height: 40px;
257 border: 3px solid rgba(255, 255, 255, 0.12);
258 border-top-color: rgba(255, 255, 255, 0.7);
259 border-radius: 50%;
260 animation: preview-spin 0.7s linear infinite;
261 }
262
263 @keyframes preview-spin {
264 to { transform: rotate(360deg); }
265 }
266
252 267 .move-modal {
253 268 width: min(92vw, 760px);
254 269 max-height: min(86vh, 760px);
@@ -106,7 +106,7 @@
106/* .file-item in expanded preview state */
106/* .file-item in expanded preview state */
107.file-item.file-item--preview {
107.file-item.file-item--preview {
108 background: var(--surface, #1a1d27) !important;
108 background: var(--surface, #1a1d27) !important;
109 border: 1px solid var(--border, #2e3247) !important;
109 border: 2px solid var(--preview-accent, var(--border, #2e3247)) !important;
110 border-radius: 12px !important;
110 border-radius: 12px !important;
111 cursor: default !important;
111 cursor: default !important;
112 user-select: text;
112 user-select: text;
@@ -139,9 +139,10 @@
139 width: min(72%, 640px);
139 width: min(72%, 640px);
140 height: min(72%, 640px);
140 height: min(72%, 640px);
141 transform: translate(-50%, -50%);
141 transform: translate(-50%, -50%);
142 opacity: 0.22;
142 opacity: 0.18;
143 pointer-events: none;
143 pointer-events: none;
144 z-index: 1;
144 z-index: 1;
145 filter: drop-shadow(0 0 10px var(--preview-accent, transparent));
145}
146}
146
147
147.file-item.file-item--preview .icon .preview-expand-content {
148.file-item.file-item--preview .icon .preview-expand-content {
@@ -249,6 +250,20 @@
249 opacity: 0.85;
250 opacity: 0.85;
250}
251}
251
252
253/* Spinner shown inside the expanded tile while content is loading */
254.preview-loading-spinner {
255 width: 40px;
256 height: 40px;
257 border: 3px solid rgba(255, 255, 255, 0.12);
258 border-top-color: rgba(255, 255, 255, 0.7);
259 border-radius: 50%;
260 animation: preview-spin 0.7s linear infinite;
261}
262
263@keyframes preview-spin {
264 to { transform: rotate(360deg); }
265}
266
252.move-modal {
267.move-modal {
253 width: min(92vw, 760px);
268 width: min(92vw, 760px);
254 max-height: min(86vh, 760px);
269 max-height: min(86vh, 760px);
public/index.html +0 −13
@@ -250,19 +250,6 @@
250 250 </div>
251 251
252 252 <!-- FILE PREVIEW OVERLAY -->
253 <div id="preview-overlay" class="preview-overlay hidden" role="dialog" aria-modal="true"
254 aria-labelledby="preview-title">
255 <div id="preview-sheet" class="preview-sheet" role="document">
256 <div class="preview-fold" aria-hidden="true"></div>
257 <button id="preview-close" class="preview-close" aria-label="Close preview">✕</button>
258 <h2 id="preview-title" class="preview-title"></h2>
259 <div id="preview-body" class="preview-body"></div>
260 <div class="preview-footer">
261 <button id="preview-download" class="primary">Download</button>
262 </div>
263 </div>
264 </div>
265
266 253 <!-- TOAST -->
267 254 <div id="toast" aria-live="assertive" aria-atomic="true"></div>
268 255
@@ -250,19 +250,6 @@
250 </div>
250 </div>
251
251
252 <!-- FILE PREVIEW OVERLAY -->
252 <!-- FILE PREVIEW OVERLAY -->
253 <div id="preview-overlay" class="preview-overlay hidden" role="dialog" aria-modal="true"
254 aria-labelledby="preview-title">
255 <div id="preview-sheet" class="preview-sheet" role="document">
256 <div class="preview-fold" aria-hidden="true"></div>
257 <button id="preview-close" class="preview-close" aria-label="Close preview">✕</button>
258 <h2 id="preview-title" class="preview-title"></h2>
259 <div id="preview-body" class="preview-body"></div>
260 <div class="preview-footer">
261 <button id="preview-download" class="primary">Download</button>
262 </div>
263 </div>
264 </div>
265
266 <!-- TOAST -->
253 <!-- TOAST -->
267 <div id="toast" aria-live="assertive" aria-atomic="true"></div>
254 <div id="toast" aria-live="assertive" aria-atomic="true"></div>
268
255
public/style.css +2 −107
@@ -625,99 +625,8 @@ button.danger:hover {
625 625 }
626 626
627 627 /* =========================================================
628 FILE PREVIEW OVERLAY
629 ========================================================= */
630 .preview-overlay {
631 position: fixed;
632 inset: 0;
633 z-index: 120;
634 background: rgba(8, 9, 14, 0.82);
635 display: flex;
636 align-items: center;
637 justify-content: center;
638 padding: 2rem;
639 }
640
641 .preview-sheet {
642 --preview-accent: #3fcf8e;
643 position: relative;
644 width: min(94vw, 1100px);
645 height: min(90vh, 860px);
646 border: 2px solid var(--preview-accent);
647 border-radius: 12px;
648 background: linear-gradient(180deg, #151925 0%, #111521 100%);
649 box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
650 display: flex;
651 flex-direction: column;
652 overflow: hidden;
653 }
654
655 .preview-fold {
656 position: absolute;
657 top: 0;
658 right: 0;
659 width: 64px;
660 height: 64px;
661 background: linear-gradient(135deg, #182135 0%, #0f1525 100%);
662 clip-path: polygon(100% 0, 100% 100%, 0 0);
663 border-left: 1px solid var(--preview-accent);
664 border-bottom: 1px solid var(--preview-accent);
665 }
666
667 .preview-prep {
668 opacity: 0;
669 }
670
671 .preview-prep .preview-sheet {
672 opacity: 0;
673 }
674
675 .preview-ghost {
676 position: fixed;
677 z-index: 130;
678 pointer-events: none;
679 display: block;
680 }
681
682 .preview-close {
683 position: absolute;
684 top: 8px;
685 right: 8px;
686 width: 28px;
687 height: 28px;
688 background: transparent;
689 color: #d6deef;
690 border-radius: 999px;
691 font-size: 0.95rem;
692 z-index: 2;
693 }
694
695 .preview-close:hover {
696 background: rgba(255, 255, 255, 0.08);
697 }
698
699 .preview-title {
700 font-size: 1rem;
701 color: var(--text);
702 padding: 0.85rem 1rem;
703 margin: 0;
704 border-bottom: 1px solid var(--border);
705 white-space: nowrap;
706 overflow: hidden;
707 text-overflow: ellipsis;
708 padding-right: 3.5rem;
709 }
710
711 .preview-body {
712 flex: 1;
713 min-height: 0;
714 overflow: auto;
715 display: flex;
716 align-items: center;
717 justify-content: center;
718 padding: 0.9rem;
719 }
720
628 FILE PREVIEW — SHARED MEDIA STYLES
629 ========================================================= */
721 630 .preview-media {
722 631 max-width: 100%;
723 632 max-height: 100%;
@@ -795,20 +704,6 @@ button.danger:hover {
795 704
796 705
797 706 /* =========================================================
798 TOAST
799 ========================================================= */
800 #toast {
801 position: fixed;
802 bottom: 1.5rem;
803 left: 50%;
804 transform: translateX(-50%);
805 z-index: 200;
806 display: flex;
807 flex-direction: column;
808 align-items: center;
809 gap: 0.5rem;
810 pointer-events: none;
811 }
812 707
813 708 .toast-msg {
814 709 background: var(--surface2);
@@ -625,99 +625,8 @@ button.danger:hover {
625}
625}
626
626
627/* =========================================================
627/* =========================================================
628 FILE PREVIEW OVERLAY
628 FILE PREVIEW — SHARED MEDIA STYLES
629 ========================================================= */
629 ========================================================= */
630.preview-overlay {
631 position: fixed;
632 inset: 0;
633 z-index: 120;
634 background: rgba(8, 9, 14, 0.82);
635 display: flex;
636 align-items: center;
637 justify-content: center;
638 padding: 2rem;
639}
640
641.preview-sheet {
642 --preview-accent: #3fcf8e;
643 position: relative;
644 width: min(94vw, 1100px);
645 height: min(90vh, 860px);
646 border: 2px solid var(--preview-accent);
647 border-radius: 12px;
648 background: linear-gradient(180deg, #151925 0%, #111521 100%);
649 box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
650 display: flex;
651 flex-direction: column;
652 overflow: hidden;
653}
654
655.preview-fold {
656 position: absolute;
657 top: 0;
658 right: 0;
659 width: 64px;
660 height: 64px;
661 background: linear-gradient(135deg, #182135 0%, #0f1525 100%);
662 clip-path: polygon(100% 0, 100% 100%, 0 0);
663 border-left: 1px solid var(--preview-accent);
664 border-bottom: 1px solid var(--preview-accent);
665}
666
667.preview-prep {
668 opacity: 0;
669}
670
671.preview-prep .preview-sheet {
672 opacity: 0;
673}
674
675.preview-ghost {
676 position: fixed;
677 z-index: 130;
678 pointer-events: none;
679 display: block;
680}
681
682.preview-close {
683 position: absolute;
684 top: 8px;
685 right: 8px;
686 width: 28px;
687 height: 28px;
688 background: transparent;
689 color: #d6deef;
690 border-radius: 999px;
691 font-size: 0.95rem;
692 z-index: 2;
693}
694
695.preview-close:hover {
696 background: rgba(255, 255, 255, 0.08);
697}
698
699.preview-title {
700 font-size: 1rem;
701 color: var(--text);
702 padding: 0.85rem 1rem;
703 margin: 0;
704 border-bottom: 1px solid var(--border);
705 white-space: nowrap;
706 overflow: hidden;
707 text-overflow: ellipsis;
708 padding-right: 3.5rem;
709}
710
711.preview-body {
712 flex: 1;
713 min-height: 0;
714 overflow: auto;
715 display: flex;
716 align-items: center;
717 justify-content: center;
718 padding: 0.9rem;
719}
720
721.preview-media {
630.preview-media {
722 max-width: 100%;
631 max-width: 100%;
723 max-height: 100%;
632 max-height: 100%;
@@ -795,20 +704,6 @@ button.danger:hover {
795
704
796
705
797/* =========================================================
706/* =========================================================
798 TOAST
799 ========================================================= */
800#toast {
801 position: fixed;
802 bottom: 1.5rem;
803 left: 50%;
804 transform: translateX(-50%);
805 z-index: 200;
806 display: flex;
807 flex-direction: column;
808 align-items: center;
809 gap: 0.5rem;
810 pointer-events: none;
811}
812
707
813.toast-msg {
708.toast-msg {
814 background: var(--surface2);
709 background: var(--surface2);
tests/page.load.test.js +1 −0
@@ -74,6 +74,7 @@ describe('page load smoke test', () =>
74 74 return fetch(new URL(url, baseUrl).toString(), init);
75 75 };
76 76 window.HTMLElement.prototype.focus = function focus () { };
77 window.HTMLCanvasElement.prototype.getContext = () => null;
77 78 window.matchMedia = () => ({ matches: mobile, addListener () { }, removeListener () { }, addEventListener () { }, removeEventListener () { } });
78 79 window.scrollTo = () => { };
79 80
@@ -74,6 +74,7 @@ describe('page load smoke test', () =>
74 return fetch(new URL(url, baseUrl).toString(), init);
74 return fetch(new URL(url, baseUrl).toString(), init);
75 };
75 };
76 window.HTMLElement.prototype.focus = function focus () { };
76 window.HTMLElement.prototype.focus = function focus () { };
77 window.HTMLCanvasElement.prototype.getContext = () => null;
77 window.matchMedia = () => ({ matches: mobile, addListener () { }, removeListener () { }, addEventListener () { }, removeEventListener () { } });
78 window.matchMedia = () => ({ matches: mobile, addListener () { }, removeListener () { }, addEventListener () { }, removeEventListener () { } });
78 window.scrollTo = () => { };
79 window.scrollTo = () => { };
79
80