Created
May 13, 2022 14:24
-
-
Save whisher/33bac45c38d8ff968893302235bfaa01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script context="module" lang="ts"> | |
import type {SvelteComponent} from 'svelte' | |
export const getItemId = (index: number, carouselName = 'carousel') => | |
`${carouselName}-item-${index}` | |
export type Item = { | |
props: Record<string, any> | |
component: typeof SvelteComponent | |
} | |
</script> | |
<script lang="ts"> | |
export let items: Item[] | |
export const name = 'carousel' | |
</script> | |
<ul | |
class="flex overflow-x-auto gap-6 snap-x snap-mandatory before:shrink-0 before:w-[30vw] after:shrink-0 after:w-[30vw] pb-6" | |
> | |
{#each items as { props, component }, index} | |
<svelte:component this={component} id={getItemId(index)} {...props} /> | |
{/each} | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment