Added global color defaults
This commit is contained in:
parent
62f7ac7301
commit
7aeb1954b2
8 changed files with 90 additions and 28 deletions
|
|
@ -7,11 +7,11 @@
|
|||
@theme {
|
||||
--font-sans: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
|
||||
--font-serif: 'Playfair Display', Georgia, serif;
|
||||
--color-warm: #faf8f5;
|
||||
--color-charcoal: #2c2c2c;
|
||||
--color-sage: #8a9a7b;
|
||||
--color-sage-dark: #66755d;
|
||||
--color-terracotta: #c9825f;
|
||||
--color-warm: var(--color-bg, #faf8f5);
|
||||
--color-charcoal: var(--color-heading, #2c2c2c);
|
||||
--color-sage: var(--color-primary, #8a9a7b);
|
||||
--color-sage-dark: color-mix(in srgb, var(--color-primary, #8a9a7b) 80%, #000);
|
||||
--color-terracotta: var(--color-accent, #c9825f);
|
||||
}
|
||||
|
||||
@keyframes shrink {
|
||||
|
|
@ -40,9 +40,9 @@
|
|||
}
|
||||
|
||||
:root {
|
||||
--fg-heading: #2c2c2c;
|
||||
--fg-body: #2c2c2c;
|
||||
background: #faf8f5;
|
||||
--fg-heading: var(--color-heading, #2c2c2c);
|
||||
--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;
|
||||
}
|
||||
|
|
@ -55,13 +55,14 @@
|
|||
.text-fg-body\/70 { color: color-mix(in srgb, var(--fg-body, #2c2c2c) 70%, transparent); }
|
||||
.text-fg-body\/60 { color: color-mix(in srgb, var(--fg-body, #2c2c2c) 60%, transparent); }
|
||||
.text-fg-heading { color: var(--fg-heading, #2c2c2c); }
|
||||
.text-fg-subheading { color: var(--color-subheading, #4a4a4a); }
|
||||
|
||||
body {
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
background:
|
||||
radial-gradient(circle at top left, rgba(201, 130, 95, 0.1), transparent 36rem),
|
||||
#faf8f5;
|
||||
radial-gradient(circle at top left, rgba(var(--color-accent-rgb, 201, 130, 95), 0.1), transparent 36rem),
|
||||
var(--color-bg, #faf8f5);
|
||||
}
|
||||
|
||||
h1,
|
||||
|
|
@ -94,7 +95,7 @@ h4 {
|
|||
}
|
||||
|
||||
.prose-wellness a {
|
||||
color: #66755d;
|
||||
color: color-mix(in srgb, var(--color-primary, #8a9a7b) 90%, #000);
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 3px;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@
|
|||
<div class="flex items-center justify-between">
|
||||
<span class="label-text w-24">Color</span>
|
||||
<div class="flex flex-1 items-center gap-2">
|
||||
<input class="input input-bordered w-10 h-10 p-1 cursor-pointer" type="color" value={block.data.color || '#66755d'} oninput={(e) => updateData({ color: e.currentTarget.value })} />
|
||||
<input class="input input-bordered flex-1" placeholder="#66755d or color name" value={block.data.color || ''} oninput={(e) => updateData({ color: e.currentTarget.value })} />
|
||||
<input class="input input-bordered w-10 h-10 p-1 cursor-pointer" type="color" value={block.data.color || 'var(--color-primary)'} oninput={(e) => updateData({ color: e.currentTarget.value })} />
|
||||
<input class="input input-bordered flex-1" placeholder="Leave empty to use global primary" value={block.data.color || ''} oninput={(e) => updateData({ color: e.currentTarget.value })} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
</nav>
|
||||
|
||||
{#if header.ctaButton?.label}
|
||||
<a class="btn rounded-full border-0 bg-sage px-6 text-white hover:bg-sage-dark" href={header.ctaButton.href}>{header.ctaButton.label}</a>
|
||||
<a class="btn rounded-full border-0 px-6 text-white hover:opacity-90" style="background-color: var(--color-primary, #8a9a7b);" href={header.ctaButton.href}>{header.ctaButton.label}</a>
|
||||
{/if}
|
||||
</div>
|
||||
</header>
|
||||
|
|
|
|||
|
|
@ -69,3 +69,21 @@ export const defaultFooter: FooterGlobal = {
|
|||
socialLinks: [{ platform: 'instagram', url: '' }],
|
||||
copyrightText: `© ${new Date().getFullYear()} Eva Shafik Massage. All rights reserved.`
|
||||
};
|
||||
|
||||
export type ColorsGlobal = {
|
||||
background: string;
|
||||
heading: string;
|
||||
subheading: string;
|
||||
text: string;
|
||||
primary: string;
|
||||
accent: string;
|
||||
};
|
||||
|
||||
export const defaultColors: ColorsGlobal = {
|
||||
background: '#faf8f5',
|
||||
heading: '#2c2c2c',
|
||||
subheading: '#4a4a4a',
|
||||
text: '#2c2c2c',
|
||||
primary: '#8a9a7b',
|
||||
accent: '#c9825f'
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { defaultFooter, defaultHeader } from '$lib/types';
|
||||
import { defaultColors, defaultFooter, defaultHeader } from '$lib/types';
|
||||
import type { LayoutServerLoad } from './$types';
|
||||
|
||||
async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
|
||||
|
|
@ -11,10 +11,11 @@ async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
|
|||
}
|
||||
|
||||
export const load: LayoutServerLoad = async ({ locals, url }) => {
|
||||
const [header, footer] = await Promise.all([
|
||||
const [header, footer, colors] = await Promise.all([
|
||||
getGlobal(locals.pb, 'header', defaultHeader),
|
||||
getGlobal(locals.pb, 'footer', defaultFooter)
|
||||
getGlobal(locals.pb, 'footer', defaultFooter),
|
||||
getGlobal(locals.pb, 'colors', defaultColors)
|
||||
]);
|
||||
|
||||
return { header, footer, user: locals.user, url: { pathname: url.pathname } };
|
||||
return { header, footer, colors, user: locals.user, url: { pathname: url.pathname } };
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,9 +3,22 @@
|
|||
import favicon from '$lib/assets/favicon.svg';
|
||||
import Header from '$lib/components/Header.svelte';
|
||||
import Footer from '$lib/components/Footer.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let { children, data } = $props();
|
||||
let isAdmin = $derived(data.url?.pathname?.startsWith('/admin'));
|
||||
|
||||
onMount(() => {
|
||||
if (data.colors && !isAdmin) {
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { defaultFooter, defaultHeader } from '$lib/types';
|
||||
import { defaultColors, defaultFooter, defaultHeader } from '$lib/types';
|
||||
import type { Actions, PageServerLoad } from './$types';
|
||||
|
||||
async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
|
||||
|
|
@ -10,11 +10,12 @@ async function getGlobal(pb: App.Locals['pb'], key: string, fallback: unknown) {
|
|||
}
|
||||
|
||||
export const load: PageServerLoad = async ({ locals }) => {
|
||||
const [header, footer] = await Promise.all([
|
||||
const [header, footer, colors] = await Promise.all([
|
||||
getGlobal(locals.pb, 'header', defaultHeader),
|
||||
getGlobal(locals.pb, 'footer', defaultFooter)
|
||||
getGlobal(locals.pb, 'footer', defaultFooter),
|
||||
getGlobal(locals.pb, 'colors', defaultColors)
|
||||
]);
|
||||
return { header, footer };
|
||||
return { header, footer, colors };
|
||||
};
|
||||
|
||||
export const actions: Actions = {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
let { data } = $props();
|
||||
let header = $state(structuredClone(data.header.data));
|
||||
let footer = $state(structuredClone(data.footer.data));
|
||||
let colors = $state(structuredClone(data.colors.data));
|
||||
|
||||
function addHeaderLink() { header.navLinks = [...(header.navLinks || []), { label: '', href: '' }]; }
|
||||
function addSocial() { footer.socialLinks = [...(footer.socialLinks || []), { platform: '', url: '' }]; }
|
||||
|
|
@ -13,11 +14,11 @@
|
|||
|
||||
<div class="mb-6">
|
||||
<h1 class="text-3xl font-bold">Global sections</h1>
|
||||
<p class="text-base-content/60">Edit the site header and footer content.</p>
|
||||
<p class="text-base-content/60">Edit the site header, footer, and global color settings.</p>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-6 lg:grid-cols-2">
|
||||
<form class="rounded-box bg-base-100 p-5 shadow" method="POST" action="?/save">
|
||||
<div class="grid gap-6 xl:grid-cols-3">
|
||||
<form class="rounded-box bg-base-100 p-5 shadow flex flex-col" method="POST" action="?/save">
|
||||
<input type="hidden" name="id" value={data.header.id} />
|
||||
<input type="hidden" name="data" value={JSON.stringify(header)} />
|
||||
<h2 class="mb-4 text-2xl font-bold">Header</h2>
|
||||
|
|
@ -34,10 +35,11 @@
|
|||
<h3 class="mt-6 font-bold">CTA button</h3>
|
||||
<input class="input input-bordered mb-2 w-full" bind:value={header.ctaButton.label} placeholder="Label" />
|
||||
<input class="input input-bordered w-full" bind:value={header.ctaButton.href} placeholder="Href" />
|
||||
<button class="btn btn-primary mt-6" type="submit">Save header</button>
|
||||
<div class="flex-grow"></div>
|
||||
<button class="btn btn-primary mt-6 block w-full" type="submit">Save header</button>
|
||||
</form>
|
||||
|
||||
<form class="rounded-box bg-base-100 p-5 shadow" method="POST" action="?/save">
|
||||
<form class="rounded-box bg-base-100 p-5 shadow flex flex-col" method="POST" action="?/save">
|
||||
<input type="hidden" name="id" value={data.footer.id} />
|
||||
<input type="hidden" name="data" value={JSON.stringify(footer)} />
|
||||
<h2 class="mb-4 text-2xl font-bold">Footer</h2>
|
||||
|
|
@ -56,6 +58,32 @@
|
|||
</div>
|
||||
{/each}
|
||||
<button class="btn btn-sm" type="button" onclick={addSocial}>Add social link</button>
|
||||
<button class="btn btn-primary mt-6 block" type="submit">Save footer</button>
|
||||
<div class="flex-grow"></div>
|
||||
<button class="btn btn-primary mt-6 block w-full" type="submit">Save footer</button>
|
||||
</form>
|
||||
|
||||
<form class="rounded-box bg-base-100 p-5 shadow flex flex-col" method="POST" action="?/save">
|
||||
<input type="hidden" name="id" value={data.colors.id} />
|
||||
<input type="hidden" name="data" value={JSON.stringify(colors)} />
|
||||
<h2 class="mb-4 text-2xl font-bold">Colors</h2>
|
||||
<p class="text-sm text-base-content/60 mb-4">These colors are applied across the site as defaults.</p>
|
||||
{#each [
|
||||
{ key: 'background', label: 'Background color' },
|
||||
{ key: 'heading', label: 'Heading color' },
|
||||
{ key: 'subheading', label: 'Subheading color' },
|
||||
{ key: 'text', label: 'Text color' },
|
||||
{ key: 'primary', label: 'Primary color (buttons, links)' },
|
||||
{ key: 'accent', label: 'Accent color (highlights)' }
|
||||
] as { key, label }}
|
||||
<label class="form-control w-full mb-3">
|
||||
<div class="label"><span class="label-text">{label}</span></div>
|
||||
<div class="flex gap-2">
|
||||
<input type="color" class="cursor-pointer" bind:value={colors[key]} />
|
||||
<input type="text" class="input input-bordered flex-1 font-mono text-sm" bind:value={colors[key]} />
|
||||
</div>
|
||||
</label>
|
||||
{/each}
|
||||
<div class="flex-grow"></div>
|
||||
<button class="btn btn-primary mt-6 block w-full" type="submit">Save colors</button>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue