Changeset 00a2bcd in Klonkt


Ignore:
Timestamp:
06/27/2026 12:20:10 AM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
16e99e5
Parents:
cd6a008
Message:

feat(profile): click the profile photo to open it in a lightbox

When the header has a real photo it becomes a lightbox trigger (enlarged view, click/Esc
to close) instead of a home link; the name still links home. No photo → unchanged home
link with the fallback avatar.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/views/partials/profile-header.ejs

    rcd6a008 r00a2bcd  
    3232  <div class="container profile-header-inner">
    3333
    34     <a class="profile-photo" href="<%= (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : '' %>/"
    35        hx-get="<%= (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : '' %>/?partial=1"
    36        hx-target="#pcms-main" hx-swap="innerHTML"
    37        hx-push-url="<%= (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : '' %>/"
    38        hx-indicator="#pcms-loading" aria-label="Home">
    39       <% if (site.profile_photo) { %>
    40         <img src="<%= site.profile_photo %>" alt="">
    41       <% } else if (typeof siteOwnerAvatar !== 'undefined' && siteOwnerAvatar) { %>
    42         <img src="<%= siteOwnerAvatar %>" alt="">
    43       <% } else if (site.enable_audio_player && (typeof audioEnabled === 'undefined' || audioEnabled)) { %>
    44         <span class="profile-photo-fallback profile-photo-fallback--music" aria-hidden="true">
    45           <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
    46             <path d="M9 17V5l12-2v12"/>
    47             <circle cx="6" cy="17" r="3"/>
    48             <circle cx="18" cy="15" r="3"/>
    49           </svg>
    50         </span>
    51       <% } else { %>
    52         <span class="profile-photo-fallback" aria-hidden="true"><%= (_displayName || '?').charAt(0).toUpperCase() %></span>
    53       <% } %>
    54     </a>
     34    <% var _base = (typeof siteUrlBase !== 'undefined' && siteUrlBase) ? siteUrlBase : ''; %>
     35    <% var _avatarUrl = site.profile_photo || ((typeof siteOwnerAvatar !== 'undefined' && siteOwnerAvatar) || ''); %>
     36    <% if (_avatarUrl) { %>
     37      <%# With a real photo: clicking opens a lightbox (enlarged view) instead of going home. %>
     38      <button type="button" class="profile-photo" data-lightbox="<%= _avatarUrl %>" aria-label="<%= _displayName || 'Profile photo' %>">
     39        <img src="<%= _avatarUrl %>" alt="">
     40      </button>
     41    <% } else { %>
     42      <a class="profile-photo" href="<%= _base %>/"
     43         hx-get="<%= _base %>/?partial=1" hx-target="#pcms-main" hx-swap="innerHTML"
     44         hx-push-url="<%= _base %>/" hx-indicator="#pcms-loading" aria-label="Home">
     45        <% if (site.enable_audio_player && (typeof audioEnabled === 'undefined' || audioEnabled)) { %>
     46          <span class="profile-photo-fallback profile-photo-fallback--music" aria-hidden="true">
     47            <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
     48              <path d="M9 17V5l12-2v12"/>
     49              <circle cx="6" cy="17" r="3"/>
     50              <circle cx="18" cy="15" r="3"/>
     51            </svg>
     52          </span>
     53        <% } else { %>
     54          <span class="profile-photo-fallback" aria-hidden="true"><%= (_displayName || '?').charAt(0).toUpperCase() %></span>
     55        <% } %>
     56      </a>
     57    <% } %>
    5558
    5659    <div class="profile-info">
     
    117120  });
    118121})();
     122
     123/* Lightbox: click the profile photo to see it enlarged. */
     124(function () {
     125  if (window.__pcmsLightboxWired) return; window.__pcmsLightboxWired = true;
     126  var lb = null;
     127  function close(){ if (lb) lb.classList.remove('is-open'); }
     128  document.addEventListener('click', function (e) {
     129    var t = e.target.closest && e.target.closest('.profile-photo[data-lightbox]');
     130    if (!t) return;
     131    e.preventDefault();
     132    var url = t.getAttribute('data-lightbox'); if (!url) return;
     133    if (!lb) {
     134      lb = document.createElement('div'); lb.className = 'pcms-lightbox';
     135      lb.innerHTML = '<img alt=""><button type="button" class="pcms-lightbox-close" aria-label="Sluiten">&times;</button>';
     136      document.body.appendChild(lb);
     137      lb.addEventListener('click', function (ev) { if (ev.target === lb || (ev.target.closest && ev.target.closest('.pcms-lightbox-close'))) close(); });
     138    }
     139    lb.querySelector('img').src = url;
     140    lb.classList.add('is-open');
     141  });
     142  document.addEventListener('keydown', function (e) { if (e.key === 'Escape') close(); });
     143})();
    119144</script>
    120145<% } %>
     
    142167  width: 80px;
    143168  height: 80px;
     169  padding: 0;
    144170  border-radius: 50%;
    145171  overflow: hidden;
     
    148174  transition: width 250ms, height 250ms;
    149175  cursor: pointer;
    150 }
     176  font: inherit;
     177  -webkit-appearance: none;
     178  appearance: none;
     179}
     180.profile-photo[data-lightbox] { cursor: zoom-in; }
    151181.profile-photo:hover {
    152182  border-color: var(--accent);
     
    282312   glyph at 18px — render it larger INSIDE the same 36px circle (circle unchanged). */
    283313.profile-fedi-link svg { width: 22px; height: 22px; }
     314
     315/* Profile-photo lightbox overlay */
     316.pcms-lightbox { position: fixed; inset: 0; z-index: 2147483600; display: none;
     317  align-items: center; justify-content: center; padding: 4vmin;
     318  background: rgba(0,0,0,.86); cursor: zoom-out; }
     319.pcms-lightbox.is-open { display: flex; }
     320.pcms-lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 12px;
     321  box-shadow: 0 10px 50px rgba(0,0,0,.55); cursor: default; }
     322.pcms-lightbox-close { position: fixed; top: 1rem; right: 1.1rem; width: 44px; height: 44px;
     323  border: 0; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff;
     324  font-size: 1.9rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
     325.pcms-lightbox-close:hover { background: rgba(255,255,255,.26); }
    284326</style>
Note: See TracChangeset for help on using the changeset viewer.