summaryrefslogtreecommitdiff
path: root/src/components/jet/shelf/EditorialCardShelf.svelte
blob: efbd71dce955c585df31db8f258f83d76e10e574 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<script lang="ts" context="module">
    import type { Shelf, EditorialCard } from '@jet-app/app-store/api/models';

    interface EditorialCardShelf extends Shelf {
        items: EditorialCard[];
    }

    export function isEditorialCardShelf(
        shelf: Shelf,
    ): shelf is EditorialCardShelf {
        const { contentType, items } = shelf;

        return contentType === 'editorialCard' && Array.isArray(items);
    }
</script>

<script lang="ts">
    import HeroCarousel from '~/components/hero/Carousel.svelte';
    import EditorialCardItem from '~/components/jet/item/EditorialCardItem.svelte';

    export let shelf: EditorialCardShelf;

    $: items = shelf.items;

    function deriveBackgroundArtworkFromItem(item: EditorialCard) {
        return item.artwork;
    }
</script>

<HeroCarousel {shelf} {items} {deriveBackgroundArtworkFromItem} let:item>
    <EditorialCardItem {item} />
</HeroCarousel>