Files
Skald-Circle/web/css/file-viewer.css
T
Daniele 1515492938
Nightly Build / build (push) Successful in 8m5s
feat(file-viewer): browse a versioned file's git history
A clock button in the file viewer header lists the versions of a file
whose project keeps a git history; picking one shows the file as of
that commit, read-only, with a banner back to the current version.

A past version is never served from the working tree: the whole
repository is materialized at that revision (git archive streamed
through tar into a size-bounded, immutable-by-rev cache) and every
fetch — content, compiled LaTeX, markdown images, downloads — resolves
inside that tree, so dependencies are contemporaneous with the file:
a .tex compiles against its \input's and images of that moment.

Backend: new git_versions module (repo discovery bounded by the
workspace mount, host-git log/rev-parse/archive, extraction cache with
oldest-first prune) + GET /api/file/versions and a rev param on
GET /api/file (rev is the ETag; never X-Writable). Frontend: history
mode in FileViewerBase shared by the desktop and mobile viewers —
popover, banner, watcher paused while browsing, rev propagated to
every /api/file URL it builds.
2026-08-10 14:27:48 +01:00

550 lines
14 KiB
CSS

/* ── File viewer page ───────────────────────────────────────────────────────── */
.fv-page {
flex-direction: column;
min-height: 0;
}
.fv-title {
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
font-size: 0.95rem;
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
opacity: 0.9;
margin: 0;
/* RTL flips the ellipsis to the *start*, so a long path keeps its tail (the
filename) visible — `<bdi>` around the path preserves left-to-right order. */
direction: rtl;
text-align: left;
flex: 1 1 auto;
min-width: 0;
}
.fv-download-btn {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
padding: 0 !important;
border-radius: 6px !important;
flex-shrink: 0;
}
.fv-body {
flex: 1 1 auto;
overflow: auto;
position: relative;
min-height: 0;
}
.fv-state {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
padding: 2rem;
font-size: 0.9rem;
}
/* ── Markdown preview ────────────────────────────────────────────────────────── */
.fv-md-wrap {
display: flex;
flex-direction: column;
min-height: 100%;
}
/* View | Edit tab bar — shown only when the caller can write the file. */
.fv-md-tabs {
display: flex;
align-items: center;
gap: 0.15rem;
padding: 0.4rem 1rem 0;
border-bottom: 1px solid var(--bs-border-color);
flex-shrink: 0;
}
.fv-md-tab {
appearance: none;
background: none;
border: none;
border-bottom: 2px solid transparent;
padding: 0.35rem 0.85rem;
margin-bottom: -1px;
font-size: 0.85rem;
color: var(--bs-secondary-color);
cursor: pointer;
border-radius: 4px 4px 0 0;
}
.fv-md-tab:hover { color: var(--bs-body-color); }
.fv-md-tab.active {
color: var(--bs-body-color);
border-bottom-color: var(--accent);
font-weight: 600;
}
.fv-md-dirty-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--accent);
margin-left: 0.35rem;
flex-shrink: 0;
}
/* ── Source editor (Edit tab) ───────────────────────────────────────────────── */
.fv-edit {
flex: 1 1 auto;
display: flex;
flex-direction: column;
min-height: 0;
padding: 0.75rem 1rem 1rem;
gap: 0.5rem;
}
.fv-edit-textarea {
flex: 1 1 auto;
min-height: 50vh;
width: 100%;
resize: vertical;
padding: 0.85rem 1rem;
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
font-size: 0.85rem;
line-height: 1.55;
tab-size: 4;
color: var(--bs-body-color);
background: var(--bs-secondary-bg);
border: 1px solid var(--bs-border-color);
border-radius: 6px;
white-space: pre;
overflow-wrap: normal;
overflow: auto;
}
.fv-edit-textarea:focus {
outline: none;
border-color: var(--accent);
box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}
.fv-edit-toolbar {
display: flex;
align-items: center;
gap: 0.5rem;
flex-shrink: 0;
}
.fv-edit-hint {
font-size: 0.78rem;
color: var(--bs-secondary-color);
margin-left: auto;
}
/* ── Conflict banner (remote changed while editing) ─────────────────────────── */
.fv-conflict-banner {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.6rem;
padding: 0.6rem 0.85rem;
background: var(--bs-warning-bg-subtle, #fff3cd);
border: 1px solid var(--bs-warning-border-subtle, #ffe69c);
color: var(--bs-emphasis-color, inherit);
border-radius: 6px;
flex-shrink: 0;
}
.fv-conflict-banner > .bi {
color: var(--bs-warning-text-emphasis, #664d03);
font-size: 1.05rem;
flex-shrink: 0;
}
.fv-conflict-text {
flex: 1 1 200px;
font-size: 0.82rem;
min-width: 0;
}
.fv-conflict-actions {
display: flex;
flex-wrap: wrap;
gap: 0.4rem;
flex-shrink: 0;
}
.fv-md {
max-width: 100%;
padding: 1.5rem 2rem;
line-height: 1.6;
font-size: 0.8rem;
}
.fv-md > *:first-child { margin-top: 0; }
.fv-md > *:last-child { margin-bottom: 0; }
.fv-md h1,
.fv-md h2,
.fv-md h3,
.fv-md h4 { margin: 1.2rem 0 0.5rem; line-height: 1.3; }
.fv-md h1 { font-size: 1.5em; }
.fv-md h2 { font-size: 1.3em; }
.fv-md h3 { font-size: 1.15em; }
.fv-md h4 { font-size: 1em; }
.fv-md p { margin: 0.5rem 0; }
.fv-md ul,
.fv-md ol { margin: 0.5rem 0; padding-left: 1.5rem; }
.fv-md li { margin: 0.2rem 0; }
.fv-md code {
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
font-size: 0.85em;
background: var(--bs-secondary-bg);
padding: 0.1rem 0.35rem;
border-radius: 3px;
}
.fv-md pre {
background: var(--bs-secondary-bg);
padding: 0.85rem 1rem;
border-radius: 6px;
overflow: auto;
margin: 0.75rem 0;
}
.fv-md pre code { background: none; padding: 0; font-size: inherit; }
.fv-md blockquote {
border-left: 3px solid var(--bs-border-color);
margin: 0.75rem 0;
padding: 0.25rem 0 0.25rem 1rem;
color: var(--bs-secondary-color);
}
.fv-md hr { border: none; border-top: 1px solid var(--bs-border-color); margin: 1.25rem 0; }
.fv-md a { color: var(--accent); text-decoration: underline; }
.fv-md strong { font-weight: 700; }
.fv-md em { font-style: italic; }
.fv-md img { max-width: 100%; border-radius: 4px; }
.fv-md table {
border-collapse: collapse;
margin: 0.75rem 0;
}
.fv-md th,
.fv-md td {
border: 1px solid var(--bs-border-color);
padding: 0.4rem 0.6rem;
}
/* ── Code/text preview ───────────────────────────────────────────────────────── */
.fv-code {
margin: 0;
padding: 1.25rem 1.5rem;
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
font-size: 0.85rem;
line-height: 1.55;
white-space: pre;
overflow: auto;
background: var(--bs-secondary-bg);
color: var(--bs-body-color);
min-height: 100%;
tab-size: 4;
}
/* Header action buttons (mode toggle + download) sit in one row. */
.fv-header-actions {
display: flex;
align-items: center;
gap: 0.4rem;
flex-shrink: 0;
}
/* ── History mode (git versions) ───────────────────────────────────────────── */
.fv-history {
position: relative;
display: inline-flex;
}
/* Transparent click-catcher that closes the popover on outside click. */
.fv-history-overlay {
position: fixed;
inset: 0;
z-index: 1040;
}
.fv-history-pop {
position: absolute;
top: calc(100% + 6px);
right: 0;
z-index: 1050;
display: flex;
flex-direction: column;
gap: 2px;
min-width: 260px;
max-width: min(340px, 80vw);
max-height: 320px;
overflow-y: auto;
padding: 4px;
background: var(--card-bg);
border: 1px solid var(--card-border);
border-radius: var(--radius-md);
box-shadow: var(--card-shadow);
}
.fv-history-row {
display: flex;
flex-direction: column;
gap: 1px;
padding: 0.45rem 0.6rem;
text-align: left;
background: none;
border: 0;
border-radius: var(--radius-sm);
color: var(--bs-body-color);
cursor: pointer;
}
.fv-history-row:hover { background: var(--sidebar-hover); }
.fv-history-row.active { background: var(--sidebar-active-bg); }
.fv-history-date {
display: flex;
align-items: center;
gap: 0.4rem;
font-size: 0.72rem;
color: var(--bs-secondary-color);
}
.fv-history-current {
padding: 0 0.35rem;
font-size: 0.66rem;
border-radius: 999px;
background: var(--accent-soft);
color: var(--accent);
}
.fv-history-subject {
font-size: 0.8rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* Banner shown between header and body while viewing a past revision. */
.fv-version-banner {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.6rem;
padding: 0.45rem 0.85rem;
background: var(--bs-info-bg-subtle, #cff4fc);
border-bottom: 1px solid var(--bs-info-border-subtle, #9eeaf9);
color: var(--bs-emphasis-color, inherit);
flex-shrink: 0;
}
.fv-version-banner > .bi {
color: var(--bs-info-text-emphasis, #055160);
flex-shrink: 0;
}
.fv-version-text {
flex: 1 1 200px;
min-width: 0;
font-size: 0.82rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* ── PDF preview ─────────────────────────────────────────────────────────────── */
/* PDFs are drawn by <pdf-view> (web/components/shared/pdf-view.js) on canvas, not
handed to the browser's built-in viewer: WebKit paints only a static first page
inside a frame — which is why iOS showed page 1 and nothing else — and the
desktop browsers each mount a different viewer chrome. `.fv-pdf` is the block
the viewer body gives it; everything below is that component's own layout. */
.fv-pdf {
display: block;
width: 100%;
height: 100%;
min-height: 0;
}
.pdfv {
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
}
.pdfv-toolbar {
display: flex;
align-items: center;
gap: 0.4rem;
padding: 0.35rem 0.6rem;
border-bottom: 1px solid var(--bs-border-color);
background: var(--bs-tertiary-bg);
flex-shrink: 0;
}
.pdfv-btn {
border: 1px solid var(--bs-border-color);
background: var(--bs-body-bg);
color: var(--bs-body-color);
border-radius: var(--radius-sm);
padding: 0.15rem 0.5rem;
line-height: 1.4;
cursor: pointer;
}
.pdfv-btn:hover:not(:disabled) { background: var(--bs-secondary-bg); }
.pdfv-btn:disabled { opacity: 0.4; cursor: default; }
.pdfv-zoom {
min-width: 3.5rem;
text-align: center;
font-size: 0.85rem;
color: var(--bs-secondary-color);
font-variant-numeric: tabular-nums;
}
.pdfv-pageno {
margin-left: auto;
font-size: 0.85rem;
color: var(--bs-secondary-color);
font-variant-numeric: tabular-nums;
}
/* The scroll root. `position: relative` makes it the offsetParent of every page
box, which is what lets the component compare `offsetTop` against `scrollTop`
when it decides which pages hold pixels. */
.pdfv-scroll {
position: relative;
flex: 1;
min-height: 0;
overflow: auto;
overscroll-behavior: contain;
-webkit-overflow-scrolling: touch;
background: var(--bs-secondary-bg);
}
/* `width: max-content` + `min-width: 100%` is what makes zoom usable: with a
plain `align-items: center`, a page wider than the scroll box overflows on
*both* sides and the left half becomes unreachable — centring happens before
scrolling exists. Growing this box to the widest page instead gives an honest
horizontal scroll range, while min-width keeps pages centred when they fit. */
.pdfv-pages {
display: flex;
flex-direction: column;
align-items: center;
width: max-content;
min-width: 100%;
gap: 0.6rem;
padding: 0.6rem;
}
/* A page box is sized before it is drawn, so the scrollbar is honest from the
start and a page that is currently released leaves no gap. The pdf.js text
layer positions itself against these CSS variables. */
.pdfv-page {
position: relative;
background: #fff;
box-shadow: 0 1px 6px rgb(0 0 0 / 0.35);
overflow: hidden;
--user-unit: 1;
--total-scale-factor: calc(var(--scale-factor) * var(--user-unit));
--scale-round-x: 1px;
--scale-round-y: 1px;
}
.pdfv-canvas {
display: block;
}
.pdfv-page-failed::after {
content: "!";
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
color: var(--bs-danger, #b91c1c);
font-size: 2rem;
}
.pdfv-error-detail {
margin-top: 0.4rem;
font-size: 0.8rem;
opacity: 0.75;
word-break: break-word;
}
/* ── HTML live preview ───────────────────────────────────────────────────────── */
/* Rendered in an origin-isolated iframe (srcdoc + sandbox="allow-scripts").
White canvas so pages that don't set their own background stay legible. */
.fv-html {
width: 100%;
height: 100%;
border: none;
display: block;
background: #fff;
}
/* ── LaTeX compile-error banner (shown above the source fallback) ─────────────── */
.fv-compile-error {
margin: 0;
padding: 0.5rem 1.5rem;
background: var(--bs-warning-bg-subtle, #fff3cd);
border-bottom: 1px solid var(--bs-border-color);
font-size: 0.85rem;
}
.fv-compile-error > summary {
cursor: pointer;
user-select: none;
padding: 0.25rem 0;
}
.fv-compile-error > pre {
margin: 0.5rem 0 0.75rem;
padding: 0.75rem 1rem;
max-height: 40vh;
overflow: auto;
background: var(--bs-secondary-bg);
border-radius: 6px;
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
font-size: 0.8rem;
white-space: pre-wrap;
word-break: break-word;
}
/* ── Image preview ───────────────────────────────────────────────────────────── */
.fv-image-wrap {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;
background: var(--bs-secondary-bg);
}
.fv-image {
max-width: 100%;
max-height: 100%;
object-fit: contain;
border-radius: 4px;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}
/* SVG renders in a sandboxed iframe; the SVG root fills the iframe viewport and
scales to its viewBox. White canvas so light-on-transparent SVGs stay legible. */
.fv-svg {
width: 100%;
height: 100%;
border: none;
background: #fff;
border-radius: 4px;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}