From 45eb8178e8a6d05a384c9385cefdd51c1b7c3de1 Mon Sep 17 00:00:00 2001 From: MinamiFunakoshiTR Date: Thu, 20 Mar 2025 14:49:53 -0700 Subject: [PATCH 1/2] set up photo carousel --- src/components/@types/global.ts | 19 ++ .../PhotoCarousel/PhotoCarousel.mdx | 63 +++++ .../PhotoCarousel.stories.svelte | 59 ++--- .../PhotoCarousel/PhotoCarousel.svelte | 216 ++++++++---------- .../{stories => demo}/photos.json | 0 .../PhotoCarousel/stories/docs/component.md | 21 -- .../PhotoCarousel/stories/docs/withCustom.md | 27 --- 7 files changed, 195 insertions(+), 210 deletions(-) create mode 100644 src/components/PhotoCarousel/PhotoCarousel.mdx rename src/components/PhotoCarousel/{stories => demo}/photos.json (100%) delete mode 100644 src/components/PhotoCarousel/stories/docs/component.md delete mode 100644 src/components/PhotoCarousel/stories/docs/withCustom.md diff --git a/src/components/@types/global.ts b/src/components/@types/global.ts index 5dfd180e..8b7408d8 100644 --- a/src/components/@types/global.ts +++ b/src/components/@types/global.ts @@ -48,3 +48,22 @@ export interface ScrollerStep { */ foregroundProps?: object; } + +export interface PhotoCarouselImage { + /** + * Image src + */ + src: string; + /** + * Image alt text + */ + altText: string; + /** Optional caption as a string */ + caption?: string; + /** Optional credit as string */ + credit?: string; + /** Optional object-fit rule */ + objectFit?: string; + /** Optional object-position rule */ + objectPosition?: string; +} diff --git a/src/components/PhotoCarousel/PhotoCarousel.mdx b/src/components/PhotoCarousel/PhotoCarousel.mdx new file mode 100644 index 00000000..44188191 --- /dev/null +++ b/src/components/PhotoCarousel/PhotoCarousel.mdx @@ -0,0 +1,63 @@ +import { Meta, Canvas } from '@storybook/blocks'; + +import * as PhotoCarouselStories from './PhotoCarousel.stories.svelte'; + + + +# PhotoCarousel + +The `PhotoCarousel` component creates a simple, accessible photo carousel with lazy-loading and mobile swipe built in. + +```svelte + + + +``` + + + +## Custom text + +Use named slots to style your own custom credits and/or captions. + +```svelte + +

{credit}

+

{caption}

+
+ + +``` + + diff --git a/src/components/PhotoCarousel/PhotoCarousel.stories.svelte b/src/components/PhotoCarousel/PhotoCarousel.stories.svelte index 3b1bc3a0..76db1c5c 100644 --- a/src/components/PhotoCarousel/PhotoCarousel.stories.svelte +++ b/src/components/PhotoCarousel/PhotoCarousel.stories.svelte @@ -1,68 +1,41 @@ - - - - - {#snippet credit({ credit })} -

{credit}

- {/snippet} - {#snippet caption({ caption })} -

{caption}

- {/snippet} + + + {#snippet credit(photo)} +

{photo.credit}

+ {/snippet} + {#snippet caption(photo)} +

{photo.caption}

+ {/snippet}
diff --git a/src/components/PhotoCarousel/PhotoCarousel.svelte b/src/components/PhotoCarousel/PhotoCarousel.svelte index a785c761..400970a8 100644 --- a/src/components/PhotoCarousel/PhotoCarousel.svelte +++ b/src/components/PhotoCarousel/PhotoCarousel.svelte @@ -1,108 +1,86 @@ - -