diff --git a/src/components/GraphicBlock/GraphicBlock.mdx b/src/components/GraphicBlock/GraphicBlock.mdx index 14dd3dad..3df1e4e3 100644 --- a/src/components/GraphicBlock/GraphicBlock.mdx +++ b/src/components/GraphicBlock/GraphicBlock.mdx @@ -6,7 +6,7 @@ import * as GraphicBlockStories from './GraphicBlock.stories.svelte'; # GraphicBlock -The `GraphicBlock` component is a special derivative of the [Block](./?path=/docs/layout-block) component that wraps around your graphic. It also adds a title, description, notes and other text elements. +The `GraphicBlock` component is a special derivative of the [Block](?path=/docs/components-page-layout-block--docs) component that wraps around your graphic. It also adds a title, description, notes and other text elements. Many other Reuters Graphics components use `GraphicBlock` to wrap graphics with styled text. @@ -106,12 +106,12 @@ To pass your ai2svelte graphic into `GraphicBlock` component, import your ai2sve ## Custom text -You can override the default styles for title and notes by making your own custom elements with the `customTitle` and `customNotes` [snippets](https://svelte.dev/docs/svelte/snippet): +You can override the default styles for title and notes by making your own custom elements and passing them as `title` and `notes` [snippets](https://svelte.dev/docs/svelte/snippet) instead of as strings: ```svelte - {#snippet customTitle()} + {#snippet title()}
My smaller title
{/snippet} @@ -119,7 +119,7 @@ You can override the default styles for title and notes by making your own custo
- {#snippet customNotes()} + {#snippet notes()} @@ -153,7 +153,7 @@ The `ariaDescription` string will be processed as markdown, so you can add multi ## Custom ARIA descriptions -Sometimes, instead of a simple sentence, we want to provide a data table or something more complex as an ARIA description. To do this, use the `customAria` [snippet](https://svelte.dev/docs/svelte/snippet). +Sometimes, instead of a simple sentence, we want to provide a data table or something more complex as an ARIA description. To do this, pass the custom elements as an `ariaDescription` [snippet](https://svelte.dev/docs/svelte/snippet) instead of as a string, as in the [example above](?path=/docs/components-graphics-graphicblock--docs#aria-descriptions). [Read this](https://accessibility.psu.edu/images/charts/) for more information on using screen reader data tables for charts. @@ -169,7 +169,7 @@ Sometimes, instead of a simple sentence, we want to provide a data table or some - {#snippet customAria()} + {#snippet ariaDescription()}

A shakemap shows the intensity of the 7.2-magnitude earthquake that struck Haiti at 8:29 a.m. EST, Aug. 14, 2021. diff --git a/src/components/GraphicBlock/GraphicBlock.stories.svelte b/src/components/GraphicBlock/GraphicBlock.stories.svelte index 7e0e8452..07c70115 100644 --- a/src/components/GraphicBlock/GraphicBlock.stories.svelte +++ b/src/components/GraphicBlock/GraphicBlock.stories.svelte @@ -51,11 +51,11 @@ placeholder - {#snippet customTitle()} + {#snippet title()}

My smaller title
{/snippet} - {#snippet customNotes()} + {#snippet notes()} @@ -81,7 +81,7 @@ notes="Note: A shakemap represents the ground shaking produced by an earthquake." > - {#snippet customAria()} + {#snippet ariaDescription()}

A shakemap shows the intensity of the 7.2-magnitude earthquake that struck Haiti at 8:29 a.m. EST, Aug. 14, 2021. diff --git a/src/components/GraphicBlock/GraphicBlock.svelte b/src/components/GraphicBlock/GraphicBlock.svelte index b5079208..0ae66ca8 100644 --- a/src/components/GraphicBlock/GraphicBlock.svelte +++ b/src/components/GraphicBlock/GraphicBlock.svelte @@ -29,11 +29,9 @@ */ role?: string; /** - * Notes to the graphic, passed in as a markdown string. + * Notes to the graphic, passed in as a markdown string OR as a custom snippet. */ - notes?: string; - /** Custom notes snippet */ - customNotes?: Snippet; + notes?: string | Snippet; /** * Width of the component within the text well. */ @@ -43,11 +41,9 @@ */ textWidth?: ContainerWidth; /** - * Title of the graphic + * Title of the graphic as a string or a custom snippet. */ - title?: string; - /** Custom title snippet */ - customTitle?: Snippet; + title?: string | Snippet; /** * Description of the graphic, passed in as a markdown string. */ @@ -57,11 +53,9 @@ */ ariaLabel?: string; /** - * ARIA description, passed in as a markdown string. + * ARIA description, passed in as a markdown string OR as a custom snippet. */ - ariaDescription?: string; - /** Custom ARIA snippet */ - customAria?: Snippet; + ariaDescription?: string | Snippet; } let { @@ -71,27 +65,18 @@ snap = false, role, notes, - customNotes, width = 'normal', textWidth = 'normal', title, - customTitle, description, ariaLabel = 'chart', ariaDescription, - customAria, }: Props = $props(); - {#if customTitle} - - - - {@render customTitle()} - - - {:else if title} + + {#if typeof title === 'string'}

{title}

@@ -100,29 +85,29 @@ {/if} + {:else if title} + + + + {@render title()} + + {/if} -