From 81aedad0b6efc114f228d7de06da8aff19ab38f3 Mon Sep 17 00:00:00 2001 From: MinamiFunakoshiTR Date: Thu, 20 Mar 2025 15:17:52 -0700 Subject: [PATCH] migrated, added docs, adds assets prop --- src/components/@types/global.ts | 19 ++ src/components/BodyText/BodyText.mdx | 9 +- .../PhotoCarousel/PhotoCarousel.mdx | 125 ++++++++++ .../PhotoCarousel.stories.svelte | 59 ++--- .../PhotoCarousel/PhotoCarousel.svelte | 227 +++++++++--------- .../{stories => demo}/photos.json | 0 .../PhotoCarousel/stories/docs/component.md | 21 -- .../PhotoCarousel/stories/docs/withCustom.md | 27 --- 8 files changed, 275 insertions(+), 212 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..01d74235 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 source + */ + src: string; + /** + * Image alt text + */ + altText: string; + /** Optional caption */ + caption?: string; + /** Optional credit */ + credit?: string; + /** Optional object-fit rule */ + objectFit?: string; + /** Optional object-position rule */ + objectPosition?: string; +} diff --git a/src/components/BodyText/BodyText.mdx b/src/components/BodyText/BodyText.mdx index 9cd25312..d51f7356 100644 --- a/src/components/BodyText/BodyText.mdx +++ b/src/components/BodyText/BodyText.mdx @@ -30,10 +30,10 @@ Venison shoulder *ham hock ham leberkas*. Flank beef ribs fatback, jerky meatbal ## Using with ArchieML docs -With the graphics kit, you'll likely get your text value from an ArchieML doc. +With the Graphics Kit, you'll likely get your text value from an ArchieML doc... ```yaml -# Archie ML doc +# ArchieML doc [blocks] type: text @@ -49,6 +49,11 @@ text: Bacon ipsum ... ```svelte + + {#each content.blocks as block} {#if block.type === 'text'} diff --git a/src/components/PhotoCarousel/PhotoCarousel.mdx b/src/components/PhotoCarousel/PhotoCarousel.mdx new file mode 100644 index 00000000..5b447618 --- /dev/null +++ b/src/components/PhotoCarousel/PhotoCarousel.mdx @@ -0,0 +1,125 @@ +import { Meta, Canvas } from '@storybook/blocks'; + +import * as PhotoCarouselStories from './PhotoCarousel.stories.svelte'; + + + +# PhotoCarousel + +The `PhotoCarousel` component creates a simple and accessible photo carousel with built-in lazy-loading and mobile swipe. + +```svelte + + + +``` + + + +## Using with ArchieML docs + +With the Graphics Kit, you'll likely get your text value from an ArchieML doc... + +```yaml +# ArchieML doc +[blocks] +type: photo-carousel + +# List of photo data +[.photos] + # Photo 1 + src: 'images/myImage.jpg', # The source path can be a URL or a local path + altText: 'A picture of...', + caption: 'My caption...', // Optional + credit: 'REUTERS/Jane Doe', // Optional + objectFit: 'contain', // Optional + objectPosition: '50% 50%', // Optional + + # Photo 2 + src: 'images/myImage2.jpg', + altText: 'A picture of...', + caption: 'My caption...', // Optional + credit: 'REUTERS/Jane Doe', // Optional + objectFit: 'contain', // Optional + objectPosition: '50% 50%', // Optional + ... +[] +[] +``` + +... which you'll parse out of a ArchieML block object before passing to the `PhotoCarousel` component. + +> **Important❗:** If you're using the Graphics Kit and your photos are saved locally in `src/statics` instead of being on the web, pass the Svelte-kit `assets` string to `PhotoCarousel` to get the correct path. You can't mix and match, though -- all photos must be either local or web-hosted. + +```svelte + + + +{#each content.blocks as block} + {#if block.type === 'photo-carousel'} + + + {/if} +{/each} + +``` + + + +## Custom text + +To customise the credit and/or caption style, use the `credit` and `caption` [snippets](https://svelte.dev/docs/svelte/snippet) and pass `photo` as an argument. + +```svelte + + + {#snippet credit(photo)} +

{photo.credit}

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

{photo.caption}

+ {/snippet} +
+ + + +``` + + 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..4aae06f9 100644 --- a/src/components/PhotoCarousel/PhotoCarousel.svelte +++ b/src/components/PhotoCarousel/PhotoCarousel.svelte @@ -1,108 +1,90 @@ - -