Polish: smaller version text, bigger loader logo, keep RevealJS slide on recompile
Build and Deploy Verso / deploy (push) Successful in 9m35s
Build and Deploy Verso / deploy (push) Successful in 9m35s
- Reduce the dashboard instance-name/version font size (07 -> 06). - Enlarge the Verso logo in the loading animation (160px -> 240px). - Preserve the current RevealJS slide across recompiles: capture the deck's URL hash (same-origin) and re-append it to the iframe src so the new build reopens on the same slide instead of jumping to the start. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { lazy, memo } from 'react'
|
||||
import { lazy, memo, useCallback, useRef } from 'react'
|
||||
import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context'
|
||||
|
||||
const PdfJsViewer = lazy(
|
||||
@@ -8,6 +8,36 @@ const PdfJsViewer = lazy(
|
||||
function PdfViewer() {
|
||||
const { pdfUrl, pdfFile, pdfViewer } = useCompileContext()
|
||||
|
||||
// Remember the current RevealJS slide (kept in the deck's URL hash, e.g.
|
||||
// "#/3/2") so that recompiling — which swaps the iframe src for a fresh
|
||||
// build — reopens the deck on the same slide instead of jumping to the
|
||||
// start. Only works when the output is same-origin (the usual self-hosted
|
||||
// case); cross-origin reads fail silently and we just lose the position.
|
||||
const lastHashRef = useRef('')
|
||||
|
||||
const handlePresentationLoad = useCallback(
|
||||
(event: React.SyntheticEvent<HTMLIFrameElement>) => {
|
||||
const win = event.currentTarget.contentWindow
|
||||
if (!win) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const capture = () => {
|
||||
try {
|
||||
lastHashRef.current = win.location.hash
|
||||
} catch {
|
||||
// cross-origin after navigation — ignore
|
||||
}
|
||||
}
|
||||
capture()
|
||||
win.addEventListener('hashchange', capture)
|
||||
} catch {
|
||||
// cross-origin: can't track the slide position
|
||||
}
|
||||
},
|
||||
[]
|
||||
)
|
||||
|
||||
if (!pdfUrl) {
|
||||
return null
|
||||
}
|
||||
@@ -15,10 +45,14 @@ function PdfViewer() {
|
||||
// HTML outputs (RevealJS, etc.) must always use the native iframe;
|
||||
// PDF.js cannot render HTML.
|
||||
if (pdfUrl.includes('output.html')) {
|
||||
// Re-append the remembered slide hash so the new build opens where the
|
||||
// user left off. RevealJS reads the hash on load and navigates there.
|
||||
const src = `${pdfUrl}${lastHashRef.current}`
|
||||
return (
|
||||
<iframe
|
||||
title="Presentation Preview"
|
||||
src={pdfUrl}
|
||||
src={src}
|
||||
onLoad={handlePresentationLoad}
|
||||
style={{ width: '100%', height: '100%', border: 'none' }}
|
||||
sandbox="allow-scripts allow-same-origin allow-presentation allow-popups"
|
||||
/>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
);
|
||||
|
||||
// Title, when used instead of a logo (the Verso instance name + version)
|
||||
--navbar-title-font-size: var(--font-size-07);
|
||||
--navbar-title-font-size: var(--font-size-06);
|
||||
--navbar-title-color: var(--neutral-20);
|
||||
--navbar-title-color-hover: var(--neutral-40);
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
background-color: var(--loading-screen-bg-color);
|
||||
|
||||
.loading-screen-brand-container {
|
||||
min-width: 160px;
|
||||
min-width: 240px;
|
||||
}
|
||||
|
||||
// Verso logo loader: the four quadrant circles drift on their own little
|
||||
@@ -67,7 +67,7 @@
|
||||
// breathes on top.
|
||||
.verso-loader {
|
||||
display: block;
|
||||
width: 160px;
|
||||
width: 240px;
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
margin: 0 auto;
|
||||
|
||||
Reference in New Issue
Block a user