Compare commits
2 commits
7da1a10af2
...
0d35dc9d29
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d35dc9d29 | |||
| ded828ddef |
28 changed files with 593 additions and 100 deletions
22
README.md
22
README.md
|
|
@ -15,20 +15,36 @@ Tablet und Desktop.
|
|||
- Termine & Schließzeiten, gruppiert nach Monat, mit Kalender-Abo (`/termine.ics`)
|
||||
- Ansprechpartner-Verzeichnis, Kontaktformular, Volltextsuche
|
||||
- **Barrierearm:** klare Schrift (Montserrat, selbst gehostet), 3 Schriftgrößen, Hell/Dunkel,
|
||||
**Vorlesen**-Funktion, **Leichte Sprache** pro Seite/Meldung
|
||||
**Leichte Sprache** pro Seite/Meldung
|
||||
- **Vorlesen** jeder Seite (Knopf in der Kopfzeile) oder eines Artikels: satzweise, der gelesene Satz
|
||||
wird markiert und mitgescrollt, mit Pause, Satz vor/zurück und langsamem Tempo
|
||||
- Merkliste (lokal auf dem Gerät), Teilen, offline lesbar, als App installierbar
|
||||
- Keine Werbung, kein Tracking, keine externen Schriften oder CDNs
|
||||
|
||||
**Redaktion (`/admin`)**
|
||||
|
||||
- Übersicht, Meldungen (Entwurf, geplante Veröffentlichung, anheften), Seitenbaum, Termine,
|
||||
Startseiten-Kacheln, Ansprechpartner, Mediathek, Postfach
|
||||
- **Redaktionskalender** fürs Team: Planungen mit Status (Idee → In Arbeit → Zur Freigabe → Geplant →
|
||||
Erledigt), Zuständigkeit, Frist, Notizen und Kommentaren; Monatsansicht mit Meldungen und Terminen,
|
||||
Board nach Status, Liste; Ziehen & Ablegen (mit Tastatur-Alternative), Ideenspeicher,
|
||||
„Meldung daraus erstellen“, „Meine Aufgaben“ auf der Übersicht
|
||||
- **Ansprechpartner** einmal anlegen und in beliebig vielen Seiten und Meldungen verwenden – mit Suche,
|
||||
Reihenfolge, Anlegen direkt aus dem Auswahlfeld und „Verwendet in“
|
||||
- Meldungen (Entwurf, geplante Veröffentlichung, anheften), Seitenbaum, Termine,
|
||||
Startseiten-Bereiche, Mediathek, Postfach
|
||||
- Text-Editor mit Formatierungen, Links und Bildern
|
||||
- Bilder werden automatisch gedreht, verkleinert und als WebP gespeichert
|
||||
- Rollen: **Redakteur** (Inhalte) und **Administrator** (zusätzlich Benutzer & Einstellungen)
|
||||
- Einstellungen: App-Name, Logo, Farbpaar (Haupt- und Akzentfarbe), Titelbild, Texte, Impressum,
|
||||
Datenschutz – das App-Symbol wird daraus automatisch erzeugt
|
||||
|
||||
## Barrierefreiheit
|
||||
|
||||
App und Redaktion werden mit [axe-core](https://github.com/dequelabs/axe-core) gegen WCAG 2.2 AA geprüft
|
||||
(hell und dunkel, Handy und Desktop) – aktuell ohne Befund. Dazu u. a.: Sprunglinks zum Inhalt,
|
||||
sichtbarer Tastaturfokus, beschriftete Bedienelemente, Ansagen für Screenreader bei Änderungen,
|
||||
Tastatur-Alternativen zu Ziehen & Ablegen, `prefers-reduced-motion`, Kontrast ≥ 4,5 : 1.
|
||||
Schriftgröße und Farbschema lassen sich auch in der Redaktion einstellen (Mein Konto).
|
||||
|
||||
## Technik
|
||||
|
||||
SvelteKit 2 (Svelte 5) · Tailwind CSS 4 · SQLite (better-sqlite3) mit Drizzle ORM · sharp · Tiptap.
|
||||
|
|
|
|||
22
src/app.css
22
src/app.css
|
|
@ -15,8 +15,9 @@
|
|||
/* ruhige Flächen: Lavendel, aus der Markenfarbe abgeleitet */
|
||||
--surface-2: color-mix(in oklab, var(--brand) 8%, white);
|
||||
--ink: color-mix(in oklab, var(--brand) 92%, black);
|
||||
--ink-2: color-mix(in oklab, var(--brand) 40%, #5d6073);
|
||||
--ink-3: color-mix(in oklab, var(--brand) 22%, #7f84a3);
|
||||
--ink-2: color-mix(in oklab, var(--brand) 40%, #50536a);
|
||||
/* Hilfstext: mindestens 4,5:1 auch auf Lavendel-Flächen (WCAG AA) */
|
||||
--ink-3: color-mix(in oklab, var(--brand) 25%, #5f6386);
|
||||
--line: color-mix(in oklab, var(--brand) 13%, white);
|
||||
--shadow: 0 1px 2px rgb(20 16 60 / 0.05), 0 8px 24px -12px rgb(20 16 60 / 0.14);
|
||||
--shadow-lg: 0 2px 6px rgb(20 16 60 / 0.06), 0 24px 48px -20px rgb(20 16 60 / 0.3);
|
||||
|
|
@ -35,7 +36,7 @@
|
|||
--surface-2: #242050;
|
||||
--ink: #efedfb;
|
||||
--ink-2: #bdb9dc;
|
||||
--ink-3: #8f8bb8;
|
||||
--ink-3: #a19dc9;
|
||||
--line: #302b63;
|
||||
--shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px -12px rgb(0 0 0 / 0.6);
|
||||
--shadow-lg: 0 2px 6px rgb(0 0 0 / 0.3), 0 24px 48px -20px rgb(0 0 0 / 0.75);
|
||||
|
|
@ -54,7 +55,7 @@
|
|||
--surface-2: #242050;
|
||||
--ink: #efedfb;
|
||||
--ink-2: #bdb9dc;
|
||||
--ink-3: #8f8bb8;
|
||||
--ink-3: #a19dc9;
|
||||
--line: #302b63;
|
||||
--shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px -12px rgb(0 0 0 / 0.6);
|
||||
--shadow-lg: 0 2px 6px rgb(0 0 0 / 0.3), 0 24px 48px -20px rgb(0 0 0 / 0.75);
|
||||
|
|
@ -113,8 +114,9 @@
|
|||
.tone-slate { --tone: #56647a; }
|
||||
|
||||
[class*='tone-'] {
|
||||
--tone-soft: color-mix(in oklab, var(--tone) 12%, var(--surface));
|
||||
--tone-ink: color-mix(in oklab, var(--tone) 85%, var(--ink));
|
||||
--tone-soft: color-mix(in oklab, var(--tone) 10%, var(--surface));
|
||||
/* dunkel genug für 4,5:1 auf der hellen Tönung */
|
||||
--tone-ink: color-mix(in oklab, var(--tone) 68%, #120f2e);
|
||||
}
|
||||
:root[data-theme='dark'] [class*='tone-'] {
|
||||
--tone-soft: color-mix(in oklab, var(--tone) 26%, var(--surface));
|
||||
|
|
@ -284,6 +286,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
/* Satz, der gerade vorgelesen wird */
|
||||
::highlight(vorlesen) {
|
||||
background-color: var(--accent-soft);
|
||||
color: var(--ink);
|
||||
text-decoration: underline 3px var(--accent);
|
||||
text-underline-offset: 4px;
|
||||
}
|
||||
|
||||
@utility safe-bottom {
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,51 +2,179 @@
|
|||
import { untrack } from 'svelte';
|
||||
import X from '@lucide/svelte/icons/x';
|
||||
import Plus from '@lucide/svelte/icons/plus';
|
||||
import Search from '@lucide/svelte/icons/search';
|
||||
import ChevronUp from '@lucide/svelte/icons/chevron-up';
|
||||
import ChevronDown from '@lucide/svelte/icons/chevron-down';
|
||||
import UserPlus from '@lucide/svelte/icons/user-plus';
|
||||
import Check from '@lucide/svelte/icons/check';
|
||||
import { toasts } from './toast.svelte';
|
||||
import type { ContactCard } from '$lib/types';
|
||||
|
||||
type Option = { id: number; name: string; role: string };
|
||||
let { name, options, value = [] }: { name: string; options: Option[]; value?: number[] } = $props();
|
||||
/**
|
||||
* Ansprechpartner auswählen – einmal unter „Ansprechpartner“ angelegt,
|
||||
* überall wiederverwendbar. Neue Personen lassen sich direkt hier anlegen.
|
||||
*/
|
||||
let { name, options, value = [] }: { name: string; options: ContactCard[]; value?: number[] } = $props();
|
||||
|
||||
let all = $state<ContactCard[]>(untrack(() => [...options]));
|
||||
let selected = $state<number[]>(untrack(() => value));
|
||||
let adding = $state('');
|
||||
let open = $state(false);
|
||||
let q = $state('');
|
||||
let creating = $state(false);
|
||||
let draft = $state({ name: '', role: '', email: '', phone: '' });
|
||||
let saving = $state(false);
|
||||
let announce = $state('');
|
||||
|
||||
const byId = $derived(new Map(options.map((o) => [o.id, o])));
|
||||
const available = $derived(options.filter((o) => !selected.includes(o.id)));
|
||||
const uid = $props.id();
|
||||
const byId = $derived(new Map(all.map((o) => [o.id, o])));
|
||||
const filtered = $derived(
|
||||
all.filter((o) => [o.name, o.role, o.location].join(' ').toLowerCase().includes(q.trim().toLowerCase()))
|
||||
);
|
||||
|
||||
function toggle(id: number, on: boolean) {
|
||||
selected = on ? [...selected, id] : selected.filter((x) => x !== id);
|
||||
announce = `${byId.get(id)?.name} ${on ? 'hinzugefügt' : 'entfernt'}`;
|
||||
}
|
||||
|
||||
function move(i: number, d: number) {
|
||||
const next = [...selected];
|
||||
[next[i], next[i + d]] = [next[i + d], next[i]];
|
||||
selected = next;
|
||||
announce = `${byId.get(next[i + d])?.name} auf Position ${i + d + 1} verschoben`;
|
||||
}
|
||||
|
||||
async function create() {
|
||||
if (!draft.name.trim()) return;
|
||||
saving = true;
|
||||
const res = await fetch('/admin/api/ansprechpartner', {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify(draft)
|
||||
});
|
||||
saving = false;
|
||||
if (!res.ok) {
|
||||
toasts.show((await res.json().catch(() => null))?.message ?? 'Anlegen fehlgeschlagen.', 'error');
|
||||
return;
|
||||
}
|
||||
const contact: ContactCard = await res.json();
|
||||
all = [...all, contact].sort((a, b) => a.name.localeCompare(b.name, 'de'));
|
||||
selected = [...selected, contact.id];
|
||||
draft = { name: '', role: '', email: '', phone: '' };
|
||||
creating = false;
|
||||
toasts.show(`${contact.name} angelegt und hinzugefügt`);
|
||||
}
|
||||
|
||||
const initialsOf = (n: string) =>
|
||||
n
|
||||
.split(/\s+/)
|
||||
.map((w) => w[0])
|
||||
.slice(0, 2)
|
||||
.join('');
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<span class="label">Ansprechpartner</span>
|
||||
<fieldset>
|
||||
<legend class="label">Ansprechpartner</legend>
|
||||
<input type="hidden" {name} value={JSON.stringify(selected)} />
|
||||
<p class="sr-only" aria-live="polite">{announce}</p>
|
||||
|
||||
{#if selected.length}
|
||||
<ul class="flex flex-wrap gap-2 mb-2">
|
||||
{#each selected as id (id)}
|
||||
<ol class="space-y-2 mb-3">
|
||||
{#each selected as id, i (id)}
|
||||
{@const c = byId.get(id)}
|
||||
{#if c}
|
||||
<li class="inline-flex items-center gap-2 rounded-full bg-brand-soft text-brand-ink pl-3 pr-1 py-1 text-sm font-semibold">
|
||||
{c.name}
|
||||
<button type="button" class="grid place-items-center size-6 rounded-full hover:bg-white/60" aria-label="{c.name} entfernen" onclick={() => (selected = selected.filter((x) => x !== id))}><X class="size-3.5" /></button>
|
||||
<li class="flex items-center gap-3 rounded-xl border border-line bg-surface px-2.5 py-2">
|
||||
{#if c.photo}
|
||||
<img src={c.photo.thumb} alt="" class="size-9 rounded-full object-cover shrink-0" />
|
||||
{:else}
|
||||
<span class="grid place-items-center size-9 rounded-full bg-surface-2 text-brand-ink text-xs font-bold shrink-0" aria-hidden="true">{initialsOf(c.name)}</span>
|
||||
{/if}
|
||||
<span class="flex-1 min-w-0 leading-tight">
|
||||
<span class="block font-semibold text-sm truncate">{c.name}</span>
|
||||
{#if c.role || c.location}<span class="block text-xs text-ink-3 truncate">{[c.role, c.location].filter(Boolean).join(' · ')}</span>{/if}
|
||||
</span>
|
||||
{#if selected.length > 1}
|
||||
<span class="flex">
|
||||
<button type="button" class="grid place-items-center size-7 rounded-lg text-ink-3 hover:bg-surface-2 disabled:opacity-30" disabled={i === 0} aria-label="{c.name} nach oben" onclick={() => move(i, -1)}><ChevronUp class="size-4" /></button>
|
||||
<button type="button" class="grid place-items-center size-7 rounded-lg text-ink-3 hover:bg-surface-2 disabled:opacity-30" disabled={i === selected.length - 1} aria-label="{c.name} nach unten" onclick={() => move(i, 1)}><ChevronDown class="size-4" /></button>
|
||||
</span>
|
||||
{/if}
|
||||
<button type="button" class="grid place-items-center size-7 rounded-lg text-ink-3 hover:bg-surface-2 hover:text-danger" aria-label="{c.name} entfernen" onclick={() => toggle(id, false)}><X class="size-4" /></button>
|
||||
</li>
|
||||
{/if}
|
||||
{/each}
|
||||
</ul>
|
||||
</ol>
|
||||
{/if}
|
||||
{#if available.length}
|
||||
<div class="flex gap-2">
|
||||
<select bind:value={adding} class="field min-h-10 py-1.5" aria-label="Ansprechpartner hinzufügen">
|
||||
<option value="">Ansprechpartner hinzufügen …</option>
|
||||
{#each available as o (o.id)}<option value={String(o.id)}>{o.name}{o.role ? ` – ${o.role}` : ''}</option>{/each}
|
||||
</select>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-soft btn-sm btn-icon shrink-0 self-center"
|
||||
aria-label="Hinzufügen"
|
||||
disabled={!adding}
|
||||
onclick={() => {
|
||||
selected = [...selected, Number(adding)];
|
||||
adding = '';
|
||||
}}><Plus class="size-4" /></button
|
||||
>
|
||||
|
||||
<button type="button" class="btn btn-soft btn-sm" aria-expanded={open} aria-controls="{uid}-panel" onclick={() => (open = !open)}>
|
||||
<Plus class="size-4" />{open ? 'Auswahl schließen' : 'Ansprechpartner wählen'}
|
||||
</button>
|
||||
|
||||
{#if open}
|
||||
<div id="{uid}-panel" class="mt-3 rounded-2xl border border-line bg-surface-2/50 p-3 space-y-3">
|
||||
{#if all.length > 5}
|
||||
<label class="relative block">
|
||||
<span class="sr-only">Ansprechpartner suchen</span>
|
||||
<Search class="size-4 text-ink-3 absolute left-3 top-1/2 -translate-y-1/2" />
|
||||
<input bind:value={q} type="search" class="field min-h-10 py-1.5 pl-9 text-sm" placeholder="Name, Aufgabe oder Standort" />
|
||||
</label>
|
||||
{/if}
|
||||
|
||||
{#if filtered.length}
|
||||
<ul class="max-h-64 overflow-y-auto space-y-1 pr-1" aria-label="Verfügbare Ansprechpartner">
|
||||
{#each filtered as c (c.id)}
|
||||
{@const on = selected.includes(c.id)}
|
||||
<li>
|
||||
<label class="flex items-center gap-3 rounded-xl px-2 py-1.5 cursor-pointer hover:bg-surface {on ? 'bg-surface' : ''}">
|
||||
<input type="checkbox" class="sr-only peer" checked={on} onchange={(e) => toggle(c.id, e.currentTarget.checked)} />
|
||||
<span class="grid place-items-center size-5 rounded-md border-2 shrink-0 peer-focus-visible:ring-2 peer-focus-visible:ring-accent {on ? 'bg-brand border-brand text-on-brand' : 'border-line bg-surface'}" aria-hidden="true">
|
||||
{#if on}<Check class="size-3.5" strokeWidth={3} />{/if}
|
||||
</span>
|
||||
{#if c.photo}
|
||||
<img src={c.photo.thumb} alt="" class="size-8 rounded-full object-cover shrink-0" />
|
||||
{:else}
|
||||
<span class="grid place-items-center size-8 rounded-full bg-surface text-brand-ink text-[0.7rem] font-bold shrink-0" aria-hidden="true">{initialsOf(c.name)}</span>
|
||||
{/if}
|
||||
<span class="min-w-0 leading-tight">
|
||||
<span class="block text-sm font-semibold truncate">{c.name}</span>
|
||||
{#if c.role}<span class="block text-xs text-ink-3 truncate">{c.role}</span>{/if}
|
||||
</span>
|
||||
</label>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{:else}
|
||||
<p class="text-sm text-ink-3 px-1">{all.length ? 'Niemand gefunden.' : 'Noch keine Ansprechpartner angelegt.'}</p>
|
||||
{/if}
|
||||
|
||||
{#if creating}
|
||||
<div class="rounded-xl bg-surface border border-line p-3 space-y-3" role="group" aria-label="Neue Person anlegen">
|
||||
<div class="grid sm:grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="label" for="{uid}-name">Name</label>
|
||||
<input id="{uid}-name" bind:value={draft.name} class="field min-h-10 py-1.5 text-sm" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label" for="{uid}-role">Aufgabe / Funktion</label>
|
||||
<input id="{uid}-role" bind:value={draft.role} class="field min-h-10 py-1.5 text-sm" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label" for="{uid}-email">E-Mail</label>
|
||||
<input id="{uid}-email" type="email" bind:value={draft.email} class="field min-h-10 py-1.5 text-sm" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label" for="{uid}-phone">Telefon</label>
|
||||
<input id="{uid}-phone" type="tel" bind:value={draft.phone} class="field min-h-10 py-1.5 text-sm" />
|
||||
</div>
|
||||
</div>
|
||||
<p class="hint !mt-0">Foto und Standort kannst du später unter „Ansprechpartner“ ergänzen.</p>
|
||||
<div class="flex gap-2">
|
||||
<button type="button" class="btn btn-primary btn-sm" disabled={!draft.name.trim() || saving} onclick={create}>Anlegen & hinzufügen</button>
|
||||
<button type="button" class="btn btn-ghost btn-sm" onclick={() => (creating = false)}>Abbrechen</button>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<button type="button" class="btn btn-ghost btn-sm" onclick={() => (creating = true)}><UserPlus class="size-4" />Neue Person anlegen</button>
|
||||
{/if}
|
||||
</div>
|
||||
{:else if !options.length}
|
||||
<p class="hint">Lege zuerst unter „Ansprechpartner“ Personen an.</p>
|
||||
{/if}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
>
|
||||
<div class="grid xl:grid-cols-[1fr_20rem] gap-6 items-start">
|
||||
<div class="space-y-6 min-w-0">{@render children()}</div>
|
||||
{#if aside}<aside class="space-y-6 xl:sticky xl:top-6">{@render aside()}</aside>{/if}
|
||||
{#if aside}<aside aria-label="Weitere Angaben" class="space-y-6 xl:sticky xl:top-6">{@render aside()}</aside>{/if}
|
||||
</div>
|
||||
|
||||
<div class="sticky bottom-0 -mx-4 sm:-mx-8 mt-8 px-4 sm:px-8 py-3 bg-bg/85 backdrop-blur border-t border-line flex items-center gap-2 z-20">
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@
|
|||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
<button type="button" onclick={() => (open = true)} class="aspect-square rounded-xl border-2 border-dashed border-line hover:border-brand text-ink-3 hover:text-brand-ink grid place-items-center">
|
||||
<Plus class="size-7" />
|
||||
<button type="button" aria-label="Bilder zur Galerie hinzufügen" onclick={() => (open = true)} class="aspect-square rounded-xl border-2 border-dashed border-line hover:border-brand text-ink-3 hover:text-brand-ink grid place-items-center">
|
||||
<Plus class="size-7" aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
<button type="button" class="text-sm font-bold text-brand-ink mt-2" onclick={() => (showAll = !showAll)}>
|
||||
<button type="button" class="text-sm font-bold text-brand-ink mt-2 min-h-8 px-1 -mx-1 rounded-lg hover:bg-surface-2" onclick={() => (showAll = !showAll)}>
|
||||
{showAll ? 'Weniger anzeigen' : 'Alle Symbole anzeigen'}
|
||||
</button>
|
||||
</fieldset>
|
||||
|
|
|
|||
|
|
@ -47,7 +47,14 @@
|
|||
],
|
||||
content: value,
|
||||
editorProps: {
|
||||
attributes: { class: 'rich focus:outline-none px-4 py-3', style: `min-height:${minHeight}` }
|
||||
attributes: {
|
||||
class: 'rich focus:outline-none px-4 py-3',
|
||||
style: `min-height:${minHeight}`,
|
||||
role: 'textbox',
|
||||
'aria-multiline': 'true',
|
||||
'aria-label': label,
|
||||
...(hint ? { 'aria-description': hint } : {})
|
||||
}
|
||||
},
|
||||
onTransaction: () => tick++,
|
||||
onUpdate: ({ editor }) => {
|
||||
|
|
|
|||
|
|
@ -36,11 +36,11 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<div class="flex gap-4 overflow-x-auto pb-4 -mx-4 px-4 sm:mx-0 sm:px-0 snap-x">
|
||||
<div class="flex gap-4 overflow-x-auto pb-4 -mx-4 px-4 sm:mx-0 sm:px-0 snap-x 2xl:grid 2xl:grid-cols-5 2xl:overflow-visible">
|
||||
{#each columns as col (col.status)}
|
||||
<section
|
||||
aria-labelledby="col-{col.status}"
|
||||
class="tone-{STATUS_TONE[col.status]} snap-start shrink-0 w-72 rounded-2xl bg-surface-2 p-3 transition-colors {dropTarget === col.status ? 'outline-2 outline-dashed outline-tone bg-tone-soft' : ''}"
|
||||
class="tone-{STATUS_TONE[col.status]} snap-start shrink-0 w-72 2xl:w-auto rounded-2xl bg-surface-2 p-3 transition-colors {dropTarget === col.status ? 'outline-2 outline-dashed outline-tone bg-tone-soft' : ''}"
|
||||
ondragover={(e) => {
|
||||
if (!e.dataTransfer?.types.includes('application/x-redaktion')) return;
|
||||
e.preventDefault();
|
||||
|
|
|
|||
|
|
@ -51,10 +51,10 @@
|
|||
ondragstart={dragstart}
|
||||
onclick={() => onopen(entry)}
|
||||
aria-label={label}
|
||||
class="tone-{STATUS_TONE[entry.status]} group w-full text-left rounded-lg bg-surface border border-line border-l-4 border-l-tone px-2 py-1.5 hover:border-brand/40 hover:shadow-card transition cursor-grab active:cursor-grabbing {entry.status === 'done' ? 'opacity-60' : ''}"
|
||||
class="tone-{STATUS_TONE[entry.status]} group w-full text-left rounded-lg bg-surface border border-line border-l-4 border-l-tone px-2 py-1.5 hover:border-brand/40 hover:shadow-card transition cursor-grab active:cursor-grabbing {entry.status === 'done' ? 'bg-surface-2' : ''}"
|
||||
>
|
||||
<span class="flex items-start gap-1.5">
|
||||
<span class="flex-1 min-w-0 text-[0.8rem] font-semibold leading-snug {compact ? 'line-clamp-2' : ''} {entry.status === 'done' ? 'line-through' : ''}">{entry.title}</span>
|
||||
<span class="flex-1 min-w-0 text-[0.8rem] font-semibold leading-snug {compact ? 'line-clamp-2' : ''} {entry.status === 'done' ? 'line-through text-ink-2' : ''}">{entry.title}</span>
|
||||
{#if assignee}
|
||||
<span class="grid place-items-center size-5 rounded-full bg-brand text-on-brand text-[0.6rem] font-bold shrink-0" aria-hidden="true" title={assignee.name}>{assignee.initials}</span>
|
||||
{/if}
|
||||
|
|
|
|||
|
|
@ -1,43 +1,21 @@
|
|||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import Volume2 from '@lucide/svelte/icons/volume-2';
|
||||
import Square from '@lucide/svelte/icons/square';
|
||||
import Bookmark from '@lucide/svelte/icons/bookmark';
|
||||
import BookmarkCheck from '@lucide/svelte/icons/bookmark-check';
|
||||
import Share2 from '@lucide/svelte/icons/share-2';
|
||||
import { favorites } from '$lib/favorites.svelte';
|
||||
import { speech } from '$lib/speech.svelte';
|
||||
import type { Favorite } from '$lib/types';
|
||||
|
||||
let { target, favorite }: { target: string; favorite?: Favorite } = $props();
|
||||
|
||||
let canSpeak = $state(false);
|
||||
let speaking = $state(false);
|
||||
let shared = $state(false);
|
||||
const reading = $derived(speech.active);
|
||||
|
||||
onMount(() => (canSpeak = 'speechSynthesis' in window));
|
||||
onDestroy(() => speaking && speechSynthesis.cancel());
|
||||
|
||||
/** Liest den Inhalt des Elements #target vor – satzweise, damit lange Texte nicht abbrechen. */
|
||||
function toggleSpeak() {
|
||||
if (speaking) {
|
||||
speechSynthesis.cancel();
|
||||
speaking = false;
|
||||
return;
|
||||
}
|
||||
const el = document.getElementById(target);
|
||||
if (!el) return;
|
||||
const sentences = (el.innerText.match(/[^.!?\n]+[.!?]*/g) ?? []).map((s) => s.trim()).filter(Boolean);
|
||||
const voice = speechSynthesis.getVoices().find((v) => v.lang.startsWith('de'));
|
||||
speechSynthesis.cancel();
|
||||
sentences.forEach((s, i) => {
|
||||
const u = new SpeechSynthesisUtterance(s);
|
||||
u.lang = 'de-DE';
|
||||
u.rate = 0.95;
|
||||
if (voice) u.voice = voice;
|
||||
if (i === sentences.length - 1) u.onend = () => (speaking = false);
|
||||
speechSynthesis.speak(u);
|
||||
});
|
||||
speaking = sentences.length > 0;
|
||||
if (speech.active) speech.stop();
|
||||
else speech.start(target, 'Text');
|
||||
}
|
||||
|
||||
async function share() {
|
||||
|
|
@ -59,9 +37,9 @@
|
|||
</script>
|
||||
|
||||
<div class="flex flex-wrap gap-2">
|
||||
{#if canSpeak}
|
||||
<button type="button" class="btn btn-sm {speaking ? 'btn-primary' : 'btn-soft'}" onclick={toggleSpeak} aria-pressed={speaking}>
|
||||
{#if speaking}<Square class="size-4" /> Stopp{:else}<Volume2 class="size-4" /> Vorlesen{/if}
|
||||
{#if speech.supported}
|
||||
<button type="button" class="btn btn-sm {reading ? 'btn-primary' : 'btn-soft'}" onclick={toggleSpeak} aria-pressed={reading}>
|
||||
{#if reading}<Square class="size-4" /> Stopp{:else}<Volume2 class="size-4" /> Vorlesen{/if}
|
||||
</button>
|
||||
{/if}
|
||||
{#if favorite}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
{:else}
|
||||
<!-- Platzhalter, bis in den Einstellungen ein Titelbild gewählt ist -->
|
||||
<div class="absolute inset-0 bg-[linear-gradient(135deg,var(--brand)_0%,color-mix(in_oklab,var(--brand)_60%,var(--accent))_100%)]">
|
||||
<p class="absolute left-5 top-5 lg:left-8 lg:top-7 inline-flex items-center gap-2 rounded-full bg-white/10 px-3 py-1.5 text-xs font-semibold text-white/75">
|
||||
<p data-nicht-vorlesen class="absolute left-5 top-5 lg:left-8 lg:top-7 inline-flex items-center gap-2 rounded-full bg-white/10 px-3 py-1.5 text-xs font-semibold text-white/75">
|
||||
<ImageIcon class="size-4" /> Platzhalter für das Titelbild
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
import { relative } from '$lib/dates';
|
||||
import type { PostCard } from '$lib/types';
|
||||
|
||||
let { post, variant = 'card' }: { post: PostCard; variant?: 'card' | 'row' } = $props();
|
||||
/** level: Überschriften-Ebene passend zur Seite (h2 in Listen direkt unter dem h1, sonst h3) */
|
||||
let { post, variant = 'card', level = 3 }: { post: PostCard; variant?: 'card' | 'row'; level?: 2 | 3 } = $props();
|
||||
</script>
|
||||
|
||||
{#if variant === 'card'}
|
||||
|
|
@ -25,7 +26,7 @@
|
|||
{#if post.pinned}<Pin class="size-3.5" aria-label="Angeheftet" />{/if}
|
||||
{relative(post.publishedAt)}
|
||||
</p>
|
||||
<h3 class="text-xl text-brand-ink mt-1.5 group-hover:underline decoration-2 underline-offset-4 decoration-accent">{post.title}</h3>
|
||||
<svelte:element this={`h${level}`} class="text-xl font-bold text-brand-ink mt-1.5 group-hover:underline decoration-2 underline-offset-4 decoration-accent">{post.title}</svelte:element>
|
||||
{#if post.teaser}<p class="text-ink-2 mt-2 line-clamp-3">{post.teaser}</p>{/if}
|
||||
</a>
|
||||
{:else}
|
||||
|
|
@ -39,7 +40,7 @@
|
|||
</div>
|
||||
<div class="min-w-0">
|
||||
<p class="eyebrow !text-accent-ink !text-[0.7rem]">{relative(post.publishedAt)}</p>
|
||||
<h3 class="text-[1.05rem] text-brand-ink leading-snug mt-1 line-clamp-2 group-hover:underline decoration-accent underline-offset-4">{post.title}</h3>
|
||||
<svelte:element this={`h${level}`} class="text-[1.05rem] font-bold text-brand-ink leading-snug mt-1 line-clamp-2 group-hover:underline decoration-accent underline-offset-4">{post.title}</svelte:element>
|
||||
{#if post.teaser}<p class="text-sm text-ink-2 mt-1 line-clamp-2">{post.teaser}</p>{/if}
|
||||
</div>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
import BookHeart from '@lucide/svelte/icons/book-heart';
|
||||
import { prefs } from '$lib/prefs.svelte';
|
||||
|
||||
let { compact = false }: { compact?: boolean } = $props();
|
||||
let { compact = false, easy = true }: { compact?: boolean; easy?: boolean } = $props();
|
||||
|
||||
const themes = [
|
||||
{ value: 'light', label: 'Hell', icon: Sun },
|
||||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
<div class="space-y-5">
|
||||
<!-- Leichte Sprache -->
|
||||
{#if easy}
|
||||
<label class="flex items-center gap-3 cursor-pointer">
|
||||
<span class="grid place-items-center size-10 rounded-xl bg-brand-soft text-brand-ink shrink-0">
|
||||
<BookHeart class="size-5" />
|
||||
|
|
@ -40,6 +41,7 @@
|
|||
onchange={(e) => prefs.set({ easy: e.currentTarget.checked })}
|
||||
/>
|
||||
</label>
|
||||
{/if}
|
||||
|
||||
<fieldset>
|
||||
<legend class="font-semibold mb-2">Schriftgröße</legend>
|
||||
|
|
|
|||
54
src/lib/components/ReadAloudBar.svelte
Normal file
54
src/lib/components/ReadAloudBar.svelte
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { afterNavigate } from '$app/navigation';
|
||||
import Pause from '@lucide/svelte/icons/pause';
|
||||
import Play from '@lucide/svelte/icons/play';
|
||||
import Square from '@lucide/svelte/icons/square';
|
||||
import SkipBack from '@lucide/svelte/icons/skip-back';
|
||||
import SkipForward from '@lucide/svelte/icons/skip-forward';
|
||||
import Snail from '@lucide/svelte/icons/snail';
|
||||
import { speech } from '$lib/speech.svelte';
|
||||
|
||||
onMount(() => {
|
||||
speech.init();
|
||||
return () => speech.stop();
|
||||
});
|
||||
// Beim Seitenwechsel aufhören
|
||||
afterNavigate(({ from }) => from && speech.stop());
|
||||
</script>
|
||||
|
||||
{#if speech.active}
|
||||
<div
|
||||
role="region"
|
||||
aria-label="Vorlesen"
|
||||
class="fixed inset-x-3 bottom-[5.5rem] lg:bottom-6 z-40 mx-auto max-w-md rounded-full bg-brand text-on-brand shadow-float pl-5 pr-2 py-2 flex items-center gap-1"
|
||||
data-nicht-vorlesen
|
||||
>
|
||||
<p class="flex-1 min-w-0 text-sm font-semibold leading-tight" aria-live="polite">
|
||||
<span class="block truncate">{speech.paused ? 'Pausiert' : 'Liest vor …'}</span>
|
||||
<span class="block text-xs font-medium opacity-80">Satz {speech.index + 1} von {speech.total}</span>
|
||||
</p>
|
||||
<button type="button" class="grid place-items-center size-10 rounded-full hover:bg-white/15" aria-label="Vorheriger Satz" onclick={() => speech.step(-1)}>
|
||||
<SkipBack class="size-5" />
|
||||
</button>
|
||||
<button type="button" class="grid place-items-center size-11 rounded-full bg-white text-brand hover:bg-white/90" aria-label={speech.paused ? 'Weiter vorlesen' : 'Pause'} onclick={() => speech.togglePause()}>
|
||||
{#if speech.paused}<Play class="size-5 ml-0.5" />{:else}<Pause class="size-5" />{/if}
|
||||
</button>
|
||||
<button type="button" class="grid place-items-center size-10 rounded-full hover:bg-white/15" aria-label="Nächster Satz" onclick={() => speech.step(1)}>
|
||||
<SkipForward class="size-5" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="grid place-items-center size-10 rounded-full transition {speech.slow ? 'bg-white/25' : 'hover:bg-white/15'}"
|
||||
aria-label="Langsam vorlesen"
|
||||
aria-pressed={speech.slow}
|
||||
title="Langsamer"
|
||||
onclick={() => speech.toggleRate()}
|
||||
>
|
||||
<Snail class="size-5" />
|
||||
</button>
|
||||
<button type="button" class="grid place-items-center size-10 rounded-full hover:bg-white/15" aria-label="Vorlesen beenden" onclick={() => speech.stop()}>
|
||||
<Square class="size-4" fill="currentColor" />
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
|
|
@ -50,6 +50,12 @@ export function contactsByIds(ids: number[]): ContactCard[] {
|
|||
}));
|
||||
}
|
||||
|
||||
/** Alle Ansprechpartner für Auswahlfelder in der Redaktion (inkl. nicht gelisteter) */
|
||||
export function contactOptions() {
|
||||
const rows = db.select({ id: contacts.id }).from(contacts).orderBy(asc(contacts.name)).all();
|
||||
return contactsByIds(rows.map((r) => r.id));
|
||||
}
|
||||
|
||||
export function listedContacts(): ContactCard[] {
|
||||
const rows = db
|
||||
.select({ id: contacts.id })
|
||||
|
|
|
|||
189
src/lib/speech.svelte.ts
Normal file
189
src/lib/speech.svelte.ts
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
/**
|
||||
* Vorlesen mit der Sprachausgabe des Geräts (Web Speech API).
|
||||
* Liest einen Bereich satzweise vor und markiert den aktuellen Satz
|
||||
* (CSS Custom Highlight API), damit man mitlesen kann.
|
||||
*/
|
||||
|
||||
type Sentence = { text: string; range: Range | null };
|
||||
|
||||
const RATE_KEY = 'wa_speech_rate';
|
||||
const HIGHLIGHT = 'vorlesen';
|
||||
|
||||
/** Text-Knoten, die vorgelesen werden (ohne versteckte Elemente und Bedienelemente) */
|
||||
function textNodes(root: Element): Text[] {
|
||||
const skip = 'script, style, noscript, button, nav, [aria-hidden="true"], [hidden], .sr-only, [data-nicht-vorlesen]';
|
||||
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {
|
||||
acceptNode: (n) => {
|
||||
const el = n.parentElement;
|
||||
if (!el || el.closest(skip) || !n.textContent?.trim()) return NodeFilter.FILTER_REJECT;
|
||||
const style = getComputedStyle(el);
|
||||
return style.display === 'none' || style.visibility === 'hidden' ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT;
|
||||
}
|
||||
});
|
||||
const nodes: Text[] = [];
|
||||
while (walker.nextNode()) nodes.push(walker.currentNode as Text);
|
||||
return nodes;
|
||||
}
|
||||
|
||||
/** Zerlegt den Bereich in Sätze inkl. Textbereich (Range) für die Markierung */
|
||||
function sentencesOf(root: Element): Sentence[] {
|
||||
const nodes = textNodes(root);
|
||||
// Alles, was auf dem Bildschirm als eigener Block erscheint, endet mit einer Satzgrenze
|
||||
const blockOf = (n: Text) => {
|
||||
for (let el = n.parentElement; el && el !== root; el = el.parentElement) {
|
||||
if (!getComputedStyle(el).display.startsWith('inline')) return el;
|
||||
}
|
||||
return root;
|
||||
};
|
||||
let full = '';
|
||||
const map: { node: Text; start: number }[] = [];
|
||||
let prevBlock: Element | null = null;
|
||||
for (const node of nodes) {
|
||||
const block = blockOf(node);
|
||||
if (prevBlock && block !== prevBlock) full += '\n';
|
||||
prevBlock = block;
|
||||
map.push({ node, start: full.length });
|
||||
full += node.textContent;
|
||||
}
|
||||
|
||||
const locate = (pos: number) => {
|
||||
let i = map.length - 1;
|
||||
while (i > 0 && map[i].start > pos) i--;
|
||||
const { node, start } = map[i];
|
||||
return { node, offset: Math.min(Math.max(pos - start, 0), node.length) };
|
||||
};
|
||||
|
||||
const out: Sentence[] = [];
|
||||
const re = /[^.!?\n]+(?:[.!?]+["“”»)]*|\n|$)/g;
|
||||
let m: RegExpExecArray | null;
|
||||
while ((m = re.exec(full))) {
|
||||
const raw = m[0];
|
||||
const text = raw.replace(/\s+/g, ' ').trim();
|
||||
if (!text) {
|
||||
if (m.index === re.lastIndex) re.lastIndex++;
|
||||
continue;
|
||||
}
|
||||
const lead = raw.length - raw.trimStart().length;
|
||||
const s = m.index + lead;
|
||||
const e = m.index + raw.trimEnd().length;
|
||||
let range: Range | null = null;
|
||||
try {
|
||||
const a = locate(s);
|
||||
const b = locate(e);
|
||||
range = document.createRange();
|
||||
range.setStart(a.node, a.offset);
|
||||
range.setEnd(b.node, b.offset);
|
||||
} catch {
|
||||
range = null;
|
||||
}
|
||||
out.push({ text, range });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
class Speech {
|
||||
supported = $state(false);
|
||||
active = $state(false);
|
||||
paused = $state(false);
|
||||
index = $state(0);
|
||||
total = $state(0);
|
||||
slow = $state(false);
|
||||
label = $state('');
|
||||
#sentences: Sentence[] = [];
|
||||
#run = 0;
|
||||
|
||||
init() {
|
||||
this.supported = typeof window !== 'undefined' && 'speechSynthesis' in window;
|
||||
try {
|
||||
this.slow = localStorage.getItem(RATE_KEY) === 'slow';
|
||||
} catch {
|
||||
/* ohne Speicher */
|
||||
}
|
||||
}
|
||||
|
||||
/** Liest das Element mit der ID `targetId` vor (Standard: Hauptinhalt) */
|
||||
start(targetId = 'inhalt', label = 'Seite') {
|
||||
const root = document.getElementById(targetId);
|
||||
if (!root || !this.supported) return;
|
||||
this.stop();
|
||||
this.#sentences = sentencesOf(root);
|
||||
if (!this.#sentences.length) return;
|
||||
this.label = label;
|
||||
this.total = this.#sentences.length;
|
||||
this.active = true;
|
||||
this.paused = false;
|
||||
this.#speakFrom(0);
|
||||
}
|
||||
|
||||
#speakFrom(i: number) {
|
||||
const run = ++this.#run;
|
||||
speechSynthesis.cancel();
|
||||
const voice = speechSynthesis.getVoices().find((v) => v.lang.startsWith('de'));
|
||||
for (let k = i; k < this.#sentences.length; k++) {
|
||||
const u = new SpeechSynthesisUtterance(this.#sentences[k].text);
|
||||
u.lang = 'de-DE';
|
||||
u.rate = this.slow ? 0.75 : 0.95;
|
||||
if (voice) u.voice = voice;
|
||||
u.onstart = () => {
|
||||
if (run !== this.#run) return;
|
||||
this.index = k;
|
||||
this.#highlight(k);
|
||||
};
|
||||
if (k === this.#sentences.length - 1) u.onend = () => run === this.#run && this.stop();
|
||||
speechSynthesis.speak(u);
|
||||
}
|
||||
}
|
||||
|
||||
#highlight(k: number) {
|
||||
const range = this.#sentences[k]?.range;
|
||||
if (!range) return;
|
||||
if ('highlights' in CSS) CSS.highlights.set(HIGHLIGHT, new Highlight(range));
|
||||
const r = range.getBoundingClientRect();
|
||||
const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
if (r.top < 90 || r.bottom > innerHeight - 140)
|
||||
scrollBy({ top: r.top - innerHeight / 3, behavior: reduce ? 'auto' : 'smooth' });
|
||||
}
|
||||
|
||||
togglePause() {
|
||||
if (!this.active) return;
|
||||
if (this.paused) {
|
||||
// Neu ab aktuellem Satz – zuverlässiger als resume() auf allen Geräten
|
||||
this.paused = false;
|
||||
this.#speakFrom(this.index);
|
||||
} else {
|
||||
this.paused = true;
|
||||
this.#run++;
|
||||
speechSynthesis.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
step(delta: number) {
|
||||
if (!this.active) return;
|
||||
const next = Math.min(Math.max(this.index + delta, 0), this.total - 1);
|
||||
this.index = next;
|
||||
this.#highlight(next);
|
||||
if (!this.paused) this.#speakFrom(next);
|
||||
}
|
||||
|
||||
toggleRate() {
|
||||
this.slow = !this.slow;
|
||||
try {
|
||||
localStorage.setItem(RATE_KEY, this.slow ? 'slow' : 'normal');
|
||||
} catch {
|
||||
/* ohne Speicher */
|
||||
}
|
||||
if (this.active && !this.paused) this.#speakFrom(this.index);
|
||||
}
|
||||
|
||||
stop() {
|
||||
this.#run++;
|
||||
if (this.supported) speechSynthesis.cancel();
|
||||
if (typeof CSS !== 'undefined' && 'highlights' in CSS) CSS.highlights.delete(HIGHLIGHT);
|
||||
this.active = false;
|
||||
this.paused = false;
|
||||
this.index = 0;
|
||||
this.total = 0;
|
||||
}
|
||||
}
|
||||
|
||||
export const speech = new Speech();
|
||||
|
|
@ -3,6 +3,8 @@
|
|||
import CircleHelp from '@lucide/svelte/icons/circle-help';
|
||||
</script>
|
||||
|
||||
<svelte:head><title>{page.status === 404 ? 'Nicht gefunden' : 'Fehler'}</title></svelte:head>
|
||||
|
||||
<div class="max-w-md mx-auto text-center py-16 flex flex-col items-center gap-4">
|
||||
<div class="grid place-items-center size-20 rounded-3xl bg-brand-soft text-brand"><CircleHelp class="size-10" /></div>
|
||||
<h1 class="text-3xl sm:text-4xl text-brand-ink">{page.status === 404 ? 'Nicht gefunden' : 'Hoppla!'}</h1>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
import Bookmark from '@lucide/svelte/icons/bookmark';
|
||||
import Menu from '@lucide/svelte/icons/menu';
|
||||
import Search from '@lucide/svelte/icons/search';
|
||||
import Volume2 from '@lucide/svelte/icons/volume-2';
|
||||
import ReadAloudBar from '$lib/components/ReadAloudBar.svelte';
|
||||
import { speech } from '$lib/speech.svelte';
|
||||
import MenuSheet from '$lib/components/MenuSheet.svelte';
|
||||
import { favorites } from '$lib/favorites.svelte';
|
||||
|
||||
|
|
@ -67,6 +70,17 @@
|
|||
{/each}
|
||||
</nav>
|
||||
|
||||
{#if speech.supported}
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-icon {speech.active ? 'btn-primary' : 'btn-ghost text-brand-ink'}"
|
||||
aria-label={speech.active ? 'Vorlesen beenden' : 'Seite vorlesen'}
|
||||
aria-pressed={speech.active}
|
||||
onclick={() => (speech.active ? speech.stop() : speech.start('inhalt'))}
|
||||
>
|
||||
<Volume2 class="size-6" strokeWidth={2.25} />
|
||||
</button>
|
||||
{/if}
|
||||
<a href="/suche" class="btn btn-ghost btn-icon text-brand-ink" aria-label="Suche">
|
||||
<Search class="size-6" strokeWidth={2.25} />
|
||||
</a>
|
||||
|
|
@ -120,4 +134,6 @@
|
|||
</div>
|
||||
</nav>
|
||||
|
||||
<ReadAloudBar />
|
||||
|
||||
<MenuSheet bind:open={menuOpen} pages={data.menuPages} website={data.website} />
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
{#if data.items.length}
|
||||
<div class="grid md:grid-cols-2 lg:grid-cols-3 gap-x-6 gap-y-10">
|
||||
{#each data.items as p (p.id)}
|
||||
<PostCard post={p} />
|
||||
<PostCard post={p} level={2} />
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
|
|
|
|||
13
src/routes/+error.svelte
Normal file
13
src/routes/+error.svelte
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<script lang="ts">
|
||||
import { page } from '$app/state';
|
||||
</script>
|
||||
|
||||
<svelte:head><title>{page.status === 404 ? 'Nicht gefunden' : 'Fehler'}</title></svelte:head>
|
||||
|
||||
<main class="min-h-dvh grid place-items-center p-6 bg-bg">
|
||||
<div class="max-w-md text-center space-y-4">
|
||||
<h1 class="text-3xl font-bold text-brand-ink">{page.status === 404 ? 'Nicht gefunden' : 'Da ist etwas schiefgelaufen'}</h1>
|
||||
<p class="text-ink-2">{page.error?.message ?? 'Bitte versuche es noch einmal.'}</p>
|
||||
<a href="/" class="btn btn-primary">Zur Startseite</a>
|
||||
</div>
|
||||
</main>
|
||||
13
src/routes/admin/(panel)/+error.svelte
Normal file
13
src/routes/admin/(panel)/+error.svelte
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<script lang="ts">
|
||||
import { page } from '$app/state';
|
||||
import CircleAlert from '@lucide/svelte/icons/circle-alert';
|
||||
</script>
|
||||
|
||||
<svelte:head><title>{page.status === 404 ? 'Nicht gefunden' : 'Fehler'} · Redaktion</title></svelte:head>
|
||||
|
||||
<div class="max-w-md py-16 flex flex-col items-start gap-4">
|
||||
<span class="grid place-items-center size-14 rounded-full bg-surface-2 text-brand-ink"><CircleAlert class="size-7" /></span>
|
||||
<h1 class="text-2xl font-bold">{page.status === 404 ? 'Nicht gefunden' : 'Da ist etwas schiefgelaufen'}</h1>
|
||||
<p class="text-ink-2">{page.error?.message ?? 'Bitte versuche es noch einmal.'}</p>
|
||||
<a href="/admin" class="btn btn-primary">Zur Übersicht</a>
|
||||
</div>
|
||||
|
|
@ -65,6 +65,8 @@
|
|||
|
||||
<svelte:head><title>Redaktion · {data.brand.appName}</title></svelte:head>
|
||||
|
||||
<a href="#inhalt" class="sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-[60] btn btn-primary">Zum Inhalt springen</a>
|
||||
|
||||
<div class="min-h-dvh lg:grid lg:grid-cols-[16rem_1fr]">
|
||||
<!-- Mobile Kopfzeile -->
|
||||
<header class="lg:hidden sticky top-0 z-30 flex items-center gap-3 h-14 px-3 bg-surface border-b border-line">
|
||||
|
|
@ -77,6 +79,7 @@
|
|||
{/if}
|
||||
|
||||
<aside
|
||||
aria-label="Seitenleiste"
|
||||
class="fixed lg:sticky top-0 z-50 h-dvh w-64 flex flex-col bg-surface border-r border-line transition-transform lg:translate-x-0 {navOpen ? 'translate-x-0' : '-translate-x-full'}"
|
||||
>
|
||||
<div class="flex items-center gap-3 px-4 h-16 border-b border-line">
|
||||
|
|
@ -134,7 +137,11 @@
|
|||
</div>
|
||||
</aside>
|
||||
|
||||
<main class="min-w-0 px-4 sm:px-8 py-6 sm:py-8 max-w-6xl w-full">
|
||||
<main
|
||||
id="inhalt"
|
||||
tabindex="-1"
|
||||
class="min-w-0 px-4 sm:px-8 py-6 sm:py-8 w-full focus:outline-none {page.url.pathname.startsWith('/admin/redaktion') ? 'max-w-[110rem]' : 'max-w-6xl'}"
|
||||
>
|
||||
{@render children()}
|
||||
</main>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -7,13 +7,22 @@ import { fields, parseId } from '$lib/server/forms';
|
|||
import { nextSortOrder } from '$lib/server/sorting';
|
||||
import type { MediaItem } from '$lib/types';
|
||||
|
||||
/** Wo wird diese Person angezeigt? */
|
||||
function usage(id: number) {
|
||||
const hit = (ids: number[]) => ids.includes(id);
|
||||
return [
|
||||
...db.select({ id: pages.id, title: pages.title, contactIds: pages.contactIds }).from(pages).all().filter((p) => hit(p.contactIds)).map((p) => ({ href: `/admin/seiten/${p.id}`, title: p.title, kind: 'Seite' })),
|
||||
...db.select({ id: posts.id, title: posts.title, contactIds: posts.contactIds }).from(posts).all().filter((p) => hit(p.contactIds)).map((p) => ({ href: `/admin/meldungen/${p.id}`, title: p.title, kind: 'Meldung' }))
|
||||
];
|
||||
}
|
||||
|
||||
export const load = ({ params }) => {
|
||||
const id = parseId(params.id);
|
||||
if (id === 'new')
|
||||
return { isNew: true, contact: { id: 0, name: '', role: '', location: '', email: '', phone: '', listed: true, photo: null as MediaItem | null } };
|
||||
return { isNew: true, usage: [] as ReturnType<typeof usage>, contact: { id: 0, name: '', role: '', location: '', email: '', phone: '', listed: true, photo: null as MediaItem | null } };
|
||||
const c = db.select().from(contacts).where(eq(contacts.id, id)).get();
|
||||
if (!c) error(404);
|
||||
return { isNew: false, contact: { ...c, photo: getMedia(c.photoId) } };
|
||||
return { isNew: false, usage: usage(c.id), contact: { ...c, photo: getMedia(c.photoId) } };
|
||||
};
|
||||
|
||||
export const actions = {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,24 @@
|
|||
<ImageField name="photoId" value={c.photo} label="Foto" aspect="aspect-square" />
|
||||
<Switch name="listed" checked={c.listed} label="Im Verzeichnis zeigen" hint="Unter „Ansprechpartner“ in der App" />
|
||||
</Panel>
|
||||
{#if !data.isNew}
|
||||
<Panel title="Verwendet in" description="Hier erscheint die Person. Änderungen gelten überall.">
|
||||
{#if data.usage.length}
|
||||
<ul class="space-y-1.5 -mt-2">
|
||||
{#each data.usage as u (u.href)}
|
||||
<li>
|
||||
<a href={u.href} class="flex items-baseline gap-2 text-sm hover:text-brand-ink">
|
||||
<span class="text-xs font-bold uppercase tracking-wider text-ink-3 w-16 shrink-0">{u.kind}</span>
|
||||
<span class="font-semibold">{u.title}</span>
|
||||
</a>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{:else}
|
||||
<p class="text-sm text-ink-3 -mt-2">Noch bei keiner Seite oder Meldung eingetragen.</p>
|
||||
{/if}
|
||||
</Panel>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</EditForm>
|
||||
{/key}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,19 @@
|
|||
import PageHeader from '$lib/admin/PageHeader.svelte';
|
||||
import EditForm from '$lib/admin/EditForm.svelte';
|
||||
import Panel from '$lib/admin/Panel.svelte';
|
||||
import PrefsControls from '$lib/components/PrefsControls.svelte';
|
||||
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<PageHeader title="Mein Konto" description={data.user.email} />
|
||||
|
||||
<section class="card p-5 sm:p-6 mb-6 max-w-2xl" aria-labelledby="anzeige">
|
||||
<h2 id="anzeige" class="text-lg font-bold">Anzeige</h2>
|
||||
<p class="text-sm text-ink-3 mb-5">Gilt für dieses Gerät – in der Redaktion und in der App. Wird sofort übernommen.</p>
|
||||
<PrefsControls easy={false} />
|
||||
</section>
|
||||
|
||||
<EditForm>
|
||||
<Panel>
|
||||
<div class="max-w-md">
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { error, fail, redirect } from '@sveltejs/kit';
|
||||
import { asc, eq } from 'drizzle-orm';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { db } from '$lib/server/db';
|
||||
import { contacts, posts } from '$lib/server/db/schema';
|
||||
import { attachmentsOf, getMedia, mediaByIds } from '$lib/server/content';
|
||||
import { posts } from '$lib/server/db/schema';
|
||||
import { attachmentsOf, contactOptions as listContactOptions, getMedia, mediaByIds } from '$lib/server/content';
|
||||
import { fields, parseId, uniqueSlug } from '$lib/server/forms';
|
||||
import { cleanHtml } from '$lib/server/sanitize';
|
||||
import { fromLocalInput, toLocalInput } from '$lib/dates';
|
||||
|
|
@ -10,11 +10,7 @@ import type { MediaItem } from '$lib/types';
|
|||
|
||||
export const load = ({ params }) => {
|
||||
const id = parseId(params.id);
|
||||
const contactOptions = db
|
||||
.select({ id: contacts.id, name: contacts.name, role: contacts.role })
|
||||
.from(contacts)
|
||||
.orderBy(asc(contacts.name))
|
||||
.all();
|
||||
const contactOptions = listContactOptions();
|
||||
|
||||
if (id === 'new') {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { error, fail, redirect } from '@sveltejs/kit';
|
||||
import { asc, eq, isNull } from 'drizzle-orm';
|
||||
import { eq, isNull } from 'drizzle-orm';
|
||||
import { db } from '$lib/server/db';
|
||||
import { contacts, pages } from '$lib/server/db/schema';
|
||||
import { attachmentsOf, getMedia } from '$lib/server/content';
|
||||
import { pages } from '$lib/server/db/schema';
|
||||
import { attachmentsOf, contactOptions as listContactOptions, getMedia } from '$lib/server/content';
|
||||
import { fields, parseId, uniqueSlug } from '$lib/server/forms';
|
||||
import { cleanHtml } from '$lib/server/sanitize';
|
||||
import { descendantsOf, pageTree } from '$lib/server/pageTree';
|
||||
|
|
@ -13,7 +13,7 @@ import type { MediaItem } from '$lib/types';
|
|||
|
||||
export const load = ({ params, url }) => {
|
||||
const id = parseId(params.id);
|
||||
const contactOptions = db.select({ id: contacts.id, name: contacts.name, role: contacts.role }).from(contacts).orderBy(asc(contacts.name)).all();
|
||||
const contactOptions = listContactOptions();
|
||||
const excluded = id === 'new' ? new Set<number>() : descendantsOf(id);
|
||||
const parentOptions = pageTree()
|
||||
.filter((r) => !excluded.has(r.id))
|
||||
|
|
|
|||
21
src/routes/admin/api/ansprechpartner/+server.ts
Normal file
21
src/routes/admin/api/ansprechpartner/+server.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { error, json } from '@sveltejs/kit';
|
||||
import { db } from '$lib/server/db';
|
||||
import { contacts } from '$lib/server/db/schema';
|
||||
import { contactsByIds } from '$lib/server/content';
|
||||
import { nextSortOrder } from '$lib/server/sorting';
|
||||
|
||||
/** Ansprechpartner direkt aus einem Auswahlfeld heraus anlegen */
|
||||
export const POST = async ({ request }) => {
|
||||
const body = await request.json().catch(() => null);
|
||||
const str = (v: unknown, max = 200) => (typeof v === 'string' ? v.trim().slice(0, max) : '');
|
||||
const name = str(body?.name);
|
||||
const email = str(body?.email);
|
||||
if (!name) error(400, 'Bitte gib einen Namen ein.');
|
||||
if (email && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) error(400, 'Die E-Mail-Adresse sieht nicht richtig aus.');
|
||||
const created = db
|
||||
.insert(contacts)
|
||||
.values({ name, role: str(body?.role), location: str(body?.location), email, phone: str(body?.phone, 50), sortOrder: nextSortOrder(contacts) })
|
||||
.returning({ id: contacts.id })
|
||||
.get();
|
||||
return json(contactsByIds([created.id])[0]);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue