blob: 31a02871a6b590e86c2fed7c3cdb3c3726717e64 (
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
33
34
35
36
37
38
|
<script lang="ts" context="module">
import type {
Shelf,
HeroCarousel as HeroCarouselModel,
HeroCarouselItem as HeroCarouselItemModel,
} from '@jet-app/app-store/api/models';
interface HeroCarouselShelf extends Shelf {
items: [HeroCarouselModel];
}
export function isHeroCarouselShelf(
shelf: Shelf,
): shelf is HeroCarouselShelf {
const { contentType, items } = shelf;
return contentType === 'heroCarousel' && Array.isArray(items);
}
</script>
<script lang="ts">
import HeroCarousel from '~/components/hero/Carousel.svelte';
import HeroCarouselItem from '~/components/jet/item/HeroCarouselItem.svelte';
import { isRtl } from '~/utils/locale';
export let shelf: HeroCarouselShelf;
$: ({ items: ltrItems, rtlItems } = shelf.items[0]);
$: items = isRtl() && rtlItems.length ? rtlItems : ltrItems;
function deriveBackgroundArtworkFromItem(item: HeroCarouselItemModel) {
return item.artwork || item.video?.preview;
}
</script>
<HeroCarousel {shelf} {items} {deriveBackgroundArtworkFromItem} let:item>
<HeroCarouselItem {item} />
</HeroCarousel>
|