Theme: admin and site colours follow Site design, rendered server-side

- Admin primary/secondary now follow the site's Primary/Accent colours
  (owner's request), replacing the fixed admin sage. Text on them is picked
  automatically (white or dark, whichever contrasts more), which keeps the
  earlier low-contrast problem from coming back with light brand colours;
  brand colour is no longer used as text (active nav item, placeholders).
- New $shared/theme renders the colours as a <style> in <head> during
  SSR. The public site used to apply them in onMount, so every page load
  flashed the default colours first.
- DaisyUI `secondary` now maps to the site Accent everywhere — the
  button block's "Secondary" variant was DaisyUI's default pink.
- Colours are admin-entered text placed inside <style>, so only plain
  colour values are accepted (hex, named, rgb()/hsl()/oklch()…); anything
  else falls back to the default.
- Saving colours in Site design refreshes the admin theme immediately.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KgF3Kf47LjPGHKQHszpUAv
This commit is contained in:
agent 2026-10-06 11:32:21 +00:00
parent 015ce2a63f
commit 3399daf951
7 changed files with 98 additions and 40 deletions

View file

@ -4,7 +4,7 @@
import Header from '$lib/components/Header.svelte';
import Footer from '$lib/components/Footer.svelte';
import { createBasketStore, setBasketContext } from '$lib/basket.svelte';
import { onMount } from 'svelte';
import { rootStyleTag, siteThemeVars } from '$shared/theme';
let { children, data } = $props();
@ -16,23 +16,14 @@
// Keep the store in sync when layout data refreshes (e.g. after checkout
// clears the cookie and data.basket becomes null).
$effect(() => basketStore.syncFrom(data.basket ?? null));
onMount(() => {
if (data.colors) {
const root = document.documentElement;
root.style.setProperty('--color-bg', data.colors.background);
root.style.setProperty('--color-heading', data.colors.heading);
root.style.setProperty('--color-subheading', data.colors.subheading);
root.style.setProperty('--color-text', data.colors.text);
root.style.setProperty('--color-primary', data.colors.primary);
root.style.setProperty('--color-accent', data.colors.accent);
}
});
</script>
<svelte:head>
<link rel="icon" href={favicon} />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Site colours, rendered server-side (previously applied in onMount, which
flashed the defaults on every page load). Values are sanitised. -->
{@html rootStyleTag(siteThemeVars(data.colors))}
</svelte:head>
<Header header={data.header} />