@swr-data-lab/components 1.9.1 → 1.11.0
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 +2 -2
- package/package.json +68 -69
- package/src/Autocomplete/Autocomplete.stories.svelte +2 -3
- package/src/Autocomplete/Autocomplete.svelte +4 -5
- package/src/Button/Button.stories.svelte +20 -0
- package/src/Button/Button.svelte +14 -11
- package/src/Caption/Caption.stories.svelte +23 -0
- package/src/Caption/Caption.svelte +29 -0
- package/src/Caption/index.ts +2 -0
- package/src/Card/Card.stories.svelte +1 -2
- package/src/Card/Card.svelte +5 -3
- package/src/ChartFooter/ChartFooter.mdx +1 -1
- package/src/ChartFooter/ChartFooter.stories.svelte +1 -2
- package/src/ChartFooter/ChartFooter.svelte +7 -20
- package/src/ChartHeader/ChartHeader.mdx +2 -1
- package/src/ChartHeader/ChartHeader.stories.svelte +2 -3
- package/src/ChartHeader/ChartHeader.svelte +9 -16
- package/src/Copy/Copy.stories.svelte +31 -0
- package/src/Copy/Copy.svelte +29 -0
- package/src/Copy/index.ts +2 -0
- package/src/DesignTokens/DesignTokens.mdx +50 -14
- package/src/DesignTokens/DesignTokens.svelte +48 -22
- package/src/DesignTokens/{Tokens.js → Tokens.ts} +41 -26
- package/src/FormLabel/FormLabel.mdx +13 -0
- package/src/FormLabel/FormLabel.stories.svelte +50 -0
- package/src/FormLabel/FormLabel.svelte +36 -0
- package/src/FormLabel/index.ts +2 -0
- package/src/Headline/Headline.stories.svelte +16 -0
- package/src/Headline/Headline.svelte +23 -0
- package/src/Headline/index.ts +2 -0
- package/src/HighlightCard/HighlightCard.stories.svelte +1 -2
- package/src/HighlightCard/HighlightCard.svelte +1 -2
- package/src/Input/Input.svelte +3 -4
- package/src/Intro.mdx +1 -1
- package/src/Logotype/Logotype.stories.svelte +1 -2
- package/src/Middot/Middot.stories.svelte +1 -2
- package/src/Note/Note.stories.svelte +22 -0
- package/src/Note/Note.svelte +38 -0
- package/src/Note/index.ts +2 -0
- package/src/Select/Select.mdx +1 -1
- package/src/Select/Select.stories.svelte +4 -4
- package/src/Select/SelectStoriesTemplate.svelte +2 -6
- package/src/Switcher/Switcher.mdx +1 -1
- package/src/Switcher/Switcher.stories.svelte +2 -3
- package/src/Switcher/Switcher.svelte +8 -12
- package/src/styles/base.scss +8 -33
- package/vitest.workspace.ts +1 -1
|
@@ -1,10 +1,29 @@
|
|
|
1
|
-
import { Title, Story, ColorPalette, ColorItem, Meta, Typeset } from '@storybook/blocks';
|
|
2
|
-
import { shades, scales } from "./Tokens"
|
|
1
|
+
import { Title, Story, ColorPalette, ColorItem, Meta, Typeset, Canvas } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import { shades, scales, typography } from "./Tokens"
|
|
3
|
+
|
|
4
|
+
import * as HeadlineStories from "../Headline/Headline.stories.svelte"
|
|
5
|
+
import * as CopyStories from "../Copy/Copy.stories.svelte"
|
|
6
|
+
import * as CaptionStories from "../Caption/Caption.stories.svelte"
|
|
7
|
+
import * as NoteStories from "../Note/Note.stories.svelte"
|
|
3
8
|
|
|
4
9
|
<Meta title='Design Tokens'/>
|
|
5
10
|
|
|
6
11
|
# Design Tokens
|
|
7
12
|
|
|
13
|
+
## Table of Contents
|
|
14
|
+
|
|
15
|
+
- [Usage](#usage)
|
|
16
|
+
- [Web](#web)
|
|
17
|
+
- [Figma](#figma)
|
|
18
|
+
- [Typography](#typography)
|
|
19
|
+
- [Sizes](#sizes)
|
|
20
|
+
- [Styles](#styles)
|
|
21
|
+
- [Colours](#colours)
|
|
22
|
+
- [Shades](#shades)
|
|
23
|
+
- [Linear scales](#linear-scales)
|
|
24
|
+
- [Categorical Scales](#categorical-scales)
|
|
25
|
+
- [Divergent Scales](#divergent-scales)
|
|
26
|
+
|
|
8
27
|
## Usage
|
|
9
28
|
|
|
10
29
|
### Web
|
|
@@ -39,12 +58,32 @@ const sampleScale = scaleThreshold([0, 10], tokens.scales.red_blue);
|
|
|
39
58
|
|
|
40
59
|
The tokens on this page are available as a [Figma library](https://www.figma.com/design/Wrd7uUV3GxpNXXkM5ozuHk/Datalab-Design-Tokens?node-id=0-1&t=iOqDxhuMdvEyY8VK-1). This is enabled by default for any file in the [SWR Data Lab team](https://www.figma.com/files/1125823985461580916/team/1415988138343592768).
|
|
41
60
|
|
|
42
|
-
## Available Tokens
|
|
43
61
|
|
|
44
|
-
|
|
62
|
+
## Typography
|
|
63
|
+
|
|
64
|
+
Type sizes and paragraph styles are designed to match the typography on [swr.de](https://www.swr.de/). **Styles** come with built-in settings for `line-height`, `letter-spacing`, etc. and should be preferred over using **sizes** directly.
|
|
65
|
+
|
|
66
|
+
### Styles
|
|
67
|
+
#### H2
|
|
68
|
+
<Canvas of={HeadlineStories.Default}/>
|
|
69
|
+
|
|
70
|
+
#### Copy
|
|
71
|
+
<Canvas of={CopyStories.Default}/>
|
|
72
|
+
|
|
73
|
+
#### Caption
|
|
74
|
+
<Canvas of={CaptionStories.Default}/>
|
|
45
75
|
|
|
46
|
-
|
|
76
|
+
#### Note
|
|
77
|
+
<Canvas of={NoteStories.Default}/>
|
|
47
78
|
|
|
79
|
+
### Sizes
|
|
80
|
+
<Typeset fontWeight={600} fontFamily='SWR-VAR-Text' sampleText='Pollenflug in BW: Was Heuschnupfengeplagte jetzt wissen sollten' fontSizes={Object.entries(typography.wide.sizes).map(([key, size]) => {
|
|
81
|
+
return size
|
|
82
|
+
}).reverse()}/>
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
## Colours
|
|
86
|
+
### Shades
|
|
48
87
|
<ColorPalette>
|
|
49
88
|
{["violet", "plum", "pink", "red", "orange", "yellow", "apple" , "forest","teal", "blue", "gray"].map((el, i) => {
|
|
50
89
|
return(
|
|
@@ -61,14 +100,11 @@ The tokens on this page are available as a [Figma library](https://www.figma.com
|
|
|
61
100
|
### Divergent Scales
|
|
62
101
|
|
|
63
102
|
<ColorPalette>
|
|
64
|
-
{["red_blue", "red_violet",
|
|
65
|
-
return(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
colors={scales[el]}
|
|
71
|
-
/>
|
|
72
|
-
)
|
|
103
|
+
{["red_blue", "red_violet", "red_forest", "red_apple", "red_teal", "violet_teal", "violet_orange", "blue_pink", "teal_pink", "forest_plum", "apple_plum", "orange_blue", "orange_teal"].map((el, _) => {
|
|
104
|
+
return(<ColorItem
|
|
105
|
+
title={`${el.split("_").map(c => {return c[0].toUpperCase() + c.slice(1)}).join("/")}`}
|
|
106
|
+
subtitle={el}
|
|
107
|
+
colors={scales[el]}
|
|
108
|
+
/>)
|
|
73
109
|
})}
|
|
74
110
|
</ColorPalette>
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
<script>
|
|
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])
|
|
@@ -11,35 +17,55 @@
|
|
|
11
17
|
: `--${key}-${ldb}-${index}: ${value}`;
|
|
12
18
|
})
|
|
13
19
|
.join(';');
|
|
14
|
-
})
|
|
15
|
-
,
|
|
16
|
-
'display: contents',
|
|
17
|
-
'--fast: 150ms',
|
|
18
|
-
'--slow: 300ms',
|
|
19
|
-
'--app-max-width: 40rem',
|
|
20
|
-
'--br-large: 8px',
|
|
21
|
-
'--br-small: 4px',
|
|
22
|
-
'--input-height: 2.5rem',
|
|
23
|
-
'--swr-sans: "SWR-VAR-Sans", sans-serif',
|
|
24
|
-
'--swr-text: "SWR-VAR-Text", sans-serif',
|
|
25
|
-
'--ratio: 1.15',
|
|
26
|
-
'--fs-small-3: calc(var(--fs-small-2) / var(--ratio))',
|
|
27
|
-
'--fs-small-2: calc(var(--fs-small-1) / var(--ratio))',
|
|
28
|
-
'--fs-small-1: calc(var(--fs-base) / var(--ratio))',
|
|
29
|
-
'--fs-base: clamp(1rem, calc(1.5vw + 0.25rem), 1.125rem)',
|
|
30
|
-
'--fs-large-1: calc(var(--fs-base) * var(--ratio))',
|
|
31
|
-
'--fs-large-2: calc(var(--fs-large-1) * var(--ratio))',
|
|
32
|
-
'--fs-large-3: calc(var(--fs-large-2) * var(--ratio))'
|
|
20
|
+
})
|
|
33
21
|
];
|
|
34
22
|
</script>
|
|
35
23
|
|
|
36
24
|
<div class="container" style={rules.join(';')}>
|
|
37
|
-
|
|
25
|
+
{#if children}
|
|
26
|
+
{@render children()}
|
|
27
|
+
{/if}
|
|
38
28
|
</div>
|
|
39
29
|
|
|
40
|
-
<style>
|
|
30
|
+
<style lang="scss">
|
|
31
|
+
@use '../styles/base.scss';
|
|
32
|
+
|
|
41
33
|
:global(*) {
|
|
42
34
|
margin: 0;
|
|
43
35
|
padding: 0;
|
|
44
36
|
}
|
|
37
|
+
|
|
38
|
+
.container {
|
|
39
|
+
display: contents;
|
|
40
|
+
--fast: 150ms;
|
|
41
|
+
--slow: 300ms;
|
|
42
|
+
--app-max-width: 40rem;
|
|
43
|
+
--br-large: 8px;
|
|
44
|
+
--br-small: 4px;
|
|
45
|
+
--input-height: 2.5rem;
|
|
46
|
+
--swr-text: 'SWR-VAR-Text', sans-serif;
|
|
47
|
+
--swr-sans: 'SWR-VAR-Sans', sans-serif;
|
|
48
|
+
|
|
49
|
+
// Type scale copied 1:1 from swr.de
|
|
50
|
+
|
|
51
|
+
--fs-small-3: 0.75rem;
|
|
52
|
+
--fs-small-2: 0.875rem;
|
|
53
|
+
--fs-small-1: 1rem;
|
|
54
|
+
--fs-base: 1.125rem;
|
|
55
|
+
--fs-large-1: 1.25rem;
|
|
56
|
+
--fs-large-2: 1.5rem;
|
|
57
|
+
--fs-large-3: 1.75rem;
|
|
58
|
+
--fs-large-4: 2.25rem;
|
|
59
|
+
|
|
60
|
+
@media (min-width: base.$bp-m) {
|
|
61
|
+
--fs-small-3: 0.75rem;
|
|
62
|
+
--fs-small-2: 0.875rem;
|
|
63
|
+
--fs-small-1: 1rem;
|
|
64
|
+
--fs-base: 1.25rem;
|
|
65
|
+
--fs-large-1: 1.5rem;
|
|
66
|
+
--fs-large-2: 2rem;
|
|
67
|
+
--fs-large-3: 2.5rem;
|
|
68
|
+
--fs-large-4: 3.5rem;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
45
71
|
</style>
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
interface ColourMap {
|
|
2
|
+
[index: string]: ColourPalette | ColourList;
|
|
3
|
+
}
|
|
4
|
+
interface ColourPalette {
|
|
5
|
+
[index: string]: string
|
|
6
|
+
}
|
|
7
|
+
interface ColourList {
|
|
8
|
+
[index: number]: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const shades: ColourMap = {
|
|
2
12
|
violet: {
|
|
3
13
|
light5: '#f3eefa',
|
|
4
14
|
light4: '#e5dbf5',
|
|
@@ -138,31 +148,36 @@ const shades = {
|
|
|
138
148
|
}
|
|
139
149
|
};
|
|
140
150
|
|
|
141
|
-
const scales = {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
],
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
red_forest: [...Object.entries(shades.red).reverse(), ...Object.entries(shades.forest)],
|
|
156
|
-
red_apple: [...Object.entries(shades.red).reverse(), ...Object.entries(shades.apple)],
|
|
157
|
-
red_teal: [...Object.entries(shades.red).reverse(), ...Object.entries(shades.violet)],
|
|
158
|
-
violet_orange: [...Object.entries(shades.violet).reverse(), ...Object.entries(shades.orange)],
|
|
159
|
-
orange_blue: [...Object.entries(shades.orange).reverse(), ...Object.entries(shades.blue)],
|
|
160
|
-
teal_pink: [...Object.entries(shades.teal).reverse(), ...Object.entries(shades.pink)],
|
|
161
|
-
blue_pink: [...Object.entries(shades.blue).reverse(), ...Object.entries(shades.pink)],
|
|
162
|
-
apple_plum: [...Object.entries(shades.apple).reverse(), ...Object.entries(shades.plum)],
|
|
163
|
-
forest_plum: [...Object.entries(shades.forest).reverse(), ...Object.entries(shades.plum)]
|
|
151
|
+
const scales: ColourMap = {
|
|
152
|
+
red_blue: [...Object.values(shades.red).reverse(), ...Object.values(shades.blue)],
|
|
153
|
+
red_violet: [...Object.values(shades.red).reverse(), ...Object.values(shades.violet)],
|
|
154
|
+
violet_teal: [...Object.values(shades.violet).reverse(), ...Object.values(shades.teal)],
|
|
155
|
+
orange_teal: [...Object.values(shades.orange).reverse(), ...Object.values(shades.teal)],
|
|
156
|
+
red_forest: [...Object.values(shades.red).reverse(), ...Object.values(shades.forest)],
|
|
157
|
+
red_apple: [...Object.values(shades.red).reverse(), ...Object.values(shades.apple)],
|
|
158
|
+
red_teal: [...Object.values(shades.red).reverse(), ...Object.values(shades.violet)],
|
|
159
|
+
violet_orange: [...Object.values(shades.violet).reverse(), ...Object.values(shades.orange)],
|
|
160
|
+
orange_blue: [...Object.values(shades.orange).reverse(), ...Object.values(shades.blue)],
|
|
161
|
+
teal_pink: [...Object.values(shades.teal).reverse(), ...Object.values(shades.pink)],
|
|
162
|
+
blue_pink: [...Object.values(shades.blue).reverse(), ...Object.values(shades.pink)],
|
|
163
|
+
apple_plum: [...Object.values(shades.apple).reverse(), ...Object.values(shades.plum)],
|
|
164
|
+
forest_plum: [...Object.values(shades.forest).reverse(), ...Object.values(shades.plum)]
|
|
164
165
|
};
|
|
165
166
|
|
|
166
|
-
const typography = {};
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
const typography = {
|
|
169
|
+
wide: {
|
|
170
|
+
sizes: {
|
|
171
|
+
"fs-small-3": "0.75rem",
|
|
172
|
+
"fs-small-2": "0.875rem",
|
|
173
|
+
"fs-small-1": "1rem",
|
|
174
|
+
"fs-base": "1.25rem",
|
|
175
|
+
"fs-large-1": "1.5rem",
|
|
176
|
+
"fs-large-2": "2rem",
|
|
177
|
+
"fs-large-3": "2.5rem",
|
|
178
|
+
"fs-large-4": "3.5rem"
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export { shades, scales, typography };
|
|
@@ -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,50 @@
|
|
|
1
|
+
<script context="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
|
+
});
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<Story name="Default">
|
|
16
|
+
<DesignTokens>
|
|
17
|
+
<FormLabel htmlFor="">Deine Gemeinde</FormLabel>
|
|
18
|
+
</DesignTokens>
|
|
19
|
+
</Story>
|
|
20
|
+
|
|
21
|
+
<Story
|
|
22
|
+
name="With Select"
|
|
23
|
+
play={async ({ canvasElement, step }) => {
|
|
24
|
+
const canvas = within(canvasElement);
|
|
25
|
+
const label = canvas.getByTestId('label-container');
|
|
26
|
+
const input = canvas.getByPlaceholderText('...');
|
|
27
|
+
await step('Label renders children', async () => {
|
|
28
|
+
await userEvent.click(label);
|
|
29
|
+
expect(label).toHaveTextContent('Deine Gemeinde');
|
|
30
|
+
});
|
|
31
|
+
await step('Clicking the label focuses the input', async () => {
|
|
32
|
+
await userEvent.click(label);
|
|
33
|
+
expect(input).toHaveFocus();
|
|
34
|
+
});
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
<DesignTokens>
|
|
38
|
+
<FormLabel htmlFor="select-gemeinde">Deine Gemeinde</FormLabel>
|
|
39
|
+
<Select
|
|
40
|
+
inputId="select-gemeinde"
|
|
41
|
+
placeholder="..."
|
|
42
|
+
value={undefined}
|
|
43
|
+
items={[
|
|
44
|
+
{ value: 'konstanz', label: 'Konstanz' },
|
|
45
|
+
{ value: 'stuttgart', label: 'Stuttgart' },
|
|
46
|
+
{ value: 'heidelberg', label: 'Heidelberg' }
|
|
47
|
+
]}
|
|
48
|
+
></Select>
|
|
49
|
+
</DesignTokens>
|
|
50
|
+
</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>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script context="module">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import DesignTokens from '../DesignTokens/DesignTokens.svelte';
|
|
4
|
+
|
|
5
|
+
import Headline from './Headline.svelte';
|
|
6
|
+
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
title: 'Typography/Headline'
|
|
9
|
+
});
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Story name="Default">
|
|
13
|
+
<DesignTokens>
|
|
14
|
+
<Headline>Baden-Württemberg heizt überdurchschnittlich viel mit Wärmepumpe</Headline>
|
|
15
|
+
</DesignTokens>
|
|
16
|
+
</Story>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
interface HeadlineProps {
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
}
|
|
7
|
+
let { children }: HeadlineProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<h2 class="container">
|
|
11
|
+
{#if children}
|
|
12
|
+
{@render children()}
|
|
13
|
+
{/if}
|
|
14
|
+
</h2>
|
|
15
|
+
|
|
16
|
+
<style>
|
|
17
|
+
.container {
|
|
18
|
+
font-family: var(--swr-text);
|
|
19
|
+
font-size: var(--fs-large-1);
|
|
20
|
+
font-weight: 550;
|
|
21
|
+
letter-spacing: 0.005em;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
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
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script context="module">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import DesignTokens from '../DesignTokens/DesignTokens.svelte';
|
|
4
|
+
import Middot from '../Middot/Middot.svelte';
|
|
5
|
+
|
|
6
|
+
import Note from './Note.svelte';
|
|
7
|
+
|
|
8
|
+
const { Story } = defineMeta({
|
|
9
|
+
title: 'Typography/Note'
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Story name="Default">
|
|
14
|
+
<DesignTokens>
|
|
15
|
+
<Note>
|
|
16
|
+
Daten: <a href="#1">Zensus 2022</a>
|
|
17
|
+
(Durchschnittsmieten und Einwohnerzahlen),
|
|
18
|
+
<a href="#1">OpenStreetMap</a> (Kartenmaterial) <Middot /> In unserer Darstellung wurde das Zensusgitter
|
|
19
|
+
auf bewohnte Gebiete begrenzt.
|
|
20
|
+
</Note>
|
|
21
|
+
</DesignTokens>
|
|
22
|
+
</Story>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
interface NoteProps {
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
}
|
|
7
|
+
let { children }: NoteProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<div class="container">
|
|
11
|
+
{#if children}
|
|
12
|
+
{@render children()}
|
|
13
|
+
{/if}
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<style lang="scss">
|
|
17
|
+
.container {
|
|
18
|
+
font-family: var(--swr-sans);
|
|
19
|
+
font-size: var(--fs-small-2);
|
|
20
|
+
line-height: 1.4;
|
|
21
|
+
letter-spacing: 0.001em;
|
|
22
|
+
color: var(--gray-base);
|
|
23
|
+
|
|
24
|
+
:global(*) {
|
|
25
|
+
color: inherit;
|
|
26
|
+
}
|
|
27
|
+
:global(p) {
|
|
28
|
+
margin-bottom: 0.5em;
|
|
29
|
+
}
|
|
30
|
+
:global(a),
|
|
31
|
+
:global(summary) {
|
|
32
|
+
&:hover,
|
|
33
|
+
&:focus-visible {
|
|
34
|
+
color: var(--gray-dark-3);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
</style>
|
package/src/Select/Select.mdx
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
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
|
|
|
7
8
|
const { Story } = defineMeta({
|
|
8
|
-
title: 'Form/Select'
|
|
9
|
-
component: Select
|
|
9
|
+
title: 'Form/Select'
|
|
10
10
|
});
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
13
|
<script lang="ts">
|
|
14
|
-
import { userEvent, within, expect } from '
|
|
14
|
+
import { userEvent, within, expect } from 'storybook/test';
|
|
15
15
|
import { type SelectItem } from './Select.types';
|
|
16
16
|
let selectedItem: SelectItem | undefined = undefined;
|
|
17
17
|
</script>
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
>
|
|
149
149
|
<StoryTemplate>
|
|
150
150
|
{#snippet demoComponent()}
|
|
151
|
-
<
|
|
151
|
+
<FormLabel htmlFor="job-select">Berufe</FormLabel>
|
|
152
152
|
<Select
|
|
153
153
|
bind:value={selectedItem}
|
|
154
154
|
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,11 +2,10 @@
|
|
|
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
|
-
title: 'Form/Switcher'
|
|
9
|
-
component: Switcher
|
|
8
|
+
title: 'Form/Switcher'
|
|
10
9
|
});
|
|
11
10
|
</script>
|
|
12
11
|
|