forge
Explore
Log in

Don't you dare go Hollow

The PDF reader gets the workbook's full-size panel, a presentation mode, and an aligned header: the plugin only unfolds its full toolbar with room, so the panel takes the viewer out to min(96vw, 1400px) and full height; a Present control fullscreens the panel with the plugin's own toolbar intact, Escape in fullscreen exits the presentation without closing the viewer; and the header's actions center on one row instead of the download box riding the headline's top edge — plus a few stray blank lines in i18n.rs left over from the avatar batch

Browse files at this commit

c7f38efd1a8e684c7408aa9c7245797e4269ecb3Ahmet Kaan GümüşParent: 8eb2137
crates/iz-web/src/detail.rsmodified+36 -2
@@ -31,7 +31,7 @@ use topcoat::router::{HeaderName, StatusCode, header, route};
31 use topcoat::view::{class, view};31 use topcoat::view::{class, view};
32 32
33 use crate::i18n::{Key, Lang, t};33 use crate::i18n::{Key, Lang, t};
34-use crate::server::{Refusal, store, back_to, mail, refusal_of, require_user, require_writer};34+use crate::server::{Refusal, back_to, mail, refusal_of, require_user, require_writer, store};
35 35
36 /// A task this board could be linked to: enough to name it in the picker and36 /// A task this board could be linked to: enough to name it in the picker and
37 /// nothing more.37 /// nothing more.
@@ -417,7 +417,9 @@ async fn load_snapshot(
417 state_kind: state_kind.to_string(),417 state_kind: state_kind.to_string(),
418 attempts: send.attempts,418 attempts: send.attempts,
419 last_error: may_administer.then(|| send.last_error.clone()).flatten(),419 last_error: may_administer.then(|| send.last_error.clone()).flatten(),
420- sent_at: send.sent_at.map(|at| moment_label_with_seconds_in(at, zone)),420+ sent_at: send
421+ .sent_at
422+ .map(|at| moment_label_with_seconds_in(at, zone)),
421 }423 }
422 })424 })
423 .collect();425 .collect();
@@ -1168,6 +1170,7 @@ pub(crate) async fn escape_closes(cx: &Cx) -> Result {
1168 window.__izEsc.register(90, function () { \1170 window.__izEsc.register(90, function () { \
1169 if (document.querySelector('.datepick-pop .edit-toggle:checked')) { return false; } \1171 if (document.querySelector('.datepick-pop .edit-toggle:checked')) { return false; } \
1170 if (document.querySelector('.viewer-scrim')) { \1172 if (document.querySelector('.viewer-scrim')) { \
1173+ if (document.fullscreenElement) { return true; } \
1171 window.__izCloseViewer(); \1174 window.__izCloseViewer(); \
1172 return true; \1175 return true; \
1173 } \1176 } \
@@ -2478,6 +2481,9 @@ pub async fn file_viewer_modal(
2478 <div class="modal viewer" tabindex="-1">2481 <div class="modal viewer" tabindex="-1">
2479 <header class="detail-head">2482 <header class="detail-head">
2480 <span class="detail-headline"><span class="detail-key">(name.clone())</span></span>2483 <span class="detail-headline"><span class="detail-key">(name.clone())</span></span>
2484+ if kind == crate::files::ViewerKind::Pdf {
2485+ <button type="button" class="quiet viewer-present">(t(lang, Key::Present))</button>
2486+ }
2481 <a class="quiet" href=(download_href)>(t(lang, Key::Download))</a>2487 <a class="quiet" href=(download_href)>(t(lang, Key::Download))</a>
2482 <span class="detail-esc">(t(lang, Key::Esc))</span>2488 <span class="detail-esc">(t(lang, Key::Esc))</span>
2483 <a class="detail-close" href=(close_href) aria-label=(t(lang, Key::CloseTheFile))>(glyph::cross(cx).await?)</a>2489 <a class="detail-close" href=(close_href) aria-label=(t(lang, Key::CloseTheFile))>(glyph::cross(cx).await?)</a>
@@ -2506,10 +2512,38 @@ pub async fn file_viewer_modal(
2506 }2512 }
2507 </div>2513 </div>
2508 </div>2514 </div>
2515+ if kind == crate::files::ViewerKind::Pdf {
2516+ (pdf_present_script(cx).await?)
2517+ }
2509 </div>2518 </div>
2510 }2519 }
2511 }2520 }
2512 2521
2522+/// The PDF reader's presentation mode: the browser's own plugin fills the
2523+/// screen — its toolbar, page box and thumbnails all keep working there,
2524+/// which a drawn-over canvas of our own would not give. Wiring is one
2525+/// delegated document listener, so a soft swap that replaces the button
2526+/// needs no re-wire: whichever `.viewer-present` is on screen when the
2527+/// click lands is the one that presents. `Escape` in fullscreen is the
2528+/// browser's own exit gesture and never reaches the page; the guard in
2529+/// [`escape_closes`] covers the ones that do.
2530+async fn pdf_present_script(cx: &Cx) -> Result {
2531+ use topcoat::view::Unescaped;
2532+ const JS: &str = "\
2533+ (function () { \
2534+ if (window.__izPresentWired) { return; } \
2535+ window.__izPresentWired = true; \
2536+ document.addEventListener('click', function (e) { \
2537+ var button = e.target.closest('.viewer-present'); \
2538+ if (!button) { return; } \
2539+ var panel = button.closest('.viewer'); \
2540+ if (!panel || !panel.requestFullscreen) { return; } \
2541+ if (document.fullscreenElement) { document.exitFullscreen(); } else { panel.requestFullscreen(); } \
2542+ }); \
2543+ })();";
2544+ view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }
2545+}
2546+
2513 /// One window of one sheet as a table: the tab strip when the book has more2547 /// One window of one sheet as a table: the tab strip when the book has more
2514 /// than one sheet, the grid with its column letters and row numbers, and the2548 /// than one sheet, the grid with its column letters and row numbers, and the
2515 /// two pagers that move the window. A workbook no reader here understands2549 /// two pagers that move the window. A workbook no reader here understands
crates/iz-web/src/i18n.rsmodified+3 -6
@@ -66,6 +66,7 @@ pub enum Key {
66 Play,66 Play,
67 Pause,67 Pause,
68 CloseTheFile,68 CloseTheFile,
69+ Present,
69 ThisFileWillNotOpen,70 ThisFileWillNotOpen,
70 Previous,71 Previous,
71 Next,72 Next,
@@ -359,7 +360,6 @@ pub fn take_off_this_task(lang: Lang, name: &str) -> String {
359 }360 }
360 }361 }
361 362
362-
363 /// The phrase a key names, in a user's language.363 /// The phrase a key names, in a user's language.
364 pub fn t(lang: Lang, key: Key) -> &'static str {364 pub fn t(lang: Lang, key: Key) -> &'static str {
365 use Key::*;365 use Key::*;
@@ -431,6 +431,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
431 (Play, Tr) => "Oynat",431 (Play, Tr) => "Oynat",
432 (Pause, En) => "Pause",432 (Pause, En) => "Pause",
433 (Pause, Tr) => "Duraklat",433 (Pause, Tr) => "Duraklat",
434+ (Present, En) => "Present",
435+ (Present, Tr) => "Sun",
434 (CloseTheFile, En) => "Close the file",436 (CloseTheFile, En) => "Close the file",
435 (CloseTheFile, Tr) => "Dosyayı kapat",437 (CloseTheFile, Tr) => "Dosyayı kapat",
436 (ThisFileWillNotOpen, En) => "This file will not open.",438 (ThisFileWillNotOpen, En) => "This file will not open.",
@@ -663,7 +665,6 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
663 (SenderNotConfiguredYet, En) => "No sender to test.",665 (SenderNotConfiguredYet, En) => "No sender to test.",
664 (SenderNotConfiguredYet, Tr) => "Test edilecek gönderen yok.",666 (SenderNotConfiguredYet, Tr) => "Test edilecek gönderen yok.",
665 667
666-
667 (MailRules, En) => "Mail rules",668 (MailRules, En) => "Mail rules",
668 (MailRules, Tr) => "Posta kuralları",669 (MailRules, Tr) => "Posta kuralları",
669 (EditLabel, En) => "Edit",670 (EditLabel, En) => "Edit",
@@ -1032,7 +1033,6 @@ pub fn last_seen_label(lang: Lang, day: &str) -> String {
1032 }1033 }
1033 }1034 }
1034 1035
1035-
1036 /// The sender panel's failed-test note, in a user's language.1036 /// The sender panel's failed-test note, in a user's language.
1037 pub fn not_delivered_label(lang: Lang, moment: &str, problem: &str) -> String {1037 pub fn not_delivered_label(lang: Lang, moment: &str, problem: &str) -> String {
1038 match lang {1038 match lang {
@@ -1141,9 +1141,6 @@ pub fn unblocked_label(lang: Lang, detail: &str) -> String {
1141 }1141 }
1142 }1142 }
1143 1143
1144-
1145-
1146-
1147 pub fn role_changed_label(lang: Lang, detail: &str) -> String {1144 pub fn role_changed_label(lang: Lang, detail: &str) -> String {
1148 match lang {1145 match lang {
1149 Lang::En => format!("made {detail}"),1146 Lang::En => format!("made {detail}"),
style/main.scssmodified+40 -0
@@ -1263,6 +1263,45 @@ img.avatar {
1263 1263
1264 .viewer-pdf { width: 100%; height: 78vh; border: 1px solid var(--border); border-radius: var(--radius-md); }1264 .viewer-pdf { width: 100%; height: 78vh; border: 1px solid var(--border); border-radius: var(--radius-md); }
1265 1265
1266+// A PDF is the browser's own reader living in an <object>, and it reads like
1267+// a workbook does: the panel takes the viewer the whole way out, because the
1268+// plugin only unfolds its full toolbar — page box, thumbnails, zoom — when
1269+// it has the room, and a document is read, not peeked at through 960px.
1270+.viewer:has(.viewer-pdf) {
1271+ width: min(96vw, 1400px);
1272+ height: calc(100vh - 96px);
1273+ display: flex;
1274+ flex-direction: column;
1275+ overflow: hidden;
1276+
1277+ .viewer-body {
1278+ flex: 1;
1279+ min-height: 0;
1280+ align-items: stretch;
1281+ padding: 16px 20px 20px;
1282+ }
1283+
1284+ .viewer-pdf { height: 100%; max-height: none; }
1285+}
1286+
1287+// Presented, the panel is the screen. The plugin keeps its own toolbar and
1288+// the header keeps its actions; only the frame's chrome comes off.
1289+.viewer:fullscreen {
1290+ width: 100%;
1291+ max-width: none;
1292+ height: 100%;
1293+ max-height: none;
1294+ border: none;
1295+ border-radius: 0;
1296+}
1297+
1298+// The viewer's header actions line up on one centered row: the filename is a
1299+// single line, and the download/present boxes center against it instead of
1300+// riding the headline's top edge the way the task modal's taller controls do.
1301+.viewer .detail-head { align-items: center; }
1302+
1303+.viewer .detail-esc { margin-top: 0; }
1304+
1266 // A workbook has no element of its own, so the viewer draws it: a tab strip1305 // A workbook has no element of its own, so the viewer draws it: a tab strip
1267 // when the book has more than one sheet, and a grid that pans inside its own1306 // when the book has more than one sheet, and a grid that pans inside its own
1268 // box — the document never scrolls.1307 // box — the document never scrolls.
@@ -4107,6 +4146,7 @@ input[type="radio"] {
4107 .modal-scrim { padding: 16px; }4146 .modal-scrim { padding: 16px; }
4108 4147
4109 .modal { max-height: calc(100dvh - 32px); }4148 .modal { max-height: calc(100dvh - 32px); }
4149+ .viewer:has(.viewer-pdf) { height: calc(100dvh - 32px); }
4110 4150
4111 .new-task-row { flex-wrap: wrap; }4151 .new-task-row { flex-wrap: wrap; }
4112 4152