diff --git a/crates/forge-web/assets/nav.js b/crates/forge-web/assets/nav.js index 869814a..33b2e92 100644 --- a/crates/forge-web/assets/nav.js +++ b/crates/forge-web/assets/nav.js @@ -837,6 +837,13 @@ // swap, because the swap restores it as a changed field. Each panel is set up once; after that its // shown panel follows its tab radios. Called on every page change (see `enhance`). function enhanceColours() { + // The server renders each stripe's stored hue as the range value only, so the row's `--hue` (which + // the Custom swatch reads) is set here from that value. Each row is set through the CSSOM because + // the CSP forbids inline style attributes from the server. + document.querySelectorAll('.hue-row').forEach(function (row) { + var range = row.querySelector('input[data-hue-stripe]'); + if (range) { row.style.setProperty('--hue', range.value); } + }); document.querySelectorAll('[data-colour-group]').forEach(function (group) { var tabs = group.querySelectorAll('input[data-colour-tab]'); if (!group.__colourTab) { @@ -850,6 +857,8 @@ if (on) { group.setAttribute('data-tab', on.value); } }); } + // The authoring script below runs this from its own `enhance`, so it is shared the way `__forgeQuery` is. + window.__forgeColours = enhanceColours; // A filtered view asked for in place: the URL is replaced (no history entry per change), fields // and caret come through the swap, and the scroll stays put. @@ -1994,7 +2003,7 @@ // ---- toolbar and upload ---- function enhance() { - enhanceColours(); + if (window.__forgeColours) { window.__forgeColours(); } document.querySelectorAll('textarea').forEach(function (ta) { if (ta.__md || !eligible(ta)) { return; } ta.__md = true;