From 53aad54cd8b14199f26155296b2eeb8ad2eafac6 Mon Sep 17 00:00:00 2001 From: MinamiFunakoshiTR Date: Wed, 26 Mar 2025 09:12:22 -0700 Subject: [PATCH] fixes assets handling --- .../PhotoCarousel/PhotoCarousel.mdx | 28 +++++++++-------- .../PhotoCarousel.stories.svelte | 17 +++++------ .../PhotoCarousel/PhotoCarousel.svelte | 30 +++++++++---------- .../demo/{photos.json => images.json} | 0 4 files changed, 39 insertions(+), 36 deletions(-) rename src/components/PhotoCarousel/demo/{photos.json => images.json} (100%) diff --git a/src/components/PhotoCarousel/PhotoCarousel.mdx b/src/components/PhotoCarousel/PhotoCarousel.mdx index 718535df..d2ef465f 100644 --- a/src/components/PhotoCarousel/PhotoCarousel.mdx +++ b/src/components/PhotoCarousel/PhotoCarousel.mdx @@ -39,7 +39,7 @@ With the Graphics Kit, you'll likely get your text value from an ArchieML doc... type: photo-carousel # List of photo data -[.photos] +[.images] # Photo 1 src: 'images/myImage.jpg', # The source path can be a URL or a local path altText: 'A picture of...', @@ -62,6 +62,8 @@ type: photo-carousel ... which you'll parse out of a ArchieML block object before passing to the `PhotoCarousel` component. +> **Note:** If you're using local images files stored in your Graphics Kit project, prefix `assets` to the image source path, as in the example below. + ```svelte {#each content.blocks as block} {#if block.type === 'photo-carousel'} - + ({ + ...img, + src: `${assets}/${img.src}`, + }))} + /> {/if} {/each} - ``` @@ -88,15 +92,15 @@ type: photo-carousel 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 credit(image)} +

{image.credit}

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

{photo.caption}

+ + {#snippet caption(image)} +

{image.caption}

{/snippet}
diff --git a/src/components/PhotoCarousel/PhotoCarousel.stories.svelte b/src/components/PhotoCarousel/PhotoCarousel.stories.svelte index 76db1c5c..0092f7f6 100644 --- a/src/components/PhotoCarousel/PhotoCarousel.stories.svelte +++ b/src/components/PhotoCarousel/PhotoCarousel.stories.svelte @@ -15,26 +15,25 @@ - - {#snippet credit(photo)} -

{photo.credit}

+ + {#snippet credit(image)} +

{image.credit}

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

{photo.caption}

+ {#snippet caption(image)} +

{image.caption}

{/snippet}
diff --git a/src/components/PhotoCarousel/PhotoCarousel.svelte b/src/components/PhotoCarousel/PhotoCarousel.svelte index d3331d56..a420e542 100644 --- a/src/components/PhotoCarousel/PhotoCarousel.svelte +++ b/src/components/PhotoCarousel/PhotoCarousel.svelte @@ -26,8 +26,8 @@ type ObjectFit = 'cover' | 'contain'; interface Props { - /** Array of photos. */ - photos: PhotoCarouselImage[]; + /** Array of images. */ + images: PhotoCarouselImage[]; /** Width of the component within the text well: normal, wide, wider, widest, fluid */ width?: ContainerWidth; /** @@ -61,7 +61,7 @@ textWidth = 'normal', id = '', cls = '', - photos, + images, maxHeight = 660, defaultImageObjectFit = 'cover', defaultImageObjectPosition = 'center center', @@ -103,7 +103,7 @@ >
- {#each photos as photo} + {#each images as image}
{photo.altText} - {#if credit && photo.credit} - {@render credit(photo)} + {#if credit && image.credit} + {@render credit(image)} - {:else if photo.credit} + {:else if image.credit} {photo.credit}{image.credit} {/if}
@@ -137,8 +137,8 @@ {/each} - {#if photos[activeImageIndex].caption} - {@const activePhoto = photos[activeImageIndex]} + {#if images[activeImageIndex].caption} + {@const activePhoto = images[activeImageIndex]} diff --git a/src/components/PhotoCarousel/demo/photos.json b/src/components/PhotoCarousel/demo/images.json similarity index 100% rename from src/components/PhotoCarousel/demo/photos.json rename to src/components/PhotoCarousel/demo/images.json