Photo actions ride the profile head, iz's identity row
Browse files at this commit99c1ffe90e777c45e73695bd3a5a8da6823b285bParent: 8092e0d3 changed files +102 -79
- crates/im-web/assets/main.css +22 -19
- crates/im-web/src/pages.rs +46 -36
- style/main.scss +34 -24
crates/im-web/assets/main.cssmodified+22 -19
| @@ -362,6 +362,7 @@ body:has(.auth-stage) > .auth-stage::-webkit-scrollbar { | |||
| 362 | } | 362 | } |
| 363 | 363 | ||
| 364 | .profile-heading { | 364 | .profile-heading { |
| 365 | + flex: 1; | ||
| 365 | display: flex; | 366 | display: flex; |
| 366 | flex-direction: column; | 367 | flex-direction: column; |
| 367 | gap: 6px; | 368 | gap: 6px; |
| @@ -398,35 +399,37 @@ body:has(.auth-stage) > .auth-stage::-webkit-scrollbar { | |||
| 398 | font-size: 13px; | 399 | font-size: 13px; |
| 399 | } | 400 | } |
| 400 | 401 | ||
| 401 | -.profile-photo-actions { | 402 | +.auth-card .profile-photo-form { |
| 402 | display: flex; | 403 | display: flex; |
| 404 | + flex-direction: row; | ||
| 405 | + flex-wrap: wrap; | ||
| 403 | gap: 8px; | 406 | gap: 8px; |
| 404 | align-items: center; | 407 | align-items: center; |
| 405 | } | 408 | } |
| 406 | -.profile-photo-actions .profile-upload { | 409 | +.auth-card .profile-photo-form label.admin-action { |
| 407 | - flex: 1; | 410 | + display: inline-flex; |
| 408 | - width: auto; | 411 | + align-items: center; |
| 412 | + box-sizing: border-box; | ||
| 413 | + cursor: pointer; | ||
| 409 | } | 414 | } |
| 410 | 415 | ||
| 411 | -#profile-photo-remove { | 416 | +.profile-file-hidden { |
| 412 | display: none; | 417 | display: none; |
| 413 | } | 418 | } |
| 414 | 419 | ||
| 415 | -.profile-file { | 420 | +.profile-photo-save { |
| 416 | - height: auto; | 421 | + display: none; |
| 417 | - padding: 7px 12px; | ||
| 418 | - font-size: 12px; | ||
| 419 | - color: var(--muted); | ||
| 420 | } | 422 | } |
| 421 | -.profile-file::file-selector-button { | 423 | + |
| 422 | - margin-right: 10px; | 424 | +.profile-photo-form:has(.profile-file-hidden:valid) .profile-photo-save { |
| 423 | - padding: 4px 10px; | 425 | + display: inline-flex; |
| 424 | - background: var(--panel-sunken); | 426 | +} |
| 425 | - border: 1px solid var(--border-strong); | 427 | + |
| 426 | - border-radius: var(--radius); | 428 | +#profile-photo-remove { |
| 427 | - color: var(--ink); | 429 | + display: none; |
| 428 | - font-family: var(--font-sans); | 430 | +} |
| 429 | - font-size: 12px; | 431 | + |
| 432 | +.profile-avatar-upload { | ||
| 430 | cursor: pointer; | 433 | cursor: pointer; |
| 431 | } | 434 | } |
| 432 | 435 | ||
crates/im-web/src/pages.rsmodified+46 -36
| @@ -427,7 +427,15 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result { | |||
| 427 | (wordmark(cx).await?) | 427 | (wordmark(cx).await?) |
| 428 | <div class="auth-card"> | 428 | <div class="auth-card"> |
| 429 | <div class="profile-head"> | 429 | <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 | + } | ||
| 431 | <div class="profile-heading"> | 439 | <div class="profile-heading"> |
| 432 | <div class="auth-title">(user.name.clone())</div> | 440 | <div class="auth-title">(user.name.clone())</div> |
| 433 | <div class="profile-marks"> | 441 | <div class="profile-marks"> |
| @@ -440,6 +448,43 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result { | |||
| 440 | <span class="chip chip-accent">"Admin"</span> | 448 | <span class="chip chip-accent">"Admin"</span> |
| 441 | } | 449 | } |
| 442 | </div> | 450 | </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> | ||
| 443 | </div> | 488 | </div> |
| 444 | </div> | 489 | </div> |
| 445 | if let Some(code) = ok { | 490 | if let Some(code) = ok { |
| @@ -458,41 +503,6 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result { | |||
| 458 | <dd class="profile-value">(joined)</dd> | 503 | <dd class="profile-value">(joined)</dd> |
| 459 | </div> | 504 | </div> |
| 460 | </dl> | 505 | </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> | ||
| 496 | <a class="auth-alt" href=(format!("/people/{}", user.id))>"Public profile"</a> | 506 | <a class="auth-alt" href=(format!("/people/{}", user.id))>"Public profile"</a> |
| 497 | if user.has_photo { | 507 | if user.has_photo { |
| 498 | <form | 508 | <form |
style/main.scssmodified+34 -24
| @@ -402,6 +402,7 @@ body:has(.auth-stage) { | |||
| 402 | } | 402 | } |
| 403 | 403 | ||
| 404 | .profile-heading { | 404 | .profile-heading { |
| 405 | + flex: 1; | ||
| 405 | display: flex; | 406 | display: flex; |
| 406 | flex-direction: column; | 407 | flex-direction: column; |
| 407 | gap: 6px; | 408 | gap: 6px; |
| @@ -440,42 +441,51 @@ body:has(.auth-stage) { | |||
| 440 | font-size: 13px; | 441 | font-size: 13px; |
| 441 | } | 442 | } |
| 442 | 443 | ||
| 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 { | ||
| 444 | display: flex; | 448 | display: flex; |
| 449 | + flex-direction: row; | ||
| 450 | + flex-wrap: wrap; | ||
| 445 | gap: 8px; | 451 | gap: 8px; |
| 446 | align-items: center; | 452 | align-items: center; |
| 447 | 453 | ||
| 448 | - .profile-upload { | 454 | + // A label wearing the quiet-button skin needs the flex centering a button |
| 449 | - flex: 1; | 455 | + // gets for free. |
| 450 | - width: auto; | 456 | + label.admin-action { |
| 457 | + display: inline-flex; | ||
| 458 | + align-items: center; | ||
| 459 | + box-sizing: border-box; | ||
| 460 | + cursor: pointer; | ||
| 451 | } | 461 | } |
| 452 | } | 462 | } |
| 453 | 463 | ||
| 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 | + | ||
| 454 | // The remove form carries no visible chrome of its own — its button lives in | 479 | // 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=`. |
| 456 | #profile-photo-remove { | 481 | #profile-photo-remove { |
| 457 | display: none; | 482 | display: none; |
| 458 | } | 483 | } |
| 459 | 484 | ||
| 460 | -// A file input in the auth-input skin: the native button wears the quiet | 485 | +// The no-photo face is the upload affordance: the whole tile opens the |
| 461 | -// control look, the height follows the content instead of the 40px field. | 486 | +// picker. |
| 462 | -.profile-file { | 487 | +.profile-avatar-upload { |
| 463 | - height: auto; | 488 | + cursor: pointer; |
| 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 | - } | ||
| 479 | } | 489 | } |
| 480 | 490 | ||
| 481 | .profile-stats { | 491 | .profile-stats { |