Compare commits
No commits in common. "4b50067a4a687986805a2de06dde7b9f4d1cd867" and "d29f101b29dd01196d7d349b8e37c47db406359e" have entirely different histories.
4b50067a4a
...
d29f101b29
4 changed files with 3 additions and 27 deletions
|
|
@ -13,15 +13,10 @@ async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const load: LayoutServerLoad = async ({ locals }) => {
|
export const load: LayoutServerLoad = async ({ locals }) => {
|
||||||
const [colors, header] = await Promise.all([
|
const colors = await getGlobal(locals.pb, 'colors', defaultColors);
|
||||||
getGlobal(locals.pb, 'colors', defaultColors),
|
|
||||||
getGlobal(locals.pb, 'header', {}) as Promise<{ logo?: { url?: string } }>
|
|
||||||
]);
|
|
||||||
return {
|
return {
|
||||||
user: locals.user,
|
user: locals.user,
|
||||||
colors,
|
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
|
// Admin dates/times are entered and shown in the site's timezone, and
|
||||||
// prices in the shop currency — same settings the booking emails use.
|
// prices in the shop currency — same settings the booking emails use.
|
||||||
timezone: env.SITE_TIMEZONE || 'Europe/Oslo',
|
timezone: env.SITE_TIMEZONE || 'Europe/Oslo',
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,8 @@
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
import { createBasketStore, setBasketContext } from '$lib/basket.svelte';
|
import { createBasketStore, setBasketContext } from '$lib/basket.svelte';
|
||||||
import { brandThemeVars, rootStyleTag } from '$shared/theme';
|
import { brandThemeVars, rootStyleTag } from '$shared/theme';
|
||||||
import { thumbUrl } from '$shared/pb';
|
|
||||||
|
|
||||||
let { children, data } = $props();
|
let { children, data } = $props();
|
||||||
let icon = $derived(data.logoUrl ? thumbUrl(data.logoUrl) : favicon);
|
|
||||||
|
|
||||||
// Routes rendered without the admin shell: the login screen, and the
|
// Routes rendered without the admin shell: the login screen, and the
|
||||||
// preview iframe (which must look like the public site, not the admin).
|
// preview iframe (which must look like the public site, not the admin).
|
||||||
|
|
@ -69,7 +67,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<link rel="icon" href={icon} />
|
<link rel="icon" href={favicon} />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<!-- Admin buttons/highlights use the site's Primary and Accent colours (sanitised; readable text picked automatically). -->
|
<!-- Admin buttons/highlights use the site's Primary and Accent colours (sanitised; readable text picked automatically). -->
|
||||||
{@html rootStyleTag(brandThemeVars(data.colors))}
|
{@html rootStyleTag(brandThemeVars(data.colors))}
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,9 @@
|
||||||
import Footer from '$lib/components/Footer.svelte';
|
import Footer from '$lib/components/Footer.svelte';
|
||||||
import { createBasketStore, setBasketContext } from '$lib/basket.svelte';
|
import { createBasketStore, setBasketContext } from '$lib/basket.svelte';
|
||||||
import { rootStyleTag, siteThemeVars } from '$shared/theme';
|
import { rootStyleTag, siteThemeVars } from '$shared/theme';
|
||||||
import { thumbUrl } from '$shared/pb';
|
|
||||||
|
|
||||||
let { children, data } = $props();
|
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
|
// One basket store per public layout instance — provided to all children
|
||||||
// (Header indicator, ShopBlock, CheckoutBlock). Never module-level state.
|
// (Header indicator, ShopBlock, CheckoutBlock). Never module-level state.
|
||||||
const basketStore = createBasketStore(data.basket ?? null);
|
const basketStore = createBasketStore(data.basket ?? null);
|
||||||
|
|
@ -31,9 +27,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<link rel="icon" href={icon} />
|
<link rel="icon" href={favicon} />
|
||||||
<!-- Home-screen icon on phones; iOS ignores SVG, so only for an uploaded logo. -->
|
|
||||||
{#if icon !== favicon}<link rel="apple-touch-icon" href={icon} />{/if}
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<!-- Site colours, rendered server-side (previously applied in onMount, which
|
<!-- Site colours, rendered server-side (previously applied in onMount, which
|
||||||
flashed the defaults on every page load). Values are sanitised. -->
|
flashed the defaults on every page load). Values are sanitised. -->
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,3 @@ export function createPocketBase(authCookie?: string, url = pbUrl) {
|
||||||
export function getFileUrl(collectionIdOrName: string, recordId: string, filename: string) {
|
export function getFileUrl(collectionIdOrName: string, recordId: string, filename: string) {
|
||||||
return `${pbUrl}/api/files/${collectionIdOrName}/${recordId}/${filename}`;
|
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}`;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue