Ananto30/ask-hadith

View on GitHub
web/src/lib/HadithList.svelte

Summary

Maintainability
Test Coverage
<script lang="ts">
    import { slide } from 'svelte/transition';
    import { hadithsByCollection, selectedCollection } from '../store';
    import Hadith from '$lib/Hadith.svelte';
    import type { HadithModel } from '../models';

    let hadiths: HadithModel[] = [];

    $: if ($hadithsByCollection.has($selectedCollection)) {
        hadiths = $hadithsByCollection.get($selectedCollection) || [];
    }
</script>

<div in:slide class="flex flex-col gap-4 pb-20 md:gap-8">
    {#each hadiths as hadith}
        <Hadith bind:hadith />
    {/each}
</div>