Something went wrong. Try again.
Monorepo for Tangled forked from tangled.org/core
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192<script lang="ts"> import BellOff from "$icon/bell-off"; import Inbox from "$icon/inbox"; import EmptyState from "#lib/components/ui/EmptyState.svelte"; import LayerCard from "#lib/components/ui/LayerCard.svelte"; import LayerCardPrimary from "#lib/components/ui/LayerCardPrimary.svelte"; import LayerCardSecondary from "#lib/components/ui/LayerCardSecondary.svelte"; import NotificationItem from "#lib/components/notifications/NotificationItem.svelte"; import notificationsNotificationlistSkeletonFixture from "#lib/bones/notifications-notificationlist--skeleton-fixture.bones.json"; import notificationsSociallistSkeletonFixture from "#lib/bones/notifications-notificationlist--social-skeleton-fixture.bones.json"; import Bones from "#lib/components/ui/Bones.svelte"; import { formatCount } from "#lib/format.ts"; import type { NotificationSummary, ReadFilter } from "#lib/components/notifications/types.ts";
interface Props { notifications?: NotificationSummary[]; title?: string; unreadCount?: number; readFilter?: ReadFilter; border?: boolean; compact?: boolean; loading?: boolean; onToggleRead?: (uri: string, read: boolean) => void; }
let { notifications = [], title, unreadCount = 0, readFilter = "inbox", border = true, compact = false, loading = false, onToggleRead }: Props = $props();
const empty = $derived(notifications.length === 0);</script>
{#if loading} <Bones capture={title === "social" ? notificationsSociallistSkeletonFixture : notificationsNotificationlistSkeletonFixture} />{:else if title || unreadCount > 0} <LayerCard as="section" class="self-start"> <LayerCardSecondary class="justify-between"> <h2 class="typography-paragraph-regular font-medium text-foreground-default capitalize"> {title} </h2> {#if unreadCount > 0} <span class="flex h-5 min-w-5 items-center justify-center rounded-full bg-background-info-emphasis px-2xs typography-paragraph-small text-foreground-on-emphasis" > {formatCount(unreadCount)} </span> {/if} </LayerCardSecondary> <LayerCardPrimary padding="none" class="[--panel-border:0px]"> {@render list()} </LayerCardPrimary> </LayerCard>{:else} <div class="overflow-hidden bg-background-default {border ? 'rounded-md border border-border-default' : ''}" > {@render list()} </div>{/if}
{#snippet list()} {#if empty} <EmptyState border={false} background={false} icon={readFilter === "unread" ? Inbox : BellOff} message={readFilter === "unread" ? "All caught up!" : "No notifications"} /> {:else} <div class="grid h-fit grid-cols-[auto_1fr_auto] content-start gap-x-md p-2xs [--notification-radius:calc(var(--radius-md)-var(--panel-border,1px)-var(--spacing-2xs))]" > {#each notifications as notification (notification.uri)} <NotificationItem {notification} {compact} {onToggleRead} /> {/each} </div> {/if}{/snippet}