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:
parent
c35f9a60cc
commit
91f6705899
29 changed files with 628 additions and 110 deletions
|
|
@ -13,9 +13,28 @@
|
|||
white-space: normal;
|
||||
}
|
||||
|
||||
/* Site design → Style sets the --site-* variables (siteStyleVars in
|
||||
$shared/theme) on the public site and the admin preview; without them
|
||||
(the admin's own pages) every token below is its usual value. Corners,
|
||||
shadows and widths are scaled here, so blocks just use rounded-xl,
|
||||
shadow-sm, max-w-6xl… Buttons and chips use rounded-button (a pill when
|
||||
Round); dots and avatars stay rounded-full. */
|
||||
@theme {
|
||||
--font-sans: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
|
||||
--font-serif: 'Playfair Display', Georgia, serif;
|
||||
--font-sans: var(--site-font-body, 'DM Sans Variable', ui-sans-serif, system-ui, sans-serif);
|
||||
--font-serif: var(--site-font-heading, 'Playfair Display Variable', Georgia, serif);
|
||||
--radius-lg: calc(0.5rem * var(--site-corners, 1));
|
||||
--radius-xl: calc(0.75rem * var(--site-corners, 1));
|
||||
--radius-2xl: calc(1rem * var(--site-corners, 1));
|
||||
--radius-card: calc(1.25rem * var(--site-corners, 1));
|
||||
--radius-panel: calc(2rem * var(--site-corners, 1));
|
||||
--radius-button: var(--site-button-radius, 9999px);
|
||||
--shadow-sm: 0 1px 3px 0 rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1))), 0 1px 2px -1px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1)));
|
||||
--shadow-md: 0 4px 6px -1px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1))), 0 2px 4px -2px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1)));
|
||||
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1))), 0 4px 6px -4px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1)));
|
||||
--shadow-xl: 0 20px 25px -5px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1))), 0 8px 10px -6px rgb(0 0 0 / calc(0.1 * var(--site-shadow, 1)));
|
||||
--container-3xl: calc(48rem * var(--site-width, 1));
|
||||
--container-6xl: calc(72rem * var(--site-width, 1));
|
||||
--container-7xl: calc(80rem * var(--site-width, 1));
|
||||
--color-warm: var(--color-bg, #faf8f5);
|
||||
--color-charcoal: var(--color-heading, #2c2c2c);
|
||||
--color-sage: var(--color-primary, #8a9a7b);
|
||||
|
|
@ -54,7 +73,9 @@
|
|||
--fg-body: var(--color-text, #2c2c2c);
|
||||
background: var(--color-bg, #faf8f5);
|
||||
color: var(--fg-body);
|
||||
font-family: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
|
||||
font-family: var(--font-sans);
|
||||
/* Site design → Style → Text size; rem-sized spacing grows with it. */
|
||||
font-size: var(--site-text-size, 100%);
|
||||
}
|
||||
|
||||
/* ── Foreground colour utilities (set per-block via BackgroundWrapper) ── */
|
||||
|
|
@ -84,7 +105,7 @@ h1,
|
|||
h2,
|
||||
h3,
|
||||
h4 {
|
||||
font-family: 'Playfair Display', Georgia, serif;
|
||||
font-family: var(--font-serif);
|
||||
color: var(--fg-heading, #2c2c2c);
|
||||
}
|
||||
|
||||
|
|
@ -124,7 +145,7 @@ h4 {
|
|||
margin: 0.75rem 0;
|
||||
padding-left: 1.25rem;
|
||||
border-left: 3px solid var(--color-primary, #8a9a7b);
|
||||
font-family: 'Playfair Display', Georgia, serif;
|
||||
font-family: var(--font-serif);
|
||||
font-size: 1.35rem;
|
||||
font-style: italic;
|
||||
}
|
||||
|
|
|
|||
19
app-admin/src/lib/fonts.ts
Normal file
19
app-admin/src/lib/fonts.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// The fonts Site design → Style offers (SITE_FONTS in $shared/theme), bundled
|
||||
// and served by this app, not loaded from Google: a Google Fonts request sends
|
||||
// every visitor's IP address to Google (GDPR). Each import only declares the
|
||||
// font; a browser downloads the files of the fonts a page actually uses.
|
||||
import '@fontsource-variable/playfair-display';
|
||||
import '@fontsource-variable/cormorant-garamond';
|
||||
import '@fontsource-variable/eb-garamond';
|
||||
import '@fontsource-variable/libre-baskerville';
|
||||
import '@fontsource-variable/lora';
|
||||
import '@fontsource-variable/fraunces';
|
||||
import '@fontsource-variable/dm-sans';
|
||||
import '@fontsource-variable/inter';
|
||||
import '@fontsource-variable/manrope';
|
||||
import '@fontsource-variable/montserrat';
|
||||
import '@fontsource-variable/nunito';
|
||||
import '@fontsource-variable/outfit';
|
||||
import '@fontsource-variable/raleway';
|
||||
import '@fontsource-variable/work-sans';
|
||||
import '@fontsource-variable/josefin-sans';
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { env } from '$env/dynamic/private';
|
||||
import { defaultColors } from '$lib/types';
|
||||
import { defaultColors, defaultStyle } from '$lib/types';
|
||||
import { shopCurrency } from '$shared/calendar';
|
||||
import type { LayoutServerLoad } from './$types';
|
||||
|
||||
|
|
@ -13,13 +13,16 @@ async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
|
|||
}
|
||||
|
||||
export const load: LayoutServerLoad = async ({ locals }) => {
|
||||
const [colors, header] = await Promise.all([
|
||||
const [colors, header, style] = await Promise.all([
|
||||
getGlobal(locals.pb, 'colors', defaultColors),
|
||||
getGlobal(locals.pb, 'header', {}) as Promise<{ logo?: { url?: string } }>
|
||||
getGlobal(locals.pb, 'header', {}) as Promise<{ logo?: { url?: string } }>,
|
||||
// Only /preview uses it: the admin's own pages keep their look.
|
||||
getGlobal(locals.pb, 'style', defaultStyle)
|
||||
]);
|
||||
return {
|
||||
user: locals.user,
|
||||
colors,
|
||||
style,
|
||||
// The site's logo is the admin's tab icon too (same as the public site).
|
||||
logoUrl: header?.logo?.url || '',
|
||||
// Admin dates/times are entered and shown in the site's timezone, and
|
||||
|
|
|
|||
|
|
@ -1,13 +1,6 @@
|
|||
<script lang="ts">
|
||||
import '../app.css';
|
||||
// Fonts are bundled and served by this app, not loaded from Google: a
|
||||
// Google Fonts request sends every visitor's IP address to Google (GDPR).
|
||||
import '@fontsource/dm-sans/400.css';
|
||||
import '@fontsource/dm-sans/500.css';
|
||||
import '@fontsource/dm-sans/600.css';
|
||||
import '@fontsource/dm-sans/700.css';
|
||||
import '@fontsource/playfair-display/600.css';
|
||||
import '@fontsource/playfair-display/700.css';
|
||||
import '$lib/fonts';
|
||||
import favicon from '$lib/assets/favicon.svg';
|
||||
import { afterNavigate } from '$app/navigation';
|
||||
import { page } from '$app/state';
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ import { fail, redirect } from '@sveltejs/kit';
|
|||
import { ClientResponseError } from 'pocketbase';
|
||||
import { PRIVACY_PAGE_SLUG, privacyTemplateHtml } from '$lib/admin/privacyTemplate';
|
||||
import { attempt } from '$lib/server/actions';
|
||||
import { defaultColors, defaultFooter, defaultHeader } from '$lib/types';
|
||||
import { defaultColors, defaultFooter, defaultHeader, defaultStyle } from '$lib/types';
|
||||
import type { Actions, PageServerLoad } from './$types';
|
||||
|
||||
const SECTIONS = ['header', 'footer', 'colors'] as const;
|
||||
const SECTIONS = ['header', 'footer', 'colors', 'style'] as const;
|
||||
|
||||
async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
|
||||
try {
|
||||
|
|
@ -21,10 +21,11 @@ async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
|
|||
}
|
||||
|
||||
export const load: PageServerLoad = async ({ locals }) => {
|
||||
const [header, footer, colors] = await Promise.all([
|
||||
const [header, footer, colors, style] = await Promise.all([
|
||||
getGlobal(locals.pb, 'header', defaultHeader),
|
||||
getGlobal(locals.pb, 'footer', defaultFooter),
|
||||
getGlobal(locals.pb, 'colors', defaultColors)
|
||||
getGlobal(locals.pb, 'colors', defaultColors),
|
||||
getGlobal(locals.pb, 'style', defaultStyle)
|
||||
]);
|
||||
|
||||
// All pages for the page selectors, with what the basket setting warns
|
||||
|
|
@ -35,7 +36,7 @@ export const load: PageServerLoad = async ({ locals }) => {
|
|||
return { id: page.id, slug: page.slug, title: page.title, published: !!page.published, hasCheckout: types.has('checkout') };
|
||||
});
|
||||
|
||||
return { header, footer, colors, pages };
|
||||
return { header, footer, colors, style, pages };
|
||||
};
|
||||
|
||||
export const actions: Actions = {
|
||||
|
|
|
|||
|
|
@ -3,14 +3,19 @@
|
|||
import { enhance } from '$app/forms';
|
||||
import { fly, slide } from 'svelte/transition';
|
||||
import ImagePicker from '$lib/admin/editors/ImagePicker.svelte';
|
||||
import SegmentedControl from '$lib/admin/editors/SegmentedControl.svelte';
|
||||
import { PRIVACY_PAGE_SLUG } from '$lib/admin/privacyTemplate';
|
||||
import { shopLinks } from '$lib/types';
|
||||
import { defaultStyle, shopLinks } from '$lib/types';
|
||||
import { SITE_FONTS, readableTextOn, siteStyleVars } from '$shared/theme';
|
||||
import type { SubmitFunction } from '@sveltejs/kit';
|
||||
|
||||
let { data, form } = $props();
|
||||
let header = $state(structuredClone(data.header.data));
|
||||
let footer = $state(structuredClone(data.footer.data));
|
||||
let colors = $state(structuredClone(data.colors.data));
|
||||
let style = $state({ ...defaultStyle, ...data.style.data });
|
||||
// The sample below the style settings: the variables the public site gets, as an inline style.
|
||||
let styleSample = $derived(Object.entries(siteStyleVars(style)).map(([name, value]) => `${name}:${value}`).join(';'));
|
||||
let saving = $state('');
|
||||
// Older records may predate the CTA button and the basket page; the inputs below need values.
|
||||
header.ctaButton ??= { label: '', href: '' };
|
||||
|
|
@ -116,7 +121,7 @@
|
|||
|
||||
<div class="mb-6">
|
||||
<h1 class="text-3xl font-bold">Site design</h1>
|
||||
<p class="text-base-content/60">The header, footer and colors shared by every page of the site.</p>
|
||||
<p class="text-base-content/60">The header, footer, colors and style shared by every page of the site.</p>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-6 xl:grid-cols-3">
|
||||
|
|
@ -218,4 +223,53 @@
|
|||
{/each}
|
||||
{@render saveButton('colors', 'Save colors')}
|
||||
</form>
|
||||
|
||||
<form class="flex flex-col rounded-box bg-base-100 p-5 shadow" method="POST" action="?/save" use:enhance={submit}>
|
||||
<input type="hidden" name="id" value={data.style.id} />
|
||||
<input type="hidden" name="section" value="style" />
|
||||
<input type="hidden" name="data" value={JSON.stringify(style)} />
|
||||
<h2 class="mb-4 text-2xl font-bold">Style</h2>
|
||||
<p class="mb-2 text-sm text-base-content/60">Fonts and shapes for the public site. The fonts come with the site, so visitors' browsers don't contact Google for them.</p>
|
||||
{#snippet fontSelect(label: string, key: 'headingFont' | 'bodyFont')}
|
||||
<label class="fieldset py-1">
|
||||
<span class="fieldset-legend pb-0">{label}</span>
|
||||
<select class="select w-full" bind:value={style[key]}>
|
||||
<optgroup label="Serif">
|
||||
{#each SITE_FONTS.filter((font) => font.serif) as font (font.id)}
|
||||
<option value={font.id} style="font-family: '{font.family}'">{font.label}</option>
|
||||
{/each}
|
||||
</optgroup>
|
||||
<optgroup label="Sans-serif">
|
||||
{#each SITE_FONTS.filter((font) => !font.serif) as font (font.id)}
|
||||
<option value={font.id} style="font-family: '{font.family}'">{font.label}</option>
|
||||
{/each}
|
||||
</optgroup>
|
||||
</select>
|
||||
</label>
|
||||
{/snippet}
|
||||
{@render fontSelect('Headings', 'headingFont')}
|
||||
{@render fontSelect('Body text', 'bodyFont')}
|
||||
<div class="mt-3 space-y-2">
|
||||
<SegmentedControl label="Corners" options={['sharp', 'soft', 'round']} value={style.corners} onChange={(v) => (style.corners = v as typeof style.corners)} />
|
||||
<SegmentedControl label="Text size" options={['small', 'normal', 'large']} value={style.textSize} onChange={(v) => (style.textSize = v as typeof style.textSize)} />
|
||||
<SegmentedControl label="Shadows" options={['none', 'soft', 'strong']} value={style.shadows} onChange={(v) => (style.shadows = v as typeof style.shadows)} />
|
||||
<SegmentedControl label="Page width" options={['narrow', 'normal', 'wide']} value={style.width} onChange={(v) => (style.width = v as typeof style.width)} />
|
||||
</div>
|
||||
<p class="mt-1 text-sm text-base-content/60">Page width is how wide text and sections may get on a big screen; phones are unaffected.</p>
|
||||
|
||||
<!-- How the choices look. Inline styles, because the radius and shadow tokens in app.css
|
||||
are worked out once for the whole page and can't follow variables set on this box. -->
|
||||
<div
|
||||
class="mt-4 border border-base-300 p-4"
|
||||
style="{styleSample}; background: {colors.background}; color: {colors.text}; font-family: var(--site-font-body); font-size: var(--site-text-size); border-radius: calc(1rem * var(--site-corners))"
|
||||
aria-label="Style sample"
|
||||
>
|
||||
<p class="text-2xl font-semibold" style="font-family: var(--site-font-heading); color: {colors.heading}">A calm space for you</p>
|
||||
<div class="mt-3 bg-white p-3" style="border-radius: calc(1rem * var(--site-corners)); box-shadow: 0 1px 3px 0 rgb(0 0 0 / calc(0.1 * var(--site-shadow))), 0 1px 2px -1px rgb(0 0 0 / calc(0.1 * var(--site-shadow)))">
|
||||
<p>Body text looks like this. Sessions last an hour.</p>
|
||||
<span class="mt-3 inline-block px-5 py-2 text-sm font-medium" style="border-radius: var(--site-button-radius); background: {colors.primary}; color: {readableTextOn(colors.primary)}">Book</span>
|
||||
</div>
|
||||
</div>
|
||||
{@render saveButton('style', 'Save style')}
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@
|
|||
|
||||
<svelte:head>
|
||||
<title>Preview</title>
|
||||
<!-- Full site colours so the draft looks like the public site. -->
|
||||
{@html rootStyleTag(siteThemeVars(data.colors))}
|
||||
<!-- Full site colours and style so the draft looks like the public site. -->
|
||||
{@html rootStyleTag(siteThemeVars(data.colors, data.style))}
|
||||
</svelte:head>
|
||||
|
||||
{#if blocks.length}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue