Gruppen-Plugin 1.0.0
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
5bdfb8a082
49 changed files with 4679 additions and 0 deletions
103
resources/js/components/Comments.vue
Normal file
103
resources/js/components/Comments.vue
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { CornerDownRight, LoaderCircle, SendHorizontal, Trash2 } from '@lucide/vue';
|
||||
import { PersonAvatar, formatRelative, http, toast } from '@inhaus/ui';
|
||||
import RichText from './RichText.vue';
|
||||
|
||||
/** Kommentare unter einem Beitrag – mit Antworten (eine Ebene) */
|
||||
const props = defineProps({
|
||||
post: { type: Object, required: true },
|
||||
full: { type: Boolean, default: false },
|
||||
initial: { type: Array, default: null },
|
||||
});
|
||||
|
||||
const comments = ref(props.initial ?? props.post.comments);
|
||||
const loadedAll = ref(props.full);
|
||||
const body = ref('');
|
||||
const replyTo = ref(null);
|
||||
const replyBody = ref('');
|
||||
const busy = ref(false);
|
||||
|
||||
async function loadAll() {
|
||||
comments.value = (await http.get(`/gruppen/beitraege/${props.post.id}/kommentare`)).comments;
|
||||
loadedAll.value = true;
|
||||
}
|
||||
|
||||
async function send(text, parentId = null) {
|
||||
if (!text.trim()) return;
|
||||
|
||||
busy.value = true;
|
||||
|
||||
try {
|
||||
const data = await http.post(`/gruppen/beitraege/${props.post.id}/kommentare`, { body: text, parent_id: parentId });
|
||||
comments.value = data.comments;
|
||||
loadedAll.value = true;
|
||||
props.post.comments_count = data.comments.reduce((n, c) => n + 1 + c.replies.length, 0);
|
||||
body.value = replyBody.value = '';
|
||||
replyTo.value = null;
|
||||
} catch (error) {
|
||||
toast.error(error.message);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(comment) {
|
||||
if (!window.confirm('Kommentar löschen?')) return;
|
||||
|
||||
await http.delete(`/gruppen/kommentare/${comment.id}`);
|
||||
await loadAll();
|
||||
props.post.comments_count = comments.value.reduce((n, c) => n + 1 + c.replies.length, 0);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="ih:grid ih:gap-3 ih:border-t ih:px-4 ih:pt-3 ih:pb-4 ih:sm:px-5">
|
||||
<button v-if="!loadedAll && post.comments_count > comments.length" type="button" class="ih:justify-self-start ih:text-[13px] ih:font-medium ih:text-muted-foreground ih:hover:text-foreground ih:hover:underline" @click="loadAll">
|
||||
Alle {{ post.comments_count }} Kommentare anzeigen
|
||||
</button>
|
||||
|
||||
<div v-for="c in comments" :id="`kommentar-${c.id}`" :key="c.id" class="ih:grid ih:gap-2">
|
||||
<div class="ih:flex ih:gap-2.5">
|
||||
<PersonAvatar v-if="c.user" :person="c.user" class="ih:size-8 ih:text-[11px]" />
|
||||
<div class="ih:min-w-0 ih:flex-1">
|
||||
<div class="ih:inline-block ih:max-w-full ih:rounded-2xl ih:bg-muted ih:px-3 ih:py-2 ih:text-sm">
|
||||
<a v-if="c.user" :href="`/personen/${c.user.id}`" class="ih:font-semibold ih:hover:underline">{{ c.user.name }}</a>
|
||||
<RichText :text="c.body" :limit="400" />
|
||||
</div>
|
||||
<div class="ih:mt-0.5 ih:flex ih:gap-3 ih:px-3 ih:text-xs ih:text-muted-foreground">
|
||||
<span>{{ formatRelative(c.created_at) }}</span>
|
||||
<button v-if="post.can_comment" type="button" class="ih:font-medium ih:hover:text-foreground" @click="replyTo = replyTo === c.id ? null : c.id">Antworten</button>
|
||||
<button v-if="c.can_delete" type="button" class="ih:hover:text-destructive" :aria-label="`Kommentar von ${c.user?.name} löschen`" @click="remove(c)"><Trash2 class="ih:size-3.5" /></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-for="r in c.replies" :id="`kommentar-${r.id}`" :key="r.id" class="ih:ml-10 ih:flex ih:gap-2.5">
|
||||
<PersonAvatar v-if="r.user" :person="r.user" class="ih:size-7 ih:text-[10px]" />
|
||||
<div class="ih:min-w-0 ih:flex-1">
|
||||
<div class="ih:inline-block ih:max-w-full ih:rounded-2xl ih:bg-muted ih:px-3 ih:py-2 ih:text-sm">
|
||||
<a v-if="r.user" :href="`/personen/${r.user.id}`" class="ih:font-semibold ih:hover:underline">{{ r.user.name }}</a>
|
||||
<RichText :text="r.body" :limit="400" />
|
||||
</div>
|
||||
<div class="ih:mt-0.5 ih:flex ih:gap-3 ih:px-3 ih:text-xs ih:text-muted-foreground">
|
||||
<span>{{ formatRelative(r.created_at) }}</span>
|
||||
<button v-if="r.can_delete" type="button" class="ih:hover:text-destructive" aria-label="Antwort löschen" @click="remove(r)"><Trash2 class="ih:size-3.5" /></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form v-if="replyTo === c.id" class="ih:ml-10 ih:flex ih:items-center ih:gap-2" @submit.prevent="send(replyBody, c.id)">
|
||||
<CornerDownRight class="ih:size-4 ih:shrink-0 ih:text-muted-foreground" />
|
||||
<input v-model="replyBody" maxlength="3000" :placeholder="`Antwort an ${c.user?.name ?? ''}`" aria-label="Antwort" autofocus class="ih:h-9 ih:min-w-0 ih:flex-1 ih:rounded-full ih:border ih:border-input ih:bg-background ih:px-4 ih:text-sm ih:focus-visible:ring-3 ih:focus-visible:ring-ring/30 ih:focus-visible:outline-none" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<form v-if="post.can_comment" class="ih:flex ih:items-center ih:gap-2" @submit.prevent="send(body)">
|
||||
<input v-model="body" maxlength="3000" placeholder="Kommentieren …" aria-label="Kommentar" class="ih:h-9 ih:min-w-0 ih:flex-1 ih:rounded-full ih:border ih:border-input ih:bg-background ih:px-4 ih:text-sm ih:focus-visible:ring-3 ih:focus-visible:ring-ring/30 ih:focus-visible:outline-none" />
|
||||
<button type="submit" class="ih:grid ih:size-9 ih:shrink-0 ih:place-items-center ih:rounded-full ih:text-brand-text ih:hover:bg-brand-soft ih:disabled:opacity-40" :disabled="busy || !body.trim()" aria-label="Kommentar senden">
|
||||
<LoaderCircle v-if="busy" class="ih:size-4 ih:animate-spin" /><SendHorizontal v-else class="ih:size-4" />
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
27
resources/js/components/GroupCard.vue
Normal file
27
resources/js/components/GroupCard.vue
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<script setup>
|
||||
import { Link, router } from '@inertiajs/vue3';
|
||||
import { Globe, Lock, EyeOff, Users } from '@lucide/vue';
|
||||
import { Button } from '@inhaus/ui';
|
||||
|
||||
const props = defineProps({ group: { type: Object, required: true } });
|
||||
const icons = { open: Globe, closed: Lock, secret: EyeOff };
|
||||
const join = () => router.post(`/gruppen/${props.group.slug}/beitreten`, {}, { preserveScroll: true });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<article class="ih:flex ih:flex-col ih:overflow-hidden ih:rounded-xl ih:border ih:bg-card ih:shadow-xs">
|
||||
<Link :href="group.url" class="ih:block ih:h-24 ih:bg-brand ih:bg-cover ih:bg-center" :style="group.cover_url ? { backgroundImage: `url(${group.cover_url})` } : {}" :aria-label="group.name" />
|
||||
<div class="ih:flex ih:flex-1 ih:flex-col ih:gap-1 ih:p-4">
|
||||
<Link :href="group.url" class="ih:font-semibold ih:hover:underline">{{ group.name }}</Link>
|
||||
<p class="ih:flex ih:items-center ih:gap-1.5 ih:text-xs ih:text-muted-foreground">
|
||||
<component :is="icons[group.privacy]" class="ih:size-3.5" /> {{ group.privacy_label }} · <Users class="ih:size-3.5" /> {{ group.members_count }}
|
||||
</p>
|
||||
<p v-if="group.description" class="ih:line-clamp-2 ih:text-sm ih:text-muted-foreground">{{ group.description }}</p>
|
||||
<div class="ih:mt-auto ih:pt-3">
|
||||
<Button v-if="group.status === 'active'" variant="outline" size="sm" class="ih:w-full" as-child><Link :href="group.url">Ansehen</Link></Button>
|
||||
<Button v-else-if="group.status === 'pending'" variant="outline" size="sm" class="ih:w-full" disabled>Angefragt</Button>
|
||||
<Button v-else size="sm" class="ih:w-full" @click="join">{{ group.status === 'invited' ? 'Einladung annehmen' : group.privacy === 'open' ? 'Beitreten' : 'Beitritt anfragen' }}</Button>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
60
resources/js/components/GroupDialog.vue
Normal file
60
resources/js/components/GroupDialog.vue
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<script setup>
|
||||
import { watch } from 'vue';
|
||||
import { useForm } from '@inertiajs/vue3';
|
||||
import { LoaderCircle } from '@lucide/vue';
|
||||
import { Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, FormField, Input, Textarea } from '@inhaus/ui';
|
||||
|
||||
/** Gruppe gründen bzw. bearbeiten */
|
||||
const props = defineProps({
|
||||
group: { type: Object, default: null },
|
||||
privacy: { type: Object, required: true },
|
||||
privacyHints: { type: Object, required: true },
|
||||
});
|
||||
const open = defineModel('open', { type: Boolean, default: false });
|
||||
const form = useForm({ name: '', description: '', privacy: 'open', cover: null, remove_cover: false });
|
||||
|
||||
watch(open, (value) => {
|
||||
if (!value) return;
|
||||
form.clearErrors();
|
||||
form.defaults({ name: props.group?.name ?? '', description: props.group?.description ?? '', privacy: props.group?.privacy ?? 'open', cover: null, remove_cover: false });
|
||||
form.reset();
|
||||
});
|
||||
|
||||
function submit() {
|
||||
form.post(props.group ? `/gruppen/${props.group.slug}` : '/gruppen', { forceFormData: true, preserveScroll: true, onSuccess: () => (open.value = false) });
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Dialog v-model:open="open">
|
||||
<DialogContent class="ih:sm:max-w-lg">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{{ group ? 'Gruppe bearbeiten' : 'Gruppe gründen' }}</DialogTitle>
|
||||
<DialogDescription>{{ group ? 'Name, Beschreibung, Art und Titelbild.' : 'Zu einem Thema, einem Hobby oder einem Projekt – Sie verwalten die Gruppe.' }}</DialogDescription>
|
||||
</DialogHeader>
|
||||
<form id="group-form" class="ih:grid ih:gap-4" @submit.prevent="submit">
|
||||
<FormField id="g-name" label="Name" :error="form.errors.name">
|
||||
<Input id="g-name" v-model="form.name" maxlength="100" placeholder="z. B. Laufgruppe Mainz" />
|
||||
</FormField>
|
||||
<FormField id="g-description" label="Worum geht es? (optional)" :error="form.errors.description">
|
||||
<Textarea id="g-description" v-model="form.description" rows="3" maxlength="2000" />
|
||||
</FormField>
|
||||
<fieldset class="ih:grid ih:gap-2">
|
||||
<legend class="ih:mb-1 ih:text-sm ih:font-medium">Wer darf rein?</legend>
|
||||
<label v-for="(label, key) in privacy" :key="key" class="ih:flex ih:cursor-pointer ih:items-start ih:gap-3 ih:rounded-md ih:border ih:p-3 ih:text-sm ih:has-[:checked]:border-brand ih:has-[:checked]:bg-brand-soft/50">
|
||||
<input v-model="form.privacy" type="radio" name="privacy" :value="key" class="ih:mt-0.5 ih:size-4 ih:accent-[var(--color-brand)]" />
|
||||
<span><span class="ih:font-medium">{{ label }}</span><span class="ih:block ih:text-xs ih:text-muted-foreground">{{ privacyHints[key] }}</span></span>
|
||||
</label>
|
||||
</fieldset>
|
||||
<FormField id="g-cover" label="Titelbild (optional)" :error="form.errors.cover">
|
||||
<input id="g-cover" type="file" accept="image/jpeg,image/png,image/webp" class="ih:text-sm" @change="form.cover = $event.target.files[0] ?? null" />
|
||||
</FormField>
|
||||
<label v-if="group?.cover_url" class="ih:flex ih:items-center ih:gap-2 ih:text-sm"><input v-model="form.remove_cover" type="checkbox" /> Titelbild entfernen</label>
|
||||
</form>
|
||||
<DialogFooter>
|
||||
<Button variant="ghost" @click="open = false">Abbrechen</Button>
|
||||
<Button type="submit" form="group-form" :disabled="form.processing || !form.name.trim()"><LoaderCircle v-if="form.processing" class="ih:animate-spin" /> {{ group ? 'Speichern' : 'Gründen' }}</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</template>
|
||||
98
resources/js/components/PeopleSelect.vue
Normal file
98
resources/js/components/PeopleSelect.vue
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { Search, X } from '@lucide/vue';
|
||||
import { PersonAvatar } from '@inhaus/ui';
|
||||
import { http } from '@inhaus/ui';
|
||||
|
||||
/**
|
||||
* Personen suchen und auswählen – einzeln (Direktnachricht) oder mehrere (Gruppe).
|
||||
* v-model: Liste der Personen [{ id, name, … }]
|
||||
*/
|
||||
const props = defineProps({
|
||||
multiple: { type: Boolean, default: false },
|
||||
exclude: { type: Array, default: () => [] },
|
||||
placeholder: { type: String, default: 'Name oder E-Mail eingeben …' },
|
||||
autofocus: { type: Boolean, default: false },
|
||||
});
|
||||
const emit = defineEmits(['pick']);
|
||||
const selected = defineModel({ type: Array, default: () => [] });
|
||||
|
||||
const query = ref('');
|
||||
const results = ref([]);
|
||||
const active = ref(0);
|
||||
const loading = ref(false);
|
||||
let timer;
|
||||
|
||||
watch(query, (value) => {
|
||||
clearTimeout(timer);
|
||||
|
||||
if (value.trim().length < 2) {
|
||||
results.value = [];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
timer = setTimeout(async () => {
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
const ids = [...props.exclude, ...selected.value.map((p) => p.id)];
|
||||
results.value = (await http.get(`/personen/suche?q=${encodeURIComponent(value.trim())}`)).people.filter((p) => !ids.includes(p.id));
|
||||
active.value = 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}, 200);
|
||||
});
|
||||
|
||||
function choose(person) {
|
||||
if (!person) return;
|
||||
|
||||
emit('pick', person);
|
||||
|
||||
if (props.multiple) selected.value = [...selected.value, person];
|
||||
query.value = '';
|
||||
results.value = [];
|
||||
}
|
||||
|
||||
const remove = (person) => (selected.value = selected.value.filter((p) => p.id !== person.id));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="ih:grid ih:gap-2">
|
||||
<div v-if="multiple && selected.length" class="ih:flex ih:flex-wrap ih:gap-1.5">
|
||||
<span v-for="person in selected" :key="person.id" class="ih:inline-flex ih:items-center ih:gap-1.5 ih:rounded-full ih:border ih:bg-card ih:py-0.5 ih:pr-1 ih:pl-0.5 ih:text-[13px]">
|
||||
<PersonAvatar :person="person" class="ih:size-6 ih:text-[10px]" />
|
||||
{{ person.name }}
|
||||
<button type="button" class="ih:rounded-full ih:p-0.5 ih:text-muted-foreground ih:hover:bg-muted ih:hover:text-foreground" :aria-label="`${person.name} entfernen`" @click="remove(person)"><X class="ih:size-3.5" /></button>
|
||||
</span>
|
||||
</div>
|
||||
<div class="ih:relative">
|
||||
<Search class="ih:pointer-events-none ih:absolute ih:top-1/2 ih:left-2.5 ih:size-4 ih:-translate-y-1/2 ih:text-muted-foreground" />
|
||||
<input
|
||||
v-model="query"
|
||||
type="search"
|
||||
autocomplete="off"
|
||||
:autofocus="autofocus"
|
||||
:placeholder="placeholder"
|
||||
aria-label="Person suchen"
|
||||
class="ih:h-10 ih:w-full ih:rounded-md ih:border ih:border-input ih:bg-card ih:pr-3 ih:pl-8 ih:text-sm ih:shadow-xs ih:focus-visible:ring-3 ih:focus-visible:ring-ring/30 ih:focus-visible:outline-none"
|
||||
@keydown.down.prevent="active = Math.min(results.length - 1, active + 1)"
|
||||
@keydown.up.prevent="active = Math.max(0, active - 1)"
|
||||
@keydown.enter.prevent="choose(results[active])"
|
||||
/>
|
||||
</div>
|
||||
<ul v-if="results.length" class="ih:max-h-64 ih:overflow-y-auto ih:rounded-md ih:border ih:bg-popover ih:p-1" role="listbox">
|
||||
<li v-for="(person, i) in results" :key="person.id" role="option" :aria-selected="i === active">
|
||||
<button type="button" class="ih:flex ih:w-full ih:items-center ih:gap-2.5 ih:rounded ih:px-2 ih:py-1.5 ih:text-left ih:text-sm" :class="i === active ? 'ih:bg-accent' : 'ih:hover:bg-accent/60'" @click="choose(person)" @mouseenter="active = i">
|
||||
<PersonAvatar :person="person" class="ih:size-7 ih:text-[11px]" />
|
||||
<span class="ih:min-w-0 ih:flex-1">
|
||||
<span class="ih:block ih:truncate ih:font-medium">{{ person.name }}</span>
|
||||
<span v-if="person.job_title || person.department" class="ih:block ih:truncate ih:text-xs ih:text-muted-foreground">{{ [person.job_title, person.department].filter(Boolean).join(' · ') }}</span>
|
||||
</span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<p v-else-if="query.trim().length >= 2 && !loading" class="ih:px-1 ih:text-[13px] ih:text-muted-foreground">Niemand gefunden.</p>
|
||||
</div>
|
||||
</template>
|
||||
191
resources/js/components/PostCard.vue
Normal file
191
resources/js/components/PostCard.vue
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { Download, Flag, MessageCircle, MoreHorizontal, Pencil, Pin, PinOff, Trash2 } from '@lucide/vue';
|
||||
import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, FileIcon, PersonAvatar, formatRelative, http, toast } from '@inhaus/ui';
|
||||
import Comments from './Comments.vue';
|
||||
import RichText from './RichText.vue';
|
||||
import { fileSize } from '../lib/format';
|
||||
|
||||
const props = defineProps({
|
||||
post: { type: Object, required: true },
|
||||
reactions: { type: Array, required: true },
|
||||
showGroup: { type: Boolean, default: false },
|
||||
fullComments: { type: Array, default: null },
|
||||
});
|
||||
const emit = defineEmits(['deleted', 'changed']);
|
||||
|
||||
const p = props.post;
|
||||
const showComments = ref(!!props.fullComments || p.comments.length > 0);
|
||||
const editing = ref(false);
|
||||
const draft = ref(p.body ?? '');
|
||||
|
||||
// Reaktion: ein Klick = 👍, Auswahl beim Überfahren
|
||||
async function react(emoji) {
|
||||
const next = p.my_reaction === emoji ? null : emoji;
|
||||
const old = p.my_reaction;
|
||||
const bump = (e, d) => {
|
||||
if (!e) return;
|
||||
const r = p.reactions.find((x) => x.emoji === e);
|
||||
r ? (r.count += d) : d > 0 && p.reactions.push({ emoji: e, count: 1 });
|
||||
p.reactions = p.reactions.filter((x) => x.count > 0).sort((a, b) => b.count - a.count);
|
||||
p.reactions_total += d;
|
||||
};
|
||||
bump(old, -1);
|
||||
bump(next, 1);
|
||||
p.my_reaction = next;
|
||||
await http.post(`/gruppen/beitraege/${p.id}/reaktion`, { emoji: next }).catch((e) => toast.error(e.message));
|
||||
}
|
||||
|
||||
// Umfrage
|
||||
const selection = ref([...(p.poll?.mine ?? [])]);
|
||||
const voted = computed(() => (p.poll?.mine ?? []).length > 0);
|
||||
const totalVotes = computed(() => p.poll?.options.reduce((n, o) => n + o.votes, 0) ?? 0);
|
||||
async function vote(options) {
|
||||
try {
|
||||
p.poll = (await http.post(`/gruppen/beitraege/${p.id}/abstimmen`, { options })).poll;
|
||||
selection.value = [...p.poll.mine];
|
||||
} catch (e) {
|
||||
toast.error(e.message);
|
||||
}
|
||||
}
|
||||
function choose(i) {
|
||||
if (!p.can_comment) return;
|
||||
if (p.poll.multiple) {
|
||||
selection.value = selection.value.includes(i) ? selection.value.filter((x) => x !== i) : [...selection.value, i];
|
||||
} else {
|
||||
vote([i]);
|
||||
}
|
||||
}
|
||||
|
||||
async function pin() {
|
||||
try {
|
||||
await http.post(`/gruppen/beitraege/${p.id}/anpinnen`, { pinned: !p.pinned });
|
||||
p.pinned = !p.pinned;
|
||||
emit('changed');
|
||||
} catch (e) {
|
||||
toast.error(e.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function remove() {
|
||||
if (!window.confirm('Beitrag löschen?')) return;
|
||||
await http.delete(`/gruppen/beitraege/${p.id}`);
|
||||
emit('deleted', p);
|
||||
}
|
||||
|
||||
async function saveEdit() {
|
||||
await http.put(`/gruppen/beitraege/${p.id}`, { body: draft.value });
|
||||
p.body = draft.value;
|
||||
p.edited = true;
|
||||
editing.value = false;
|
||||
}
|
||||
|
||||
async function report() {
|
||||
const reason = window.prompt('Was stimmt mit diesem Beitrag nicht?');
|
||||
if (!reason?.trim()) return;
|
||||
const data = await http.post(`/gruppen/beitraege/${p.id}/melden`, { reason });
|
||||
toast.success(data.message);
|
||||
}
|
||||
|
||||
const shownImages = computed(() => p.images.slice(0, 4));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<article class="ih:overflow-hidden ih:rounded-xl ih:border ih:bg-card ih:shadow-xs" :aria-label="`Beitrag von ${p.user?.name ?? 'Gelöschtes Konto'}`">
|
||||
<header class="ih:flex ih:items-start ih:gap-3 ih:px-4 ih:pt-4 ih:sm:px-5">
|
||||
<PersonAvatar v-if="p.user" :person="p.user" class="ih:size-10" />
|
||||
<div class="ih:min-w-0 ih:flex-1 ih:text-sm">
|
||||
<p class="ih:leading-snug">
|
||||
<a v-if="p.user" :href="`/personen/${p.user.id}`" class="ih:font-semibold ih:hover:underline">{{ p.user.name }}</a>
|
||||
<template v-if="showGroup"><span class="ih:mx-1 ih:text-muted-foreground">in</span><a :href="`/gruppen/${p.group.slug}`" class="ih:font-semibold ih:hover:underline">{{ p.group.name }}</a></template>
|
||||
</p>
|
||||
<p class="ih:flex ih:items-center ih:gap-1.5 ih:text-xs ih:text-muted-foreground">
|
||||
<a :href="p.url" class="ih:hover:underline">{{ formatRelative(p.created_at) }}</a>
|
||||
<template v-if="p.edited"> · bearbeitet</template>
|
||||
<span v-if="p.pinned" class="ih:inline-flex ih:items-center ih:gap-0.5 ih:font-medium ih:text-brand-text"><Pin class="ih:size-3" /> Angepinnt</span>
|
||||
</p>
|
||||
</div>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger as-child>
|
||||
<button type="button" class="ih:grid ih:size-8 ih:place-items-center ih:rounded-full ih:text-muted-foreground ih:hover:bg-accent" aria-label="Weitere Aktionen"><MoreHorizontal class="ih:size-5" /></button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem v-if="p.can_pin" @select="pin"><component :is="p.pinned ? PinOff : Pin" /> {{ p.pinned ? 'Nicht mehr anpinnen' : 'Oben anpinnen' }}</DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="p.can_edit && p.body !== null" @select="editing = true; draft = p.body"><Pencil /> Bearbeiten</DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="p.can_delete" class="ih:text-destructive" @select="remove"><Trash2 /> Löschen</DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="!p.can_edit" @select="report"><Flag /> Melden</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</header>
|
||||
|
||||
<div class="ih:px-4 ih:pt-3 ih:text-[15px] ih:leading-relaxed ih:sm:px-5">
|
||||
<form v-if="editing" class="ih:grid ih:gap-2" @submit.prevent="saveEdit">
|
||||
<textarea v-model="draft" rows="4" maxlength="10000" aria-label="Beitrag bearbeiten" class="ih:w-full ih:rounded-md ih:border ih:border-input ih:bg-background ih:p-3 ih:text-sm" />
|
||||
<div class="ih:flex ih:gap-2"><Button size="sm" type="submit">Speichern</Button><Button size="sm" variant="ghost" type="button" @click="editing = false">Abbrechen</Button></div>
|
||||
</form>
|
||||
<RichText v-else-if="p.body" :text="p.body" />
|
||||
</div>
|
||||
|
||||
<!-- Fotos -->
|
||||
<div v-if="p.images.length" class="ih:mt-3 ih:grid ih:gap-0.5" :class="p.images.length === 1 ? '' : 'ih:grid-cols-2'">
|
||||
<a v-for="(img, i) in shownImages" :key="img.id" :href="img.url" target="_blank" rel="noopener" class="ih:relative ih:block ih:overflow-hidden ih:bg-muted" :class="p.images.length === 3 && i === 0 ? 'ih:row-span-2' : ''">
|
||||
<img :src="p.images.length === 1 ? img.url : img.thumb_url" :alt="img.name" loading="lazy" class="ih:w-full ih:object-cover" :class="p.images.length === 1 ? 'ih:max-h-[32rem]' : 'ih:aspect-square ih:h-full'" />
|
||||
<span v-if="i === 3 && p.images.length > 4" class="ih:absolute ih:inset-0 ih:grid ih:place-items-center ih:bg-foreground/55 ih:text-2xl ih:font-semibold ih:text-background">+{{ p.images.length - 4 }}</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Dateien -->
|
||||
<div v-if="p.files.length" class="ih:grid ih:gap-2 ih:px-4 ih:pt-3 ih:sm:px-5">
|
||||
<a v-for="f in p.files" :key="f.id" :href="f.url" class="ih:flex ih:items-center ih:gap-3 ih:rounded-lg ih:border ih:p-2.5 ih:hover:bg-accent/60">
|
||||
<FileIcon :extension="f.name.split('.').pop()" class="ih:shrink-0" />
|
||||
<span class="ih:min-w-0 ih:flex-1"><span class="ih:block ih:truncate ih:text-sm ih:font-medium">{{ f.name }}</span><span class="ih:text-xs ih:text-muted-foreground">{{ fileSize(f.size) }}</span></span>
|
||||
<Download class="ih:size-4 ih:text-muted-foreground" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Umfrage -->
|
||||
<fieldset v-if="p.poll" class="ih:mx-4 ih:mt-3 ih:grid ih:gap-2 ih:rounded-lg ih:border ih:p-3 ih:sm:mx-5">
|
||||
<legend class="ih:px-1 ih:text-xs ih:font-semibold ih:text-muted-foreground">Umfrage{{ p.poll.multiple ? ' · mehrere Antworten möglich' : '' }}</legend>
|
||||
<button
|
||||
v-for="(o, i) in p.poll.options"
|
||||
:key="i"
|
||||
type="button"
|
||||
class="ih:relative ih:overflow-hidden ih:rounded-md ih:border ih:px-3 ih:py-2 ih:text-left ih:text-sm ih:disabled:cursor-default"
|
||||
:class="(voted ? p.poll.mine : selection).includes(i) ? 'ih:border-brand' : 'ih:hover:border-brand/50'"
|
||||
:aria-pressed="(voted ? p.poll.mine : selection).includes(i)"
|
||||
:disabled="!p.can_comment"
|
||||
@click="choose(i)"
|
||||
>
|
||||
<span v-if="voted" class="ih:absolute ih:inset-y-0 ih:left-0 ih:bg-brand-soft" :style="{ width: `${totalVotes ? Math.round((o.votes / totalVotes) * 100) : 0}%` }" aria-hidden="true" />
|
||||
<span class="ih:relative ih:flex ih:justify-between ih:gap-3">
|
||||
<span :class="{ 'ih:font-semibold': p.poll.mine.includes(i) }">{{ o.label }}</span>
|
||||
<span v-if="voted" class="ih:text-muted-foreground ih:tabular-nums">{{ totalVotes ? Math.round((o.votes / totalVotes) * 100) : 0 }} % · {{ o.votes }}</span>
|
||||
</span>
|
||||
</button>
|
||||
<div class="ih:flex ih:items-center ih:justify-between ih:text-xs ih:text-muted-foreground">
|
||||
<span>{{ p.poll.voters }} {{ p.poll.voters === 1 ? 'Person hat' : 'Personen haben' }} abgestimmt</span>
|
||||
<Button v-if="p.poll.multiple && p.can_comment" size="sm" variant="outline" :disabled="!selection.length && !voted" @click="vote(selection)">{{ voted ? 'Stimme ändern' : 'Abstimmen' }}</Button>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Reaktionen und Kommentare -->
|
||||
<div class="ih:mt-3 ih:flex ih:items-center ih:justify-between ih:px-4 ih:text-[13px] ih:text-muted-foreground ih:sm:px-5">
|
||||
<span v-if="p.reactions_total" class="ih:inline-flex ih:items-center ih:gap-1"><span class="ih:tracking-tighter">{{ p.reactions.slice(0, 3).map((r) => r.emoji).join('') }}</span> {{ p.reactions_total }}</span><span v-else />
|
||||
<button v-if="p.comments_count" type="button" class="ih:hover:underline" @click="showComments = !showComments">{{ p.comments_count }} {{ p.comments_count === 1 ? 'Kommentar' : 'Kommentare' }}</button>
|
||||
</div>
|
||||
<div v-if="p.can_comment" class="ih:mx-4 ih:mt-2 ih:grid ih:grid-cols-2 ih:border-t ih:py-1 ih:sm:mx-5">
|
||||
<div class="ih:group/react ih:relative">
|
||||
<button type="button" class="ih:flex ih:w-full ih:items-center ih:justify-center ih:gap-2 ih:rounded-md ih:py-2 ih:text-sm ih:font-medium ih:hover:bg-accent" :class="p.my_reaction ? 'ih:text-brand-text' : 'ih:text-muted-foreground'" :aria-pressed="!!p.my_reaction" @click="react(p.my_reaction ?? '👍')">
|
||||
<span class="ih:text-base">{{ p.my_reaction ?? '👍' }}</span> {{ p.my_reaction ? 'Reagiert' : 'Gefällt mir' }}
|
||||
</button>
|
||||
<div class="ih:absolute ih:bottom-full ih:left-2 ih:z-20 ih:hidden ih:gap-0.5 ih:rounded-full ih:border ih:bg-popover ih:p-1 ih:shadow-md ih:group-focus-within/react:flex ih:group-hover/react:flex">
|
||||
<button v-for="emoji in reactions" :key="emoji" type="button" class="ih:grid ih:size-9 ih:place-items-center ih:rounded-full ih:text-xl ih:transition-transform ih:hover:scale-125" :aria-label="`Mit ${emoji} reagieren`" @click="react(emoji)">{{ emoji }}</button>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="ih:flex ih:items-center ih:justify-center ih:gap-2 ih:rounded-md ih:py-2 ih:text-sm ih:font-medium ih:text-muted-foreground ih:hover:bg-accent" @click="showComments = true"><MessageCircle class="ih:size-4" /> Kommentieren</button>
|
||||
</div>
|
||||
<div v-else class="ih:h-3" />
|
||||
|
||||
<Comments v-if="showComments" :post="p" :full="!!fullComments" :initial="fullComments" />
|
||||
</article>
|
||||
</template>
|
||||
112
resources/js/components/PostComposer.vue
Normal file
112
resources/js/components/PostComposer.vue
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { BarChart3, File as FileGlyph, ImagePlus, LoaderCircle, Paperclip, Plus, X } from '@lucide/vue';
|
||||
import { Button, PersonAvatar, Switch, http, toast } from '@inhaus/ui';
|
||||
import { fileSize } from '../lib/format';
|
||||
|
||||
const props = defineProps({
|
||||
group: { type: Object, required: true },
|
||||
me: { type: Object, required: true },
|
||||
});
|
||||
const emit = defineEmits(['created']);
|
||||
|
||||
const body = ref('');
|
||||
const files = ref([]);
|
||||
const poll = ref(null); // Liste der Antworten oder null
|
||||
const multiple = ref(false);
|
||||
const busy = ref(false);
|
||||
const photoInput = ref(null);
|
||||
const fileInput = ref(null);
|
||||
const focused = ref(false);
|
||||
const canSend = computed(() => !busy.value && (body.value.trim() || files.value.length || (poll.value && poll.value.filter((o) => o.trim()).length >= 2)));
|
||||
|
||||
function add(list) {
|
||||
for (const file of list) {
|
||||
if (files.value.length >= 10) {
|
||||
toast.error('Höchstens 10 Dateien je Beitrag.');
|
||||
break;
|
||||
}
|
||||
files.value.push({ file, url: file.type.startsWith('image/') ? URL.createObjectURL(file) : null });
|
||||
}
|
||||
focused.value = true;
|
||||
}
|
||||
|
||||
function removeFile(i) {
|
||||
const [f] = files.value.splice(i, 1);
|
||||
f?.url && URL.revokeObjectURL(f.url);
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
busy.value = true;
|
||||
const data = new FormData();
|
||||
body.value.trim() && data.append('body', body.value);
|
||||
files.value.forEach((f) => data.append('files[]', f.file));
|
||||
|
||||
if (poll.value) {
|
||||
poll.value.filter((o) => o.trim()).forEach((o) => data.append('poll[]', o));
|
||||
data.append('multiple', multiple.value ? '1' : '0');
|
||||
}
|
||||
|
||||
try {
|
||||
const { post } = await http.post(`/gruppen/${props.group.slug}/beitraege`, data);
|
||||
emit('created', post);
|
||||
files.value.forEach((f) => f.url && URL.revokeObjectURL(f.url));
|
||||
body.value = '';
|
||||
files.value = [];
|
||||
poll.value = null;
|
||||
focused.value = false;
|
||||
} catch (error) {
|
||||
toast.error(error.message);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="ih:rounded-xl ih:border ih:bg-card ih:p-4 ih:shadow-xs" aria-label="Neuer Beitrag" @dragover.prevent @drop.prevent="add([...$event.dataTransfer.files])">
|
||||
<div class="ih:flex ih:gap-3">
|
||||
<PersonAvatar :person="me" class="ih:size-10" />
|
||||
<textarea
|
||||
v-model="body"
|
||||
:rows="focused || body ? 4 : 1"
|
||||
maxlength="10000"
|
||||
:placeholder="`Was möchten Sie mit „${group.name}“ teilen?`"
|
||||
aria-label="Beitrag schreiben"
|
||||
class="ih:min-h-10 ih:flex-1 ih:resize-none ih:rounded-2xl ih:bg-muted ih:px-4 ih:py-2 ih:text-[15px] ih:focus-visible:bg-background ih:focus-visible:ring-3 ih:focus-visible:ring-ring/30 ih:focus-visible:outline-none"
|
||||
@focus="focused = true"
|
||||
@paste="$event.clipboardData?.files?.length && ($event.preventDefault(), add([...$event.clipboardData.files]))"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ul v-if="files.length" class="ih:mt-3 ih:flex ih:flex-wrap ih:gap-2 ih:pl-13">
|
||||
<li v-for="(f, i) in files" :key="i" class="ih:relative">
|
||||
<img v-if="f.url" :src="f.url" :alt="f.file.name" class="ih:size-20 ih:rounded-md ih:border ih:object-cover" />
|
||||
<span v-else class="ih:flex ih:h-20 ih:w-40 ih:items-center ih:gap-2 ih:rounded-md ih:border ih:bg-muted ih:px-2 ih:text-xs"><FileGlyph class="ih:size-5 ih:shrink-0" /><span class="ih:min-w-0"><span class="ih:block ih:truncate ih:font-medium">{{ f.file.name }}</span>{{ fileSize(f.file.size) }}</span></span>
|
||||
<button type="button" class="ih:absolute ih:-top-1.5 ih:-right-1.5 ih:grid ih:size-5 ih:place-items-center ih:rounded-full ih:bg-foreground ih:text-background" :aria-label="`${f.file.name} entfernen`" @click="removeFile(i)"><X class="ih:size-3" /></button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div v-if="poll" class="ih:mt-3 ih:grid ih:gap-2 ih:rounded-lg ih:border ih:p-3 ih:sm:ml-13">
|
||||
<div class="ih:flex ih:items-center ih:justify-between">
|
||||
<span class="ih:text-sm ih:font-medium">Umfrage</span>
|
||||
<button type="button" class="ih:text-xs ih:text-muted-foreground ih:hover:text-foreground" @click="poll = null">Entfernen</button>
|
||||
</div>
|
||||
<input v-for="(o, i) in poll" :key="i" v-model="poll[i]" maxlength="120" :placeholder="`Antwort ${i + 1}`" :aria-label="`Antwort ${i + 1}`" class="ih:h-9 ih:rounded-md ih:border ih:border-input ih:bg-background ih:px-3 ih:text-sm" />
|
||||
<div class="ih:flex ih:flex-wrap ih:items-center ih:justify-between ih:gap-2">
|
||||
<button v-if="poll.length < 10" type="button" class="ih:inline-flex ih:items-center ih:gap-1 ih:text-sm ih:text-brand-text ih:hover:underline" @click="poll.push('')"><Plus class="ih:size-4" /> Antwort</button>
|
||||
<label class="ih:flex ih:items-center ih:gap-2 ih:text-sm"><Switch v-model="multiple" /> Mehrere Antworten erlauben</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="focused || body || files.length || poll" class="ih:mt-3 ih:flex ih:flex-wrap ih:items-center ih:gap-1 ih:border-t ih:pt-3">
|
||||
<button type="button" class="ih:inline-flex ih:items-center ih:gap-1.5 ih:rounded-md ih:px-2.5 ih:py-1.5 ih:text-sm ih:text-muted-foreground ih:hover:bg-accent" @click="photoInput?.click()"><ImagePlus class="ih:size-4" /> Foto</button>
|
||||
<button type="button" class="ih:inline-flex ih:items-center ih:gap-1.5 ih:rounded-md ih:px-2.5 ih:py-1.5 ih:text-sm ih:text-muted-foreground ih:hover:bg-accent" @click="fileInput?.click()"><Paperclip class="ih:size-4" /> Datei</button>
|
||||
<button v-if="!poll" type="button" class="ih:inline-flex ih:items-center ih:gap-1.5 ih:rounded-md ih:px-2.5 ih:py-1.5 ih:text-sm ih:text-muted-foreground ih:hover:bg-accent" @click="poll = ['', '']"><BarChart3 class="ih:size-4" /> Umfrage</button>
|
||||
<span class="ih:flex-1" />
|
||||
<Button :disabled="!canSend" @click="submit"><LoaderCircle v-if="busy" class="ih:animate-spin" /> Veröffentlichen</Button>
|
||||
<input ref="photoInput" type="file" accept="image/*" multiple class="ih:hidden" @change="add([...$event.target.files]); $event.target.value = ''" />
|
||||
<input ref="fileInput" type="file" multiple class="ih:hidden" @change="add([...$event.target.files]); $event.target.value = ''" />
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
23
resources/js/components/RichText.vue
Normal file
23
resources/js/components/RichText.vue
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { linkify } from '../lib/format';
|
||||
|
||||
/** Text mit Links; lange Texte werden gekürzt („Mehr anzeigen“) */
|
||||
const props = defineProps({
|
||||
text: { type: String, default: '' },
|
||||
limit: { type: Number, default: 600 },
|
||||
});
|
||||
const expanded = ref(false);
|
||||
const long = computed(() => props.text.length > props.limit);
|
||||
const shown = computed(() => (long.value && !expanded.value ? `${props.text.slice(0, props.limit).trimEnd()} …` : props.text));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<p class="ih:break-words ih:whitespace-pre-wrap">
|
||||
<template v-for="(part, i) in linkify(shown)" :key="i">
|
||||
<a v-if="part.href" :href="part.href" target="_blank" rel="noopener noreferrer" class="ih:text-brand-text ih:underline ih:underline-offset-2">{{ part.text }}</a>
|
||||
<template v-else>{{ part.text }}</template>
|
||||
</template>
|
||||
<button v-if="long" type="button" class="ih:ml-1 ih:font-medium ih:text-brand-text ih:hover:underline" @click="expanded = !expanded">{{ expanded ? 'Weniger' : 'Mehr anzeigen' }}</button>
|
||||
</p>
|
||||
</template>
|
||||
22
resources/js/lib/format.js
Normal file
22
resources/js/lib/format.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/** Text in Stücke zerlegen, Links erkennen – ohne v-html */
|
||||
export function linkify(text) {
|
||||
const parts = [];
|
||||
const pattern = /(https?:\/\/[^\s<>"']+[^\s<>"'.,;:!?)\]])/g;
|
||||
let last = 0;
|
||||
|
||||
for (const match of (text ?? '').matchAll(pattern)) {
|
||||
if (match.index > last) parts.push({ text: text.slice(last, match.index) });
|
||||
parts.push({ text: match[0], href: match[0] });
|
||||
last = match.index + match[0].length;
|
||||
}
|
||||
|
||||
if (last < (text ?? '').length) parts.push({ text: text.slice(last) });
|
||||
|
||||
return parts;
|
||||
}
|
||||
|
||||
export function fileSize(bytes) {
|
||||
if (bytes < 1024 * 1024) return `${Math.max(1, Math.round(bytes / 1024))} KB`;
|
||||
|
||||
return `${(bytes / 1024 / 1024).toFixed(1).replace('.', ',')} MB`;
|
||||
}
|
||||
47
resources/js/pages/Discover.vue
Normal file
47
resources/js/pages/Discover.vue
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { Link, router, usePage } from '@inertiajs/vue3';
|
||||
import { Compass, Plus, Search } from '@lucide/vue';
|
||||
import { AppLayout, Button, EmptyState, PageHeader, toast } from '@inhaus/ui';
|
||||
import GroupCard from '../components/GroupCard.vue';
|
||||
import GroupDialog from '../components/GroupDialog.vue';
|
||||
|
||||
const props = defineProps({
|
||||
groups: { type: Array, required: true },
|
||||
pagination: { type: Object, required: true },
|
||||
q: { type: String, default: '' },
|
||||
privacy: { type: Object, required: true },
|
||||
privacyHints: { type: Object, required: true },
|
||||
});
|
||||
|
||||
const page = usePage();
|
||||
watch(() => page.props.flash?.status, (status) => status && toast.success(status), { immediate: true });
|
||||
const query = ref(props.q);
|
||||
const creating = ref(false);
|
||||
let timer;
|
||||
watch(query, (value) => {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => router.get('/gruppen/entdecken', value ? { q: value } : {}, { preserveState: true }), 300);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout title="Gruppen entdecken">
|
||||
<PageHeader title="Gruppen entdecken" :breadcrumbs="[{ label: 'Gruppen', href: '/gruppen' }]">
|
||||
<template #actions><Button @click="creating = true"><Plus /> Gruppe gründen</Button></template>
|
||||
</PageHeader>
|
||||
<div class="ih:relative ih:mb-5 ih:max-w-md">
|
||||
<Search class="ih:pointer-events-none ih:absolute ih:top-1/2 ih:left-2.5 ih:size-4 ih:-translate-y-1/2 ih:text-muted-foreground" />
|
||||
<input v-model="query" type="search" placeholder="Gruppen suchen" aria-label="Gruppen suchen" class="ih:h-10 ih:w-full ih:rounded-md ih:border ih:border-input ih:bg-card ih:pr-3 ih:pl-8 ih:text-sm ih:shadow-xs" />
|
||||
</div>
|
||||
<div v-if="groups.length" class="ih:grid ih:gap-4 ih:sm:grid-cols-2 ih:lg:grid-cols-3 ih:xl:grid-cols-4">
|
||||
<GroupCard v-for="g in groups" :key="g.id" :group="g" />
|
||||
</div>
|
||||
<div v-else class="ih:rounded-xl ih:border ih:bg-card"><EmptyState :icon="Compass" :title="q ? 'Keine passenden Gruppen' : 'Noch keine Gruppen'" text="Gründen Sie die erste!" /></div>
|
||||
<nav v-if="pagination.prev || pagination.next" class="ih:mt-6 ih:flex ih:justify-between ih:text-sm">
|
||||
<Link v-if="pagination.prev" :href="pagination.prev" class="ih:text-brand-text ih:hover:underline">← Zurück</Link><span v-else />
|
||||
<Link v-if="pagination.next" :href="pagination.next" class="ih:text-brand-text ih:hover:underline">Weiter →</Link>
|
||||
</nav>
|
||||
<GroupDialog v-model:open="creating" :privacy="privacy" :privacy-hints="privacyHints" />
|
||||
</AppLayout>
|
||||
</template>
|
||||
82
resources/js/pages/Index.vue
Normal file
82
resources/js/pages/Index.vue
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { Link, usePage } from '@inertiajs/vue3';
|
||||
import { Compass, LoaderCircle, Plus, UsersRound } from '@lucide/vue';
|
||||
import { AppLayout, Button, EmptyState, PageHeader, http, toast } from '@inhaus/ui';
|
||||
import GroupCard from '../components/GroupCard.vue';
|
||||
import GroupDialog from '../components/GroupDialog.vue';
|
||||
import PostCard from '../components/PostCard.vue';
|
||||
|
||||
const props = defineProps({
|
||||
posts: { type: Array, required: true },
|
||||
more: { type: Boolean, default: false },
|
||||
groups: { type: Array, required: true },
|
||||
invitations: { type: Array, default: () => [] },
|
||||
suggested: { type: Array, default: () => [] },
|
||||
privacy: { type: Object, required: true },
|
||||
privacyHints: { type: Object, required: true },
|
||||
});
|
||||
|
||||
const page = usePage();
|
||||
watch(() => page.props.flash?.status, (status) => status && toast.success(status), { immediate: true });
|
||||
|
||||
const feed = ref(props.posts);
|
||||
const hasMore = ref(props.more);
|
||||
const loading = ref(false);
|
||||
const creating = ref(false);
|
||||
const reactions = ['👍', '❤️', '😂', '😮', '😢', '👏'];
|
||||
|
||||
async function loadMore() {
|
||||
loading.value = true;
|
||||
const data = await http.get(`/gruppen?vor=${feed.value.at(-1).id}`);
|
||||
feed.value.push(...data.posts);
|
||||
hasMore.value = data.more;
|
||||
loading.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout title="Gruppen">
|
||||
<PageHeader title="Gruppen" description="Austausch zu Themen, Hobbys und Projekten – offen, geschlossen oder privat.">
|
||||
<template #actions>
|
||||
<Button variant="outline" as-child><Link href="/gruppen/entdecken"><Compass /> Gruppen entdecken</Link></Button>
|
||||
<Button @click="creating = true"><Plus /> Gruppe gründen</Button>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<div class="ih:grid ih:gap-6 ih:lg:grid-cols-[minmax(0,1fr)_20rem]">
|
||||
<section class="ih:mx-auto ih:grid ih:w-full ih:max-w-2xl ih:content-start ih:gap-4" aria-label="Neue Beiträge aus Ihren Gruppen">
|
||||
<PostCard v-for="post in feed" :key="post.id" :post="post" :reactions="reactions" show-group @deleted="feed = feed.filter((p) => p.id !== post.id)" />
|
||||
<Button v-if="hasMore" variant="outline" :disabled="loading" @click="loadMore"><LoaderCircle v-if="loading" class="ih:animate-spin" /> Ältere Beiträge laden</Button>
|
||||
<div v-if="!feed.length" class="ih:rounded-xl ih:border ih:bg-card">
|
||||
<EmptyState :icon="UsersRound" :title="groups.length ? 'Noch keine Beiträge' : 'Sie sind noch in keiner Gruppe'" :text="groups.length ? 'Schreiben Sie den ersten Beitrag in einer Ihrer Gruppen.' : 'Entdecken Sie Gruppen zu Ihren Themen – oder gründen Sie selbst eine.'" />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<aside class="ih:grid ih:content-start ih:gap-5">
|
||||
<section v-if="invitations.length" class="ih:rounded-xl ih:border ih:border-brand/40 ih:bg-brand-soft/40 ih:p-4">
|
||||
<h2 class="ih:mb-2 ih:text-sm ih:font-semibold">Einladungen</h2>
|
||||
<div class="ih:grid ih:gap-3"><GroupCard v-for="g in invitations" :key="g.id" :group="g" /></div>
|
||||
</section>
|
||||
<section class="ih:rounded-xl ih:border ih:bg-card ih:p-4">
|
||||
<h2 class="ih:mb-2 ih:text-sm ih:font-semibold">Ihre Gruppen</h2>
|
||||
<ul v-if="groups.length" class="ih:-mx-2 ih:grid">
|
||||
<li v-for="g in groups" :key="g.id">
|
||||
<Link :href="g.url" class="ih:flex ih:items-center ih:gap-3 ih:rounded-md ih:p-2 ih:hover:bg-accent/60">
|
||||
<span class="ih:size-10 ih:shrink-0 ih:rounded-md ih:bg-brand ih:bg-cover ih:bg-center" :style="g.cover_url ? { backgroundImage: `url(${g.cover_url})` } : {}" />
|
||||
<span class="ih:min-w-0"><span class="ih:block ih:truncate ih:text-sm ih:font-medium">{{ g.name }}</span><span class="ih:text-xs ih:text-muted-foreground">{{ g.members_count }} {{ g.members_count === 1 ? 'Mitglied' : 'Mitglieder' }}</span></span>
|
||||
</Link>
|
||||
</li>
|
||||
</ul>
|
||||
<p v-else class="ih:text-sm ih:text-muted-foreground">Noch keine.</p>
|
||||
</section>
|
||||
<section v-if="suggested.length" class="ih:grid ih:gap-3">
|
||||
<h2 class="ih:text-sm ih:font-semibold">Vorschläge</h2>
|
||||
<GroupCard v-for="g in suggested" :key="g.id" :group="g" />
|
||||
</section>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<GroupDialog v-model:open="creating" :privacy="privacy" :privacy-hints="privacyHints" />
|
||||
</AppLayout>
|
||||
</template>
|
||||
40
resources/js/pages/Post.vue
Normal file
40
resources/js/pages/Post.vue
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<script setup>
|
||||
import { onMounted } from 'vue';
|
||||
import { Link, router } from '@inertiajs/vue3';
|
||||
import { ChevronLeft, Flag } from '@lucide/vue';
|
||||
import { AppLayout, Button, http, toast } from '@inhaus/ui';
|
||||
import PostCard from '../components/PostCard.vue';
|
||||
|
||||
const props = defineProps({
|
||||
group: { type: Object, required: true },
|
||||
post: { type: Object, required: true },
|
||||
comments: { type: Array, required: true },
|
||||
reactions: { type: Array, required: true },
|
||||
reports: { type: Array, default: () => [] },
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
const target = location.hash && document.querySelector(location.hash);
|
||||
target?.scrollIntoView({ block: 'center' });
|
||||
});
|
||||
|
||||
async function resolve() {
|
||||
await http.post(`/gruppen/beitraege/${props.post.id}/meldungen-erledigt`);
|
||||
toast.success('Meldungen erledigt');
|
||||
router.reload();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout :title="`Beitrag in ${group.name}`">
|
||||
<div class="ih:mx-auto ih:grid ih:max-w-2xl ih:gap-4">
|
||||
<Link :href="group.url" class="ih:inline-flex ih:items-center ih:gap-1 ih:text-sm ih:font-medium ih:text-muted-foreground ih:hover:text-foreground"><ChevronLeft class="ih:size-4" /> {{ group.name }}</Link>
|
||||
<div v-if="reports.length" class="ih:rounded-md ih:border ih:border-destructive/30 ih:bg-destructive/5 ih:p-3 ih:text-sm">
|
||||
<p class="ih:flex ih:items-center ih:gap-2 ih:font-medium"><Flag class="ih:size-4 ih:text-destructive" /> {{ reports.length }} {{ reports.length === 1 ? 'Meldung' : 'Meldungen' }}</p>
|
||||
<ul class="ih:mt-1 ih:list-disc ih:pl-6 ih:text-muted-foreground"><li v-for="r in reports" :key="r.id">{{ r.comment_id ? 'Kommentar: ' : '' }}{{ r.reason }}</li></ul>
|
||||
<Button size="sm" variant="outline" class="ih:mt-2" @click="resolve">In Ordnung – erledigt</Button>
|
||||
</div>
|
||||
<PostCard :post="post" :reactions="reactions" :full-comments="comments" @deleted="router.visit(group.url)" />
|
||||
</div>
|
||||
</AppLayout>
|
||||
</template>
|
||||
168
resources/js/pages/Show.vue
Normal file
168
resources/js/pages/Show.vue
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
<script setup>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { Link, router, usePage } from '@inertiajs/vue3';
|
||||
import { Bell, BellOff, Check, EyeOff, Flag, Globe, LoaderCircle, Lock, LogOut, PencilLine, Trash2, UserMinus, UserPlus, Users, X } from '@lucide/vue';
|
||||
import { AppLayout, Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, EmptyState, PersonAvatar, http, toast } from '@inhaus/ui';
|
||||
import GroupDialog from '../components/GroupDialog.vue';
|
||||
import PeopleSelect from '../components/PeopleSelect.vue';
|
||||
import PostCard from '../components/PostCard.vue';
|
||||
import PostComposer from '../components/PostComposer.vue';
|
||||
|
||||
const props = defineProps({
|
||||
group: { type: Object, required: true },
|
||||
membership: { type: Object, default: null },
|
||||
can: { type: Object, required: true },
|
||||
posts: { type: Array, required: true },
|
||||
more: { type: Boolean, default: false },
|
||||
members: { type: Object, default: null },
|
||||
privacy: { type: Object, required: true },
|
||||
privacyHints: { type: Object, required: true },
|
||||
roles: { type: Object, required: true },
|
||||
reactions: { type: Array, required: true },
|
||||
tab: { type: String, default: 'beitraege' },
|
||||
reports: { type: Number, default: 0 },
|
||||
});
|
||||
|
||||
const page = usePage();
|
||||
watch(() => page.props.flash?.status, (status) => status && toast.success(status), { immediate: true });
|
||||
const me = computed(() => page.props.auth.user);
|
||||
|
||||
const feed = ref(props.posts);
|
||||
watch(() => props.posts, (posts) => (feed.value = posts));
|
||||
const hasMore = ref(props.more);
|
||||
const loading = ref(false);
|
||||
const activeTab = ref(props.tab);
|
||||
const editing = ref(false);
|
||||
const inviting = ref(false);
|
||||
const invitees = ref([]);
|
||||
const icons = { open: Globe, closed: Lock, secret: EyeOff };
|
||||
const status = computed(() => props.membership?.status);
|
||||
|
||||
async function loadMore() {
|
||||
loading.value = true;
|
||||
const last = feed.value.filter((p) => !p.pinned).at(-1);
|
||||
const data = await http.get(`/gruppen/${props.group.slug}?vor=${last?.id ?? 0}`);
|
||||
feed.value.push(...data.posts.filter((p) => !feed.value.some((x) => x.id === p.id)));
|
||||
hasMore.value = data.more;
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
const act = (url, data = {}, method = 'post') => router.visit(`/gruppen/${props.group.slug}${url}`, { method, data, preserveScroll: true });
|
||||
const removeMember = (m) => window.confirm(`${m.name} aus der Gruppe entfernen?`) && act(`/mitglieder/${m.id}`, {}, 'delete');
|
||||
const leave = () => window.confirm(`„${props.group.name}“ verlassen?`) && act('/verlassen');
|
||||
const destroy = () => window.confirm(`Gruppe „${props.group.name}“ mit allen Beiträgen löschen?`) && act('', {}, 'delete');
|
||||
function invite() {
|
||||
router.post(`/gruppen/${props.group.slug}/einladen`, { users: invitees.value.map((p) => p.id) }, { preserveScroll: true, onSuccess: () => { inviting.value = false; invitees.value = []; } });
|
||||
}
|
||||
const canInvite = computed(() => props.can.post && (props.group.privacy === 'open' || props.can.moderate));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout :title="group.name">
|
||||
<!-- Kopf mit Titelbild -->
|
||||
<header class="ih:overflow-hidden ih:rounded-xl ih:border ih:bg-card ih:shadow-xs">
|
||||
<div class="ih:h-36 ih:bg-brand ih:bg-cover ih:bg-center ih:sm:h-52" :style="group.cover_url ? { backgroundImage: `url(${group.cover_url})` } : {}" />
|
||||
<div class="ih:flex ih:flex-wrap ih:items-end ih:gap-4 ih:p-5">
|
||||
<div class="ih:min-w-0 ih:flex-1">
|
||||
<p class="ih:mb-1 ih:text-[13px]"><Link href="/gruppen" class="ih:text-muted-foreground ih:hover:underline">Gruppen</Link></p>
|
||||
<h1 class="ih:text-2xl ih:font-semibold ih:tracking-tight">{{ group.name }}</h1>
|
||||
<p class="ih:mt-1 ih:flex ih:flex-wrap ih:items-center ih:gap-x-3 ih:gap-y-1 ih:text-sm ih:text-muted-foreground">
|
||||
<span class="ih:inline-flex ih:items-center ih:gap-1" :title="group.privacy_hint"><component :is="icons[group.privacy]" class="ih:size-4" /> {{ group.privacy_label }}e Gruppe</span>
|
||||
<span class="ih:inline-flex ih:items-center ih:gap-1"><Users class="ih:size-4" /> {{ group.members_count }} {{ group.members_count === 1 ? 'Mitglied' : 'Mitglieder' }}</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="ih:flex ih:flex-wrap ih:gap-2">
|
||||
<template v-if="status === 'active'">
|
||||
<Button v-if="canInvite" @click="inviting = true"><UserPlus /> Einladen</Button>
|
||||
<Button variant="outline" size="icon" :aria-label="membership.notify === 'all' ? 'Benachrichtigungen ausschalten' : 'Benachrichtigungen einschalten'" :title="membership.notify === 'all' ? 'Sie werden über neue Beiträge benachrichtigt' : 'Keine Benachrichtigungen'" @click="act('/benachrichtigungen', { notify: membership.notify === 'all' ? 'off' : 'all' }, 'put')">
|
||||
<component :is="membership.notify === 'all' ? Bell : BellOff" />
|
||||
</Button>
|
||||
<Button v-if="can.admin" variant="outline" @click="editing = true"><PencilLine /> Bearbeiten</Button>
|
||||
<Button variant="ghost" class="ih:text-muted-foreground" @click="leave"><LogOut /> Verlassen</Button>
|
||||
</template>
|
||||
<Button v-else-if="status === 'pending'" variant="outline" disabled>Beitritt angefragt</Button>
|
||||
<Button v-else-if="status === 'invited'" @click="act('/beitreten')"><Check /> Einladung annehmen</Button>
|
||||
<Button v-else-if="group.privacy !== 'secret'" @click="act('/beitreten')">{{ group.privacy === 'open' ? 'Beitreten' : 'Beitritt anfragen' }}</Button>
|
||||
<Button v-if="can.admin && status !== 'active'" variant="outline" @click="editing = true"><PencilLine /> Bearbeiten</Button>
|
||||
</div>
|
||||
</div>
|
||||
<nav class="ih:flex ih:gap-1 ih:border-t ih:px-3" role="tablist">
|
||||
<button v-for="t in [{ key: 'beitraege', label: 'Beiträge' }, { key: 'mitglieder', label: 'Mitglieder' }, { key: 'info', label: 'Info' }]" :key="t.key" type="button" role="tab" :aria-selected="activeTab === t.key" class="ih:relative ih:px-3 ih:py-3 ih:text-sm ih:font-medium" :class="activeTab === t.key ? 'ih:text-foreground' : 'ih:text-muted-foreground ih:hover:text-foreground'" @click="activeTab = t.key">
|
||||
{{ t.label }}<span v-if="t.key === 'mitglieder' && members?.pending.length" class="ih:ml-1 ih:rounded-full ih:bg-brand ih:px-1.5 ih:text-[11px] ih:text-brand-foreground">{{ members.pending.length }}</span>
|
||||
<span v-if="activeTab === t.key" class="ih:absolute ih:inset-x-2 ih:bottom-0 ih:h-[3px] ih:rounded-t-full ih:bg-brand" />
|
||||
</button>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<div class="ih:mx-auto ih:mt-6 ih:grid ih:max-w-2xl ih:gap-4">
|
||||
<p v-if="can.moderate && reports" class="ih:flex ih:items-center ih:gap-2 ih:rounded-md ih:border ih:border-destructive/30 ih:bg-destructive/5 ih:p-3 ih:text-sm"><Flag class="ih:size-4 ih:text-destructive" /> {{ reports }} offene {{ reports === 1 ? 'Meldung' : 'Meldungen' }} – zu finden an den betroffenen Beiträgen.</p>
|
||||
|
||||
<!-- Beiträge -->
|
||||
<template v-if="activeTab === 'beitraege'">
|
||||
<template v-if="can.read">
|
||||
<PostComposer v-if="can.post" :group="group" :me="me" @created="(post) => feed.splice(feed.filter((p) => p.pinned).length, 0, post)" />
|
||||
<PostCard v-for="post in feed" :key="post.id" :post="post" :reactions="reactions" @deleted="feed = feed.filter((p) => p.id !== post.id)" />
|
||||
<Button v-if="hasMore" variant="outline" :disabled="loading" @click="loadMore"><LoaderCircle v-if="loading" class="ih:animate-spin" /> Ältere Beiträge laden</Button>
|
||||
<div v-if="!feed.length" class="ih:rounded-xl ih:border ih:bg-card"><EmptyState :icon="Users" title="Noch keine Beiträge" :text="can.post ? 'Schreiben Sie den ersten Beitrag!' : 'Treten Sie bei, um mitzuschreiben.'" /></div>
|
||||
</template>
|
||||
<div v-else class="ih:rounded-xl ih:border ih:bg-card"><EmptyState :icon="Lock" title="Nur für Mitglieder" :text="group.privacy_hint" /></div>
|
||||
</template>
|
||||
|
||||
<!-- Mitglieder -->
|
||||
<section v-else-if="activeTab === 'mitglieder'" class="ih:rounded-xl ih:border ih:bg-card ih:p-5">
|
||||
<template v-if="members">
|
||||
<template v-if="members.pending.length">
|
||||
<h2 class="ih:mb-2 ih:text-sm ih:font-semibold">Beitrittsanfragen</h2>
|
||||
<ul class="ih:-mx-2 ih:mb-5 ih:grid">
|
||||
<li v-for="m in members.pending" :key="m.id" class="ih:flex ih:items-center ih:gap-3 ih:rounded-md ih:p-2">
|
||||
<PersonAvatar :person="m" class="ih:size-9" />
|
||||
<span class="ih:min-w-0 ih:flex-1 ih:text-sm"><span class="ih:font-medium">{{ m.name }}</span><span class="ih:block ih:text-xs ih:text-muted-foreground">{{ m.job_title }}</span></span>
|
||||
<Button size="sm" @click="act(`/anfragen/${m.id}`, { accept: true })"><Check /> Aufnehmen</Button>
|
||||
<Button size="sm" variant="ghost" :aria-label="`Anfrage von ${m.name} ablehnen`" @click="act(`/anfragen/${m.id}`, { accept: false })"><X /></Button>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
<h2 class="ih:mb-2 ih:text-sm ih:font-semibold">{{ members.active.length }} {{ members.active.length === 1 ? 'Mitglied' : 'Mitglieder' }}</h2>
|
||||
<ul class="ih:-mx-2 ih:grid">
|
||||
<li v-for="m in members.active" :key="m.id" class="ih:flex ih:items-center ih:gap-3 ih:rounded-md ih:p-2 ih:hover:bg-muted/50">
|
||||
<PersonAvatar :person="m" class="ih:size-9" />
|
||||
<a :href="`/personen/${m.id}`" class="ih:min-w-0 ih:flex-1 ih:text-sm ih:hover:underline"><span class="ih:font-medium">{{ m.name }}</span><span class="ih:block ih:text-xs ih:text-muted-foreground">{{ m.job_title }}</span></a>
|
||||
<select v-if="can.admin && m.id !== me.id" :value="m.role" class="ih:h-8 ih:rounded-md ih:border ih:bg-card ih:px-2 ih:text-xs" :aria-label="`Rolle von ${m.name}`" @change="act(`/mitglieder/${m.id}`, { role: $event.target.value }, 'put')">
|
||||
<option v-for="(label, key) in roles" :key="key" :value="key">{{ label }}</option>
|
||||
</select>
|
||||
<span v-else-if="m.role !== 'member'" class="ih:rounded ih:bg-brand-soft ih:px-1.5 ih:py-0.5 ih:text-[11px] ih:font-medium ih:text-brand-text">{{ roles[m.role] }}</span>
|
||||
<button v-if="can.moderate && m.id !== me.id && (can.admin || m.role === 'member')" type="button" class="ih:rounded ih:p-1.5 ih:text-muted-foreground ih:hover:text-destructive" :aria-label="`${m.name} entfernen`" @click="removeMember(m)"><UserMinus class="ih:size-4" /></button>
|
||||
</li>
|
||||
</ul>
|
||||
<template v-if="members.invited.length">
|
||||
<h2 class="ih:mt-5 ih:mb-2 ih:text-sm ih:font-semibold">Eingeladen</h2>
|
||||
<p class="ih:text-sm ih:text-muted-foreground">{{ members.invited.map((m) => m.name).join(', ') }}</p>
|
||||
</template>
|
||||
</template>
|
||||
<p v-else class="ih:text-sm ih:text-muted-foreground">Die Mitgliederliste sehen nur Mitglieder.</p>
|
||||
</section>
|
||||
|
||||
<!-- Info -->
|
||||
<section v-else class="ih:grid ih:gap-4 ih:rounded-xl ih:border ih:bg-card ih:p-5 ih:text-sm">
|
||||
<p v-if="group.description" class="ih:text-[15px] ih:leading-relaxed ih:whitespace-pre-line">{{ group.description }}</p>
|
||||
<p class="ih:flex ih:items-start ih:gap-2 ih:text-muted-foreground"><component :is="icons[group.privacy]" class="ih:mt-0.5 ih:size-4 ih:shrink-0" /> {{ group.privacy_hint }}</p>
|
||||
<Button v-if="can.admin" variant="outline" class="ih:justify-self-start ih:text-destructive ih:hover:text-destructive" @click="destroy"><Trash2 /> Gruppe löschen</Button>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<GroupDialog v-model:open="editing" :group="group" :privacy="privacy" :privacy-hints="privacyHints" />
|
||||
<Dialog v-model:open="inviting">
|
||||
<DialogContent class="ih:sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>In „{{ group.name }}“ einladen</DialogTitle>
|
||||
<DialogDescription>Die Eingeladenen bekommen eine Benachrichtigung und können annehmen.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<PeopleSelect v-model="invitees" multiple :exclude="members?.active.map((m) => m.id) ?? []" />
|
||||
<DialogFooter>
|
||||
<Button variant="ghost" @click="inviting = false">Abbrechen</Button>
|
||||
<Button :disabled="!invitees.length" @click="invite">Einladen</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</AppLayout>
|
||||
</template>
|
||||
22
resources/js/widgets/Recent.vue
Normal file
22
resources/js/widgets/Recent.vue
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<script setup>
|
||||
import { Panel, PersonAvatar, formatRelative } from '@inhaus/ui';
|
||||
|
||||
defineProps({ posts: { type: Array, required: true } });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Panel title="Aus Ihren Gruppen" action-label="Alle Gruppen" action-href="/gruppen">
|
||||
<ul class="ih:-my-1 ih:grid ih:gap-1">
|
||||
<li v-for="p in posts" :key="p.id">
|
||||
<a :href="p.url" class="ih:-mx-2 ih:flex ih:gap-2.5 ih:rounded-md ih:p-2 ih:hover:bg-accent/50">
|
||||
<PersonAvatar v-if="p.user" :person="p.user" class="ih:size-8 ih:text-[11px]" />
|
||||
<span class="ih:min-w-0 ih:text-sm">
|
||||
<span class="ih:block ih:truncate"><span class="ih:font-medium">{{ p.user?.name }}</span> <span class="ih:text-muted-foreground">in {{ p.group }}</span></span>
|
||||
<span class="ih:line-clamp-2 ih:text-[13px] ih:text-muted-foreground">{{ p.text }}</span>
|
||||
<span class="ih:text-xs ih:text-muted-foreground">{{ formatRelative(p.created_at) }}</span>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</Panel>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue