forge
Explore
Log in

Don't you dare go Hollow

Photo actions ride the profile head, iz's identity row

Browse files at this commit

99c1ffe90e777c45e73695bd3a5a8da6823b285bAhmet Kaan GümüşParent: 8092e0d
The separate Profile photo section is gone: the picker input is hidden and
its affordances live with the face — the no-photo tile is itself the picker
label, and quiet Change/Remove buttons sit under the chips when a photo is
set. im serves no script, so iz's data-autosubmit becomes a Save that
appears once the input holds a file — :has(:valid), CSS only. The form's
selector outranks .auth-card form, which would stack the row vertically.
crates/im-web/assets/main.cssmodified+22 -19
@@ -362,6 +362,7 @@ body:has(.auth-stage) > .auth-stage::-webkit-scrollbar {
362362 }
363363
364364 .profile-heading {
365+ flex: 1;
365366 display: flex;
366367 flex-direction: column;
367368 gap: 6px;
@@ -398,35 +399,37 @@ body:has(.auth-stage) > .auth-stage::-webkit-scrollbar {
398399 font-size: 13px;
399400 }
400401
401-.profile-photo-actions {
402+.auth-card .profile-photo-form {
402403 display: flex;
404+ flex-direction: row;
405+ flex-wrap: wrap;
403406 gap: 8px;
404407 align-items: center;
405408 }
406-.profile-photo-actions .profile-upload {
407- flex: 1;
408- width: auto;
409+.auth-card .profile-photo-form label.admin-action {
410+ display: inline-flex;
411+ align-items: center;
412+ box-sizing: border-box;
413+ cursor: pointer;
409414 }
410415
411-#profile-photo-remove {
416+.profile-file-hidden {
412417 display: none;
413418 }
414419
415-.profile-file {
416- height: auto;
417- padding: 7px 12px;
418- font-size: 12px;
419- color: var(--muted);
420+.profile-photo-save {
421+ display: none;
420422 }
421-.profile-file::file-selector-button {
422- margin-right: 10px;
423- padding: 4px 10px;
424- background: var(--panel-sunken);
425- border: 1px solid var(--border-strong);
426- border-radius: var(--radius);
427- color: var(--ink);
428- font-family: var(--font-sans);
429- font-size: 12px;
423+
424+.profile-photo-form:has(.profile-file-hidden:valid) .profile-photo-save {
425+ display: inline-flex;
426+}
427+
428+#profile-photo-remove {
429+ display: none;
430+}
431+
432+.profile-avatar-upload {
430433 cursor: pointer;
431434 }
432435
crates/im-web/src/pages.rsmodified+46 -36
@@ -427,7 +427,15 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
427427 (wordmark(cx).await?)
428428 <div class="auth-card">
429429 <div class="profile-head">
430- (avatar(cx, user).await?)
430+ if user.has_photo {
431+ (avatar(cx, user).await?)
432+ } else {
433+ // iz's no-photo idiom: the face itself is the
434+ // upload affordance — the label opens the picker.
435+ <label class="profile-avatar-upload" for="profile-photo-input">
436+ (avatar(cx, user).await?)
437+ </label>
438+ }
431439 <div class="profile-heading">
432440 <div class="auth-title">(user.name.clone())</div>
433441 <div class="profile-marks">
@@ -440,6 +448,43 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
440448 <span class="chip chip-accent">"Admin"</span>
441449 }
442450 </div>
451+ <form
452+ class="profile-photo-form"
453+ method="post"
454+ action="/api/profile_photo"
455+ enctype="multipart/form-data"
456+ >
457+ <input
458+ id="profile-photo-input"
459+ class="profile-file-hidden"
460+ type="file"
461+ name="photo"
462+ accept="image/png,image/jpeg,image/gif,image/webp,image/avif"
463+ required=""
464+ >
465+ <label class="admin-action" for="profile-photo-input">
466+ if user.has_photo {
467+ "Change"
468+ } else {
469+ "Add photo"
470+ }
471+ </label>
472+ // No script on im: where iz auto-submits on
473+ // change, a quiet Save appears once the input
474+ // holds a file (`:has(:valid)`, CSS-only).
475+ <button class="admin-action profile-photo-save" type="submit">
476+ "Save"
477+ </button>
478+ if user.has_photo {
479+ <button
480+ class="admin-action"
481+ type="submit"
482+ form="profile-photo-remove"
483+ >
484+ "Remove"
485+ </button>
486+ }
487+ </form>
443488 </div>
444489 </div>
445490 if let Some(code) = ok {
@@ -458,41 +503,6 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
458503 <dd class="profile-value">(joined)</dd>
459504 </div>
460505 </dl>
461- <form
462- class="profile-photo-form"
463- method="post"
464- action="/api/profile_photo"
465- enctype="multipart/form-data"
466- >
467- <label class="auth-field">
468- <span class="auth-label">"Profile photo"</span>
469- <input
470- class="auth-input profile-file"
471- type="file"
472- name="photo"
473- accept="image/png,image/jpeg,image/gif,image/webp,image/avif"
474- required=""
475- >
476- </label>
477- <div class="profile-photo-actions">
478- <button class="auth-submit profile-upload" type="submit">
479- if user.has_photo {
480- <span class="auth-submit-text">"Change"</span>
481- } else {
482- <span class="auth-submit-text">"Upload"</span>
483- }
484- </button>
485- if user.has_photo {
486- <button
487- class="admin-action"
488- type="submit"
489- form="profile-photo-remove"
490- >
491- "Remove"
492- </button>
493- }
494- </div>
495- </form>
496506 <a class="auth-alt" href=(format!("/people/{}", user.id))>"Public profile"</a>
497507 if user.has_photo {
498508 <form
style/main.scssmodified+34 -24
@@ -402,6 +402,7 @@ body:has(.auth-stage) {
402402 }
403403
404404 .profile-heading {
405+ flex: 1;
405406 display: flex;
406407 flex-direction: column;
407408 gap: 6px;
@@ -440,42 +441,51 @@ body:has(.auth-stage) {
440441 font-size: 13px;
441442 }
442443
443-.profile-photo-actions {
444+// The photo actions ride the profile head, iz's identity-row idiom: quiet
445+// row-buttons, the file input itself never seen. The selector outranks
446+// `.auth-card form`, which would otherwise stack this form vertically.
447+.auth-card .profile-photo-form {
444448 display: flex;
449+ flex-direction: row;
450+ flex-wrap: wrap;
445451 gap: 8px;
446452 align-items: center;
447453
448- .profile-upload {
449- flex: 1;
450- width: auto;
454+ // A label wearing the quiet-button skin needs the flex centering a button
455+ // gets for free.
456+ label.admin-action {
457+ display: inline-flex;
458+ align-items: center;
459+ box-sizing: border-box;
460+ cursor: pointer;
451461 }
452462 }
453463
464+// The picker opens through the labels; the input itself never shows.
465+.profile-file-hidden {
466+ display: none;
467+}
468+
469+// im serves no script, so iz's autosubmit becomes a Save that appears once
470+// the input holds a file — `:valid` on a required file input, CSS-only.
471+.profile-photo-save {
472+ display: none;
473+}
474+
475+.profile-photo-form:has(.profile-file-hidden:valid) .profile-photo-save {
476+ display: inline-flex;
477+}
478+
454479 // The remove form carries no visible chrome of its own — its button lives in
455-// the upload row and reaches it by `form=`.
480+// the actions row and reaches it by `form=`.
456481 #profile-photo-remove {
457482 display: none;
458483 }
459484
460-// A file input in the auth-input skin: the native button wears the quiet
461-// control look, the height follows the content instead of the 40px field.
462-.profile-file {
463- height: auto;
464- padding: 7px 12px;
465- font-size: 12px;
466- color: var(--muted);
467-
468- &::file-selector-button {
469- margin-right: 10px;
470- padding: 4px 10px;
471- background: var(--panel-sunken);
472- border: 1px solid var(--border-strong);
473- border-radius: var(--radius);
474- color: var(--ink);
475- font-family: var(--font-sans);
476- font-size: 12px;
477- cursor: pointer;
478- }
485+// The no-photo face is the upload affordance: the whole tile opens the
486+// picker.
487+.profile-avatar-upload {
488+ cursor: pointer;
479489 }
480490
481491 .profile-stats {