diff --git a/CHANGELOG.md b/CHANGELOG.md index 23a1bc2b..851fcfcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Next +- Add LoadingWrapper component to provide a loading graphic for components that need it + ## v0.8.0 - Simplify CSS in Toggle component diff --git a/src/docs/DatawrapperSwitching.docs.mdx b/src/docs/DatawrapperSwitching.docs.mdx index d5ec1898..bc2c05ae 100644 --- a/src/docs/DatawrapperSwitching.docs.mdx +++ b/src/docs/DatawrapperSwitching.docs.mdx @@ -14,3 +14,7 @@ It's useful to switch between Datawrapper iframes. Below, we demonstrate two use ### Switching with buttons + +### Switching with buttons (and loading wrapper) + + diff --git a/src/docs/stories/DatawrapperSwitching.stories.svelte b/src/docs/stories/DatawrapperSwitching.stories.svelte index 4af358c5..22d6ccd6 100644 --- a/src/docs/stories/DatawrapperSwitching.stories.svelte +++ b/src/docs/stories/DatawrapperSwitching.stories.svelte @@ -6,6 +6,8 @@ {/key} + + + + + {/key} +`} +> + + + + {#key selectedChart} + + + + {/key} + diff --git a/src/lib/DatawrapperIframe/DatawrapperIframe.stories.svelte b/src/lib/DatawrapperIframe/DatawrapperIframe.stories.svelte index bde74b48..8b82c8ca 100644 --- a/src/lib/DatawrapperIframe/DatawrapperIframe.stories.svelte +++ b/src/lib/DatawrapperIframe/DatawrapperIframe.stories.svelte @@ -10,7 +10,7 @@ docs: { description: { component: - "Datawrapper iframe with event dispatching enabled. All interaction events are accessible via on:eventname (no periods) on the `DatawrapperIframe` Svelte component itself.

The complete event list and associated descriptions can be found here.

In April 2024, the vis.rendered event was added to the Datawrapper event list (per the Urban team's request) in order to track when a visualization had been rendered/painted on the page. This is useful if there is a longer loading visualization (like a large map) and you'd like to indicate to the user that the visualization is still loading." + "Datawrapper iframe with event dispatching enabled. All interaction events are accessible via on:eventname (no periods) on the `DatawrapperIframe` Svelte component itself. The complete event list and associated descriptions can be found here.

Examples of how to setup \"switching\" between Datawrapper charts with a dropdown or button controls can be found in the Examples section here.

In April 2024, the vis.rendered event was added to the Datawrapper event list (per the Urban team's request) in order to track when a visualization had been rendered/painted on the page. This is useful if there is a longer loading visualization (like a large map) and you'd like to indicate to the user that the visualization is still loading.

The `startrender` event is available via the component's `beforeUpdate()` function in order to track when the iframe starts to load. This can be combined with the `vis.rendered` event to track when the visualization has been rendered/painted on the page in combination with the LoadingWrapper component." } } } diff --git a/src/lib/DatawrapperIframe/DatawrapperIframe.svelte b/src/lib/DatawrapperIframe/DatawrapperIframe.svelte index d0559b9e..eaee3d9e 100644 --- a/src/lib/DatawrapperIframe/DatawrapperIframe.svelte +++ b/src/lib/DatawrapperIframe/DatawrapperIframe.svelte @@ -1,5 +1,5 @@ + + + + + + Amet est Lorem qui ullamco laboris velit. Incididunt est sunt exercitation qui ea. Officia + Lorem est labore amet irure nostrud. Exercitation Lorem do consectetur enim esse quis mollit + cupidatat aliqua magna. Ipsum irure anim commodo Lorem. + + + + + + + + Amet est Lorem qui ullamco laboris velit. Incididunt est sunt exercitation qui ea. Officia + Lorem est labore amet irure nostrud. Exercitation Lorem do consectetur enim esse quis mollit + cupidatat aliqua magna. Ipsum irure anim commodo Lorem. + + + + + + + + + diff --git a/src/lib/LoadingWrapper/LoadingWrapper.svelte b/src/lib/LoadingWrapper/LoadingWrapper.svelte new file mode 100644 index 00000000..43db7e7d --- /dev/null +++ b/src/lib/LoadingWrapper/LoadingWrapper.svelte @@ -0,0 +1,59 @@ + + +
+ {#if isChildLoading} +
+ + + +
+ {/if} + +
+ + diff --git a/src/lib/index.js b/src/lib/index.js index bafe22a8..ccfe1829 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -25,3 +25,4 @@ export { default as Scrolly } from "./Scrolly/Scrolly.svelte"; export { default as Analytics, logClickToGA } from "./Analytics/Analytics.svelte"; export { default as Headline } from "./Headline/Headline.svelte"; export { default as PymChild } from "./Pym/PymChild.svelte"; +export { default as LoadingWrapper } from "./LoadingWrapper/LoadingWrapper.svelte";