From d3d8910c3cfc269ebcba9e75accc4240d8bb6362 Mon Sep 17 00:00:00 2001 From: agent Date: Mon, 26 Oct 2026 13:14:04 +0000 Subject: [PATCH 01/26] Public site: the Site design logo is the favicon A 300x300 thumbnail of it (PocketBase's existing media thumb size), also as the phone home-screen icon. Without a logo the bundled icon stays. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW --- app-public/src/routes/+layout.svelte | 8 +++++++- packages/shared/src/pb.ts | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app-public/src/routes/+layout.svelte b/app-public/src/routes/+layout.svelte index 44d5553..f60f23e 100644 --- a/app-public/src/routes/+layout.svelte +++ b/app-public/src/routes/+layout.svelte @@ -13,9 +13,13 @@ import Footer from '$lib/components/Footer.svelte'; import { createBasketStore, setBasketContext } from '$lib/basket.svelte'; import { rootStyleTag, siteThemeVars } from '$shared/theme'; + import { thumbUrl } from '$shared/pb'; let { children, data } = $props(); + // The logo from Site design is the tab icon (a 300×300 thumbnail, not the full upload). + let icon = $derived(data.header?.logo?.url ? thumbUrl(data.header.logo.url) : favicon); + // One basket store per public layout instance — provided to all children // (Header indicator, ShopBlock, CheckoutBlock). Never module-level state. const basketStore = createBasketStore(data.basket ?? null); @@ -27,7 +31,9 @@ - + + + {#if icon !== favicon}{/if} diff --git a/packages/shared/src/pb.ts b/packages/shared/src/pb.ts index 0797bb5..c8ac7a7 100644 --- a/packages/shared/src/pb.ts +++ b/packages/shared/src/pb.ts @@ -20,3 +20,14 @@ export function createPocketBase(authCookie?: string, url = pbUrl) { export function getFileUrl(collectionIdOrName: string, recordId: string, filename: string) { return `${pbUrl}/api/files/${collectionIdOrName}/${recordId}/${filename}`; } + +/** + * A small version of an uploaded image: PocketBase makes thumbnails of media + * files in the sizes listed on the field (`media.file` has 300x300, cropped + * to fill). Other URLs (and SVGs, which PocketBase doesn't resize) are + * returned as they are. + */ +export function thumbUrl(url: string, size: '300x300' | '1200x0' = '300x300') { + if (!url.includes('/api/files/') || /\.svg(\?|$)/i.test(url)) return url; + return `${url}${url.includes('?') ? '&' : '?'}thumb=${size}`; +} From 745cd24562f52d0c7826d8a991aab0659c269a20 Mon Sep 17 00:00:00 2001 From: agent Date: Mon, 26 Oct 2026 13:17:44 +0000 Subject: [PATCH 02/26] Admin: the Site design logo is the favicon too Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW --- app-admin/src/routes/+layout.server.ts | 7 ++++++- app-admin/src/routes/+layout.svelte | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app-admin/src/routes/+layout.server.ts b/app-admin/src/routes/+layout.server.ts index 697edf0..bdfa149 100644 --- a/app-admin/src/routes/+layout.server.ts +++ b/app-admin/src/routes/+layout.server.ts @@ -13,10 +13,15 @@ async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) { } export const load: LayoutServerLoad = async ({ locals }) => { - const colors = await getGlobal(locals.pb, 'colors', defaultColors); + const [colors, header] = await Promise.all([ + getGlobal(locals.pb, 'colors', defaultColors), + getGlobal(locals.pb, 'header', {}) as Promise<{ logo?: { url?: string } }> + ]); return { user: locals.user, colors, + // 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 // prices in the shop currency — same settings the booking emails use. timezone: env.SITE_TIMEZONE || 'Europe/Oslo', diff --git a/app-admin/src/routes/+layout.svelte b/app-admin/src/routes/+layout.svelte index 8e68676..35dc3e9 100644 --- a/app-admin/src/routes/+layout.svelte +++ b/app-admin/src/routes/+layout.svelte @@ -13,8 +13,10 @@ import { page } from '$app/state'; import { createBasketStore, setBasketContext } from '$lib/basket.svelte'; import { brandThemeVars, rootStyleTag } from '$shared/theme'; + import { thumbUrl } from '$shared/pb'; let { children, data } = $props(); + let icon = $derived(data.logoUrl ? thumbUrl(data.logoUrl) : favicon); // Routes rendered without the admin shell: the login screen, and the // preview iframe (which must look like the public site, not the admin). @@ -67,7 +69,7 @@ - + {@html rootStyleTag(brandThemeVars(data.colors))} From 93d4863cfc37d6e13444d848529248bb0820cd8f Mon Sep 17 00:00:00 2001 From: agent Date: Mon, 26 Oct 2026 13:32:43 +0000 Subject: [PATCH 03/26] Admin: one image picker everywhere, with paste and drag-and-drop ImageUploader becomes ImagePicker and replaces the separate image field on Services & products, so every image (blocks, card images, block backgrounds, emails, the logo, services) is picked the same way. Besides choosing a file it takes an image dragged onto the box or pasted (Ctrl+V while the picker has focus, or the Paste button where the browser allows reading the clipboard). Pasted images get a dated file name and no alt text made from "image.png"; files the media collection won't take are refused with a message before uploading. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW --- AGENTS.md | 1 + .../src/lib/admin/editors/BlockEditor.svelte | 8 +- .../lib/admin/editors/EmailBlockEditor.svelte | 4 +- .../src/lib/admin/editors/ImagePicker.svelte | 181 ++++++++++++++++++ .../lib/admin/editors/ImageUploader.svelte | 107 ----------- app-admin/src/lib/pb.ts | 9 +- app-admin/src/routes/globals/+page.svelte | 4 +- app-admin/src/routes/items/+page.svelte | 42 +--- 8 files changed, 200 insertions(+), 156 deletions(-) create mode 100644 app-admin/src/lib/admin/editors/ImagePicker.svelte delete mode 100644 app-admin/src/lib/admin/editors/ImageUploader.svelte diff --git a/AGENTS.md b/AGENTS.md index 633aaa9..96d0823 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -146,6 +146,7 @@ To add an email block type: add to `EmailBlockType` in `packages/shared/src/type - Section card: `rounded-box bg-base-100 p-5 shadow` with an `h2.text-2xl.font-bold` title (see Site design / globals). - Form field: ``; hints in ``. - Setting rows in editors: `SegmentedControl` (choices) and `ColorField` (colours) — label column on the left, like the block Background picker. + - Images: always `$lib/admin/editors/ImagePicker.svelte` (choose, drag in or paste an image; address and alt text). It uploads to `media` through `/api/upload`; `withUrl={false}` + `altHint=""` + the `id` from `onChange` where a field stores a media relation (Services & products). Store only `url`/`alt` from `onChange` elsewhere. - Create/edit forms open in `$lib/admin/Modal.svelte`; destructive submits use `confirmSubmit()` from `$lib/admin/confirm` (returning `false` from a handler does not cancel). - Server actions wrap PocketBase writes in `attempt()` from `$lib/server/actions` so failures show as an error banner, not a 500. - Editors with unsaved state use `use:enhance` + `warnOnUnsavedChanges()`. diff --git a/app-admin/src/lib/admin/editors/BlockEditor.svelte b/app-admin/src/lib/admin/editors/BlockEditor.svelte index d0a1f42..09787fc 100644 --- a/app-admin/src/lib/admin/editors/BlockEditor.svelte +++ b/app-admin/src/lib/admin/editors/BlockEditor.svelte @@ -2,7 +2,7 @@ import type { BlockType, ContentBlock } from '$lib/types'; import { blockLabels } from '$lib/admin/blockDefaults'; import RichTextEditor from './RichTextEditor.svelte'; - import ImageUploader from './ImageUploader.svelte'; + import ImagePicker from './ImagePicker.svelte'; import SegmentedControl from './SegmentedControl.svelte'; import ColorField from './ColorField.svelte'; import ShopBlockEditor from './ShopBlockEditor.svelte'; @@ -94,7 +94,7 @@ {:else if block.type === 'image_text'}
- updateData(image)} /> + updateData({ url: image.url, alt: image.alt })} /> updateData({ imagePosition: v })} /> updateData({ content })} />
@@ -199,7 +199,7 @@ {#if block.data.style !== 'numbered'} - updateArray('items', i, { imageUrl: image.url, imageAlt: image.alt })} /> + updateArray('items', i, { imageUrl: image.url, imageAlt: image.alt })} /> {/if}
{@render field('Title', card.title || '', (title) => updateArray('items', i, { title }))} @@ -255,7 +255,7 @@ {#if block.data._background?.type === 'color'} updateBackground({ color })} /> {:else if block.data._background?.type === 'image'} - updateBackground({ imageUrl: image.url, imageAlt: image.alt })} /> + updateBackground({ imageUrl: image.url, imageAlt: image.alt })} /> updateBackground({ attachment })} /> Use placeholders like {'{{customer_first_name}}'} — see the list above.

{:else if block.type === 'image'}
- updateData(image)} /> + updateData({ url: image.url, alt: image.alt })} /> updateData({ width: v })} formatLabel={(v) => `${v}%`} /> updateData({ alignment: v })} />
- {#if uploadError}{uploadError}{/if} + (draft = { ...draft, image: image.id ?? draft.image, imageUrl: image.url })} /> + The shop uses the name as the image’s alt text.