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 commitc7f38efd1a8e684c7408aa9c7245797e4269ecb3Parent: 8eb21373 changed files +79 -8
- crates/iz-web/src/detail.rs +36 -2
- crates/iz-web/src/i18n.rs +3 -6
- style/main.scss +40 -0
crates/iz-web/src/detail.rsmodified+36 -2
| @@ -31,7 +31,7 @@ use topcoat::router::{HeaderName, StatusCode, header, route}; | ||
| 31 | 31 | use topcoat::view::{class, view}; |
| 32 | 32 | |
| 33 | 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 | 36 | /// A task this board could be linked to: enough to name it in the picker and |
| 37 | 37 | /// nothing more. |
| @@ -417,7 +417,9 @@ async fn load_snapshot( | ||
| 417 | 417 | state_kind: state_kind.to_string(), |
| 418 | 418 | attempts: send.attempts, |
| 419 | 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 | 425 | .collect(); |
| @@ -1168,6 +1170,7 @@ pub(crate) async fn escape_closes(cx: &Cx) -> Result { | ||
| 1168 | 1170 | window.__izEsc.register(90, function () { \ |
| 1169 | 1171 | if (document.querySelector('.datepick-pop .edit-toggle:checked')) { return false; } \ |
| 1170 | 1172 | if (document.querySelector('.viewer-scrim')) { \ |
| 1173 | + if (document.fullscreenElement) { return true; } \ | |
| 1171 | 1174 | window.__izCloseViewer(); \ |
| 1172 | 1175 | return true; \ |
| 1173 | 1176 | } \ |
| @@ -2478,6 +2481,9 @@ pub async fn file_viewer_modal( | ||
| 2478 | 2481 | <div class="modal viewer" tabindex="-1"> |
| 2479 | 2482 | <header class="detail-head"> |
| 2480 | 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 | 2487 | <a class="quiet" href=(download_href)>(t(lang, Key::Download))</a> |
| 2482 | 2488 | <span class="detail-esc">(t(lang, Key::Esc))</span> |
| 2483 | 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 | 2513 | </div> |
| 2508 | 2514 | </div> |
| 2515 | + if kind == crate::files::ViewerKind::Pdf { | |
| 2516 | + (pdf_present_script(cx).await?) | |
| 2517 | + } | |
| 2509 | 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 | 2547 | /// One window of one sheet as a table: the tab strip when the book has more |
| 2514 | 2548 | /// than one sheet, the grid with its column letters and row numbers, and the |
| 2515 | 2549 | /// 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 | 66 | Play, |
| 67 | 67 | Pause, |
| 68 | 68 | CloseTheFile, |
| 69 | + Present, | |
| 69 | 70 | ThisFileWillNotOpen, |
| 70 | 71 | Previous, |
| 71 | 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 | 363 | /// The phrase a key names, in a user's language. |
| 364 | 364 | pub fn t(lang: Lang, key: Key) -> &'static str { |
| 365 | 365 | use Key::*; |
| @@ -431,6 +431,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | ||
| 431 | 431 | (Play, Tr) => "Oynat", |
| 432 | 432 | (Pause, En) => "Pause", |
| 433 | 433 | (Pause, Tr) => "Duraklat", |
| 434 | + (Present, En) => "Present", | |
| 435 | + (Present, Tr) => "Sun", | |
| 434 | 436 | (CloseTheFile, En) => "Close the file", |
| 435 | 437 | (CloseTheFile, Tr) => "Dosyayı kapat", |
| 436 | 438 | (ThisFileWillNotOpen, En) => "This file will not open.", |
| @@ -663,7 +665,6 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | ||
| 663 | 665 | (SenderNotConfiguredYet, En) => "No sender to test.", |
| 664 | 666 | (SenderNotConfiguredYet, Tr) => "Test edilecek gönderen yok.", |
| 665 | 667 | |
| 666 | - | |
| 667 | 668 | (MailRules, En) => "Mail rules", |
| 668 | 669 | (MailRules, Tr) => "Posta kuralları", |
| 669 | 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 | 1036 | /// The sender panel's failed-test note, in a user's language. |
| 1037 | 1037 | pub fn not_delivered_label(lang: Lang, moment: &str, problem: &str) -> String { |
| 1038 | 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 | 1144 | pub fn role_changed_label(lang: Lang, detail: &str) -> String { |
| 1148 | 1145 | match lang { |
| 1149 | 1146 | Lang::En => format!("made {detail}"), |
style/main.scssmodified+40 -0
| @@ -1263,6 +1263,45 @@ img.avatar { | ||
| 1263 | 1263 | |
| 1264 | 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 | 1305 | // A workbook has no element of its own, so the viewer draws it: a tab strip |
| 1267 | 1306 | // when the book has more than one sheet, and a grid that pans inside its own |
| 1268 | 1307 | // box — the document never scrolls. |
| @@ -4107,6 +4146,7 @@ input[type="radio"] { | ||
| 4107 | 4146 | .modal-scrim { padding: 16px; } |
| 4108 | 4147 | |
| 4109 | 4148 | .modal { max-height: calc(100dvh - 32px); } |
| 4149 | + .viewer:has(.viewer-pdf) { height: calc(100dvh - 32px); } | |
| 4110 | 4150 | |
| 4111 | 4151 | .new-task-row { flex-wrap: wrap; } |
| 4112 | 4152 |