From 36482a43131f467683fe7d1c5605cd38b60083f2 Mon Sep 17 00:00:00 2001 From: MinamiFunakoshiTR Date: Thu, 13 Mar 2025 12:12:06 -0700 Subject: [PATCH] cleaned up docs --- src/components/BeforeAfter/BeforeAfter.mdx | 112 ++++++++++-------- .../BeforeAfter/BeforeAfter.stories.svelte | 43 +------ src/components/BeforeAfter/BeforeAfter.svelte | 16 ++- 3 files changed, 72 insertions(+), 99 deletions(-) diff --git a/src/components/BeforeAfter/BeforeAfter.mdx b/src/components/BeforeAfter/BeforeAfter.mdx index dfb459f8..41529395 100644 --- a/src/components/BeforeAfter/BeforeAfter.mdx +++ b/src/components/BeforeAfter/BeforeAfter.mdx @@ -24,9 +24,46 @@ The `BeforeAfter` component shows a before-and-after comparison of an image. -## Using with overlays +## Using with ArchieML docs -Add overlays with the `beforeOverlay` and `afterOverlay` slots and a caption to the `caption` slot, then style these elements to match your page design as below. +With the Graphics Kit, you'll likely get your text value from an ArchieML doc... + +```yaml +# ArchieML doc +[blocks] + +type: before-after +beforeSrc: images/before-after/myrne-before.jpg +beforeAlt: Satellite image of Russian base at Myrne taken on July 7, 2020. +afterSrc: images/before-after/myrne-after.jpg +afterAlt: Satellite image of Russian base at Myrne taken on Oct. 20, 2020. + +[] +``` + +... which you'll parse out of a ArchieML block object before passing to the `BeforeAfter` component. + +```svelte + +{#each content.blocks as block} + {#if block.type === 'before-after'} + + {/if} +{/each} +``` + + + +## Adding text + +To add text overlays and captions, use [snippets](https://svelte.dev/docs/svelte/snippet) for `beforeOverlay`, `afterOverlay` and `caption`. You can style these snippets to match your page design, like in [this demo](./?path=/story/components-multimedia-beforeafter--with-overlays). + +> 💡**NOTE:** The text in the overlays are used as [ARIA descriptions](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby) for your before and after images. You must always use the `beforeAlt` / `afterAlt` props to label your image for visually impaired readers, but these ARIA descriptions provide additional information or context that the reader might need. ```svelte -
-

July 7, 2020

-

Initially, this site was far smaller.

-
-
-

Oct. 20, 2020

-

But then forces built up.

-
-

Photos by MAXAR Technologies, 2021.

+ + {#snippet beforeOverlay()} +
+

July 7, 2020

+

Initially, this site was far smaller.

+
+ {/snippet} + + + {#snippet afterOverlay()} +
+

Oct. 20, 2020

+

But then forces built up.

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

Photos by MAXAR Technologies, 2021.

+ {/snippet}
``` - - -## Adding ARIA descriptions - -Use text elements in your overlays as [ARIA descriptions](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby) for your images by setting an ID on text elements within each overlay with the `description` [slot prop](https://svelte.dev/tutorial/slot-props). - -> **💡 TIP:** You must always use the `beforeAlt` / `afterAlt` props to label your image for visually impaired readers, but you can use these descriptions to provide more information or context that the reader might also need. - -```svelte - -
-

July 7, 2020

-

Initially, this site was far smaller.

-
-
-

Oct. 20, 2020

-

But then forces built up.

-
-

Photos by MAXAR Technologies, 2021.

-
- - -``` - - + diff --git a/src/components/BeforeAfter/BeforeAfter.stories.svelte b/src/components/BeforeAfter/BeforeAfter.stories.svelte index 02a54187..74ef3be3 100644 --- a/src/components/BeforeAfter/BeforeAfter.stories.svelte +++ b/src/components/BeforeAfter/BeforeAfter.stories.svelte @@ -32,7 +32,7 @@ }} /> - + - - - - {#snippet beforeOverlay()} -
-

- On July 7, 2020, the base contained only a few transport vehicles. -

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

- But by October, tanks and artillery could be seen. -

-

- In total, over 50 pieces of heavy machinery and 200 personnel are now - based here. -

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

Photos by MAXAR Technologies, 2021.

- {/snippet} -
- - -
diff --git a/src/components/BeforeAfter/BeforeAfter.svelte b/src/components/BeforeAfter/BeforeAfter.svelte index 23621bfc..f7f8b976 100644 --- a/src/components/BeforeAfter/BeforeAfter.svelte +++ b/src/components/BeforeAfter/BeforeAfter.svelte @@ -197,7 +197,7 @@ ontouchstart={start} onmousedown={start} bind:this={figure} - aria-labelledby={(caption && `${id}-caption`) || ''} + aria-labelledby={(caption && `${id}-caption-description`) || undefined} > + {beforeAlt} {#if beforeOverlay}
{/if} {#if afterOverlay} -
+
{@render afterOverlay()}