nicer timeline

This commit is contained in:
Jakub Dorfman 2026-05-20 18:11:22 +02:00
parent 7aeb1954b2
commit 1b94a13d7e
3 changed files with 16 additions and 14 deletions

View file

@ -22,7 +22,7 @@ export function createBlock(type: BlockType): ContentBlock {
base.data = { url: '', alt: '', content: '<h2>Image and text</h2><p>Add content here.</p>', imagePosition: 'left' };
break;
case 'timeline':
base.data = { items: [{ year: '2026', title: 'Milestone', description: 'Describe this moment.' }] };
base.data = { items: [{ title: 'Milestone', description: 'Describe this moment.' }] };
break;
case 'hero':
base.data = {

View file

@ -56,13 +56,12 @@
{:else if block.type === 'timeline'}
{#each block.data.items || [] as item, i}
<div class="rounded-box mb-3 border border-base-300 p-3">
<input class="input input-bordered mb-2 w-full" placeholder="Year" value={item.year} oninput={(e) => updateArray('items', i, { year: e.currentTarget.value })} />
<input class="input input-bordered mb-2 w-full" placeholder="Title" value={item.title} oninput={(e) => updateArray('items', i, { title: e.currentTarget.value })} />
<textarea class="textarea textarea-bordered w-full" placeholder="Description" value={item.description} oninput={(e) => updateArray('items', i, { description: e.currentTarget.value })}></textarea>
<button class="btn btn-error btn-sm mt-2" type="button" onclick={() => removeArrayItem('items', i)}>Remove</button>
</div>
{/each}
<button class="btn" type="button" onclick={() => addArrayItem('items', { year: '', title: '', description: '' })}>Add item</button>
<button class="btn" type="button" onclick={() => addArrayItem('items', { title: '', description: '' })}>Add item</button>
{:else if block.type === 'hero'}
<label class="form-control w-full">
<div class="label"><span class="label-text">Heading</span></div>

View file

@ -1,26 +1,29 @@
<script lang="ts">
import { scrollReveal } from '$lib/scrollReveal';
type TimelineItem = { year: string; title: string; description: string };
type TimelineItem = { title: string; description: string };
let { data } = $props<{ data: { items?: TimelineItem[] } }>();
let items = $derived(data.items?.length ? data.items : [
{ year: 'Now', title: 'Your story here', description: 'Add milestones, training, or the journey behind the practice.' }
{ title: 'Your story here', description: 'Add milestones, training, or the journey behind the practice.' }
]);
let widths = $derived(items.map((_, i) => {
const opts = ['w-[78%]', 'w-[85%]', 'w-[90%]', 'w-[95%]', 'w-[98%]'];
return opts[(i * 7 + 3) % opts.length];
}));
</script>
<section class="mx-auto max-w-5xl px-6 py-16">
<div class="mb-12 text-center">
<p class="mb-2 text-sm font-semibold uppercase tracking-[0.25em] text-sage-dark">Journey</p>
<h2 class="text-4xl md:text-5xl" use:scrollReveal>A practice shaped over time</h2>
<section class="mx-auto max-w-7xl px-6 py-12">
<div class="mb-8 text-center">
<p class="mb-2 text-xs font-semibold uppercase tracking-[0.25em] text-sage-dark">Journey</p>
<h2 class="text-3xl md:text-4xl" use:scrollReveal>A practice shaped over time</h2>
</div>
<div class="relative md:before:absolute md:before:left-1/2 md:before:top-0 md:before:h-full md:before:w-px md:before:bg-sage/30">
{#each items as item, index}
<div use:scrollReveal class="reveal relative mb-8 grid gap-4 md:grid-cols-2 md:gap-12">
<div use:scrollReveal class="reveal relative mb-[-1rem] grid gap-4 md:grid-cols-2 md:gap-8">
<div class="hidden md:block" class:md:order-2={index % 2 === 0}></div>
<article class="rounded-3xl bg-white/75 p-6 shadow-sm ring-1 ring-charcoal/5" class:md:text-right={index % 2 === 0}>
<span class="text-sm font-bold uppercase tracking-[0.2em] text-terracotta">{item.year}</span>
<h3 class="mt-2 text-2xl">{item.title}</h3>
<p class="mt-3 leading-7 text-fg-body/70">{item.description}</p>
<article class="rounded-2xl bg-white/75 p-5 shadow-sm ring-1 ring-charcoal/5 -mt-4 {widths[index]} {index % 2 === 0 ? 'md:ml-auto md:text-right' : ''}">
<h3 class="text-xl">{item.title}</h3>
<p class="mt-2 text-sm leading-6 text-fg-body/70">{item.description}</p>
</article>
</div>
{/each}