Skip to content

Commit

Permalink
Merge pull request #130 from UrbanInstitute/patch_datawrapperswitching
Browse files Browse the repository at this point in the history
Patch for datawrapperswitching
  • Loading branch information
mitchthorson authored Jan 10, 2025
2 parents 79890cb + b19b9f3 commit 7259b8b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 30 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Next

## v0.12.6
- Patch: DatawrapperSwitching story to wrap the bottom block in `if` instead of `key`.

## v0.12.5
- Patch: Headline eyebrows in Drupal include a link to the Story or Data tool homepage; tweaked Headline component to do the same.
- Fix: CSS Theme variable --color-green was #ffb748, which is a kind of yellow. Changed to match style guide.
Expand Down
81 changes: 51 additions & 30 deletions src/docs/stories/DatawrapperSwitching.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,20 @@
}
];
let selectedChartLoading = "WsGs1";
const loadingChartData = [
{
value: "Toh1S",
label: "Chart #1",
ariaLabel: "Quis id magna ut esse qui nostrud magna."
},
{
value: "rgLU1",
label: "Chart #2",
ariaLabel: "Quis id magna ut esse qui nostrud magna."
}
];
let selectedChartLoading = "Toh1S";
$: selectedChartLoadingMetadata = loadingChartData.find((d) => d.value === selectedChartLoading);
</script>

<Story
Expand Down Expand Up @@ -74,13 +87,13 @@
placeholder={null}
/>
{#key selectedChart}
{#if selectedChartMetaData}
<DatawrapperIframe
datawrapperId={selectedChartMetadata.value}
title={selectedChartMetadata.label}
ariaLabel={selectedChartMetadata.ariaLabel}
/>
{/key}
{/if}
`}
>
<BasicDropdown
Expand All @@ -90,13 +103,13 @@
bind:value={selectedChart}
placeholder={null}
/>
{#key selectedChart}
{#if selectedChartMetadata}
<DatawrapperIframe
datawrapperId={selectedChartMetadata.value}
title={selectedChartMetadata.label}
ariaLabel={selectedChartMetadata.ariaLabel}
/>
{/key}
{/if}
</Story>

<Story
Expand All @@ -111,21 +124,25 @@
<Button on:click={() => (selectedChart = "91Q0t")}>Chart #2</Button>
<Button on:click={() => (selectedChart = "eaD2D")}>Chart #3</Button>
{#key selectedChart}
{#if selectedChartMetadata}
<DatawrapperIframe
datawrapperId={selectedChartMetadata.value}
title={selectedChartMetadata.label}
ariaLabel={selectedChartMetadata.ariaLabel}
/>
{/key}
{/if}
`}
>
<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} />
{/key}
{#if selectedChart}
<DatawrapperIframe
datawrapperId={selectedChartMetadata.value}
title={selectedChartMetadata.label}
ariaLabel={selectedChartMetadata.ariaLabel}
/>
{/if}
</Story>

<Story
Expand All @@ -139,29 +156,33 @@
<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}
{#if selectedChartMetadata}
<LoadingWrapper let:setChildLoaded let:setChildLoading>
{#key selectedChart}
<DatawrapperIframe
datawrapperId={selectedChartMetadata.value}
title={selectedChartMetadata.label}
ariaLabel={selectedChartMetadata.ariaLabel}
on:startrender={setChildLoading}
on:visrendered={setChildLoaded}
/>
{/key}
</LoadingWrapper>
{/if}
`}
>
<Button on:click={() => (selectedChart = "Toh1S")}>Chart #1</Button>
<Button on:click={() => (selectedChart = "rgLU1")}>Chart #2</Button>
<Button on:click={() => (selectedChartLoading = "Toh1S")}>Chart #1</Button>
<Button on:click={() => (selectedChartLoading = "rgLU1")}>Chart #2</Button>

{#key selectedChart}
{#if selectedChartLoadingMetadata}
<LoadingWrapper let:setChildLoaded let:setChildLoading>
<DatawrapperIframe
datawrapperId={selectedChartLoading}
on:startrender={setChildLoading}
on:visrendered={setChildLoaded}
/>
{#key selectedChartLoading}
<DatawrapperIframe
datawrapperId={selectedChartLoadingMetadata.value}
on:startrender={setChildLoading}
on:visrendered={setChildLoaded}
/>
{/key}
</LoadingWrapper>
{/key}
{/if}
</Story>

0 comments on commit 7259b8b

Please sign in to comment.