Files
website/layers/diary/app/components/DiaryTimeline.vue
T
2026-10-03 23:57:41 +02:00

46 lines
1.6 KiB
Vue

<script setup lang="ts">
const search = ref('')
const { years, errors } = useDiary(search)
const log = useLog()
</script>
<template>
<div class="mx-auto max-w-3xl">
<div class="mb-8 flex flex-wrap items-center justify-between gap-3">
<h1 class="text-2xl font-semibold text-highlighted">Tagebuch</h1>
<div class="flex w-full items-center gap-2 sm:w-auto">
<UInput v-model="search" icon="i-lucide-search" placeholder="Tagebuch durchsuchen" class="flex-1 sm:w-64 sm:flex-none" />
<UButton icon="i-lucide-plus" label="Eintragen" @click="log.show()" />
<AppHeaderActions />
</div>
</div>
<UAlert
v-for="{ what, error } in errors"
:key="what"
color="error"
variant="subtle"
icon="i-lucide-triangle-alert"
:title="`${what} konnten nicht geladen werden`"
:description="errorMessage(error)"
class="mb-6"
/>
<section v-for="group in years" :key="group.year" class="mb-10">
<header class="sticky top-0 z-10 mb-4 bg-default/90 py-2 backdrop-blur">
<h2 class="text-xl font-semibold text-highlighted tabular-nums">{{ group.year }}</h2>
</header>
<UTimeline :items="group.items" color="primary" size="md" :ui="{ wrapper: 'pb-6' }">
<template #wrapper="{ item }">
<DiaryEntry :key="item.value" :entry="item.entry" :search="search" />
</template>
</UTimeline>
</section>
<p v-if="!years.length && !errors.length" class="py-16 text-center text-muted">
{{ search ? 'Nichts im Tagebuch passt zur Suche.' : 'Noch nichts eingetragen.' }}
</p>
</div>
</template>