Einheitliche Listen (0.61.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 9m26s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 9m11s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 9m4s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 9m31s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 13m3s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 13m1s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 10m30s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 46s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m10s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 11m28s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 9m26s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 9m11s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 9m4s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 9m31s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 13m3s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 13m1s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 10m30s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 46s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m10s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 11m28s
Gemeinsame Werkzeugleiste ListToolbar (Filter-Chips, Suche, Sortierung, Kacheln/Liste) für Neuigkeiten, Stellen, Ideen und Personen; im SDK für Plugins. Neuigkeiten durchsuchbar. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8fbe32ed5c
commit
9cb34635bc
167 changed files with 644 additions and 482 deletions
114
resources/js/components/ListToolbar.vue
Normal file
114
resources/js/components/ListToolbar.vue
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
<script setup>
|
||||
import { onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { LayoutGrid, List, Search, X } from '@lucide/vue';
|
||||
|
||||
/**
|
||||
* Einheitliche Leiste über Listen (auch für Plugins, @inhaus/ui):
|
||||
*
|
||||
* <ListToolbar v-model:filter="status" :filters="[{ value: null, label: 'Alle', count: 12 }, …]"
|
||||
* v-model:search="q" search-placeholder="Bilder suchen"
|
||||
* v-model:sort="sort" :sorts="[{ value: 'neu', label: 'Neueste zuerst' }, …]"
|
||||
* v-model:view="view" />
|
||||
*
|
||||
* Alles optional: Ohne `filters` keine Chips, ohne `search` (undefined) kein Suchfeld,
|
||||
* ohne `sorts` keine Sortierung, ohne `view` keine Umschaltung Kacheln/Liste.
|
||||
* Die Suche meldet sich mit kurzer Verzögerung (300 ms). Weitere Schalter im Slot.
|
||||
*/
|
||||
const props = defineProps({
|
||||
filters: { type: Array, default: () => [] },
|
||||
filter: { type: [String, Number, Boolean], default: null },
|
||||
filterLabel: { type: String, default: 'Filter' },
|
||||
search: { type: String, default: undefined },
|
||||
searchPlaceholder: { type: String, default: 'Suchen' },
|
||||
sorts: { type: Array, default: () => [] },
|
||||
sort: { type: String, default: null },
|
||||
view: { type: String, default: undefined }, // 'grid' | 'list'
|
||||
});
|
||||
|
||||
const emit = defineEmits(['update:filter', 'update:search', 'update:sort', 'update:view']);
|
||||
|
||||
const query = ref(props.search ?? '');
|
||||
watch(() => props.search, (value) => {
|
||||
if (value !== undefined && value !== query.value) query.value = value;
|
||||
});
|
||||
|
||||
let timer = null;
|
||||
watch(query, (value) => {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => emit('update:search', value), 300);
|
||||
});
|
||||
onBeforeUnmount(() => clearTimeout(timer));
|
||||
|
||||
const active = (value) => (value ?? null) === (props.filter ?? null);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mb-5 flex flex-wrap items-center gap-x-3 gap-y-3">
|
||||
<nav v-if="filters.length" class="-mx-1 flex max-w-full gap-1.5 overflow-x-auto px-1 pb-0.5 [scrollbar-width:none]" :aria-label="filterLabel">
|
||||
<button
|
||||
v-for="item in filters"
|
||||
:key="String(item.value)"
|
||||
type="button"
|
||||
class="inline-flex shrink-0 items-center gap-1.5 rounded-pill border px-3.5 py-1.5 text-[13px] font-medium whitespace-nowrap transition-colors"
|
||||
:class="active(item.value) ? 'border-brand bg-brand text-brand-foreground' : 'bg-card hover:bg-accent'"
|
||||
:aria-pressed="active(item.value)"
|
||||
@click="emit('update:filter', item.value ?? null)"
|
||||
>
|
||||
{{ item.label }}
|
||||
<span v-if="item.count != null" class="text-xs tabular-nums" :class="active(item.value) ? 'opacity-80' : 'text-muted-foreground'">{{ item.count }}</span>
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<div class="ml-auto flex w-full flex-wrap items-center gap-2 sm:w-auto">
|
||||
<slot />
|
||||
|
||||
<label v-if="search !== undefined" class="relative order-first flex h-9 min-w-0 basis-full items-center sm:order-none sm:w-64 sm:basis-auto">
|
||||
<span class="sr-only">{{ searchPlaceholder }}</span>
|
||||
<Search class="pointer-events-none absolute left-3 size-4 text-muted-foreground" />
|
||||
<input
|
||||
v-model="query"
|
||||
type="search"
|
||||
:placeholder="searchPlaceholder"
|
||||
class="h-9 w-full rounded-pill border border-input bg-card pr-8 pl-9 text-sm placeholder:text-muted-foreground focus-visible:border-brand-400 focus-visible:ring-3 focus-visible:ring-ring/30 focus-visible:outline-none [&::-webkit-search-cancel-button]:hidden"
|
||||
/>
|
||||
<button v-if="query" type="button" class="absolute right-2 grid size-5 place-items-center rounded-full text-muted-foreground hover:bg-accent" aria-label="Suche leeren" @click="query = ''">
|
||||
<X class="size-3.5" />
|
||||
</button>
|
||||
</label>
|
||||
|
||||
<label v-if="sorts.length" class="relative min-w-0 flex-1 sm:flex-none">
|
||||
<span class="sr-only">Sortierung</span>
|
||||
<select
|
||||
:value="sort ?? sorts[0].value"
|
||||
class="h-9 w-full rounded-pill border border-input bg-card px-3 pr-8 text-sm focus-visible:ring-3 focus-visible:ring-ring/30 focus-visible:outline-none"
|
||||
@change="emit('update:sort', $event.target.value)"
|
||||
>
|
||||
<option v-for="item in sorts" :key="item.value" :value="item.value">{{ item.label }}</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<div v-if="view !== undefined" class="ml-auto flex rounded-pill sm:ml-0 border bg-card p-0.5" role="group" aria-label="Ansicht">
|
||||
<button
|
||||
type="button"
|
||||
class="grid size-8 place-items-center rounded-pill"
|
||||
:class="view === 'grid' ? 'bg-brand-soft text-brand-text' : 'text-muted-foreground hover:text-foreground'"
|
||||
:aria-pressed="view === 'grid'"
|
||||
aria-label="Als Kacheln"
|
||||
@click="emit('update:view', 'grid')"
|
||||
>
|
||||
<LayoutGrid class="size-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="grid size-8 place-items-center rounded-pill"
|
||||
:class="view === 'list' ? 'bg-brand-soft text-brand-text' : 'text-muted-foreground hover:text-foreground'"
|
||||
:aria-pressed="view === 'list'"
|
||||
aria-label="Als Liste"
|
||||
@click="emit('update:view', 'list')"
|
||||
>
|
||||
<List class="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue