Skip to content

Commit

Permalink
Merge pull request #116 from UrbanInstitute/patch-dw-switching
Browse files Browse the repository at this point in the history
Update Datawrapper Switching Example
  • Loading branch information
benkates authored Oct 24, 2024
2 parents 99652ff + 68222af commit 7b567c8
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 19 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Next

- Patch: Update Datawrapper Switching example with `title` and `ariaLabel` props

## v0.11.1

- Fix: Correct path for icon exports
Expand Down
89 changes: 70 additions & 19 deletions src/docs/stories/DatawrapperSwitching.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,24 @@
let selectedChart = "AHpJL";
$: selectedChartMetadata = dropdownData.find((d) => d.value === selectedChart);
const dropdownData = [
{ value: "AHpJL", label: "Chart #1" },
{ value: "91Q0t", label: "Chart #2" },
{ value: "eaD2D", label: "Chart #3" }
{
value: "AHpJL",
label: "Chart #1",
ariaLabel: "Quis id magna ut esse qui nostrud magna."
},
{
value: "91Q0t",
label: "Chart #2",
ariaLabel: "Quis id magna ut esse qui nostrud magna."
},
{
value: "eaD2D",
label: "Chart #3",
ariaLabel: "Quis id magna ut esse qui nostrud magna."
}
];
let selectedChartLoading = "WsGs1";
Expand All @@ -30,10 +44,25 @@
import { BasicDropdown, DatawrapperIframe } from "@urbaninstitute/dataviz-components";
let selectedChart;
// look up metadata based on selected chart
$: selectedChartMetadata = dropdownData.find((d) => d.value === selectedChart);
const dropdownData = [
{ value: "AHpJL", label: "Chart #1" },
{ value: "91Q0t", label: "Chart #2" },
{ value: "eaD2D", label: "Chart #3" }
{
value: "AHpJL",
label: "Chart #1",
ariaLabel: "Quis id magna ut esse qui nostrud magna."
},
{
value: "91Q0t",
label: "Chart #2",
ariaLabel: "Quis id magna ut esse qui nostrud magna."
},
{
value: "eaD2D",
label: "Chart #3",
ariaLabel: "Quis id magna ut esse qui nostrud magna."
}
];
</script>
Expand All @@ -46,7 +75,11 @@
/>
{#key selectedChart}
<DatawrapperIframe datawrapperId={selectedChart} />
<DatawrapperIframe
datawrapperId={selectedChartMetadata.value}
title={selectedChartMetadata.label}
ariaLabel={selectedChartMetadata.ariaLabel}
/>
{/key}
`}
>
Expand All @@ -58,7 +91,11 @@
placeholder={null}
/>
{#key selectedChart}
<DatawrapperIframe datawrapperId={selectedChart} />
<DatawrapperIframe
datawrapperId={selectedChartMetadata.value}
title={selectedChartMetadata.label}
ariaLabel={selectedChartMetadata.ariaLabel}
/>
{/key}
</Story>

Expand All @@ -67,15 +104,19 @@
source={`
<script>
import { Button, DatawrapperIframe } from "@urbaninstitute/dataviz-components";
let selectedChart;
// see first code chunk for setup
</script>
<Button on:click={() => (selectedChart = "AHpJL")}>Chart #1</Button>
<Button on:click={() => (selectedChart = "91Q0t")}>Chart #2</Button>
<Button on:click={() => (selectedChart = "eaD2D")}>Chart #3</Button>
{#key selectedChart}
<DatawrapperIframe datawrapperId={selectedChart} />
<DatawrapperIframe
datawrapperId={selectedChartMetadata.value}
title={selectedChartMetadata.label}
ariaLabel={selectedChartMetadata.ariaLabel}
/>
{/key}
`}
>
Expand All @@ -90,15 +131,25 @@
<Story
name="Loading"
source={`
{#key selectedChart}
<LoadingWrapper let:setChildLoaded let:setChildLoading>
<DatawrapperIframe
datawrapperId={selectedChart}
on:startrender={setChildLoading}
on:visrendered={setChildLoaded}
/>
</LoadingWrapper>
{/key}
<script>
import { Button, DatawrapperIframe, LoadingWrapper } from "@urbaninstitute/dataviz-components";
// see first code chunk for setup
</script>
<Button on:click={() => (selectedChart = "Toh1S")}>Chart #1</Button>
<Button on:click={() => (selectedChart = "rgLU1")}>Chart #2</Button>
{#key selectedChart}
<LoadingWrapper let:setChildLoaded let:setChildLoading>
<DatawrapperIframe
datawrapperId={selectedChartMetadata.value}
title={selectedChartMetadata.label}
ariaLabel={selectedChartMetadata.ariaLabel}
on:startrender={setChildLoading}
on:visrendered={setChildLoaded}
/>
</LoadingWrapper>
{/key}
`}
>
<Button on:click={() => (selectedChart = "Toh1S")}>Chart #1</Button>
Expand Down

0 comments on commit 7b567c8

Please sign in to comment.