Files
clj-ui-framework/dev/squint/index.html
Florian Schroedl 41811dba88 feat(dev): add live theme adapter panel for color customization
Floating panel in bottom-right of all dev targets lets you:
- Switch presets (Purple, Blue, Neutral, Warm, Rose, Emerald)
- Adjust gray hue/saturation and accent hue/saturation with sliders
- Preview color swatches in real-time
- Copy EDN config to paste into tokens.edn

State persists in localStorage. Panel collapses to a small toggle button.
Hiccup handler changed to use #'handler var for hot-reload.
2026-03-11 11:51:59 +01:00

52 lines
1.8 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="/theme.css" />
<style>
html, body { margin: 0; padding: 0; }
</style>
<script>
(function() {
var params = new URLSearchParams(window.location.search);
var theme = params.get('theme');
if (theme === 'dark' || theme === 'light') {
document.documentElement.dataset.theme = theme;
}
new MutationObserver(function(mutations) {
for (var i = 0; i < mutations.length; i++) {
if (mutations[i].attributeName === 'data-theme') {
var t = document.documentElement.dataset.theme;
var url = new URL(window.location);
if (t) url.searchParams.set('theme', t);
else url.searchParams.delete('theme');
history.replaceState(null, '', url);
if (window.parent !== window) {
window.parent.postMessage({ type: 'theme-change', theme: t || '' }, '*');
}
}
}
}).observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] });
document.addEventListener('click', function(e) {
var a = e.target.closest('a[href]');
if (!a) return;
try {
var url = new URL(a.href);
if (url.hostname === location.hostname && url.port !== location.port) {
var t = document.documentElement.dataset.theme;
if (t) url.searchParams.set('theme', t);
a.href = url.toString();
}
} catch (ex) {}
});
})();
</script>
</head>
<body>
<div id="app"></div>
<script type="module" src=".compiled/dev/squint.mjs"></script>
<script src="/theme-adapter.js" defer></script>
</body>
</html>