@swr-data-lab/components 1.10.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/main.ts +7 -13
- package/.storybook/preview.ts +1 -1
- package/package.json +68 -69
- package/src/Autocomplete/Autocomplete.stories.svelte +2 -2
- package/src/Autocomplete/Autocomplete.svelte +0 -3
- package/src/Button/Button.stories.svelte +2 -2
- package/src/Caption/Caption.stories.svelte +2 -2
- package/src/Card/Card.stories.svelte +1 -1
- package/src/ChartFooter/ChartFooter.mdx +1 -1
- package/src/ChartFooter/ChartFooter.stories.svelte +2 -2
- package/src/ChartHeader/ChartHeader.mdx +1 -1
- package/src/ChartHeader/ChartHeader.stories.svelte +2 -1
- package/src/Copy/Copy.stories.svelte +2 -2
- package/src/DesignTokens/DesignTokens.mdx +1 -1
- package/src/DesignTokens/DesignTokens.svelte +9 -1
- package/src/FormLabel/FormLabel.mdx +13 -0
- package/src/FormLabel/FormLabel.stories.svelte +52 -0
- package/src/FormLabel/FormLabel.svelte +36 -0
- package/src/FormLabel/index.ts +2 -0
- package/src/Headline/Headline.stories.svelte +1 -1
- package/src/HighlightCard/HighlightCard.stories.svelte +2 -2
- package/src/Input/Input.svelte +3 -4
- package/src/Intro.mdx +1 -1
- package/src/Logotype/Logotype.stories.svelte +1 -1
- package/src/Middot/Middot.stories.svelte +1 -1
- package/src/Note/Note.stories.svelte +1 -1
- package/src/Select/Select.mdx +1 -1
- package/src/Select/Select.stories.svelte +7 -3
- package/src/Select/SelectStoriesTemplate.svelte +2 -6
- package/src/Switcher/Switcher.mdx +1 -1
- package/src/Switcher/Switcher.stories.svelte +3 -2
- package/src/Switcher/Switcher.svelte +3 -7
- package/src/styles/base.scss +0 -8
- package/vitest.workspace.ts +1 -1
package/.storybook/main.ts
CHANGED
|
@@ -11,20 +11,14 @@ const config: StorybookConfig = {
|
|
|
11
11
|
'../src/**/*.mdx'
|
|
12
12
|
],
|
|
13
13
|
|
|
14
|
-
addons: [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
getAbsolutePath('@storybook/addon-links'),
|
|
22
|
-
getAbsolutePath('@storybook/addon-essentials'),
|
|
23
|
-
getAbsolutePath('@chromatic-com/storybook'),
|
|
24
|
-
getAbsolutePath('@storybook/experimental-addon-test')
|
|
25
|
-
],
|
|
14
|
+
addons: [{
|
|
15
|
+
name: getAbsolutePath("@storybook/addon-svelte-csf"),
|
|
16
|
+
options: {
|
|
17
|
+
legacyTemplate: true
|
|
18
|
+
}
|
|
19
|
+
}, getAbsolutePath('@storybook/addon-links'), getAbsolutePath('@chromatic-com/storybook'), getAbsolutePath('@storybook/addon-vitest'), getAbsolutePath("@storybook/addon-docs")],
|
|
26
20
|
framework: {
|
|
27
|
-
name:
|
|
21
|
+
name: getAbsolutePath("@storybook/sveltekit"),
|
|
28
22
|
options: {}
|
|
29
23
|
},
|
|
30
24
|
|
package/.storybook/preview.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,71 +1,70 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"version": "1.10.0"
|
|
2
|
+
"name": "@swr-data-lab/components",
|
|
3
|
+
"description": "SWR Data Lab component library",
|
|
4
|
+
"author": "SWR Data Lab",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "restricted"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "vite dev",
|
|
10
|
+
"build": "vite build",
|
|
11
|
+
"preview": "vite preview",
|
|
12
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
13
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
14
|
+
"storybook": "storybook dev -p 6006",
|
|
15
|
+
"start": "storybook dev -p 6006",
|
|
16
|
+
"build-storybook": "storybook build --disable-telemetry",
|
|
17
|
+
"test-storybook": "vitest run --project=storybook",
|
|
18
|
+
"test-storybook:ci": "concurrently -k -s first -n \"Storybook,Test\" -c \"magenta,blue\" \"npm run build-storybook --quiet && npx http-server storybook-static --port 6006 --silent\" \"wait-on tcp:6006 && npm run test-storybook\"",
|
|
19
|
+
"semantic-release": "semantic-release"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"svelte-select": "^5.8.3"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@chromatic-com/storybook": "^4.0.0-next.6",
|
|
26
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
27
|
+
"@semantic-release/git": "^10.0.1",
|
|
28
|
+
"@semantic-release/npm": "^12.0.1",
|
|
29
|
+
"@storybook/addon-docs": "^9.0.0-beta.11",
|
|
30
|
+
"@storybook/addon-links": "^9.0.0-beta.11",
|
|
31
|
+
"@storybook/addon-svelte-csf": "^5.0.0-next.30",
|
|
32
|
+
"@storybook/addon-vitest": "^9.0.0-beta.11",
|
|
33
|
+
"@storybook/sveltekit": "^9.0.0-beta.11",
|
|
34
|
+
"@storybook/test-runner": "^0.23.0-next.1",
|
|
35
|
+
"@sveltejs/adapter-auto": "^3.0.0",
|
|
36
|
+
"@sveltejs/kit": "^2.0.0",
|
|
37
|
+
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
|
38
|
+
"@vitest/browser": "^3.1.1",
|
|
39
|
+
"@vitest/coverage-v8": "^3.1.1",
|
|
40
|
+
"concurrently": "^9.0.1",
|
|
41
|
+
"http-server": "^14.1.1",
|
|
42
|
+
"playwright": "^1.51.1",
|
|
43
|
+
"sass-embedded": "^1.78.0",
|
|
44
|
+
"semantic-release": "^24.1.2",
|
|
45
|
+
"storybook": "^9.0.0-beta.11",
|
|
46
|
+
"svelte": "^5.23.0",
|
|
47
|
+
"svelte-check": "^4.0.0",
|
|
48
|
+
"typescript": "^5.0.0",
|
|
49
|
+
"vite": "^6.0.0",
|
|
50
|
+
"vitest": "^3.1.1",
|
|
51
|
+
"wait-on": "^8.0.1"
|
|
52
|
+
},
|
|
53
|
+
"type": "module",
|
|
54
|
+
"release": {
|
|
55
|
+
"plugins": [
|
|
56
|
+
"@semantic-release/commit-analyzer",
|
|
57
|
+
"@semantic-release/release-notes-generator",
|
|
58
|
+
"@semantic-release/npm"
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
"exports": {
|
|
62
|
+
".": {
|
|
63
|
+
"svelte": "./src/index.js"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"version": "1.11.1",
|
|
67
|
+
"overrides": {
|
|
68
|
+
"storybook": "$storybook"
|
|
69
|
+
}
|
|
71
70
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script module>
|
|
2
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { userEvent, within, expect } from '
|
|
3
|
+
import { userEvent, within, expect } from 'storybook/test';
|
|
4
4
|
import DesignTokens from '../DesignTokens/DesignTokens.svelte';
|
|
5
5
|
|
|
6
6
|
import Autocomplete from './Autocomplete.svelte';
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
<Story
|
|
23
23
|
name="Basic"
|
|
24
|
-
|
|
24
|
+
asChild
|
|
25
25
|
play={async ({ canvasElement, step }) => {
|
|
26
26
|
const canvas = within(canvasElement);
|
|
27
27
|
const input = canvas.getByTestId('autocomplete-input');
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
});
|
|
10
10
|
</script>
|
|
11
11
|
|
|
12
|
-
<Story name="Basic">
|
|
12
|
+
<Story name="Basic" asChild>
|
|
13
13
|
<DesignTokens>
|
|
14
14
|
<Button label="This is a button label"></Button>
|
|
15
15
|
</DesignTokens>
|
|
16
16
|
</Story>
|
|
17
|
-
<Story name="Disabled">
|
|
17
|
+
<Story name="Disabled" asChild>
|
|
18
18
|
<DesignTokens>
|
|
19
19
|
<Button disabled label="This button is disabled"></Button>
|
|
20
20
|
</DesignTokens>
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
});
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
|
-
<Story name="Default">
|
|
13
|
+
<Story name="Default" asChild>
|
|
14
14
|
<DesignTokens>
|
|
15
15
|
<Caption>Björn Schittenhelm, Apotheker aus Holzgerlingen (Kreis Böblingen)</Caption>
|
|
16
16
|
</DesignTokens>
|
|
17
17
|
</Story>
|
|
18
|
-
<Story name="Bold">
|
|
18
|
+
<Story name="Bold" asChild>
|
|
19
19
|
<DesignTokens>
|
|
20
20
|
<Caption weight="bold">
|
|
21
21
|
Björn Schittenhelm, Apotheker aus Holzgerlingen (Kreis Böblingen)
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
});
|
|
12
12
|
</script>
|
|
13
13
|
|
|
14
|
-
<Story name="One-up"
|
|
14
|
+
<Story name="One-up" asChild>
|
|
15
15
|
<DesignTokens>
|
|
16
16
|
<ChartFooter layout="one-up">
|
|
17
17
|
Daten: <a href="#1">Zensus 2022</a>
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
</DesignTokens>
|
|
23
23
|
</Story>
|
|
24
24
|
|
|
25
|
-
<Story name="Two-up">
|
|
25
|
+
<Story name="Two-up" asChild>
|
|
26
26
|
<DesignTokens>
|
|
27
27
|
<ChartFooter layout="two-up">
|
|
28
28
|
Daten: <a href="#1">Zensus 2022</a>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script context="module">
|
|
2
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
3
|
import DesignTokens from '../DesignTokens/DesignTokens.svelte';
|
|
4
|
-
import { expect } from '
|
|
4
|
+
import { expect } from 'storybook/test';
|
|
5
5
|
import ChartHeader from './ChartHeader.svelte';
|
|
6
6
|
|
|
7
7
|
const { Story } = defineMeta({
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
<Story
|
|
14
14
|
name="Default"
|
|
15
|
+
asChild
|
|
15
16
|
play={async ({ step }) => {
|
|
16
17
|
await step('Container has ID attribute derived from title prop', async () => {
|
|
17
18
|
const containerEl = document.querySelector('#mehr-uber-60-jahrige-in-allen-berufen');
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
});
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
|
-
<Story name="Default">
|
|
13
|
+
<Story name="Default" asChild>
|
|
14
14
|
<DesignTokens>
|
|
15
15
|
<Copy>
|
|
16
16
|
Björn Schittenhelm, Apotheker aus Holzgerlingen (Kreis Böblingen), bedient derzeit
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
</Copy>
|
|
21
21
|
</DesignTokens>
|
|
22
22
|
</Story>
|
|
23
|
-
<Story name="Bold">
|
|
23
|
+
<Story name="Bold" asChild>
|
|
24
24
|
<DesignTokens>
|
|
25
25
|
<Copy weight="bold">
|
|
26
26
|
Björn Schittenhelm, Apotheker aus Holzgerlingen (Kreis Böblingen), bedient derzeit
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Title, Story, ColorPalette, ColorItem, Meta, Typeset, Canvas } from '@storybook/blocks';
|
|
1
|
+
import { Title, Story, ColorPalette, ColorItem, Meta, Typeset, Canvas } from '@storybook/addon-docs/blocks';
|
|
2
2
|
import { shades, scales, typography } from "./Tokens"
|
|
3
3
|
|
|
4
4
|
import * as HeadlineStories from "../Headline/Headline.stories.svelte"
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
2
3
|
import { shades } from './Tokens';
|
|
3
4
|
|
|
5
|
+
interface DesignTokensProps {
|
|
6
|
+
children?: Snippet;
|
|
7
|
+
}
|
|
8
|
+
let { children }: DesignTokensProps = $props();
|
|
9
|
+
|
|
4
10
|
const rules = [
|
|
5
11
|
...Object.keys(shades).map((key) => {
|
|
6
12
|
return Object.entries(shades[key])
|
|
@@ -16,7 +22,9 @@
|
|
|
16
22
|
</script>
|
|
17
23
|
|
|
18
24
|
<div class="container" style={rules.join(';')}>
|
|
19
|
-
|
|
25
|
+
{#if children}
|
|
26
|
+
{@render children()}
|
|
27
|
+
{/if}
|
|
20
28
|
</div>
|
|
21
29
|
|
|
22
30
|
<style lang="scss">
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Story, Meta, Primary, Controls, Stories } from '@storybook/addon-docs/blocks';
|
|
2
|
+
|
|
3
|
+
import * as FormLabelStories from './FormLabel.stories.svelte';
|
|
4
|
+
|
|
5
|
+
<Meta of={FormLabelStories}/>
|
|
6
|
+
|
|
7
|
+
# Form Label
|
|
8
|
+
|
|
9
|
+
Standard form label. The `htmlFor` prop is required to semantically link the label to the form element it describes.
|
|
10
|
+
|
|
11
|
+
<Controls />
|
|
12
|
+
|
|
13
|
+
<Stories/>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { userEvent, within, expect } from 'storybook/test';
|
|
4
|
+
|
|
5
|
+
import DesignTokens from '../DesignTokens/DesignTokens.svelte';
|
|
6
|
+
|
|
7
|
+
import FormLabel from './FormLabel.svelte';
|
|
8
|
+
import Select from '../Select/Select.svelte';
|
|
9
|
+
|
|
10
|
+
const { Story } = defineMeta({
|
|
11
|
+
title: 'Form/Label',
|
|
12
|
+
component: FormLabel
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<Story name="Default" asChild>
|
|
17
|
+
<DesignTokens>
|
|
18
|
+
<FormLabel htmlFor="">Deine Gemeinde</FormLabel>
|
|
19
|
+
</DesignTokens>
|
|
20
|
+
</Story>
|
|
21
|
+
|
|
22
|
+
<Story
|
|
23
|
+
name="With Select"
|
|
24
|
+
asChild
|
|
25
|
+
play={async ({ canvasElement, step }) => {
|
|
26
|
+
const canvas = within(canvasElement);
|
|
27
|
+
const label = canvas.getByTestId('label-container');
|
|
28
|
+
const input = canvas.getByPlaceholderText('...');
|
|
29
|
+
await step('Label renders children', async () => {
|
|
30
|
+
await userEvent.click(label);
|
|
31
|
+
expect(label).toHaveTextContent('Deine Gemeinde');
|
|
32
|
+
});
|
|
33
|
+
await step('Clicking the label focuses the input', async () => {
|
|
34
|
+
await userEvent.click(label);
|
|
35
|
+
expect(input).toHaveFocus();
|
|
36
|
+
});
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
<DesignTokens>
|
|
40
|
+
<FormLabel htmlFor="select-gemeinde">Deine Gemeinde</FormLabel>
|
|
41
|
+
<Select
|
|
42
|
+
inputId="select-gemeinde"
|
|
43
|
+
placeholder="..."
|
|
44
|
+
value={undefined}
|
|
45
|
+
items={[
|
|
46
|
+
{ value: 'konstanz', label: 'Konstanz' },
|
|
47
|
+
{ value: 'stuttgart', label: 'Stuttgart' },
|
|
48
|
+
{ value: 'heidelberg', label: 'Heidelberg' }
|
|
49
|
+
]}
|
|
50
|
+
></Select>
|
|
51
|
+
</DesignTokens>
|
|
52
|
+
</Story>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
interface FormLabelProps {
|
|
5
|
+
as?: string;
|
|
6
|
+
htmlFor?: string;
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
}
|
|
9
|
+
let { as = 'label', htmlFor, children }: FormLabelProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
{#if as == 'legend'}
|
|
13
|
+
<legend class="container" data-testid="label-container">
|
|
14
|
+
{#if children}
|
|
15
|
+
{@render children()}
|
|
16
|
+
{/if}
|
|
17
|
+
</legend>
|
|
18
|
+
{/if}
|
|
19
|
+
{#if as == 'label'}
|
|
20
|
+
<label class="container" for={htmlFor} data-testid="label-container">
|
|
21
|
+
{#if children}
|
|
22
|
+
{@render children()}
|
|
23
|
+
{/if}
|
|
24
|
+
</label>
|
|
25
|
+
{/if}
|
|
26
|
+
|
|
27
|
+
<style>
|
|
28
|
+
.container {
|
|
29
|
+
font-family: var(--swr-text);
|
|
30
|
+
font-size: var(--fs-small-1);
|
|
31
|
+
font-weight: 400;
|
|
32
|
+
margin-bottom: 0.25em;
|
|
33
|
+
display: inline-block;
|
|
34
|
+
letter-spacing: 0.005em;
|
|
35
|
+
}
|
|
36
|
+
</style>
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
});
|
|
10
10
|
</script>
|
|
11
11
|
|
|
12
|
-
<Story name="Basic HighlightCard">
|
|
12
|
+
<Story name="Basic HighlightCard" asChild>
|
|
13
13
|
<DesignTokens>
|
|
14
14
|
<HighlightCard
|
|
15
15
|
topline="Die letzte Großspende liegt bei"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
</DesignTokens>
|
|
21
21
|
</Story>
|
|
22
22
|
|
|
23
|
-
<Story name="Multiple HighlightCards">
|
|
23
|
+
<Story name="Multiple HighlightCards" asChild>
|
|
24
24
|
<DesignTokens>
|
|
25
25
|
<div class="highlight-cards">
|
|
26
26
|
<HighlightCard
|
package/src/Input/Input.svelte
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import FormLabel from '../FormLabel/FormLabel.svelte';
|
|
3
|
+
|
|
2
4
|
export let label: string = '';
|
|
3
5
|
export let name: string = '';
|
|
4
6
|
export let placeholder: string = '';
|
|
@@ -6,16 +8,13 @@
|
|
|
6
8
|
</script>
|
|
7
9
|
|
|
8
10
|
<div class="container">
|
|
9
|
-
<
|
|
11
|
+
<FormLabel htmlFor={name}>{label}</FormLabel>
|
|
10
12
|
<input {name} type="text" {placeholder} bind:value />
|
|
11
13
|
</div>
|
|
12
14
|
|
|
13
15
|
<style lang="scss">
|
|
14
16
|
@use '../styles/base.scss';
|
|
15
17
|
|
|
16
|
-
label {
|
|
17
|
-
@extend %form-label;
|
|
18
|
-
}
|
|
19
18
|
input {
|
|
20
19
|
@extend %form-input;
|
|
21
20
|
}
|
package/src/Intro.mdx
CHANGED
package/src/Select/Select.mdx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script context="module" lang="ts">
|
|
2
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
3
|
import Select from './Select.svelte';
|
|
4
|
+
import FormLabel from '../FormLabel/FormLabel.svelte';
|
|
4
5
|
import StoryTemplate from './SelectStoriesTemplate.svelte';
|
|
5
6
|
import jobsData from './mock_data/jobs.json';
|
|
6
7
|
|
|
@@ -11,13 +12,14 @@
|
|
|
11
12
|
</script>
|
|
12
13
|
|
|
13
14
|
<script lang="ts">
|
|
14
|
-
import { userEvent, within, expect } from '
|
|
15
|
+
import { userEvent, within, expect } from 'storybook/test';
|
|
15
16
|
import { type SelectItem } from './Select.types';
|
|
16
17
|
let selectedItem: SelectItem | undefined = undefined;
|
|
17
18
|
</script>
|
|
18
19
|
|
|
19
20
|
<Story
|
|
20
21
|
name="Simple"
|
|
22
|
+
asChild
|
|
21
23
|
play={async ({ canvasElement, step }) => {
|
|
22
24
|
const canvas = within(canvasElement);
|
|
23
25
|
const select = canvas.getByLabelText('Select');
|
|
@@ -59,7 +61,7 @@
|
|
|
59
61
|
/>
|
|
60
62
|
</Story>
|
|
61
63
|
|
|
62
|
-
<Story name="Grouped">
|
|
64
|
+
<Story name="Grouped" asChild>
|
|
63
65
|
<StoryTemplate
|
|
64
66
|
bind:selectedItem
|
|
65
67
|
args={{
|
|
@@ -76,6 +78,7 @@
|
|
|
76
78
|
|
|
77
79
|
<Story
|
|
78
80
|
name="Grouped (group header selectable)"
|
|
81
|
+
asChild
|
|
79
82
|
play={async ({ canvasElement, step }) => {
|
|
80
83
|
const canvas = within(canvasElement);
|
|
81
84
|
const select = canvas.getByLabelText('Select');
|
|
@@ -123,6 +126,7 @@
|
|
|
123
126
|
|
|
124
127
|
<Story
|
|
125
128
|
name="Custom items"
|
|
129
|
+
asChild
|
|
126
130
|
play={async ({ canvasElement, step }) => {
|
|
127
131
|
const canvas = within(canvasElement);
|
|
128
132
|
const select = canvas.getByLabelText('Berufe');
|
|
@@ -148,7 +152,7 @@
|
|
|
148
152
|
>
|
|
149
153
|
<StoryTemplate>
|
|
150
154
|
{#snippet demoComponent()}
|
|
151
|
-
<
|
|
155
|
+
<FormLabel htmlFor="job-select">Berufe</FormLabel>
|
|
152
156
|
<Select
|
|
153
157
|
bind:value={selectedItem}
|
|
154
158
|
inputId="job-select"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import Select from './Select.svelte';
|
|
3
|
+
import FormLabel from '../FormLabel/FormLabel.svelte';
|
|
3
4
|
import DesignTokens from '../DesignTokens/DesignTokens.svelte';
|
|
4
5
|
|
|
5
6
|
let { args = null, selectedItem = $bindable(), demoComponent = null } = $props();
|
|
@@ -9,7 +10,7 @@
|
|
|
9
10
|
{#if demoComponent}
|
|
10
11
|
{@render demoComponent()}
|
|
11
12
|
{:else}
|
|
12
|
-
<
|
|
13
|
+
<FormLabel htmlFor={args.inputId}>Select</FormLabel>
|
|
13
14
|
<Select {...args} bind:value={selectedItem} />
|
|
14
15
|
{/if}
|
|
15
16
|
</DesignTokens>
|
|
@@ -20,11 +21,6 @@ value = {JSON.stringify(selectedItem, null, ' ')}</pre>
|
|
|
20
21
|
{/if}
|
|
21
22
|
|
|
22
23
|
<style>
|
|
23
|
-
label {
|
|
24
|
-
display: block;
|
|
25
|
-
font-family: var(--swr-sans);
|
|
26
|
-
margin-bottom: 0.25em;
|
|
27
|
-
}
|
|
28
24
|
.output {
|
|
29
25
|
display: block;
|
|
30
26
|
margin-top: 1rem;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
3
|
import Switcher from './Switcher.svelte';
|
|
4
4
|
import DesignTokens from '../DesignTokens/DesignTokens.svelte';
|
|
5
|
-
import { userEvent, within, expect } from '
|
|
5
|
+
import { userEvent, within, expect } from 'storybook/test';
|
|
6
6
|
|
|
7
7
|
const { Story } = defineMeta({
|
|
8
8
|
title: 'Form/Switcher',
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
});
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
|
-
<Story name="Two Options">
|
|
13
|
+
<Story name="Two Options" asChild>
|
|
14
14
|
<DesignTokens>
|
|
15
15
|
<Switcher options={['Option A', 'Option B']} value="Option A" size="default" label="Label" />
|
|
16
16
|
</DesignTokens>
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
<Story
|
|
20
20
|
name="Four Options"
|
|
21
|
+
asChild
|
|
21
22
|
play={async ({ canvasElement, step }) => {
|
|
22
23
|
const canvas = within(canvasElement);
|
|
23
24
|
await step('Clicking selects the expected option', async () => {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import FormLabel from '../FormLabel/FormLabel.svelte';
|
|
3
|
+
|
|
2
4
|
interface SwitcherProps {
|
|
3
5
|
/**
|
|
4
6
|
* Human-readable label
|
|
@@ -29,7 +31,7 @@
|
|
|
29
31
|
</script>
|
|
30
32
|
|
|
31
33
|
<fieldset class="container" class:small={size === 'small'}>
|
|
32
|
-
<legend>{label}</
|
|
34
|
+
<FormLabel as="legend">{label}</FormLabel>
|
|
33
35
|
<ul>
|
|
34
36
|
{#each options as o (o)}
|
|
35
37
|
<li class:is-selected={o === value}>
|
|
@@ -50,12 +52,6 @@
|
|
|
50
52
|
font-family: var(--swr-sans);
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
legend {
|
|
54
|
-
font-size: var(--fs-small-2);
|
|
55
|
-
font-weight: 500;
|
|
56
|
-
margin-bottom: 0.35em;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
55
|
ul {
|
|
60
56
|
width: 100%;
|
|
61
57
|
display: flex;
|
package/src/styles/base.scss
CHANGED
|
@@ -7,14 +7,6 @@ $bp-l: 1024px;
|
|
|
7
7
|
$bp-xl: 1440px;
|
|
8
8
|
|
|
9
9
|
// TODO drop everything below
|
|
10
|
-
%form-label {
|
|
11
|
-
font-family: var(--swr-sans);
|
|
12
|
-
font-size: 0.9rem;
|
|
13
|
-
line-height: 1;
|
|
14
|
-
letter-spacing: 0.0045em;
|
|
15
|
-
display: block;
|
|
16
|
-
margin-bottom: 0.5em;
|
|
17
|
-
}
|
|
18
10
|
|
|
19
11
|
%form-input {
|
|
20
12
|
font-family: var(--swr-sans);
|
package/vitest.workspace.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
3
3
|
|
|
4
4
|
import { defineWorkspace } from 'vitest/config';
|
|
5
5
|
|
|
6
|
-
import { storybookTest } from '@storybook/
|
|
6
|
+
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
|
|
7
7
|
|
|
8
8
|
const dirname =
|
|
9
9
|
typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));
|