diff --git a/components/src/ChartList/ChartList.mdx b/components/src/ChartList/ChartList.mdx new file mode 100644 index 00000000..b89ac069 --- /dev/null +++ b/components/src/ChartList/ChartList.mdx @@ -0,0 +1,13 @@ +import { Story, Meta, Primary, Controls, Stories } from '@storybook/addon-docs/blocks'; + +import * as ChartListStories from './ChartList.stories.svelte'; + + + +# Chart List + +Utility component for displaying a list of charts with associated embed URLs during development (typically on the `/` route of your Svelte project). + + + + diff --git a/components/src/ChartList/ChartList.stories.svelte b/components/src/ChartList/ChartList.stories.svelte new file mode 100644 index 00000000..bd9ffce0 --- /dev/null +++ b/components/src/ChartList/ChartList.stories.svelte @@ -0,0 +1,48 @@ + + + { + const canvas = within(canvasElement); + + await step('Project title renders', async () => { + const titleEl = canvas.getByTestId('chartlist-project-title'); + expect(titleEl).toHaveTextContent('Grafiken für p110: Wie sieht der Wald von morgen aus?'); + }); + + await step('All chart list items render', async () => { + testCharts.forEach((c) => { + const el = canvas.getByText(c.title); + expect(el).toBeTruthy(); + }); + }); + }} +> + + + + diff --git a/components/src/ChartList/ChartList.svelte b/components/src/ChartList/ChartList.svelte new file mode 100644 index 00000000..cf179fbf --- /dev/null +++ b/components/src/ChartList/ChartList.svelte @@ -0,0 +1,117 @@ + + +
+
+

Grafiken für {project}

+ {#if charts} + + + + + {#if baseUrl} + + {/if} + + + + {#each charts as chart} + + + {#if baseUrl} + + {/if} + + {/each} + +
TitleEmbed URL
+ {chart.title} + + +
+ {/if} +
+
+ + diff --git a/components/src/ChartList/index.ts b/components/src/ChartList/index.ts new file mode 100644 index 00000000..84db6e79 --- /dev/null +++ b/components/src/ChartList/index.ts @@ -0,0 +1,2 @@ +import ChartList from './ChartList.svelte'; +export default ChartList; diff --git a/components/src/index.js b/components/src/index.js index 6d2ed3cf..46a50e5c 100644 --- a/components/src/index.js +++ b/components/src/index.js @@ -39,3 +39,6 @@ export { default as Select } from './Select/Select.svelte'; // Deprecated export { default as Autocomplete } from './Autocomplete/Autocomplete.svelte'; + +// Meta +export { default as ChartList } from './ChartList/ChartList.svelte';