Site design → Style: fonts, corners, text size, shadows, page width

A new Style card in Site design (a `style` global) chooses the heading and
body fonts from 15 bundled ones, corners (sharp/soft/round), text size,
shadow strength and page width, with a live sample. The choices become
--site-* CSS variables that the @theme radius, shadow, container and font
tokens scale, so blocks keep using rounded-xl, shadow-sm, max-w-6xl and
follow the setting. Buttons and chips use rounded-button; the defaults
are the site's current look.

Fonts are @fontsource-variable packages (replacing the static DM Sans and
Playfair ones): still served by the site, and a browser downloads only
the fonts a page uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
This commit is contained in:
agent 2026-10-26 19:00:37 +00:00
parent c35f9a60cc
commit 91f6705899
29 changed files with 628 additions and 110 deletions

View file

@ -25,7 +25,7 @@
<div class="flex {alignmentClasses[data.alignment] || 'justify-center'}">
<a
href={data.href || '#'}
class="btn {variantClasses[data.variant] || 'btn-primary'} {sizeClasses[data.size] || ''}"
class="btn rounded-button {variantClasses[data.variant] || 'btn-primary'} {sizeClasses[data.size] || ''}"
style={data.color ? `background-color: ${data.color}; border-color: ${data.color};` : ''}
>
{data.label || 'Button'}

View file

@ -19,7 +19,7 @@
<div class="mt-6 grid gap-6 grid-cols-[repeat(auto-fit,minmax(200px,1fr))]">
{#each data.items || [] as card, i (i)}
<!-- Cards are white whatever the block's colours, so they use the site's own text colour. -->
<div class="relative overflow-hidden rounded-[1.25rem] bg-white text-[color-mix(in_srgb,var(--color-text,#2c2c2c)_85%,transparent)] shadow-[0_1px_6px_rgba(0,0,0,0.08)] transition-shadow {card.href ? 'hover:shadow-lg' : ''}">
<div class="relative overflow-hidden rounded-card bg-white text-[color-mix(in_srgb,var(--color-text,#2c2c2c)_85%,transparent)] shadow-sm transition-shadow {card.href ? 'hover:shadow-lg' : ''}">
{#if !numbered && card.imageUrl}
<img class="block aspect-[4/3] w-full object-cover" src={card.imageUrl} alt={card.imageAlt || ''} />
{/if}

View file

@ -358,7 +358,7 @@
{#if shopAbove}
<p class="mt-2 text-sm text-fg-body/70">Pick a service or product above.</p>
{:else}
<a class="mt-6 inline-flex rounded-full bg-sage px-6 py-2.5 text-sm font-medium text-primary-content transition hover:bg-sage-dark" href={bookingHref}>Book a session</a>
<a class="mt-6 inline-flex rounded-button bg-sage px-6 py-2.5 text-sm font-medium text-primary-content transition hover:bg-sage-dark" href={bookingHref}>Book a session</a>
{/if}
</div>
{:else}
@ -380,7 +380,7 @@
{#if ending && payState !== 'confirming'}
<button
type="button"
class="rounded-full border border-charcoal/20 bg-white px-4 py-1.5 font-medium transition hover:bg-charcoal/5 disabled:opacity-60"
class="rounded-button border border-charcoal/20 bg-white px-4 py-1.5 font-medium transition hover:bg-charcoal/5 disabled:opacity-60"
disabled={renewing}
onclick={renewHolds}
>
@ -460,7 +460,7 @@
<div class="flex items-center gap-2">
<button
type="button"
class="flex h-8 w-8 items-center justify-center rounded-full border border-charcoal/15 text-lg leading-none disabled:opacity-40"
class="flex h-8 w-8 items-center justify-center rounded-button border border-charcoal/15 text-lg leading-none disabled:opacity-40"
disabled={pending || line.quantity <= 1}
aria-label="Decrease quantity"
onclick={() => changeQuantity(line.id, line.quantity, -1)}
@ -470,7 +470,7 @@
<span class="w-6 text-center">{line.quantity}</span>
<button
type="button"
class="flex h-8 w-8 items-center justify-center rounded-full border border-charcoal/15 text-lg leading-none disabled:opacity-40"
class="flex h-8 w-8 items-center justify-center rounded-button border border-charcoal/15 text-lg leading-none disabled:opacity-40"
disabled={pending}
aria-label="Increase quantity"
onclick={() => changeQuantity(line.id, line.quantity, 1)}
@ -486,7 +486,7 @@
<button
type="button"
class="flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-charcoal/50 transition-colors hover:bg-terracotta/10 hover:text-terracotta disabled:opacity-40"
class="flex h-8 w-8 shrink-0 items-center justify-center rounded-button text-charcoal/50 transition-colors hover:bg-terracotta/10 hover:text-terracotta disabled:opacity-40"
disabled={pending}
aria-label="Remove {line.itemName ?? 'item'}"
onclick={() => removeLine(line.id)}
@ -542,7 +542,7 @@
class="w-36 rounded-xl border border-charcoal/15 bg-white px-3 py-2 font-mono tracking-wider uppercase focus:ring-2 focus:ring-sage/50 focus:outline-none"
bind:value={codeInput}
/>
<button type="submit" class="rounded-full border border-charcoal/20 px-4 py-2 text-sm font-medium transition hover:bg-charcoal/5 disabled:opacity-50" disabled={codeBusy || !codeInput.trim()}>
<button type="submit" class="rounded-button border border-charcoal/20 px-4 py-2 text-sm font-medium transition hover:bg-charcoal/5 disabled:opacity-50" disabled={codeBusy || !codeInput.trim()}>
{codeBusy ? 'Checking…' : 'Apply'}
</button>
</form>
@ -617,7 +617,7 @@
{#if payState === 'idle' || payState === 'creating'}
<button
type="submit"
class="btn w-full rounded-full border-0 text-primary-content"
class="btn w-full rounded-button border-0 text-primary-content"
style="background-color: var(--color-primary, #8a9a7b);"
disabled={payState === 'creating'}
>
@ -652,7 +652,7 @@
{#if payState === 'ready' || payState === 'confirming'}
<button
type="button"
class="btn mt-4 w-full rounded-full border-0 text-primary-content"
class="btn mt-4 w-full rounded-button border-0 text-primary-content"
style="background-color: var(--color-primary, #8a9a7b);"
disabled={payState === 'confirming'}
onclick={confirmPayment}

View file

@ -14,7 +14,7 @@
<section class="relative flex min-h-[80vh] items-center justify-center overflow-hidden px-6 py-20 md:min-h-[90vh]">
<div class="relative z-10 mx-auto max-w-4xl text-center">
<h1 class="animate-fade-in text-5xl leading-tight text-fg-heading md:text-7xl lg:text-8xl" style="font-family: 'Playfair Display', Georgia, serif;">
<h1 class="animate-fade-in text-5xl leading-tight text-fg-heading md:text-7xl lg:text-8xl">
{data.heading || 'Holistic and Experiential Learning about Happiness'}
</h1>
{#if data.subheading}
@ -24,7 +24,7 @@
{/if}
{#if data.buttonLabel}
<div class="animate-fade-in mt-10" style="animation-delay: 0.3s;">
<a class="btn rounded-full border-0 bg-sage px-10 py-3 text-lg text-primary-content shadow-lg transition hover:bg-sage-dark hover:shadow-xl" href={data.buttonUrl || shopLinks(page.data.header).booking}>
<a class="btn rounded-button border-0 bg-sage px-10 py-3 text-lg text-primary-content shadow-lg transition hover:bg-sage-dark hover:shadow-xl" href={data.buttonUrl || shopLinks(page.data.header).booking}>
{data.buttonLabel}
</a>
</div>

View file

@ -8,7 +8,7 @@
<section use:scrollReveal class="reveal mx-auto max-w-6xl px-6 py-14 md:py-20">
<div class="grid items-center gap-10 md:grid-cols-2">
<div class:md:order-2={data.imagePosition === 'right'} class="overflow-hidden rounded-[2rem] bg-sage/10 shadow-sm">
<div class:md:order-2={data.imagePosition === 'right'} class="overflow-hidden rounded-panel bg-sage/10 shadow-sm">
{#if data.url}
<img class="aspect-[4/5] w-full object-cover" src={data.url} alt={data.alt || ''} />
{:else}

View file

@ -353,11 +353,11 @@
{#if duration}
<span class="text-xs text-charcoal/60">{formatDuration(duration.minutes)}</span>
{:else if !isService && item.stock != null && item.stock > 0 && item.stock <= 5}
<span class="rounded-full bg-terracotta/15 px-2.5 py-0.5 text-xs font-medium text-terracotta">
<span class="rounded-button bg-terracotta/15 px-2.5 py-0.5 text-xs font-medium text-terracotta">
Only {item.stock} left
</span>
{:else if soldOut}
<span class="rounded-full bg-terracotta/15 px-2.5 py-0.5 text-xs font-medium text-terracotta">
<span class="rounded-button bg-terracotta/15 px-2.5 py-0.5 text-xs font-medium text-terracotta">
Sold out
</span>
{/if}
@ -386,7 +386,7 @@
{#if isService}
<button
type="button"
class="inline-flex items-center justify-center gap-2 rounded-full px-6 py-2.5 text-sm font-medium transition {ui?.pickerOpen
class="inline-flex items-center justify-center gap-2 rounded-button px-6 py-2.5 text-sm font-medium transition {ui?.pickerOpen
? 'border border-charcoal/15 text-charcoal hover:bg-charcoal/5'
: bookable
? 'bg-sage text-primary-content hover:bg-sage-dark'
@ -400,7 +400,7 @@
{:else}
<button
type="button"
class="inline-flex items-center justify-center gap-2 rounded-full bg-sage px-6 py-2.5 text-sm font-medium text-primary-content transition hover:bg-sage-dark disabled:cursor-not-allowed disabled:bg-charcoal/10 disabled:text-charcoal/50"
class="inline-flex items-center justify-center gap-2 rounded-button bg-sage px-6 py-2.5 text-sm font-medium text-primary-content transition hover:bg-sage-dark disabled:cursor-not-allowed disabled:bg-charcoal/10 disabled:text-charcoal/50"
disabled={soldOut || ui?.adding}
onclick={() => addItem(item.id)}
>
@ -457,7 +457,7 @@
<div class="mb-3 flex items-center justify-between gap-2">
<button
type="button"
class="flex h-8 w-8 items-center justify-center rounded-full border border-charcoal/15 text-lg leading-none text-charcoal transition hover:bg-charcoal/5 disabled:cursor-default disabled:opacity-30"
class="flex h-8 w-8 items-center justify-center rounded-button border border-charcoal/15 text-lg leading-none text-charcoal transition hover:bg-charcoal/5 disabled:cursor-default disabled:opacity-30"
aria-label="Previous month"
disabled={ui.monthOffset <= 0}
onclick={() => ui.monthOffset--}
@ -470,7 +470,7 @@
</p>
<button
type="button"
class="flex h-8 w-8 items-center justify-center rounded-full border border-charcoal/15 text-lg leading-none text-charcoal transition hover:bg-charcoal/5 disabled:cursor-default disabled:opacity-30"
class="flex h-8 w-8 items-center justify-center rounded-button border border-charcoal/15 text-lg leading-none text-charcoal transition hover:bg-charcoal/5 disabled:cursor-default disabled:opacity-30"
aria-label="Next month"
disabled={ui.monthOffset >= MAX_MONTH_OFFSET}
onclick={() => ui.monthOffset++}
@ -489,7 +489,7 @@
<span>The next available date for {formatDuration(duration.minutes)} is <strong>{longDate(zonedDateKey(ui.next, timezone))}</strong>.</span>
<button
type="button"
class="rounded-full bg-sage px-4 py-1.5 font-medium text-primary-content transition hover:bg-sage-dark"
class="rounded-button bg-sage px-4 py-1.5 font-medium text-primary-content transition hover:bg-sage-dark"
onclick={() => showDay(item.id, ui.next!)}
>
Go to next available date →
@ -516,7 +516,7 @@
disabled={!selectable}
aria-pressed={selected}
onclick={() => (ui.selectedDayKey = day.dateKey)}
class="aspect-square rounded-full text-sm transition {selected
class="aspect-square rounded-button text-sm transition {selected
? 'bg-sage font-semibold text-primary-content'
: selectable
? 'cursor-pointer bg-sage/15 font-medium text-charcoal hover:bg-sage/35'
@ -545,12 +545,12 @@
{@const label = `${formatTime(entry.start)}–${formatTime(entry.end)}`}
{#if isGroup && entry.line}
<!-- Places in a group session already in the basket: − / + -->
<div class="inline-flex items-center gap-2 rounded-full bg-sage/15 py-1 pr-1 pl-3.5 text-sm text-sage-dark">
<div class="inline-flex items-center gap-2 rounded-button bg-sage/15 py-1 pr-1 pl-3.5 text-sm text-sage-dark">
<span>{label} · {placesLeft(free)}</span>
<span class="inline-flex items-center gap-1 rounded-full bg-white px-1 py-0.5">
<span class="inline-flex items-center gap-1 rounded-button bg-white px-1 py-0.5">
<button
type="button"
class="flex h-6 w-6 items-center justify-center rounded-full leading-none text-charcoal transition hover:bg-charcoal/10 disabled:opacity-40"
class="flex h-6 w-6 items-center justify-center rounded-button leading-none text-charcoal transition hover:bg-charcoal/10 disabled:opacity-40"
aria-label="One place fewer"
disabled={ui.adding}
onclick={() => changeSeats(item.id, entry, -1)}
@ -563,7 +563,7 @@
</span>
<button
type="button"
class="flex h-6 w-6 items-center justify-center rounded-full leading-none text-charcoal transition hover:bg-charcoal/10 disabled:opacity-40"
class="flex h-6 w-6 items-center justify-center rounded-button leading-none text-charcoal transition hover:bg-charcoal/10 disabled:opacity-40"
aria-label="One place more"
disabled={ui.adding || free <= 0}
onclick={() => changeSeats(item.id, entry, 1)}
@ -577,7 +577,7 @@
type="button"
disabled={!!entry.line || !entry.time || ui.adding}
onclick={() => entry.time && addTime(item, duration.minutes, entry.time)}
class="inline-flex items-center gap-1.5 rounded-full border px-3.5 py-1.5 text-sm transition {entry.line
class="inline-flex items-center gap-1.5 rounded-button border px-3.5 py-1.5 text-sm transition {entry.line
? 'cursor-not-allowed border-transparent bg-sage/15 text-sage-dark'
: 'border-charcoal/15 bg-white text-charcoal hover:border-sage hover:bg-sage/10'} disabled:opacity-60 {ui.adding &&
!entry.line

View file

@ -52,7 +52,7 @@
<button
type="button"
onclick={prev}
class="w-10 h-10 rounded-full flex items-center justify-center transition-colors hover:bg-[rgba(255,236,224,1)] hover:text-[#93384a] bg-[rgba(255,219,197,0.8)]"
class="w-10 h-10 rounded-button flex items-center justify-center transition-colors hover:bg-[rgba(255,236,224,1)] hover:text-[#93384a] bg-[rgba(255,219,197,0.8)]"
aria-label="Previous slide"
>
<svg viewBox="0 0 7.3 13" class="w-2 h-3" fill="none" stroke="currentColor" stroke-width="1.5">
@ -75,7 +75,7 @@
<button
type="button"
onclick={next}
class="w-10 h-10 rounded-full flex items-center justify-center transition-colors hover:bg-[rgba(255,236,224,1)] hover:text-[#93384a] bg-[rgba(255,219,197,0.8)]"
class="w-10 h-10 rounded-button flex items-center justify-center transition-colors hover:bg-[rgba(255,236,224,1)] hover:text-[#93384a] bg-[rgba(255,219,197,0.8)]"
aria-label="Next slide"
>
<svg viewBox="0 0 7.3 13" class="w-2 h-3" fill="none" stroke="currentColor" stroke-width="1.5">

View file

@ -65,13 +65,13 @@
</div>
{#if visibleEvents.length === 0}
<div class="mx-auto max-w-2xl rounded-[2rem] border border-sage/20 bg-white/70 p-8 text-center shadow-sm">
<div class="mx-auto max-w-2xl rounded-panel border border-sage/20 bg-white/70 p-8 text-center shadow-sm">
<p class="text-charcoal/70">No upcoming events are available for the selected categories.</p>
</div>
{:else}
<div class="isolate grid gap-8 lg:grid-cols-2">
{#each months as month}
<div class="relative z-0 overflow-visible rounded-[2rem] border border-sage/15 bg-white/80 p-3 shadow-sm sm:p-5 backdrop-blur hover:z-[9000] focus-within:z-[9000]">
<div class="relative z-0 overflow-visible rounded-panel border border-sage/15 bg-white/80 p-3 shadow-sm sm:p-5 backdrop-blur hover:z-[9000] focus-within:z-[9000]">
<h3 class="font-display mb-5 text-center text-3xl text-charcoal">{month.label}</h3>
<div class="mb-2 grid grid-cols-7 gap-1 text-center text-xs font-semibold uppercase tracking-wide text-charcoal/45">
{#each weekdays as weekday}<div>{weekday}</div>{/each}

View file

@ -1,4 +1,4 @@
import { defaultColors, type ColorsGlobal } from './types';
import { defaultColors, defaultStyle, type ColorsGlobal, type StyleGlobal } from './types';
// Site colours (Site design → Colors) as CSS variables, rendered server-side
// into a <style> tag so pages don't flash the default colours on load.
@ -56,9 +56,68 @@ export function brandThemeVars(colors: Partial<ColorsGlobal> | null | undefined)
};
}
/** Every site colour variable — public site and the admin preview. */
export function siteThemeVars(colors: Partial<ColorsGlobal> | null | undefined): Record<string, string> {
// Fonts to pick from in Site design → Style. Each is bundled by both apps
// (src/lib/fonts.ts, @fontsource-variable packages) and a browser downloads
// only the ones a page uses. Adding one: install the package in both apps,
// import it in both fonts.ts files, add it here.
export const SITE_FONTS = [
{ id: 'playfair-display', label: 'Playfair Display', family: 'Playfair Display Variable', serif: true },
{ id: 'cormorant-garamond', label: 'Cormorant Garamond', family: 'Cormorant Garamond Variable', serif: true },
{ id: 'eb-garamond', label: 'EB Garamond', family: 'EB Garamond Variable', serif: true },
{ id: 'libre-baskerville', label: 'Libre Baskerville', family: 'Libre Baskerville Variable', serif: true },
{ id: 'lora', label: 'Lora', family: 'Lora Variable', serif: true },
{ id: 'fraunces', label: 'Fraunces', family: 'Fraunces Variable', serif: true },
{ id: 'dm-sans', label: 'DM Sans', family: 'DM Sans Variable', serif: false },
{ id: 'inter', label: 'Inter', family: 'Inter Variable', serif: false },
{ id: 'manrope', label: 'Manrope', family: 'Manrope Variable', serif: false },
{ id: 'montserrat', label: 'Montserrat', family: 'Montserrat Variable', serif: false },
{ id: 'nunito', label: 'Nunito', family: 'Nunito Variable', serif: false },
{ id: 'outfit', label: 'Outfit', family: 'Outfit Variable', serif: false },
{ id: 'raleway', label: 'Raleway', family: 'Raleway Variable', serif: false },
{ id: 'work-sans', label: 'Work Sans', family: 'Work Sans Variable', serif: false },
{ id: 'josefin-sans', label: 'Josefin Sans', family: 'Josefin Sans Variable', serif: false }
] as const;
/** CSS font-family for a SITE_FONTS id (unknown ids get `fallbackId`'s font). */
export function fontStack(id: unknown, fallbackId: string): string {
const font = SITE_FONTS.find((f) => f.id === id) ?? SITE_FONTS.find((f) => f.id === fallbackId)!;
return `'${font.family}', ${font.serif ? 'Georgia, serif' : 'ui-sans-serif, system-ui, sans-serif'}`;
}
// What each Style choice sets. The variables are read by the @theme in both
// apps' app.css (radius, shadow, container and font tokens), so every
// rounded-xl, shadow-sm, max-w-6xl… on the public site follows them.
const CORNERS = {
sharp: { scale: '0', button: '0' },
soft: { scale: '0.4', button: '0.375rem' },
round: { scale: '1', button: '9999px' }
};
const TEXT_SIZES = { small: '93.75%', normal: '100%', large: '112.5%' };
const SHADOWS = { none: '0', soft: '1', strong: '2.2' };
const WIDTHS = { narrow: '0.85', normal: '1', wide: '1.2' };
function pick<T>(table: Record<string, T>, key: unknown, fallback: string): T {
return table[String(key)] ?? table[fallback];
}
/** Site design → Style as CSS variables — public site and the admin preview. */
export function siteStyleVars(style: Partial<StyleGlobal> | null | undefined): Record<string, string> {
const corners = pick(CORNERS, style?.corners, defaultStyle.corners);
return {
'--site-font-heading': fontStack(style?.headingFont, defaultStyle.headingFont),
'--site-font-body': fontStack(style?.bodyFont, defaultStyle.bodyFont),
'--site-corners': corners.scale,
'--site-button-radius': corners.button,
'--site-text-size': pick(TEXT_SIZES, style?.textSize, defaultStyle.textSize),
'--site-shadow': pick(SHADOWS, style?.shadows, defaultStyle.shadows),
'--site-width': pick(WIDTHS, style?.width, defaultStyle.width)
};
}
/** Every site colour and style variable — public site and the admin preview. */
export function siteThemeVars(colors: Partial<ColorsGlobal> | null | undefined, style?: Partial<StyleGlobal> | null): Record<string, string> {
return {
...siteStyleVars(style),
'--color-bg': safeColor(colors?.background, defaultColors.background),
'--color-heading': safeColor(colors?.heading, defaultColors.heading),
'--color-subheading': safeColor(colors?.subheading, defaultColors.subheading),

View file

@ -360,3 +360,23 @@ export const defaultColors: ColorsGlobal = {
primary: '#8a9a7b',
accent: '#c9825f'
};
/** Site design → Style. Fonts are ids from SITE_FONTS in theme.ts. */
export type StyleGlobal = {
headingFont: string;
bodyFont: string;
corners: 'sharp' | 'soft' | 'round';
textSize: 'small' | 'normal' | 'large';
shadows: 'none' | 'soft' | 'strong';
width: 'narrow' | 'normal' | 'wide';
};
// The site's look before these settings existed.
export const defaultStyle: StyleGlobal = {
headingFont: 'playfair-display',
bodyFont: 'dm-sans',
corners: 'round',
textSize: 'normal',
shadows: 'soft',
width: 'normal'
};