Loheide-eu-mitarbeiterplatt.../resources/js/components/HeroSlider.vue
Friederich Loheide a36752e09a
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m8s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m12s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m12s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m5s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m6s
CI / Build-Artefakte aktuell (pull_request) Failing after 43s
Neuigkeiten und Termine (vorgezogen)
- Neuigkeiten mit Kategorien, Titelbild (WebP-Varianten), Lesezeit, geplanter
  Veröffentlichung und Hervorhebung; Text wird beim Speichern bereinigt
- Termine mit Ort, Online-Link, ganztägigen Terminen und .ics-Export
- Startseite nach Intranet-Vorbild: Slider, Neuigkeiten, Termine, Aktuelles
  aus den Bereichen; mobil in sinnvoller Reihenfolge
- Admin: Beiträge, Kategorien und Termine
- Bildverarbeitung für Shared Hosting: nur eine Vollbild-Kopie im Speicher,
  Speicherlimit bei Bedarf auf 256 MB angehoben (wie WordPress)
- Demo-Inhalte für die Entwicklung

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 05:16:27 +00:00

107 lines
4.4 KiB
Vue

<script setup>
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
import { Link } from '@inertiajs/vue3';
import { ArrowRight, ChevronLeft, ChevronRight, Pause, Play } from '@lucide/vue';
const props = defineProps({
posts: { type: Array, required: true },
});
const index = ref(0);
const paused = ref(false);
const current = computed(() => props.posts[index.value]);
let timer = null;
function go(to) {
index.value = (to + props.posts.length) % props.posts.length;
}
function start() {
stop();
if (props.posts.length > 1 && !paused.value && !window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
timer = setInterval(() => go(index.value + 1), 7000);
}
}
function stop() {
clearInterval(timer);
}
function togglePause() {
paused.value = !paused.value;
start();
}
onMounted(start);
onBeforeUnmount(stop);
</script>
<template>
<section
class="relative isolate aspect-[16/10] overflow-hidden rounded-lg bg-brand-950 text-white sm:aspect-[16/9] lg:aspect-auto lg:h-full lg:min-h-[400px]"
aria-roledescription="Karussell"
aria-label="Hervorgehobene Neuigkeiten"
@mouseenter="stop"
@mouseleave="start"
@focusin="stop"
@focusout="start"
>
<TransitionGroup
enter-active-class="transition-opacity duration-700"
leave-active-class="transition-opacity duration-700 absolute inset-0"
enter-from-class="opacity-0"
leave-to-class="opacity-0"
>
<img
v-for="(post, i) in posts"
v-show="i === index"
:key="post.id"
:src="post.cover_url"
alt=""
class="absolute inset-0 -z-10 size-full object-cover"
/>
</TransitionGroup>
<div class="absolute inset-0 -z-10 bg-gradient-to-t from-black/80 via-black/35 to-black/5 sm:bg-gradient-to-r sm:from-black/75 sm:via-black/40 sm:to-transparent" />
<div class="flex h-full flex-col justify-end p-6 sm:max-w-[65%] sm:justify-center sm:p-10" aria-live="polite">
<span v-if="current.category" class="mb-3 w-fit rounded-sm bg-brand px-2 py-0.5 text-[11px] font-semibold tracking-wide text-brand-foreground uppercase">
{{ current.category.name }}
</span>
<h2 class="text-2xl leading-tight font-semibold tracking-tight sm:text-[32px]">{{ current.title }}</h2>
<p v-if="current.teaser" class="mt-3 line-clamp-3 hidden text-[15px] text-white/85 sm:block">{{ current.teaser }}</p>
<Link
:href="`/neuigkeiten/${current.slug}`"
class="mt-5 inline-flex w-fit items-center gap-2 rounded-md bg-brand px-4 py-2.5 text-sm font-medium text-brand-foreground transition-colors hover:bg-brand-700"
>
Mehr erfahren
<ArrowRight class="size-4" />
</Link>
</div>
<div v-if="posts.length > 1" class="absolute right-4 bottom-4 flex items-center gap-2 sm:right-6 sm:bottom-6">
<button type="button" class="grid size-9 place-items-center rounded-full bg-black/35 hover:bg-black/55" aria-label="Vorheriger Beitrag" @click="go(index - 1)">
<ChevronLeft class="size-5" />
</button>
<div class="flex items-center gap-1.5 px-1">
<button
v-for="(post, i) in posts"
:key="post.id"
type="button"
class="h-1.5 rounded-full transition-all"
:class="i === index ? 'w-6 bg-white' : 'w-1.5 bg-white/50 hover:bg-white/80'"
:aria-label="`Beitrag ${i + 1} von ${posts.length}`"
:aria-current="i === index"
@click="go(i)"
/>
</div>
<button type="button" class="grid size-9 place-items-center rounded-full bg-black/35 hover:bg-black/55" aria-label="Nächster Beitrag" @click="go(index + 1)">
<ChevronRight class="size-5" />
</button>
<button type="button" class="grid size-9 place-items-center rounded-full bg-black/35 hover:bg-black/55" :aria-label="paused ? 'Automatisch weiterblättern' : 'Anhalten'" @click="togglePause">
<Play v-if="paused" class="size-4" />
<Pause v-else class="size-4" />
</button>
</div>
</section>
</template>