Changeset a3e2f17 in Klonkt for src/views/shell.ejs


Ignore:
Timestamp:
06/17/2026 12:49:19 AM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
1dca23b
Parents:
ee25d45
Message:

Fix: update per-site accent + palette on htmx navigation

The accent colour (style#pcms-site-accent) and palette (html[data-palette])
live in the shell <head>, which is not swapped during htmx nav. As a result
an artist inherited the colours of the previous page (e.g. De Kelderband
got the hub's purple instead of its own green). pcmsNav now sends
accent+palette along; the client updates the accent <style> and
data-palette. Applies to all htmx nav (boost + explicit links).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/views/shell.ejs

    ree25d45 ra3e2f17  
    330330
    331331  document.body.addEventListener('pcmsNav', function(ev) {
    332     var next = ev.detail && ev.detail.bodyClass;
     332    var d = ev.detail || {};
     333    // Per-site accent + palette bijwerken (head wordt niet mee-geswapt bij htmx-nav,
     334    // dus zonder dit erft een artiest de kleuren van de vorige pagina).
     335    if (d.accent && /^#[0-9a-fA-F]{6}$/.test(d.accent)) {
     336      var sa = document.getElementById('pcms-site-accent');
     337      if (sa) {
     338        sa.textContent =
     339          ':root,[data-palette]{--accent:' + d.accent +
     340          ';--accent-soft:color-mix(in srgb,' + d.accent + ' 80%,white)' +
     341          ';--accent-tint:color-mix(in srgb,' + d.accent + ' 12%,transparent);}';
     342      }
     343    }
     344    if (d.palette && /^[a-z0-9-]+$/i.test(d.palette)) {
     345      document.documentElement.setAttribute('data-palette', d.palette);
     346    }
     347
     348    var next = d.bodyClass;
    333349    if (!next) return;
    334350    // Server may send a multi-class string ("on-post extra"). Only the first
Note: See TracChangeset for help on using the changeset viewer.