The profile corner shows the whole display name, wrapping onto a second line at a space instead of cutting it with an ellipsis
Browse files at this commit5fbac6627c519c07fb37ade7733cdcd407fdfcdeParent: 67c3573- style
- the profile corner shows the whole display name, wrapping onto a second line at a space instead of cutting it with an ellipsis
- the bell opens a small popover of the eight newest notifications (unread first, loaded from /notifications/peek when it opens) with an Open notifications button to the inbox, instead of going straight there
- a modifier or middle click, or no JavaScript, still follows the link
5 changed files +433 -24
- crates/forge-web/assets/nav.js +92 -0
- crates/forge-web/src/i18n/misc.rs +17 -0
- crates/forge-web/src/pages/notifications.rs +172 -15
- crates/forge-web/src/views/mod.rs +14 -1
- style/_shell.scss +138 -8
crates/forge-web/assets/nav.jsmodified+92 -0
| @@ -706,6 +706,98 @@ | |||
| 706 | closeDropdowns(e.target && e.target.nodeType === 1 ? e.target : null); | 706 | closeDropdowns(e.target && e.target.nodeType === 1 ? e.target : null); |
| 707 | }, false); | 707 | }, false); |
| 708 | 708 | ||
| 709 | + // The bell beside the profile corner opens a popover of the newest notifications instead of going | ||
| 710 | + // to the inbox. A plain click toggles it; with a modifier or a middle click the link's own | ||
| 711 | + // behaviour stays. The Popover API light-dismisses it and Escape closes it. Its list is fetched | ||
| 712 | + // each time it opens (see the toggle handler). The bell and the popover are siblings. | ||
| 713 | + var peekPress = null; // at a press: whether the popover was open (null before any press) | ||
| 714 | + | ||
| 715 | + function isPeekOpen(pop) { | ||
| 716 | + try { return pop.matches(':popover-open'); } catch (err) { return false; } | ||
| 717 | + } | ||
| 718 | + | ||
| 719 | + // Under the bell, opening upward: the popover's bottom sits 6px above the bell's top, and its left | ||
| 720 | + // edge follows the bell but stays inside the viewport. | ||
| 721 | + function placePeek(bell, pop) { | ||
| 722 | + if (!bell) { return; } | ||
| 723 | + var r = bell.getBoundingClientRect(); | ||
| 724 | + var left = Math.max(8, Math.min(r.left, window.innerWidth - pop.offsetWidth - 8)); | ||
| 725 | + pop.style.left = left + 'px'; | ||
| 726 | + pop.style.bottom = (window.innerHeight - r.top + 6) + 'px'; | ||
| 727 | + } | ||
| 728 | + | ||
| 729 | + // Fills the popover's list with the server's fragment. A reader who closed it meanwhile, or a newer | ||
| 730 | + // open, leaves the answer unused. | ||
| 731 | + function loadPeek(pop) { | ||
| 732 | + var list = pop.querySelector('.bell-list'); | ||
| 733 | + if (!list) { return; } | ||
| 734 | + var seq = ++peekSeq; | ||
| 735 | + var note = document.createElement('p'); | ||
| 736 | + note.className = 'bell-empty muted'; | ||
| 737 | + note.textContent = pop.getAttribute('data-loading') || ''; | ||
| 738 | + list.replaceChildren(note); | ||
| 739 | + fetch('/notifications/peek', { headers: { accept: 'text/html' }, credentials: 'same-origin' }).then(function (r) { | ||
| 740 | + if (!r.ok) { throw new Error('status ' + r.status); } | ||
| 741 | + return r.text(); | ||
| 742 | + }).then(function (html) { | ||
| 743 | + if (seq !== peekSeq || !isPeekOpen(pop)) { return; } | ||
| 744 | + var tpl = document.createElement('template'); | ||
| 745 | + tpl.innerHTML = html; | ||
| 746 | + list.replaceChildren(tpl.content); | ||
| 747 | + }).catch(function () { | ||
| 748 | + if (seq !== peekSeq || !isPeekOpen(pop)) { return; } | ||
| 749 | + var err = document.createElement('p'); | ||
| 750 | + err.className = 'bell-empty muted'; | ||
| 751 | + err.textContent = pop.getAttribute('data-error') || ''; | ||
| 752 | + list.replaceChildren(err); | ||
| 753 | + }); | ||
| 754 | + } | ||
| 755 | + var peekSeq = 0; // a fetch's number: only the newest answer is drawn | ||
| 756 | + | ||
| 757 | + // Records whether the popover was open when the press began. Light dismiss closes it on the press, | ||
| 758 | + // so the click that follows must not reopen it. | ||
| 759 | + document.addEventListener('pointerdown', function (e) { | ||
| 760 | + var bell = e.target && e.target.closest ? e.target.closest('.corner-bell') : null; | ||
| 761 | + if (!bell) { return; } | ||
| 762 | + var pop = bell.nextElementSibling; | ||
| 763 | + peekPress = !!(pop && pop.classList.contains('bell-pop') && isPeekOpen(pop)); | ||
| 764 | + }, true); | ||
| 765 | + | ||
| 766 | + document.addEventListener('click', function (e) { | ||
| 767 | + if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) { return; } | ||
| 768 | + var bell = e.target && e.target.closest ? e.target.closest('.corner-bell') : null; | ||
| 769 | + if (!bell) { return; } | ||
| 770 | + var pop = bell.nextElementSibling; | ||
| 771 | + if (!pop || !pop.classList.contains('bell-pop')) { return; } | ||
| 772 | + e.preventDefault(); | ||
| 773 | + // A keyboard click has no press: the popover's own state decides. | ||
| 774 | + var was = peekPress === null ? isPeekOpen(pop) : peekPress; | ||
| 775 | + peekPress = null; | ||
| 776 | + try { | ||
| 777 | + if (was) { pop.hidePopover(); } else { pop.showPopover(); } | ||
| 778 | + } catch (err) { } | ||
| 779 | + }, false); | ||
| 780 | + | ||
| 781 | + // The popover's open state drives its bell's aria-expanded; opening places it and fetches its list. | ||
| 782 | + document.addEventListener('toggle', function (e) { | ||
| 783 | + var pop = e.target; | ||
| 784 | + if (!pop || !pop.classList || !pop.classList.contains('bell-pop')) { return; } | ||
| 785 | + var bell = pop.previousElementSibling; | ||
| 786 | + var open = e.newState === 'open'; | ||
| 787 | + if (bell && bell.classList.contains('corner-bell')) { bell.setAttribute('aria-expanded', open ? 'true' : 'false'); } | ||
| 788 | + if (open) { | ||
| 789 | + placePeek(bell, pop); | ||
| 790 | + loadPeek(pop); | ||
| 791 | + } | ||
| 792 | + }, true); | ||
| 793 | + | ||
| 794 | + // A page swap replaces the sidebar; an open popover goes with the page it was opened on. | ||
| 795 | + document.addEventListener('forge:swapped', function () { | ||
| 796 | + document.querySelectorAll('.bell-pop').forEach(function (pop) { | ||
| 797 | + try { pop.hidePopover(); } catch (err) { } | ||
| 798 | + }); | ||
| 799 | + }); | ||
| 800 | + | ||
| 709 | // Escape closes the open dropdowns and returns focus to the summary of the one that held it. | 801 | // Escape closes the open dropdowns and returns focus to the summary of the one that held it. |
| 710 | document.addEventListener('keydown', function (e) { | 802 | document.addEventListener('keydown', function (e) { |
| 711 | if (e.key !== 'Escape') { return; } | 803 | if (e.key !== 'Escape') { return; } |
crates/forge-web/src/i18n/misc.rsmodified+17 -0
| @@ -178,6 +178,11 @@ pub enum K { | |||
| 178 | Cancelled, | 178 | Cancelled, |
| 179 | YourCiRuns, | 179 | YourCiRuns, |
| 180 | SearchPublicReposFor, | 180 | SearchPublicReposFor, |
| 181 | + // The bell's popover: the newest notifications, opened from the profile corner. | ||
| 182 | + OpenNotifications, | ||
| 183 | + PeekLoading, | ||
| 184 | + PeekError, | ||
| 185 | + AllCaughtUp, | ||
| 181 | } | 186 | } |
| 182 | 187 | ||
| 183 | /// Every variant, for the coverage test below. | 188 | /// Every variant, for the coverage test below. |
| @@ -333,6 +338,10 @@ const ALL: &[K] = &[ | |||
| 333 | K::Cancelled, | 338 | K::Cancelled, |
| 334 | K::YourCiRuns, | 339 | K::YourCiRuns, |
| 335 | K::SearchPublicReposFor, | 340 | K::SearchPublicReposFor, |
| 341 | + K::OpenNotifications, | ||
| 342 | + K::PeekLoading, | ||
| 343 | + K::PeekError, | ||
| 344 | + K::AllCaughtUp, | ||
| 336 | ]; | 345 | ]; |
| 337 | 346 | ||
| 338 | pub fn t(lang: Lang, key: K) -> &'static str { | 347 | pub fn t(lang: Lang, key: K) -> &'static str { |
| @@ -663,6 +672,14 @@ pub fn t(lang: Lang, key: K) -> &'static str { | |||
| 663 | (Cancelled, Tr) => "iptal edildi", | 672 | (Cancelled, Tr) => "iptal edildi", |
| 664 | (YourCiRuns, En) => "Your CI runs", | 673 | (YourCiRuns, En) => "Your CI runs", |
| 665 | (YourCiRuns, Tr) => "CI çalıştırmaların", | 674 | (YourCiRuns, Tr) => "CI çalıştırmaların", |
| 675 | + (OpenNotifications, En) => "Open notifications", | ||
| 676 | + (OpenNotifications, Tr) => "Bildirimleri aç", | ||
| 677 | + (PeekLoading, En) => "Loading…", | ||
| 678 | + (PeekLoading, Tr) => "Yükleniyor…", | ||
| 679 | + (PeekError, En) => "Notifications could not be loaded.", | ||
| 680 | + (PeekError, Tr) => "Bildirimler yüklenemedi.", | ||
| 681 | + (AllCaughtUp, En) => "You're all caught up", | ||
| 682 | + (AllCaughtUp, Tr) => "Hepsini gördünüz", | ||
| 666 | (SearchPublicReposFor, En) => "Search public repositories for", | 683 | (SearchPublicReposFor, En) => "Search public repositories for", |
| 667 | (SearchPublicReposFor, Tr) => "Herkese açık depolarda ara:", | 684 | (SearchPublicReposFor, Tr) => "Herkese açık depolarda ara:", |
| 668 | } | 685 | } |
crates/forge-web/src/pages/notifications.rsmodified+172 -15
| @@ -19,9 +19,9 @@ use topcoat::context::{Cx, app_context}; | |||
| 19 | use topcoat::router::content::Form; | 19 | use topcoat::router::content::Form; |
| 20 | use topcoat::router::content::sse::Event; | 20 | use topcoat::router::content::sse::Event; |
| 21 | use topcoat::router::error::{SeeOther, bad_request, not_found, see_other}; | 21 | use topcoat::router::error::{SeeOther, bad_request, not_found, see_other}; |
| 22 | -use topcoat::router::response::Response; | 22 | +use topcoat::router::response::{IntoResponse, Response}; |
| 23 | use topcoat::router::{Body, StatusCode, page, path_param, query_params, route}; | 23 | use topcoat::router::{Body, StatusCode, page, path_param, query_params, route}; |
| 24 | -use topcoat::view::{View, component, view}; | 24 | +use topcoat::view::{View, ViewExt, component, view}; |
| 25 | 25 | ||
| 26 | use crate::auth::{current_user, percent_encode, require_csrf, require_user}; | 26 | use crate::auth::{current_user, percent_encode, require_csrf, require_user}; |
| 27 | use crate::i18n::alerts as alert_text; | 27 | use crate::i18n::alerts as alert_text; |
| @@ -51,6 +51,9 @@ path_param!(admin_note); | |||
| 51 | /// The pseudo repo id of the admin alerts group in the inbox. | 51 | /// The pseudo repo id of the admin alerts group in the inbox. |
| 52 | const ADMIN_GROUP: &str = "admin"; | 52 | const ADMIN_GROUP: &str = "admin"; |
| 53 | 53 | ||
| 54 | +/// Rows in the bell's popover. | ||
| 55 | +const PEEK_SIZE: u32 = 8; | ||
| 56 | + | ||
| 54 | #[query_params(error = bad_request)] | 57 | #[query_params(error = bad_request)] |
| 55 | struct InboxQuery { | 58 | struct InboxQuery { |
| 56 | all: Option<String>, | 59 | all: Option<String>, |
| @@ -146,6 +149,15 @@ impl Entry { | |||
| 146 | } | 149 | } |
| 147 | } | 150 | } |
| 148 | 151 | ||
| 152 | + fn unread(&self) -> bool { | ||
| 153 | + match self { | ||
| 154 | + Entry::Issue(note) => note.unread, | ||
| 155 | + Entry::Discussion(note) => note.unread, | ||
| 156 | + Entry::Advisory(note) => note.unread, | ||
| 157 | + Entry::Admin(note) => note.unread, | ||
| 158 | + } | ||
| 159 | + } | ||
| 160 | + | ||
| 149 | fn updated_at(&self) -> &str { | 161 | fn updated_at(&self) -> &str { |
| 150 | match self { | 162 | match self { |
| 151 | Entry::Issue(note) => ¬e.updated_at, | 163 | Entry::Issue(note) => ¬e.updated_at, |
| @@ -291,6 +303,115 @@ fn admin_row(lang: Lang, note: &AdminNotice, tz: &str, now: i64) -> RowView { | |||
| 291 | } | 303 | } |
| 292 | } | 304 | } |
| 293 | 305 | ||
| 306 | +/// Whether the viewer may see an inbox entry: its repo must be readable, and security alerts need | ||
| 307 | +/// the repo's managers, the same rule as the security page. `readable` caches the repo checks. | ||
| 308 | +/// Admin alerts need no repo. | ||
| 309 | +async fn entry_visible( | ||
| 310 | + state: &AppState, | ||
| 311 | + user: &User, | ||
| 312 | + readable: &mut HashMap<String, bool>, | ||
| 313 | + entry: &Entry, | ||
| 314 | +) -> Result<bool> { | ||
| 315 | + if let Entry::Admin(_) = entry { | ||
| 316 | + return Ok(true); | ||
| 317 | + } | ||
| 318 | + let repo_id = entry.repo_id(); | ||
| 319 | + let visible = match readable.get(repo_id) { | ||
| 320 | + Some(visible) => *visible, | ||
| 321 | + None => { | ||
| 322 | + let visible = can_read(state, user, repo_id).await?; | ||
| 323 | + readable.insert(repo_id.to_owned(), visible); | ||
| 324 | + visible | ||
| 325 | + } | ||
| 326 | + }; | ||
| 327 | + Ok(visible | ||
| 328 | + && (!matches!(entry, Entry::Advisory(_)) | ||
| 329 | + || can_manage_alerts(state, user, repo_id).await?)) | ||
| 330 | +} | ||
| 331 | + | ||
| 332 | +/// The newest entries of each list the inbox reads, unread ones only or all of them, at most | ||
| 333 | +/// `limit` from each list. | ||
| 334 | +async fn list_entries( | ||
| 335 | + state: &AppState, | ||
| 336 | + user: &User, | ||
| 337 | + unread_only: bool, | ||
| 338 | + limit: u32, | ||
| 339 | +) -> Result<Vec<Entry>> { | ||
| 340 | + let mut entries: Vec<Entry> = state | ||
| 341 | + .store | ||
| 342 | + .list_notifications(&user.id, unread_only, None, limit) | ||
| 343 | + .await? | ||
| 344 | + .into_iter() | ||
| 345 | + .map(Entry::Issue) | ||
| 346 | + .collect(); | ||
| 347 | + entries.extend( | ||
| 348 | + state | ||
| 349 | + .store | ||
| 350 | + .list_discussion_notifications(&user.id, unread_only, None, limit) | ||
| 351 | + .await? | ||
| 352 | + .into_iter() | ||
| 353 | + .map(Entry::Discussion), | ||
| 354 | + ); | ||
| 355 | + entries.extend( | ||
| 356 | + state | ||
| 357 | + .store | ||
| 358 | + .list_advisory_notifications(&user.id, unread_only, None, limit) | ||
| 359 | + .await? | ||
| 360 | + .into_iter() | ||
| 361 | + .map(Entry::Advisory), | ||
| 362 | + ); | ||
| 363 | + if user.is_admin { | ||
| 364 | + entries.extend( | ||
| 365 | + state | ||
| 366 | + .store | ||
| 367 | + .list_admin_notices(&user.id, unread_only, None, limit) | ||
| 368 | + .await? | ||
| 369 | + .into_iter() | ||
| 370 | + .map(Entry::Admin), | ||
| 371 | + ); | ||
| 372 | + } | ||
| 373 | + Ok(entries) | ||
| 374 | +} | ||
| 375 | + | ||
| 376 | +/// The bell's popover rows: the viewer's newest entries, unread ones first, then read ones, each | ||
| 377 | +/// newest first. Entries the viewer can no longer read are left out and stay as they are. | ||
| 378 | +async fn peek_rows(state: &AppState, user: &User, lang: Lang, now: i64) -> Result<Vec<RowView>> { | ||
| 379 | + let tz = user.timezone.clone(); | ||
| 380 | + let mut entries = list_entries(state, user, true, PEEK_SIZE).await?; | ||
| 381 | + // Under PEEK_SIZE unread entries in all, every list was read to its end, so none is missing; | ||
| 382 | + // the read ones come from the newest of each list. | ||
| 383 | + if entries.len() < PEEK_SIZE as usize { | ||
| 384 | + entries.extend( | ||
| 385 | + list_entries(state, user, false, PEEK_SIZE) | ||
| 386 | + .await? | ||
| 387 | + .into_iter() | ||
| 388 | + .filter(|entry| !entry.unread()), | ||
| 389 | + ); | ||
| 390 | + } | ||
| 391 | + entries.sort_by(|a, b| { | ||
| 392 | + b.unread() | ||
| 393 | + .cmp(&a.unread()) | ||
| 394 | + .then_with(|| b.updated_at().cmp(a.updated_at())) | ||
| 395 | + }); | ||
| 396 | + let mut readable = HashMap::new(); | ||
| 397 | + let mut rows = Vec::new(); | ||
| 398 | + for entry in &entries { | ||
| 399 | + if rows.len() == PEEK_SIZE as usize { | ||
| 400 | + break; | ||
| 401 | + } | ||
| 402 | + if !entry_visible(state, user, &mut readable, entry).await? { | ||
| 403 | + continue; | ||
| 404 | + } | ||
| 405 | + rows.push(match entry { | ||
| 406 | + Entry::Issue(note) => issue_row(lang, note, &tz, now), | ||
| 407 | + Entry::Discussion(note) => discussion_row(lang, note, &tz, now), | ||
| 408 | + Entry::Advisory(note) => advisory_row(lang, note, &tz, now), | ||
| 409 | + Entry::Admin(note) => admin_row(lang, note, &tz, now), | ||
| 410 | + }); | ||
| 411 | + } | ||
| 412 | + Ok(rows) | ||
| 413 | +} | ||
| 414 | + | ||
| 294 | #[page("/notifications")] | 415 | #[page("/notifications")] |
| 295 | async fn inbox(cx: &Cx) -> Result<impl View> { | 416 | async fn inbox(cx: &Cx) -> Result<impl View> { |
| 296 | let viewer = require_user(cx).await?; | 417 | let viewer = require_user(cx).await?; |
| @@ -380,19 +501,7 @@ async fn inbox(cx: &Cx) -> Result<impl View> { | |||
| 380 | } | 501 | } |
| 381 | continue; | 502 | continue; |
| 382 | } | 503 | } |
| 383 | - let visible = match readable.get(&repo_id) { | 504 | + if !entry_visible(state, user, &mut readable, &entry).await? { |
| 384 | - Some(visible) => *visible, | ||
| 385 | - None => { | ||
| 386 | - let visible = can_read(state, user, &repo_id).await?; | ||
| 387 | - readable.insert(repo_id.clone(), visible); | ||
| 388 | - visible | ||
| 389 | - } | ||
| 390 | - }; | ||
| 391 | - // Security alerts are for the repo's managers only, the same rule as the security page. | ||
| 392 | - let visible = visible | ||
| 393 | - && (!matches!(entry, Entry::Advisory(_)) | ||
| 394 | - || can_manage_alerts(state, user, &repo_id).await?); | ||
| 395 | - if !visible { | ||
| 396 | hidden.push(entry); | 505 | hidden.push(entry); |
| 397 | continue; | 506 | continue; |
| 398 | } | 507 | } |
| @@ -460,6 +569,54 @@ async fn inbox(cx: &Cx) -> Result<impl View> { | |||
| 460 | }) | 569 | }) |
| 461 | } | 570 | } |
| 462 | 571 | ||
| 572 | +/// `GET /notifications/peek`: the bell's popover, the viewer's newest notifications as an HTML | ||
| 573 | +/// fragment. Anonymous viewers get a bare 401. | ||
| 574 | +#[route(GET "/notifications/peek")] | ||
| 575 | +async fn peek(cx: &Cx) -> Result<Response> { | ||
| 576 | + let Some((user, _)) = current_user(cx).await? else { | ||
| 577 | + let mut res = Response::new(Body::empty()); | ||
| 578 | + *res.status_mut() = StatusCode::UNAUTHORIZED; | ||
| 579 | + return Ok(res); | ||
| 580 | + }; | ||
| 581 | + let state = app_context::<AppState>(cx); | ||
| 582 | + let lang = i18n::lang(cx, Some(&user)); | ||
| 583 | + let rows = peek_rows(state, &user, lang, now_unix()).await?; | ||
| 584 | + let fragment = view! { peek_list(lang: lang, rows: rows) }; | ||
| 585 | + fragment.first().await?.into_response(cx) | ||
| 586 | +} | ||
| 587 | + | ||
| 588 | +/// The bell's popover list: each row opens through its open route, which marks it read. An empty | ||
| 589 | +/// list says the viewer is all caught up. | ||
| 590 | +#[component] | ||
| 591 | +async fn peek_list(lang: Lang, rows: Vec<RowView>) -> Result<impl View> { | ||
| 592 | + let empty = rows.is_empty(); | ||
| 593 | + Ok(view! { | ||
| 594 | + if empty { | ||
| 595 | + <p class="bell-empty muted">(g::t(lang, K::AllCaughtUp))</p> | ||
| 596 | + } | ||
| 597 | + <ul class="bell-rows"> | ||
| 598 | + for row in rows.into_iter() { | ||
| 599 | + <li> | ||
| 600 | + <a class="bell-item" href=(row.open_href.as_str())> | ||
| 601 | + if row.unread { | ||
| 602 | + <span class="bell-dot unread" aria-hidden="true"></span> | ||
| 603 | + } else { | ||
| 604 | + <span class="bell-dot" aria-hidden="true"></span> | ||
| 605 | + } | ||
| 606 | + <span class="bell-text"> | ||
| 607 | + <span class="bell-line">(row.title_line.as_str())</span> | ||
| 608 | + <span class="bell-meta muted"> | ||
| 609 | + <span>(row.kind_label)</span> | ||
| 610 | + <time data-rel="true" datetime=(row.iso.as_str()) title=(row.absolute.as_str())>(row.relative.as_str())</time> | ||
| 611 | + </span> | ||
| 612 | + </span> | ||
| 613 | + </a> | ||
| 614 | + </li> | ||
| 615 | + } | ||
| 616 | + </ul> | ||
| 617 | + }) | ||
| 618 | +} | ||
| 619 | + | ||
| 463 | /// The URL of the inbox's live stream for the tab the viewer is on. | 620 | /// The URL of the inbox's live stream for the tab the viewer is on. |
| 464 | fn inbox_live_url(all: bool) -> String { | 621 | fn inbox_live_url(all: bool) -> String { |
| 465 | if all { | 622 | if all { |
crates/forge-web/src/views/mod.rsmodified+14 -1
| @@ -357,7 +357,12 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> | |||
| 357 | let settings_label = o::t(lang, OK::Settings); | 357 | let settings_label = o::t(lang, OK::Settings); |
| 358 | let admin_label = ad::t(lang, AK::AdminArea); | 358 | let admin_label = ad::t(lang, AK::AdminArea); |
| 359 | let logout_label = t(lang, Key::LogOut); | 359 | let logout_label = t(lang, Key::LogOut); |
| 360 | + let bell_title = i18n::t(lang, Key::Notifications); | ||
| 361 | + let open_label = mi::t(lang, MK::OpenNotifications); | ||
| 362 | + let loading_label = mi::t(lang, MK::PeekLoading); | ||
| 363 | + let error_label = mi::t(lang, MK::PeekError); | ||
| 360 | Ok(view! { | 364 | Ok(view! { |
| 365 | + <div class="corner-wrap"> | ||
| 361 | <details class="corner" data-unread-stream=""> | 366 | <details class="corner" data-unread-stream=""> |
| 362 | <summary class="corner-btn" aria-label=(corner.username.as_str())> | 367 | <summary class="corner-btn" aria-label=(corner.username.as_str())> |
| 363 | <span class=(ring_class)><img class="avatar avatar-sm" src=(corner.avatar.as_str()) alt="" width="28" height="28"></span> | 368 | <span class=(ring_class)><img class="avatar avatar-sm" src=(corner.avatar.as_str()) alt="" width="28" height="28"></span> |
| @@ -373,7 +378,6 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> | |||
| 373 | <a class="chip chip-failing" href=(corner.failing_href.as_str()) title=(title.as_str())><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"/></svg>(count.as_str())</a> | 378 | <a class="chip chip-failing" href=(corner.failing_href.as_str()) title=(title.as_str())><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"/></svg>(count.as_str())</a> |
| 374 | } | 379 | } |
| 375 | </span> | 380 | </span> |
| 376 | - <a class="corner-bell" href="/notifications" title=(bell_label) aria-label=(bell_label)><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/></svg></a> | ||
| 377 | </summary> | 381 | </summary> |
| 378 | <div class="corner-menu"> | 382 | <div class="corner-menu"> |
| 379 | <div class="corner-theme"><span>(theme_label)</span> | 383 | <div class="corner-theme"><span>(theme_label)</span> |
| @@ -402,6 +406,15 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> | |||
| 402 | </form> | 406 | </form> |
| 403 | </div> | 407 | </div> |
| 404 | </details> | 408 | </details> |
| 409 | + <a class="corner-bell" href="/notifications" title=(bell_label) aria-label=(bell_label) aria-expanded="false"><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/></svg></a> | ||
| 410 | + <div class="bell-pop" popover="auto" role="dialog" aria-label=(bell_title) data-loading=(loading_label) data-error=(error_label)> | ||
| 411 | + <div class="bell-box"> | ||
| 412 | + <div class="bell-head">(bell_title)</div> | ||
| 413 | + <div class="bell-list"></div> | ||
| 414 | + <a class="button bell-open" href="/notifications">(open_label)</a> | ||
| 415 | + </div> | ||
| 416 | + </div> | ||
| 417 | + </div> | ||
| 405 | }) | 418 | }) |
| 406 | } | 419 | } |
| 407 | 420 | ||
style/_shell.scssmodified+138 -8
| @@ -653,17 +653,23 @@ | |||
| 653 | 653 | ||
| 654 | // Profile corner: the signed-in user at the bottom of the sidebar. Its menu opens upward. | 654 | // Profile corner: the signed-in user at the bottom of the sidebar. Its menu opens upward. |
| 655 | 655 | ||
| 656 | -.corner { | 656 | +// The corner's outer box: the rule above it and its place at the sidebar's foot. The bell sits in it |
| 657 | +// beside the details, so the box holds both. | ||
| 658 | +.corner-wrap { | ||
| 657 | position: relative; | 659 | position: relative; |
| 658 | margin-top: auto; | 660 | margin-top: auto; |
| 659 | padding-top: 8px; | 661 | padding-top: 8px; |
| 660 | border-top: 1px solid var(--border); | 662 | border-top: 1px solid var(--border); |
| 661 | } | 663 | } |
| 662 | 664 | ||
| 663 | -.nav-panel .corner { | 665 | +.nav-panel .corner-wrap { |
| 664 | margin-top: 12px; | 666 | margin-top: 12px; |
| 665 | } | 667 | } |
| 666 | 668 | ||
| 669 | +.corner { | ||
| 670 | + position: relative; | ||
| 671 | +} | ||
| 672 | + | ||
| 667 | // The phone panel scrolls, so a menu opening upward would be cut at its top: it opens in place. | 673 | // The phone panel scrolls, so a menu opening upward would be cut at its top: it opens in place. |
| 668 | .nav-panel .corner-menu { | 674 | .nav-panel .corner-menu { |
| 669 | position: static; | 675 | position: static; |
| @@ -690,13 +696,24 @@ | |||
| 690 | } | 696 | } |
| 691 | } | 697 | } |
| 692 | 698 | ||
| 699 | +// The bell overlays the summary's right end, so the chips and the name keep clear of it. | ||
| 700 | +.corner-wrap .corner-btn { | ||
| 701 | + padding-right: 48px; | ||
| 702 | +} | ||
| 703 | + | ||
| 704 | +// The name wraps onto at most two lines, breaking at spaces. A single word too long for the line | ||
| 705 | +// breaks inside it. | ||
| 693 | .corner-name { | 706 | .corner-name { |
| 694 | min-width: 0; | 707 | min-width: 0; |
| 695 | overflow: hidden; | 708 | overflow: hidden; |
| 696 | - font-size: 14px; | 709 | + font-size: 13.5px; |
| 697 | font-weight: 600; | 710 | font-weight: 600; |
| 698 | - text-overflow: ellipsis; | 711 | + line-height: 1.2; |
| 699 | - white-space: nowrap; | 712 | + white-space: normal; |
| 713 | + overflow-wrap: break-word; | ||
| 714 | + display: -webkit-box; | ||
| 715 | + -webkit-line-clamp: 2; | ||
| 716 | + -webkit-box-orient: vertical; | ||
| 700 | } | 717 | } |
| 701 | 718 | ||
| 702 | // The avatar on its own when nothing runs; while a run of the viewer's is queued or running (.hot) | 719 | // The avatar on its own when nothing runs; while a run of the viewer's is queued or running (.hot) |
| @@ -768,8 +785,12 @@ a.chip { | |||
| 768 | } | 785 | } |
| 769 | } | 786 | } |
| 770 | 787 | ||
| 771 | -// The bell at the corner's right end: the inbox. | 788 | +// The bell at the corner's right end, over the summary row (its 50px: the 8px top padding and the |
| 789 | +// 34px avatar with the summary's padding). It opens the popover of the newest notifications. | ||
| 772 | .corner-bell { | 790 | .corner-bell { |
| 791 | + position: absolute; | ||
| 792 | + top: 19px; | ||
| 793 | + right: 14px; | ||
| 773 | display: grid; | 794 | display: grid; |
| 774 | flex: none; | 795 | flex: none; |
| 775 | place-items: center; | 796 | place-items: center; |
| @@ -789,6 +810,115 @@ a.chip { | |||
| 789 | } | 810 | } |
| 790 | } | 811 | } |
| 791 | 812 | ||
| 813 | +// The bell's popover: the newest notifications, opened upward from the bell (nav.js places it). The | ||
| 814 | +// UA's centring is reset so the fixed placement holds. It has no display of its own: the UA hides it | ||
| 815 | +// while closed. | ||
| 816 | +.bell-pop { | ||
| 817 | + position: fixed; | ||
| 818 | + inset: auto; | ||
| 819 | + margin: 0; | ||
| 820 | + box-sizing: border-box; | ||
| 821 | + width: 320px; | ||
| 822 | + max-width: calc(100vw - 16px); | ||
| 823 | + max-height: min(420px, 70vh); | ||
| 824 | + padding: 0; | ||
| 825 | + overflow: hidden; | ||
| 826 | + background: var(--surface); | ||
| 827 | + color: var(--text); | ||
| 828 | + border: 1px solid var(--border); | ||
| 829 | + border-radius: var(--radius-md); | ||
| 830 | + box-shadow: var(--shadow); | ||
| 831 | +} | ||
| 832 | + | ||
| 833 | +.bell-box { | ||
| 834 | + display: flex; | ||
| 835 | + flex-direction: column; | ||
| 836 | + max-height: min(420px, 70vh); | ||
| 837 | +} | ||
| 838 | + | ||
| 839 | +.bell-head { | ||
| 840 | + padding: 10px 14px 8px; | ||
| 841 | + border-bottom: 1px solid var(--border); | ||
| 842 | + font-size: 14px; | ||
| 843 | + font-weight: 600; | ||
| 844 | +} | ||
| 845 | + | ||
| 846 | +.bell-list { | ||
| 847 | + flex: 1 1 auto; | ||
| 848 | + min-height: 0; | ||
| 849 | + overflow-y: auto; | ||
| 850 | + padding: 4px; | ||
| 851 | +} | ||
| 852 | + | ||
| 853 | +.bell-rows { | ||
| 854 | + margin: 0; | ||
| 855 | + padding: 0; | ||
| 856 | + list-style: none; | ||
| 857 | +} | ||
| 858 | + | ||
| 859 | +.bell-item { | ||
| 860 | + display: grid; | ||
| 861 | + grid-template-columns: 8px minmax(0, 1fr); | ||
| 862 | + gap: 10px; | ||
| 863 | + align-items: start; | ||
| 864 | + padding: 8px 10px; | ||
| 865 | + border-radius: var(--radius-md); | ||
| 866 | + color: var(--text); | ||
| 867 | + text-decoration: none; | ||
| 868 | + | ||
| 869 | + &:hover { | ||
| 870 | + background: var(--surface-2); | ||
| 871 | + text-decoration: none; | ||
| 872 | + } | ||
| 873 | +} | ||
| 874 | + | ||
| 875 | +.bell-dot { | ||
| 876 | + width: 8px; | ||
| 877 | + height: 8px; | ||
| 878 | + margin-top: 6px; | ||
| 879 | + border-radius: 50%; | ||
| 880 | + | ||
| 881 | + &.unread { | ||
| 882 | + background: var(--accent); | ||
| 883 | + } | ||
| 884 | +} | ||
| 885 | + | ||
| 886 | +.bell-text { | ||
| 887 | + display: grid; | ||
| 888 | + gap: 2px; | ||
| 889 | + min-width: 0; | ||
| 890 | +} | ||
| 891 | + | ||
| 892 | +.bell-line { | ||
| 893 | + font-size: 13.5px; | ||
| 894 | + line-height: 1.3; | ||
| 895 | + overflow-wrap: break-word; | ||
| 896 | + display: -webkit-box; | ||
| 897 | + -webkit-line-clamp: 2; | ||
| 898 | + -webkit-box-orient: vertical; | ||
| 899 | + overflow: hidden; | ||
| 900 | +} | ||
| 901 | + | ||
| 902 | +.bell-meta { | ||
| 903 | + display: flex; | ||
| 904 | + flex-wrap: wrap; | ||
| 905 | + gap: 6px; | ||
| 906 | + font-size: 12px; | ||
| 907 | +} | ||
| 908 | + | ||
| 909 | +.bell-empty { | ||
| 910 | + margin: 0; | ||
| 911 | + padding: 10px; | ||
| 912 | + font-size: 13px; | ||
| 913 | +} | ||
| 914 | + | ||
| 915 | +.bell-open { | ||
| 916 | + display: block; | ||
| 917 | + margin: 4px; | ||
| 918 | + text-align: center; | ||
| 919 | + text-decoration: none; | ||
| 920 | +} | ||
| 921 | + | ||
| 792 | .chip-review { | 922 | .chip-review { |
| 793 | color: var(--important); | 923 | color: var(--important); |
| 794 | background: color-mix(in srgb, var(--important) 12%, var(--surface)); | 924 | background: color-mix(in srgb, var(--important) 12%, var(--surface)); |
| @@ -1016,12 +1146,12 @@ button.corner-link.link-button { | |||
| 1016 | 1146 | ||
| 1017 | // The profile corner stays above a repo page's fixed tabs, which end where it starts: 50px of | 1147 | // The profile corner stays above a repo page's fixed tabs, which end where it starts: 50px of |
| 1018 | // corner, its rule and the sidebar's 24px bottom padding. | 1148 | // corner, its rule and the sidebar's 24px bottom padding. |
| 1019 | - .shell-sidebar .corner { | 1149 | + .shell-sidebar .corner-wrap { |
| 1020 | position: relative; | 1150 | position: relative; |
| 1021 | z-index: 6; | 1151 | z-index: 6; |
| 1022 | } | 1152 | } |
| 1023 | 1153 | ||
| 1024 | - .shell:has(> .shell-sidebar .corner) .repo-tabs { | 1154 | + .shell:has(> .shell-sidebar .corner-wrap) .repo-tabs { |
| 1025 | bottom: 76px; | 1155 | bottom: 76px; |
| 1026 | } | 1156 | } |
| 1027 | 1157 | ||