@@ -216,5 +225,7 @@ async fn people_page(cx: &Cx) -> Result {
(crate::layout::escape_script(cx).await?)
+ (crate::detail::escape_closes(cx).await?)
+ (crate::layout::avatar_script(cx).await?)
}
}
diff --git a/crates/iz-web/src/settings.rs b/crates/iz-web/src/settings.rs
index ac7ec72..b62702d 100644
--- a/crates/iz-web/src/settings.rs
+++ b/crates/iz-web/src/settings.rs
@@ -957,7 +957,10 @@ async fn send_message(
};
let subject = input.subject.trim();
if subject.is_empty() {
- return Ok(saved_or_refused("send_message", Some(Refusal::EmptySubject)));
+ return Ok(saved_or_refused(
+ "send_message",
+ Some(Refusal::EmptySubject),
+ ));
}
let body = input.body.trim();
if body.is_empty() {
@@ -974,7 +977,12 @@ async fn send_message(
} else {
match members.into_iter().find(|member| member.id == input.to) {
Some(member) => vec![member.email],
- None => return Ok(saved_or_refused("send_message", Some(Refusal::NoSuchMember))),
+ None => {
+ return Ok(saved_or_refused(
+ "send_message",
+ Some(Refusal::NoSuchMember),
+ ));
+ }
}
};
let now = time::OffsetDateTime::now_utc();
@@ -1193,9 +1201,7 @@ fn is_origin(value: &str) -> bool {
return false;
};
let host = rest.split('/').next().unwrap_or_default();
- !host.is_empty()
- && !host.contains('@')
- && !value.chars().any(char::is_whitespace)
+ !host.is_empty() && !host.contains('@') && !value.chars().any(char::is_whitespace)
}
/// The refusal that landed on this call's redirect, if any, and this call's
@@ -1316,7 +1322,8 @@ async fn settings_page(cx: &Cx) -> Result {
None
};
let (limits, allowed_types) = if administers {
- let (attachment, photo, types, batch, reminder) = limits_now(cx, &user.workspace_id).await?;
+ let (attachment, photo, types, batch, reminder) =
+ limits_now(cx, &user.workspace_id).await?;
(Some((attachment, photo, batch, reminder)), types)
} else {
(None, Vec::new())
@@ -1954,66 +1961,6 @@ async fn settings_page(cx: &Cx) -> Result {
(crate::dropdown::dropdown_script(cx).await?)
(crate::layout::escape_script(cx).await?)
(crate::detail::escape_closes(cx).await?)
- (avatar_script(cx).await?)
+ (crate::layout::avatar_script(cx).await?)
}
}
-
-/// The profile photo's overlay: with a photo set, the avatar click opens the
-/// file viewer's chrome (`detail.rs`'s `file_viewer_modal` — the
-/// `.modal-scrim.viewer-scrim` scrim and the `.modal.viewer` panel around a
-/// `.viewer-media` image) around the same `/photo/{id}?v=` URL the avatar
-/// reads. Built here because the overlay has no server state behind it — no
-/// route, no query parameter, nothing to render — so it is client-built and
-/// `__izAdded`'d. Closing is not wired here at all: the stretched
-/// `.viewer-close` anchor and the scrim click are the global handlers in
-/// `layout.rs`'s soft-nav script, and Escape is `detail.rs`'s
-/// `escape_closes` (priority 90), emitted alongside this script. The picture
-/// is read off the avatar's own `
![]()
` at click time, stamp included, so a
-/// fresh upload is the fresh bytes. Change hands the click to the hidden
-/// file input, whose change the shared autosubmit listener in `layout.rs`
-/// posts as the photo form.
-async fn avatar_script(cx: &Cx) -> Result {
- use topcoat::view::Unescaped;
- const JS: &str = "\
- (function () { \
- if (window.__izAvatar) { return; } \
- window.__izAvatar = true; \
- document.addEventListener('click', function (e) { \
- var view = e.target.closest ? e.target.closest('.avatar-view') : null; \
- if (view) { \
- var img = view.querySelector('img.avatar'); \
- if (!img || document.querySelector('.viewer-scrim')) { return; } \
- var scrim = document.createElement('div'); \
- scrim.className = 'modal-scrim viewer-scrim'; \
- var close = document.createElement('a'); \
- close.className = 'viewer-close'; \
- close.href = window.location.href; \
- var label = view.getAttribute('data-close-label'); \
- if (label) { close.setAttribute('aria-label', label); } \
- var media = document.createElement('img'); \
- media.className = 'viewer-media'; \
- media.src = img.src; \
- media.alt = img.alt; \
- var body = document.createElement('div'); \
- body.className = 'viewer-body'; \
- body.appendChild(media); \
- var box = document.createElement('div'); \
- box.className = 'modal viewer'; \
- box.tabIndex = -1; \
- box.appendChild(body); \
- scrim.appendChild(close); \
- scrim.appendChild(box); \
- document.body.appendChild(window.__izAdded(scrim)); \
- box.focus(); \
- return; \
- } \
- var change = e.target.closest ? e.target.closest('[data-avatar-change]') : null; \
- if (change) { \
- var row = change.closest('.identity-row'); \
- var input = row ? row.querySelector('.file-upload-input') : null; \
- if (input) { input.click(); } \
- } \
- }, true); \
- })();";
- view! { cx => }
-}
diff --git a/crates/iz-web/tests/browser/photo.mjs b/crates/iz-web/tests/browser/photo.mjs
index 13e0572..c669ff6 100644
--- a/crates/iz-web/tests/browser/photo.mjs
+++ b/crates/iz-web/tests/browser/photo.mjs
@@ -211,6 +211,31 @@ if (!failures.length) {
}
}
+// The person page wears the same trigger: its xl avatar opens the same
+// overlay, at its own size — the settings row's 64px must not follow it.
+if (!failures.length) {
+ const ownId = await page.evaluate(() => {
+ const img = document.querySelector('.identity-row img.avatar');
+ const m = img && (img.getAttribute('src') || '').match(/\/photo\/([^?]+)/);
+ return m ? m[1] : null;
+ });
+ if (!ownId) {
+ failures.push('no own photo id to reach the person page with');
+ } else {
+ await page.goto(`${base}/people/${ownId}`, { waitUntil: 'networkidle' });
+ const wide = await page.evaluate(() => {
+ const img = document.querySelector('.person-head .avatar-view img.avatar');
+ return img ? img.getBoundingClientRect().width : 0;
+ });
+ if (wide <= 64) failures.push(`the person page's avatar shrank to ${wide}px inside the trigger`);
+ if (await openViewer('person-page')) {
+ await page.screenshot({ path: `${shots}/person-photo-viewer.png` });
+ await page.keyboard.press('Escape');
+ await viewerGone('person-page');
+ }
+ }
+}
+
await browser.close();
note(`page errors ${errors.length ? errors.join(' | ') : 'none'}`);
diff --git a/style/main.scss b/style/main.scss
index e4f1039..6078e0d 100644
--- a/style/main.scss
+++ b/style/main.scss
@@ -1064,24 +1064,28 @@ img.avatar {
gap: 14px;
}
-// The two faces of the 64px profile picture box: the picker label and, once
-// a photo exists, the viewer trigger.
+// The two faces of the profile picture box: the picker label and, once a
+// photo exists, the viewer trigger. The person page's own card wears the
+// trigger too — the box rules are shared, the size is not.
.avatar-upload,
.avatar-view {
position: relative;
flex: none;
cursor: pointer;
- .avatar {
- width: 64px;
- height: 64px;
- font-size: 20px;
- }
-
// The name tooltip has no job on your own picture.
.avatar[data-name]:hover::after { content: none; }
}
+// The settings row's picture is 64px whatever size class the avatar wears;
+// the person card's keeps its xl.
+.identity-row .avatar-upload .avatar,
+.identity-row .avatar-view .avatar {
+ width: 64px;
+ height: 64px;
+ font-size: 20px;
+}
+
// The trigger is the label's box with a button's chrome stripped.
.avatar-view {
appearance: none;