Explorateur : vue Galerie, panneau Détails et tri

Troisième vue de l'explorateur : il couvre toute la zone de travail,
dossiers en cartes et schémas en grandes tuiles (miniature 640 px, nom
complet, date relative et dernier auteur, taille, versions, partages,
compteurs d'éléments, tags). Le panneau Détails (bouton ⓘ ou menu)
affiche création, dimensions, fond, cadres, dernières versions et liens
de partage. Ouvrir un schéma referme la galerie ; ☰ ou Échap y ramène.
Tri par nom, date de modification ou taille dans toutes les vues.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PbFY8ZmoErQdPvgvAN3MBU
This commit is contained in:
claude BotandClaude Opus 5.5 committed 2026-10-19 12:59:25 +02:00
1 parent ef76967aa2
commit 99b088acf6
9 files changed
+1294 -213

No files matched your search

+18 -9
View File
@@ -15,7 +15,7 @@ import type {
} from "@excalidraw/excalidraw/types";
import type { OrderedExcalidrawElement } from "@excalidraw/excalidraw/element/types";
import { api, ApiError, basename, displayPath, stripExt, type Settings } from "./api";
import { Explorer } from "./Explorer";
import { Explorer, initialView, type View } from "./Explorer";
import { CloseIcon, HistoryIcon, MenuIcon, MoonIcon, PinIcon, SaveIcon, SettingsIcon, ShareIcon, SunIcon, UpdateIcon } from "./icons";
import { ShareDialog } from "./ShareDialog";
import { HistoryDialog } from "./HistoryDialog";
@@ -97,8 +97,11 @@ export default function App() {
const [scene, setScene] = useState<Scene | null>(null);
const [saveState, setSaveState] = useState<SaveState>("saved");
const [pinned, setPinned] = useState(initialPinned);
// Non épinglé : ouvert d'office tant qu'aucun schéma n'est demandé.
const [drawerOpen, setDrawerOpen] = useState(() => !isMobile() && (pinned || !pathFromHash()));
// Vue Galerie : l'explorateur couvre toute la zone de travail, comme un panneau
// flottant (il se referme à l'ouverture d'un schéma).
const [gallery, setGallery] = useState(() => initialView() === "gallery");
// Non épinglé ou Galerie : ouvert d'office tant qu'aucun schéma n'est demandé.
const [drawerOpen, setDrawerOpen] = useState(() => !isMobile() && ((pinned && !gallery) || !pathFromHash()));
const [instant, setInstant] = useState(false); // bascule sans animation de la grille
const [refreshKey, setRefreshKey] = useState(0);
const [loadError, setLoadError] = useState<string | null>(null);
@@ -126,6 +129,8 @@ export default function App() {
const openRef = useRef<(path: string, opts?: { skipFlush?: boolean }) => Promise<void>>(async () => {});
const pinnedRef = useRef(pinned);
pinnedRef.current = pinned;
const galleryRef = useRef(gallery);
galleryRef.current = gallery;
const peek = useRef<"hover" | "click" | null>(null); // comment le panneau non épinglé a été ouvert
const peekTimer = useRef<number>(undefined);
const scrollShift = useRef(0); // décalage du canevas à compenser après une bascule épinglé/non épinglé
@@ -240,7 +245,7 @@ export default function App() {
setSaveState("saved");
if (location.hash !== `#/${path}`) history.replaceState(null, "", `#/${encodeURI(path)}`);
store("lastScene", path);
if (isMobile() || !pinnedRef.current) setDrawerOpen(false);
if (isMobile() || !pinnedRef.current || galleryRef.current) setDrawerOpen(false);
} catch (e) {
setLoadError(`Impossible d'ouvrir « ${path} » : ${e instanceof Error ? e.message : e}`);
}
@@ -254,8 +259,8 @@ export default function App() {
excalidraw.current = null;
setScene(null);
history.replaceState(null, "", location.pathname);
// Non épinglé : l'explorateur revient pour choisir le schéma suivant.
if (!pinnedRef.current && !isMobile()) {
// Non épinglé ou Galerie : l'explorateur revient pour choisir le schéma suivant.
if ((!pinnedRef.current || galleryRef.current) && !isMobile()) {
peek.current = "click";
setDrawerOpen(true);
}
@@ -431,7 +436,10 @@ export default function App() {
return () => cancelAnimationFrame(id);
}, [pinned, instant]);
const floating = !pinned && drawerOpen;
// Panneau par-dessus le schéma : non épinglé, ou Galerie quand un schéma est ouvert.
const floating = drawerOpen && (!pinned || (gallery && !!scene));
const onViewChange = useCallback((v: View) => setGallery(v === "gallery"), []);
const peekOpen = () => {
clearTimeout(peekTimer.current);
@@ -517,7 +525,7 @@ export default function App() {
return (
<div
className={`app ${drawerOpen ? "drawer-open" : ""} ${pinned ? "pinned" : "unpinned"} ${resizing ? "resizing" : ""} ${instant ? "instant" : ""} ${scene ? "has-scene" : ""}`}
className={`app ${drawerOpen ? "drawer-open" : ""} ${pinned ? "pinned" : "unpinned"} ${gallery ? "gallery" : ""} ${resizing ? "resizing" : ""} ${instant ? "instant" : ""} ${scene ? "has-scene" : ""}`}
style={{ "--drawer-w": `${drawerWidth}px` } as CSSProperties}
>
<header className="topbar">
@@ -626,6 +634,7 @@ export default function App() {
onDeleted={onDeleted}
onHistory={showHistory}
onShare={setShareFor}
onViewChange={onViewChange}
toolbarEnd={
<button
className={`icon-btn pin-btn ${pinned ? "on" : ""}`}
@@ -652,7 +661,7 @@ export default function App() {
onReset={() => setDrawerWidth(clampDrawer(DRAWER_DEFAULT))}
/>
<div className="backdrop" onClick={() => setDrawerOpen(false)} />
{!pinned && !drawerOpen && (
{!pinned && !drawerOpen && !gallery && (
<div className="peek-edge" aria-hidden onMouseEnter={peekOpen} onMouseLeave={peekCancel} />
)}
+201
View File
@@ -0,0 +1,201 @@
import { useEffect, useState } from "react";
import { api, dirname, displayPath, stripExt, type Hit, type Share, type Version } from "./api";
import { fmtDate, fmtRelative, fmtSize, plural, who } from "./format";
import { CloseIcon, FolderIcon, HistoryIcon, ShareIcon, StarFilledIcon, StarIcon } from "./icons";
import { Thumb } from "./Thumb";
import { expectedThumb } from "./thumbs";
interface Props {
entry: Hit;
onOpen: (path: string) => void;
onLocate: (dir: string) => void;
onHistory: (path: string) => void;
onShare: (path: string) => void;
onFavorite: (e: Hit) => void;
onTag: (tag: string) => void;
onClose: () => void;
}
const LAST_VERSIONS = 5;
/** Panneau Détails de la vue Galerie : métadonnées complètes d'un schéma. */
export function DetailsPanel({ entry: e, onOpen, onLocate, onHistory, onShare, onFavorite, onTag, onClose }: Props) {
const [versions, setVersions] = useState<Version[] | null>(null);
const [shares, setShares] = useState<Share[] | null>(null);
const d = e.details ?? {};
// Versions et liens : relus quand le schéma change (modTime) ou qu'on en change.
useEffect(() => {
let live = true;
setVersions(null);
setShares(null);
api.history(e.path).then((v) => live && setVersions(v), () => live && setVersions([]));
api.shares(e.path).then((s) => live && setShares(s), () => live && setShares([]));
return () => {
live = false;
};
}, [e.path, e.modTime]);
const content = [
d.elements ? plural(d.elements, "élément") : "vide",
d.texts ? plural(d.texts, "texte") : "",
d.arrows ? plural(d.arrows, "flèche") : "",
d.images ? plural(d.images, "image") : "",
d.frames ? plural(d.frames, "cadre") : "",
].filter(Boolean);
const location = displayPath(dirname(e.path)) || "Racine";
return (
<aside className="details-panel" aria-label="Détails du schéma">
<div className="details-head">
<h3 title={e.name}>{stripExt(e.name)}</h3>
<button className="icon-btn" onClick={onClose} aria-label="Fermer les détails" title="Fermer (Échap)">
<CloseIcon />
</button>
</div>
<button className="details-shot" onClick={() => onOpen(e.path)} title="Ouvrir le schéma">
<Thumb path={e.path} version={e.modTime} minSize={expectedThumb(d.width, d.height)} />
</button>
<button className="details-where" onClick={() => onLocate(dirname(e.path))} title="Ouvrir l'emplacement">
<FolderIcon size={14} />
{location}
</button>
<div className="details-actions">
<button className="primary" onClick={() => onOpen(e.path)}>
Ouvrir
</button>
<button onClick={() => onShare(e.path)}>
<ShareIcon />
Partager
</button>
<button onClick={() => onHistory(e.path)}>
<HistoryIcon />
Historique
</button>
<button
className="square"
onClick={() => onFavorite(e)}
title={e.favorite ? "Retirer des favoris" : "Ajouter aux favoris"}
aria-label={e.favorite ? "Retirer des favoris" : "Ajouter aux favoris"}
aria-pressed={!!e.favorite}
>
{e.favorite ? <StarFilledIcon /> : <StarIcon />}
</button>
</div>
<dl>
<dt>Modifié</dt>
<dd>
{fmtDate(e.modTime)} <span className="muted">({fmtRelative(e.modTime)})</span>
{who(e.editedBy) && <span className="muted"> par {e.editedBy}</span>}
</dd>
{d.created && (
<>
<dt>Créé</dt>
<dd>
{fmtDate(d.created)}
{who(d.createdBy) ? (
<span className="muted"> par {d.createdBy}</span>
) : (
<span className="muted" title="Date de la plus ancienne version conservée">
{" "}
(plus ancienne version)
</span>
)}
</dd>
</>
)}
<dt>Taille</dt>
<dd>{fmtSize(e.size)}</dd>
<dt>Contenu</dt>
<dd>{content.join(", ")}</dd>
{!!d.width && !!d.height && (
<>
<dt>Dimensions</dt>
<dd>
{d.width.toLocaleString()} × {d.height.toLocaleString()} px
</dd>
</>
)}
{d.background && (
<>
<dt>Fond</dt>
<dd className="swatch-line">
<span className="swatch" style={{ background: d.background }} />
{d.background}
</dd>
</>
)}
{!!e.tags?.length && (
<>
<dt>Tags</dt>
<dd className="tags">
{e.tags.map((t) => (
<button key={t} className="chip" onClick={() => onTag(t)} title={`Filtrer sur « ${t} »`}>
{t}
</button>
))}
</dd>
</>
)}
</dl>
{!!d.frameNames?.length && (
<section>
<h4>Cadres</h4>
<ul>
{d.frameNames.map((f, i) => (
<li key={i}>{f}</li>
))}
{(d.frames ?? 0) > d.frameNames.length && (
<li className="muted">et {d.frames! - d.frameNames.length} autres</li>
)}
</ul>
</section>
)}
<section>
<h4>Versions{versions && versions.length > 0 ? ` (${versions.length})` : ""}</h4>
{versions === null ? (
<p className="muted">Chargement…</p>
) : versions.length === 0 ? (
<p className="muted">Aucune version enregistrée</p>
) : (
<ul>
{versions.slice(0, LAST_VERSIONS).map((v) => (
<li key={v.id}>
<span>{fmtDate(v.time)}</span>
<span className="muted">{fmtSize(v.size)}</span>
</li>
))}
{versions.length > LAST_VERSIONS && (
<li>
<button className="link" onClick={() => onHistory(e.path)}>
Tout l'historique…
</button>
</li>
)}
</ul>
)}
</section>
<section>
<h4>Partages actifs{shares && shares.length > 0 ? ` (${shares.length})` : ""}</h4>
{shares === null ? (
<p className="muted">Chargement…</p>
) : shares.length === 0 ? (
<p className="muted">Aucun lien de partage</p>
) : (
<ul>
{shares.map((s) => (
<li key={s.id}>
<span title={api.shareUrl(s.token)}>Créé le {fmtDate(s.created)}</span>
<span className="muted">{s.expires ? `expire le ${fmtDate(s.expires)}` : "sans expiration"}</span>
</li>
))}
</ul>
)}
</section>
</aside>
);
}
+456 -194
View File
@@ -19,6 +19,8 @@ import {
type TagCount,
} from "./api";
import {
ArrowIcon,
ClockIcon,
CloseIcon,
DeselectIcon,
CopyIcon,
@@ -30,18 +32,26 @@ import {
FolderIcon,
FolderPlusIcon,
FolderUploadIcon,
FrameIcon,
GalleryIcon,
GridIcon,
HistoryIcon,
InfoIcon,
ListIcon,
MoveIcon,
PhotoIcon,
RefreshIcon,
RestoreIcon,
SearchIcon,
SelectAllIcon,
ShapesIcon,
ShareIcon,
SizeIcon,
SortIcon,
StarFilledIcon,
StarIcon,
TagIcon,
TextIcon,
TrashFullIcon,
TrashIcon,
UpIcon,
@@ -49,12 +59,15 @@ import {
UserIcon,
} from "./icons";
import { ActionMenu } from "./ActionMenu";
import { DetailsPanel } from "./DetailsPanel";
import { fmtDate, fmtRelative, fmtSize, plural, who } from "./format";
import { FolderGlyph } from "./folderIcons";
import { IconDialog } from "./IconDialog";
import { collectDrop, collectFiles, hasFiles, type Collected } from "./importer";
import { MoveDialog } from "./MoveDialog";
import { TagsDialog } from "./TagsDialog";
import { Thumb } from "./Thumb";
import { expectedThumb } from "./thumbs";
export const EMPTY_SCENE = JSON.stringify({
type: "excalidraw",
@@ -81,38 +94,64 @@ interface Props {
onShare: (path: string) => void;
/** Contenu ajouté au bout de la barre de recherche (bouton d'épinglage du panneau). */
toolbarEnd?: ReactNode;
/** Changement de vue : la Galerie occupe toute la zone de travail (App). */
onViewChange?: (view: View) => void;
}
type View = "list" | "grid";
/** Vignettes, liste, ou Galerie (grandes tuiles avec métadonnées, pleine largeur). */
export type View = "list" | "grid" | "gallery";
const fmtDate = (iso: string) =>
new Date(iso).toLocaleString(undefined, { dateStyle: "short", timeStyle: "short" });
const fmtSize = (n: number) =>
n < 1024 ? `${n} o` : n < 1 << 20 ? `${(n / 1024).toFixed(1)} Ko` : `${(n / (1 << 20)).toFixed(1)} Mo`;
const plural = (n: number, word: string) => `${n} ${word}${n > 1 ? "s" : ""}`;
/** Tri de l'affichage : nom (ordre du serveur), date de modification ou taille. */
type Sort = "name" | "modified" | "size";
const DND_TYPE = "application/x-excalidraw-paths";
const initialView = (): View => {
const stored = <T extends string>(key: string, allowed: readonly T[], fallback: T): T => {
try {
return localStorage.getItem("explorerView") === "list" ? "list" : "grid";
const v = localStorage.getItem(key) as T | null;
return v && allowed.includes(v) ? v : fallback;
} catch {
return "grid";
return fallback;
}
};
export const initialView = () => stored<View>("explorerView", ["list", "grid", "gallery"], "grid");
const initialSort = () => stored<Sort>("explorerSort", ["name", "modified", "size"], "name");
/** Rang d'affichage : dossiers virtuels, puis dossiers, puis schémas. */
const rank = (e: Entry) => (e.special ? 0 : e.isDir ? 1 : 2);
const sortEntries = <T extends Entry>(list: T[], sort: Sort): T[] => {
if (sort === "name") return list; // ordre du serveur (nom ; pertinence pour une recherche)
const by =
sort === "modified"
? (a: T, b: T) => Date.parse(b.modTime) - Date.parse(a.modTime)
: (a: T, b: T) => (a.isDir ? 0 : b.size - a.size);
return [...list].sort((a, b) => rank(a) - rank(b) || (a.special ? 0 : by(a, b)));
};
/** Un élément peut-il être déplacé dans targetDir ? (pas sur place, pas dans lui-même) */
const canMoveInto = (path: string, targetDir: string) =>
dirname(path) !== targetDir && targetDir !== path && !targetDir.startsWith(path + "/");
export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHistory, onShare, toolbarEnd }: Props) {
export function Explorer({
current,
refreshKey,
onOpen,
onMoved,
onDeleted,
onHistory,
onShare,
toolbarEnd,
onViewChange,
}: Props) {
const [dir, setDir] = useState(() => (current ? dirname(current) : ""));
const [entries, setEntries] = useState<Entry[]>([]);
const [query, setQuery] = useState("");
const [results, setResults] = useState<Hit[] | null>(null);
const [view, setView] = useState<View>(initialView);
const [sort, setSort] = useState<Sort>(initialSort);
const [inspect, setInspect] = useState<string | null>(null); // schéma du panneau Détails (Galerie)
const [selected, setSelected] = useState<Set<string>>(new Set());
const [anchor, setAnchor] = useState<string | null>(null); // origine d'une sélection Maj+clic
const [menu, setMenu] = useState<{ entry: Hit; anchor: HTMLElement } | null>(null); // menu « … » ouvert
@@ -132,6 +171,8 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
const stay = useRef<string | null>(null); // schéma ouvert depuis Favoris : on reste dans Favoris
const list = results ?? entries;
const shown = sortEntries(list, sort);
const gallery = view === "gallery";
const filter = { tag: tagFilter };
const filtering = query.trim() !== "" || tagFilter !== null;
// Dossier Favoris : des liens vers les originaux, ni création ni déplacement.
@@ -143,6 +184,7 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
const closeMenu = useCallback(() => setMenu(null), []);
// La liste change de forme : le bouton « … » d'origine disparaît.
useEffect(closeMenu, [view, dir, results, closeMenu]);
useEffect(() => setInspect(null), [dir, results === null, view]);
const guard = useCallback(async (fn: () => Promise<unknown>) => {
setError(null);
@@ -156,7 +198,7 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
const refresh = useCallback(
() =>
guard(async () => {
const [next, tagList] = await Promise.all([api.list(dir), api.tags()]);
const [next, tagList] = await Promise.all([api.list(dir, gallery), api.tags()]);
setEntries(next);
setTags(tagList);
// Tag filtré qui n'existe plus : filtre retiré.
@@ -169,7 +211,7 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
return new Set([...s].filter((p) => still.has(p)));
});
}),
[dir, guard],
[dir, gallery, guard],
);
useEffect(() => {
@@ -194,15 +236,15 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
setResults(null);
return;
}
const t = setTimeout(() => guard(async () => setResults(await api.search(query, filter))), 250);
const t = setTimeout(() => guard(async () => setResults(await api.search(query, filter, gallery))), 250);
return () => clearTimeout(t);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [query, tagFilter, guard, refreshKey]);
}, [query, tagFilter, guard, refreshKey, gallery]);
/** Recharge le dossier et, si une recherche est affichée, ses résultats. */
const reload = async () => {
await refresh();
if (filtering) setResults(await api.search(query, filter));
if (filtering) setResults(await api.search(query, filter, gallery));
};
// Délai de purge, affiché dans la poubelle (réglé dans les paramètres).
@@ -220,7 +262,16 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
} catch {
/* stockage indisponible */
}
}, [view]);
onViewChange?.(view);
}, [view, onViewChange]);
useEffect(() => {
try {
localStorage.setItem("explorerSort", sort);
} catch {
/* stockage indisponible */
}
}, [sort]);
// --- Sélection -----------------------------------------------------------
@@ -247,7 +298,7 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
setSelected((s) => new Set([...s, ...paths.slice(lo, hi + 1)]));
};
const selectable = list.filter((e) => !e.special);
const selectable = shown.filter((e) => !e.special);
const selectAll = () => setSelected(new Set(selectable.map((e) => e.path)));
const onItemClick = (ev: MouseEvent, e: Entry) => {
@@ -269,7 +320,10 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
const onKeyDown = (ev: KeyboardEvent) => {
if ((ev.target as HTMLElement).tagName === "INPUT") return;
if (ev.key === "Escape" && selected.size > 0) {
if (ev.key === "Escape" && inspect) {
ev.preventDefault();
setInspect(null);
} else if (ev.key === "Escape" && selected.size > 0) {
ev.preventDefault();
clearSelection();
} else if ((ev.ctrlKey || ev.metaKey) && ev.key.toLowerCase() === "a") {
@@ -548,7 +602,7 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
},
};
const big = view === "grid" ? 40 : 20;
const big = view === "grid" ? 40 : gallery ? 28 : 20;
const icon = (e: Entry) =>
e.special ? (
<span className={`icon special ${e.special} ${e.count ? "full" : ""}`} aria-hidden>
@@ -583,6 +637,7 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
// Dans Favoris : actions sur l'original, retrait du lien à la place de la suppression.
const favActions = (e: Entry) => (
<>
{detailsAction(e)}
{!e.broken && (
<>
<button role="menuitem" onClick={() => setDir(dirname(e.path))}>
@@ -631,8 +686,19 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
</>
);
const detailsAction = (e: Entry) =>
gallery &&
!e.isDir &&
!e.broken && (
<button role="menuitem" onClick={() => setInspect(e.path)}>
<InfoIcon />
Détails
</button>
);
const actions = (e: Entry) => (
<>
{detailsAction(e)}
<button role="menuitem" onClick={() => rename(e)}>
<EditIcon />
Renommer
@@ -690,41 +756,86 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
</>
);
const item = (e: Hit) => {
const isSel = selected.has(e.path);
const cls = [
const itemClass = (e: Hit) =>
[
"item",
e.isDir ? "dir" : "file",
e.path === current ? "active" : "",
isSel ? "selected" : "",
selected.has(e.path) ? "selected" : "",
e.special ? "special" : "",
e.broken ? "broken" : "",
dropTarget === e.path ? "drop" : "",
].join(" ");
const checkbox = (e: Hit) =>
!e.special && (
<input
type="checkbox"
className="check"
checked={selected.has(e.path)}
aria-label={`Sélectionner ${e.name}`}
onClick={(ev) => {
ev.stopPropagation();
if (ev.shiftKey) {
ev.preventDefault();
selectRange(e.path);
}
}}
onChange={() => toggle(e.path)}
/>
);
const moreButton = (e: Hit) =>
!e.special && (
<button
className={`icon-btn more ${menu?.entry.path === e.path ? "open" : ""}`}
aria-label="Actions"
aria-haspopup="menu"
aria-expanded={menu?.entry.path === e.path}
title="Actions"
onClick={(ev) => {
const anchor = ev.currentTarget;
setMenu((m) => (m?.entry.path === e.path ? null : { entry: e, anchor }));
}}
>
<DotsIcon />
</button>
);
const tagChips = (e: Hit) =>
!!e.tags?.length && (
<span className="tags">
{e.tags.map((t) => (
<button
key={t}
className={`chip ${t === tagFilter ? "on" : ""}`}
title={`Filtrer sur « ${t} »`}
onClick={() => setTagFilter(t === tagFilter ? null : t)}
>
{t}
</button>
))}
</span>
);
/** Galerie : contenu d'un dossier sous son nom. */
const dirSummary = (e: Hit) => {
const d = e.details;
if (!d) return null;
const parts = [d.files ? plural(d.files, "schéma") : "", d.dirs ? plural(d.dirs, "dossier") : ""].filter(Boolean);
return <small className="muted dir-meta">{parts.length ? parts.join(" · ") : "vide"}</small>;
};
const item = (e: Hit) => {
return (
<li key={e.path} className={cls}>
<li key={e.path} className={itemClass(e)}>
<div
className="row"
draggable={!e.special && !locked}
onDragStart={(ev) => onDragStart(ev, e)}
{...(e.isDir ? dropProps(e.path) : {})}
>
{!e.special && (
<input
type="checkbox"
className="check"
checked={isSel}
aria-label={`Sélectionner ${e.name}`}
onClick={(ev) => {
ev.stopPropagation();
if (ev.shiftKey) {
ev.preventDefault();
selectRange(e.path);
}
}}
onChange={() => toggle(e.path)}
/>
)}
{checkbox(e)}
<button
className="name"
onClick={(ev) => onItemClick(ev, e)}
@@ -751,131 +862,249 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
{e.special === "poubelle" && !!e.count && <small className="badge">{e.count}</small>}
{(results || (favView && !e.broken)) && <small className="muted where"> {where(e.path)}</small>}
{trashView && <small className="muted where"> {e.origin ? where(e.origin) : ""}</small>}
{gallery && e.isDir && !trashView && dirSummary(e)}
{e.snippet && <small className="snippet">{e.snippet}</small>}
</span>
</button>
{!!e.tags?.length && (
<span className="tags">
{e.tags.map((t) => (
<button
key={t}
className={`chip ${t === tagFilter ? "on" : ""}`}
title={`Filtrer sur « ${t} »`}
onClick={() => setTagFilter(t === tagFilter ? null : t)}
>
{t}
</button>
))}
{tagChips(e)}
{(!e.isDir || trashView) && view !== "grid" && <span className="meta muted">{fmtDate(e.modTime)}</span>}
{moreButton(e)}
</div>
</li>
);
};
/** Galerie : tuile d'un schéma, grande miniature et métadonnées. */
const tile = (e: Hit) => {
const d = e.details ?? {};
const by = who(e.editedBy);
return (
<li key={e.path} className={`${itemClass(e)} tile ${inspect === e.path ? "inspected" : ""}`}>
<div className="row" draggable={!locked} onDragStart={(ev) => onDragStart(ev, e)}>
{checkbox(e)}
<button className="name" onClick={(ev) => onItemClick(ev, e)} title={displayPath(e.path)}>
{e.broken ? (
<span className="icon folder" aria-hidden>
<StarIcon size={40} />
</span>
) : (
<Thumb path={e.path} version={e.modTime} minSize={expectedThumb(d.width, d.height)} />
)}
<span className="label">{stripExt(e.name)}</span>
</button>
{e.favorite && (
<span className="fav-badge" title="Favori">
<StarFilledIcon size={16} />
</span>
)}
{(!e.isDir || trashView) && view === "list" && <span className="meta muted">{fmtDate(e.modTime)}</span>}
{!e.special && (
<button
className={`icon-btn more ${menu?.entry.path === e.path ? "open" : ""}`}
aria-label="Actions"
aria-haspopup="menu"
aria-expanded={menu?.entry.path === e.path}
title="Actions"
onClick={(ev) => {
const anchor = ev.currentTarget;
setMenu((m) => (m?.entry.path === e.path ? null : { entry: e, anchor }));
}}
>
<DotsIcon />
</button>
<span className="tile-tools">
{!e.broken && (
<button
className={`icon-btn ${inspect === e.path ? "on" : ""}`}
aria-label="Détails"
title="Détails"
onClick={() => setInspect(inspect === e.path ? null : e.path)}
>
<InfoIcon />
</button>
)}
{moreButton(e)}
</span>
{!e.broken && (
<div className="tile-meta">
{(results || favView) && <small className="muted where">{where(e.path)}</small>}
<span className="facts">
<span title={`Modifié le ${fmtDate(e.modTime)}${by ? ` par ${by}` : ""}`}>
<ClockIcon size={14} />
{fmtRelative(e.modTime)}
{by && <span className="by"> · {by}</span>}
</span>
</span>
<span className="facts">
<span title="Taille du fichier">
<SizeIcon size={14} />
{fmtSize(e.size)}
</span>
{!!d.versions && (
<span title="Versions dans l'historique">
<HistoryIcon size={14} />
{plural(d.versions, "version")}
</span>
)}
{!!d.shares && (
<span className="ok" title="Liens de partage actifs">
<ShareIcon size={14} />
{plural(d.shares, "partage")}
</span>
)}
</span>
<span className="facts">
<span title="Éléments">
<ShapesIcon size={14} />
{d.elements ? plural(d.elements, "élément") : "vide"}
</span>
{!!d.texts && (
<span title="Textes">
<TextIcon size={14} />
{plural(d.texts, "texte")}
</span>
)}
{!!d.arrows && (
<span title="Flèches">
<ArrowIcon size={14} />
{plural(d.arrows, "flèche")}
</span>
)}
{!!d.images && (
<span title="Images">
<PhotoIcon size={14} />
{plural(d.images, "image")}
</span>
)}
{!!d.frames && (
<span title={d.frameNames?.length ? `Cadres : ${d.frameNames.join(", ")}` : "Cadres"}>
<FrameIcon size={14} />
{plural(d.frames, "cadre")}
</span>
)}
</span>
{tagChips(e)}
{e.snippet && <small className="snippet">{e.snippet}</small>}
</div>
)}
</div>
</li>
);
};
return (
<div className={`explorer ${fileDrag ? "file-drag" : ""}`} onKeyDown={onKeyDown} {...zoneProps}>
<div className="toolbar">
<button className="ex-btn" onClick={newDrawing} title="Nouveau schéma" disabled={locked}>
<FilePlusIcon />
<span>Schéma</span>
const upItem = !results && dir && (
<li className={`item dir up ${dropTarget === dirname(dir) ? "drop" : ""}`}>
<div className="row" {...dropProps(dirname(dir))}>
<button className="name" onClick={() => setDir(dirname(dir))}>
<span className="icon" aria-hidden>
<UpIcon size={view === "grid" ? 32 : 20} />
</span>
<span className="label">..</span>
</button>
<button className="ex-btn" onClick={newFolder} title="Nouveau dossier" disabled={locked}>
<FolderPlusIcon />
<span>Dossier</span>
</button>
<button
className="ex-btn"
onClick={() => fileInput.current?.click()}
disabled={locked}
title="Importer des fichiers .excalidraw (ou glisser-déposer fichiers et dossiers ici)"
>
<UploadIcon />
<span>Importer</span>
</button>
<button
className="ex-btn square"
onClick={() => dirInput.current?.click()}
disabled={locked}
title="Importer un dossier complet (arborescence recréée, seuls les .excalidraw sont importés)"
aria-label="Importer un dossier"
>
<FolderUploadIcon />
</button>
<input
ref={fileInput}
type="file"
accept=".excalidraw"
multiple
hidden
onChange={(ev) => {
if (ev.target.files) importTree(collectFiles(ev.target.files), importDir);
ev.target.value = "";
}}
/>
<input
ref={dirInput}
type="file"
multiple
hidden
{...{ webkitdirectory: "" }}
onChange={(ev) => {
if (ev.target.files) importTree(collectFiles(ev.target.files), importDir);
ev.target.value = "";
}}
/>
</div>
</li>
);
<div className="searchbar">
<label className="search">
<SearchIcon />
const emptyText = results
? "Aucun résultat"
: favView
? "Aucun favori : étoile ou glisser-déposer un schéma ici"
: trashView
? "La poubelle est vide"
: "Dossier vide";
// Galerie : dossiers en cartes compactes, schémas en grandes tuiles.
const galleryDirs = shown.filter((e) => e.isDir || trashView);
const galleryFiles = trashView ? [] : shown.filter((e) => !e.isDir);
const inspected = gallery && inspect ? (shown.find((e) => e.path === inspect && !e.isDir) ?? null) : null;
return (
<div
className={`explorer ${gallery ? "gallery" : ""} ${fileDrag ? "file-drag" : ""}`}
onKeyDown={onKeyDown}
{...zoneProps}
>
<div className="head">
<div className="toolbar">
<button className="ex-btn" onClick={newDrawing} title="Nouveau schéma" disabled={locked}>
<FilePlusIcon />
<span>Schéma</span>
</button>
<button className="ex-btn" onClick={newFolder} title="Nouveau dossier" disabled={locked}>
<FolderPlusIcon />
<span>Dossier</span>
</button>
<button
className="ex-btn"
onClick={() => fileInput.current?.click()}
disabled={locked}
title="Importer des fichiers .excalidraw (ou glisser-déposer fichiers et dossiers ici)"
>
<UploadIcon />
<span>Importer</span>
</button>
<button
className="ex-btn square"
onClick={() => dirInput.current?.click()}
disabled={locked}
title="Importer un dossier complet (arborescence recréée, seuls les .excalidraw sont importés)"
aria-label="Importer un dossier"
>
<FolderUploadIcon />
</button>
<input
type="search"
placeholder="Rechercher (noms, textes, IP…)"
value={query}
onChange={(ev) => setQuery(ev.target.value)}
ref={fileInput}
type="file"
accept=".excalidraw"
multiple
hidden
onChange={(ev) => {
if (ev.target.files) importTree(collectFiles(ev.target.files), importDir);
ev.target.value = "";
}}
/>
<input
ref={dirInput}
type="file"
multiple
hidden
{...{ webkitdirectory: "" }}
onChange={(ev) => {
if (ev.target.files) importTree(collectFiles(ev.target.files), importDir);
ev.target.value = "";
}}
/>
</label>
<div className="segmented" role="group" aria-label="Affichage">
<button
className={`icon-btn ${view === "grid" ? "on" : ""}`}
onClick={() => setView("grid")}
title="Affichage en vignettes"
aria-label="Affichage en vignettes"
aria-pressed={view === "grid"}
>
<GridIcon />
</button>
<button
className={`icon-btn ${view === "list" ? "on" : ""}`}
onClick={() => setView("list")}
title="Affichage en liste"
aria-label="Affichage en liste"
aria-pressed={view === "list"}
>
<ListIcon />
</button>
</div>
<button className="icon-btn" onClick={refresh} title="Rafraîchir" aria-label="Rafraîchir">
<RefreshIcon />
</button>
{toolbarEnd}
<div className="searchbar">
<label className="search">
<SearchIcon />
<input
type="search"
placeholder="Rechercher (noms, textes, IP…)"
value={query}
onChange={(ev) => setQuery(ev.target.value)}
/>
</label>
<div className="segmented" role="group" aria-label="Affichage">
<button
className={`icon-btn ${view === "grid" ? "on" : ""}`}
onClick={() => setView("grid")}
title="Affichage en vignettes"
aria-label="Affichage en vignettes"
aria-pressed={view === "grid"}
>
<GridIcon />
</button>
<button
className={`icon-btn ${view === "list" ? "on" : ""}`}
onClick={() => setView("list")}
title="Affichage en liste"
aria-label="Affichage en liste"
aria-pressed={view === "list"}
>
<ListIcon />
</button>
<button
className={`icon-btn ${gallery ? "on" : ""}`}
onClick={() => setView("gallery")}
title="Galerie : grandes tuiles et détails, sur toute la largeur"
aria-label="Galerie"
aria-pressed={gallery}
>
<GalleryIcon />
</button>
</div>
<button className="icon-btn" onClick={refresh} title="Rafraîchir" aria-label="Rafraîchir">
<RefreshIcon />
</button>
{!gallery && toolbarEnd}
</div>
</div>
<div className="filters" role="group" aria-label="Filtres">
@@ -893,24 +1122,36 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
))}
</div>
{!results && (
<nav className="crumbs">
<button className={dropTarget === "" ? "drop" : ""} onClick={() => setDir("")} {...dropProps("")}>
Racine
</button>
{crumbs.map((c, i) => {
const p = crumbs.slice(0, i + 1).join("/");
return (
<span key={p}>
<span className="muted"> / </span>
<button className={dropTarget === p ? "drop" : ""} onClick={() => setDir(p)} {...dropProps(p)}>
{label(c)}
</button>
</span>
);
})}
</nav>
)}
<div className="listbar">
{results ? (
<span className="muted count">{plural(results.length, "résultat")}</span>
) : (
<nav className="crumbs">
<button className={dropTarget === "" ? "drop" : ""} onClick={() => setDir("")} {...dropProps("")}>
Racine
</button>
{crumbs.map((c, i) => {
const p = crumbs.slice(0, i + 1).join("/");
return (
<span key={p}>
<span className="muted"> / </span>
<button className={dropTarget === p ? "drop" : ""} onClick={() => setDir(p)} {...dropProps(p)}>
{label(c)}
</button>
</span>
);
})}
</nav>
)}
<label className="sort" title="Trier">
<SortIcon />
<select value={sort} onChange={(ev) => setSort(ev.target.value as Sort)} aria-label="Trier par">
<option value="name">Nom</option>
<option value="modified">Modifié</option>
<option value="size">Taille</option>
</select>
</label>
</div>
{trashView && (
<div className="trashbar">
@@ -999,32 +1240,53 @@ export function Explorer({ current, refreshKey, onOpen, onMoved, onDeleted, onHi
</div>
)}
<ul className={`entries ${view} ${selected.size > 0 ? "selecting" : ""}`}>
{!results && dir && (
<li className={`item dir up ${dropTarget === dirname(dir) ? "drop" : ""}`}>
<div className="row" {...dropProps(dirname(dir))}>
<button className="name" onClick={() => setDir(dirname(dir))}>
<span className="icon" aria-hidden>
<UpIcon size={view === "grid" ? 32 : 20} />
</span>
<span className="label">..</span>
</button>
</div>
</li>
)}
{list.map(item)}
{list.length === 0 && (
<li className="muted empty">
{results
? "Aucun résultat"
: favView
? "Aucun favori : étoile ou glisser-déposer un schéma ici"
: trashView
? "La poubelle est vide"
: "Dossier vide"}
</li>
)}
</ul>
{gallery ? (
<div className="gallery-body">
<div className={`gallery-scroll ${selected.size > 0 ? "selecting" : ""}`}>
{(upItem || galleryDirs.length > 0) && (
<>
{galleryFiles.length > 0 && !trashView && <h4 className="gallery-heading">Dossiers</h4>}
<ul className="entries gallery-dirs">
{upItem}
{galleryDirs.map(item)}
</ul>
</>
)}
{galleryFiles.length > 0 && (
<>
{(upItem || galleryDirs.length > 0) && <h4 className="gallery-heading">Schémas</h4>}
<ul className="entries gallery-tiles">{galleryFiles.map(tile)}</ul>
</>
)}
{list.length === 0 && <p className="muted empty">{emptyText}</p>}
</div>
{inspected && (
<DetailsPanel
entry={inspected}
onOpen={(p) => {
if (favView && p !== current) stay.current = p;
onOpen(p);
}}
onLocate={(d) => {
setQuery("");
setTagFilter(null);
setDir(d);
}}
onHistory={onHistory}
onShare={onShare}
onFavorite={(e) => toggleFavorite([e])}
onTag={(t) => setTagFilter(t)}
onClose={() => setInspect(null)}
/>
)}
</div>
) : (
<ul className={`entries ${view} ${selected.size > 0 ? "selecting" : ""}`}>
{upItem}
{shown.map(item)}
{list.length === 0 && <li className="muted empty">{emptyText}</li>}
</ul>
)}
{fileDrag && (
<div className="drop-hint" aria-hidden>
+13 -5
View File
@@ -1,4 +1,5 @@
import { useEffect, useRef, useState } from "react";
import type { SyntheticEvent } from "react";
import { api } from "./api";
import { ensureThumb, knownThumb } from "./thumbs";
@@ -7,9 +8,10 @@ type State = "idle" | "server" | "generating" | "retry" | "empty" | "error";
/**
* Miniature d'un schéma, chargée quand elle devient visible. Si le serveur
* n'en a pas (ou qu'elle est périmée), elle est générée dans le navigateur
* puis envoyée au serveur pour les visites suivantes.
* puis envoyée au serveur pour les visites suivantes. minSize : une miniature
* du serveur plus petite (rendue à une ancienne taille) est régénérée.
*/
export function Thumb({ path, version }: { path: string; version: string }) {
export function Thumb({ path, version, minSize }: { path: string; version: string; minSize?: number }) {
const ref = useRef<HTMLSpanElement>(null);
const [visible, setVisible] = useState(false);
const [state, setState] = useState<State>("idle");
@@ -39,12 +41,18 @@ export function Thumb({ path, version }: { path: string; version: string }) {
if (visible && state === "idle") setState("server");
}, [visible, state]);
const onError = () => {
if (state !== "server") return setState("error");
const regenerate = () => {
setState("generating");
ensureThumb(path, version).then((r) => setState(r === "ok" ? "retry" : r));
};
const onError = () => (state === "server" ? regenerate() : setState("error"));
const onLoad = (ev: SyntheticEvent<HTMLImageElement>) => {
const img = ev.currentTarget;
if (minSize && state === "server" && Math.max(img.naturalWidth, img.naturalHeight) < minSize) regenerate();
};
const src =
state === "server"
? api.thumbUrl(path, version)
@@ -55,7 +63,7 @@ export function Thumb({ path, version }: { path: string; version: string }) {
return (
<span ref={ref} className={`thumb ${state}`} aria-hidden>
{src ? (
<img src={src} alt="" loading="lazy" decoding="async" draggable={false} onError={onError} />
<img src={src} alt="" loading="lazy" decoding="async" draggable={false} onError={onError} onLoad={onLoad} />
) : (
<span className="ph">{state === "empty" ? "∅" : state === "error" ? "📄" : ""}</span>
)}
+34 -4
View File
@@ -22,6 +22,33 @@ export interface Entry {
link?: string;
/** Favori dont l'original a disparu (chemin .favoris/<lien>, à retirer). */
broken?: boolean;
/** Schéma : dernier utilisateur à l'avoir enregistré ("local" hors authentification). */
editedBy?: string;
/** Vue Galerie : détails demandés à la liste ou à la recherche (details=1). */
details?: Details;
}
/** Détails d'une entrée (internal/storage/details.go) ; compteurs absents = 0. */
export interface Details {
elements?: number;
texts?: number;
images?: number;
arrows?: number;
frames?: number;
frameNames?: string[];
/** Emprise des éléments, en px du canevas. */
width?: number;
height?: number;
background?: string;
versions?: number;
/** Liens de partage actifs. */
shares?: number;
/** Création, ou plus ancienne version connue si l'auteur n'est pas connu. */
created?: string;
createdBy?: string;
/** Dossier : sous-dossiers et schémas. */
dirs?: number;
files?: number;
}
export interface TagCount {
@@ -142,12 +169,15 @@ export const api = {
me: async (): Promise<Me> => (await request("/api/me")).json(),
list: async (dir: string): Promise<Entry[]> =>
(await request(`/api/list?path=${q(dir)}`)).json(),
/** details : détails des entrées pour la vue Galerie. */
list: async (dir: string, details = false): Promise<Entry[]> =>
(await request(`/api/list?path=${q(dir)}${details ? "&details=1" : ""}`)).json(),
search: async (text: string, f: SearchFilter = {}): Promise<Hit[]> =>
search: async (text: string, f: SearchFilter = {}, details = false): Promise<Hit[]> =>
(
await request(`/api/search?q=${q(text)}${f.tag ? `&tag=${q(f.tag)}` : ""}${f.fav ? "&fav=true" : ""}`)
await request(
`/api/search?q=${q(text)}${f.tag ? `&tag=${q(f.tag)}` : ""}${f.fav ? "&fav=true" : ""}${details ? "&details=1" : ""}`,
)
).json(),
tags: async (): Promise<TagCount[]> => (await request("/api/tags")).json(),
+24
View File
@@ -0,0 +1,24 @@
// Mise en forme des dates, tailles et auteurs (explorateur, panneau Détails).
export const fmtDate = (iso: string) =>
new Date(iso).toLocaleString(undefined, { dateStyle: "short", timeStyle: "short" });
export const fmtSize = (n: number) =>
n < 1024 ? `${n} o` : n < 1 << 20 ? `${(n / 1024).toFixed(1)} Ko` : `${(n / (1 << 20)).toFixed(1)} Mo`;
export const plural = (n: number, word: string) => `${n} ${word}${n > 1 ? "s" : ""}`;
const relative = new Intl.RelativeTimeFormat("fr", { numeric: "auto" });
/** « à l'instant », « il y a 5 minutes », « hier »… puis la date au-delà d'un mois. */
export const fmtRelative = (iso: string) => {
const s = (Date.now() - new Date(iso).getTime()) / 1000;
if (s < 60) return "à l'instant";
if (s < 3600) return relative.format(-Math.round(s / 60), "minute");
if (s < 86400) return relative.format(-Math.round(s / 3600), "hour");
if (s < 30 * 86400) return relative.format(-Math.round(s / 86400), "day");
return new Date(iso).toLocaleDateString(undefined, { dateStyle: "medium" });
};
/** Auteur affichable : rien pour l'utilisateur unique sans authentification. */
export const who = (id?: string) => (id && id !== "local" ? id : "");
+58
View File
@@ -237,3 +237,61 @@ export const LogoutIcon = icon(
<path d="M9 12h12l-3-3M18 15l3-3" />
</>,
);
// Vue Galerie et ses métadonnées.
export const GalleryIcon = icon(
<>
<rect x="3" y="4" width="8" height="7" rx="1.5" />
<rect x="13" y="4" width="8" height="7" rx="1.5" />
<path d="M3 15h8M3 19h5M13 15h8M13 19h5" />
</>,
);
export const ClockIcon = icon(
<>
<circle cx="12" cy="12" r="9" />
<path d="M12 7v5l3 3" />
</>,
);
export const ShapesIcon = icon(
<>
<rect x="3" y="3" width="8" height="8" rx="1" />
<circle cx="17" cy="17" r="4" />
<path d="M17 3l4 7h-8z" />
</>,
);
export const TextIcon = icon(<path d="M6 4h12M12 4v16M9 20h6" />);
export const PhotoIcon = icon(
<>
<rect x="3" y="4" width="18" height="16" rx="2" />
<circle cx="9" cy="10" r="1.5" />
<path d="M21 16l-5-5-8 9" />
</>,
);
export const FrameIcon = icon(<path d="M4 7h16M4 17h16M7 4v16M17 4v16" />);
export const ArrowIcon = icon(<path d="M5 19 19 5M10 5h9v9" />);
export const SizeIcon = icon(
<>
<path d="M6 4h10l4 4v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z" />
<path d="M8 4v5h7V4M8 20v-6h8v6" />
</>,
);
export const SortIcon = icon(<path d="M4 6h9M4 12h7M4 18h5M17 4v16M14 17l3 3 3-3" />);
export const InfoIcon = icon(
<>
<circle cx="12" cy="12" r="9" />
<path d="M12 8v.01M11 12h1v4h1" />
</>,
);
export const LinkIcon = icon(
<path d="M9 15l6-6M11 6l.46-.54a5 5 0 0 1 7.07 7.07l-.53.47M13 18l-.4.53a5 5 0 0 1-7.07-7.07L6 11" />,
);
+480
View File
@@ -1660,3 +1660,483 @@ button.chip.on,
max-width: 260px;
white-space: pre-line;
}
/* --- Barre de liste : fil d'Ariane (ou nombre de résultats) et tri ---------- */
.head {
display: contents; /* panneau latéral : barre d'outils et recherche l'une sous l'autre */
}
.listbar {
display: flex;
align-items: center;
gap: 6px;
min-height: 24px;
}
.listbar .crumbs {
flex: 1;
min-width: 0;
}
.listbar .count {
flex: 1;
font-size: 13px;
padding-left: 6px;
}
.sort {
display: inline-flex;
align-items: center;
gap: 2px;
flex: none;
color: var(--muted);
}
.sort select {
height: 26px;
padding: 0 4px;
border: 1px solid transparent;
border-radius: var(--ex-radius-md);
background: transparent;
color: var(--ex-on-surface);
font: 12px var(--ex-font);
cursor: pointer;
}
.sort select:hover,
.sort select:focus-visible {
border-color: var(--border);
background: var(--ex-surface-low);
outline: none;
}
/* --- Vue Galerie : l'explorateur couvre toute la zone de travail ------------ */
.app.gallery.drawer-open .drawer {
position: fixed;
z-index: 20;
inset: var(--topbar-h) 0 0 0;
width: auto;
transform: none;
visibility: visible;
border-right: none;
box-shadow: none;
}
.app.gallery .splitter,
.app.gallery.drawer-open .backdrop {
display: none;
}
.explorer.gallery {
width: 100%;
padding: 14px 20px 0;
gap: 10px;
}
.explorer.gallery .head {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
.explorer.gallery .searchbar {
flex: 1;
min-width: min(100%, 320px);
}
.explorer.gallery .search {
max-width: 640px;
}
.explorer.gallery .crumbs,
.explorer.gallery .crumbs button {
font-size: 14px;
}
.gallery-body {
flex: 1;
min-height: 0;
display: flex;
margin: 0 -20px;
border-top: 1px solid var(--border);
}
.gallery-scroll {
flex: 1;
min-width: 0;
overflow-y: auto;
padding: 4px 20px 24px;
}
.gallery-scroll > .empty {
padding: 12px 0;
}
.gallery-heading {
margin: 14px 0 8px;
font-size: 11.5px;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--muted);
}
/* Dossiers : cartes compactes. */
.entries.gallery-dirs {
flex: none;
overflow: visible;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
gap: 8px;
padding-top: 10px;
}
.entries.gallery-dirs .row {
position: relative;
height: 100%;
border: 1px solid var(--border);
border-radius: 0.625rem;
background: var(--ex-surface-lowest);
}
.entries.gallery-dirs .row:hover {
border-color: var(--ex-primary);
background: var(--ex-surface-lowest);
}
.entries.gallery-dirs .name {
padding: 8px 6px 8px 8px;
gap: 10px;
}
.entries.gallery-dirs .icon {
width: 40px;
height: 40px;
border-radius: var(--ex-radius-lg);
background: var(--ex-surface-mid);
}
.entries.gallery-dirs .label {
font-size: 13.5px;
font-weight: 600;
}
.entries.gallery-dirs .label small {
display: block;
font-weight: 400;
font-size: 12px;
overflow: hidden;
text-overflow: ellipsis;
}
.entries.gallery-dirs .check {
position: absolute;
top: 6px;
left: 4px;
z-index: 1;
margin: 0;
}
.entries.gallery-dirs .row .tags {
display: none; /* les tags d'un dossier restent visibles en liste */
}
.entries.gallery-dirs .row .meta {
padding-right: 4px;
}
.entries.gallery-dirs .more {
opacity: 0;
}
.entries.gallery-dirs .item:hover .more,
.entries.gallery-dirs .more.open,
.entries.gallery-dirs .more:focus-visible {
opacity: 1;
}
/* Schémas : grandes tuiles avec miniature et métadonnées. */
.entries.gallery-tiles {
flex: none;
overflow: visible;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 14px;
padding-top: 10px;
}
.tile > .row {
position: relative;
flex-direction: column;
align-items: stretch;
gap: 0;
height: 100%;
overflow: hidden;
border: 1px solid var(--border);
border-radius: 0.75rem;
background: var(--ex-surface-lowest);
transition:
border-color 0.1s,
box-shadow 0.1s;
}
.tile > .row:hover {
border-color: var(--ex-primary);
background: var(--ex-surface-lowest);
box-shadow: var(--ex-shadow-island);
}
.tile.inspected > .row {
border-color: var(--ex-primary);
outline: 2px solid var(--ex-primary);
outline-offset: -2px;
}
.tile .name {
flex-direction: column;
align-items: stretch;
gap: 0;
padding: 0;
border-radius: 0;
}
.tile .thumb,
.tile .icon {
width: 100%;
height: auto;
aspect-ratio: 16 / 10;
border: none;
border-bottom: 1px solid var(--border);
border-radius: 0;
}
.tile .label {
padding: 10px 12px 4px;
white-space: normal;
overflow-wrap: anywhere;
font-size: 14.5px;
font-weight: 600;
line-height: 1.25;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.tile .check {
position: absolute;
top: 8px;
left: 6px;
z-index: 1;
width: 18px;
height: 18px;
}
.tile .fav-badge {
position: absolute;
top: 8px;
left: 30px;
z-index: 1;
display: inline-flex;
color: #f59f00;
filter: drop-shadow(0 0 2px var(--ex-surface-lowest));
}
.tile .tile-tools {
position: absolute;
top: 6px;
right: 6px;
z-index: 1;
display: flex;
gap: 2px;
padding: 2px;
border-radius: var(--ex-radius-lg);
background: color-mix(in srgb, var(--ex-surface-lowest) 85%, transparent);
opacity: 0;
transition: opacity 0.1s;
}
.tile:hover .tile-tools,
.tile.inspected .tile-tools,
.tile .tile-tools:focus-within,
.tile .more.open {
opacity: 1;
}
.tile .tile-tools:has(.more.open) {
opacity: 1;
}
@media (hover: none) {
.tile .tile-tools {
opacity: 1;
}
}
.tile-meta {
display: flex;
flex-direction: column;
gap: 5px;
padding: 2px 12px 12px;
font-size: 12px;
color: var(--muted);
}
.tile-meta .where {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.tile-meta .facts {
display: flex;
flex-wrap: wrap;
gap: 3px 12px;
}
.tile-meta .facts > span {
display: inline-flex;
align-items: center;
gap: 4px;
min-width: 0;
}
.tile-meta .facts .by {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.tile-meta .ok {
color: var(--ok);
}
.tile-meta .tags {
display: flex;
flex-wrap: wrap;
gap: 4px;
margin-top: 2px;
}
.tile-meta .snippet {
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: var(--ex-on-primary-container);
opacity: 0.8;
}
/* Panneau Détails, à droite des tuiles. */
.details-panel {
flex: none;
width: 340px;
overflow-y: auto;
padding: 14px 16px 24px;
border-left: 1px solid var(--border);
background: var(--panel);
display: flex;
flex-direction: column;
gap: 10px;
font-size: 13px;
}
.details-head {
display: flex;
align-items: flex-start;
gap: 6px;
}
.details-head h3 {
flex: 1;
margin: 4px 0 0;
font-size: 16px;
line-height: 1.3;
overflow-wrap: anywhere;
}
.details-shot {
display: block;
height: auto;
padding: 0;
overflow: hidden;
border: 1px solid var(--border);
border-radius: 0.625rem;
background: var(--thumb-bg);
box-shadow: none;
}
.details-shot .thumb {
width: 100%;
height: auto;
aspect-ratio: 16 / 10;
border: none;
border-radius: 0;
}
.details-where {
align-self: flex-start;
height: auto;
padding: 2px 4px;
gap: 4px;
background: transparent;
box-shadow: none;
color: var(--muted);
font-size: 12.5px;
letter-spacing: normal;
white-space: normal;
text-align: left;
}
.details-actions {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.details-panel dl {
display: grid;
grid-template-columns: auto 1fr;
gap: 6px 12px;
margin: 4px 0;
}
.details-panel dt {
color: var(--muted);
}
.details-panel dd {
margin: 0;
min-width: 0;
overflow-wrap: anywhere;
}
.details-panel dd.tags {
display: flex;
flex-wrap: wrap;
gap: 4px;
}
.swatch-line {
display: flex;
align-items: center;
gap: 6px;
}
.swatch {
width: 14px;
height: 14px;
border-radius: 3px;
border: 1px solid var(--ex-outline-variant);
}
.details-panel h4 {
margin: 6px 0 4px;
font-size: 11.5px;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--muted);
}
.details-panel section p {
margin: 0;
}
.details-panel ul {
list-style: none;
margin: 0;
padding: 0;
}
.details-panel li {
display: flex;
justify-content: space-between;
gap: 8px;
padding: 5px 0;
border-bottom: 1px solid var(--border);
}
.details-panel li:last-child {
border-bottom: none;
}
.details-panel button.link {
height: auto;
padding: 0;
background: transparent;
box-shadow: none;
color: var(--accent);
font-size: 13px;
letter-spacing: normal;
}
@media (max-width: 768px) {
.app.gallery.drawer-open .drawer {
width: auto;
}
.explorer.gallery {
padding: 10px 12px 0;
}
.explorer.gallery .toolbar .ex-btn span {
display: none;
}
.gallery-body {
margin: 0 -12px;
}
.gallery-scroll {
padding: 4px 12px 16px;
}
.entries.gallery-dirs {
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.entries.gallery-tiles {
grid-template-columns: 1fr;
}
/* Détails : feuille plein écran au-dessus des tuiles. */
.details-panel {
position: fixed;
z-index: 30;
inset: var(--topbar-h) 0 0 0;
width: auto;
border-left: none;
padding-bottom: max(24px, env(safe-area-inset-bottom));
}
}
+10 -1
View File
@@ -6,7 +6,8 @@ import type { AppState, BinaryFiles } from "@excalidraw/excalidraw/types";
import type { ExcalidrawElement } from "@excalidraw/excalidraw/element/types";
import { api } from "./api";
const THUMB_PX = 320;
// Assez grand pour les tuiles de la vue Galerie (affichées jusqu'à ~420 px de large).
export const THUMB_PX = 640;
/** Rend la miniature d'une scène ; null si la scène est vide. */
export async function renderThumb(
@@ -101,3 +102,11 @@ export function ensureThumb(path: string, version: string): Promise<ThumbResult>
}
return p;
}
/**
* Taille minimale attendue (plus grand côté, px) d'une miniature à jour pour une
* scène dont l'emprise est w × h : Excalidraw n'agrandit pas les petites scènes.
* Une miniature plus petite date d'une ancienne taille de rendu (320 px).
*/
export const expectedThumb = (w?: number, h?: number) =>
w && h ? Math.floor(Math.min(THUMB_PX, Math.max(w, h)) * 0.9) : undefined;