@swr-data-lab/components 1.1.0 → 1.3.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/preview-head.html +13 -0
- package/.storybook/preview.ts +1 -1
- package/package.json +10 -10
- package/src/Autocomplete/Autocomplete.svelte +2 -2
- package/src/Button/Button.svelte +1 -1
- package/src/Card/Card.stories.svelte +31 -0
- package/src/Card/Card.svelte +2 -1
- package/src/Container/Container.svelte +1 -1
- package/src/HighlightCard/HighlightCard.stories.svelte +60 -0
- package/src/HighlightCard/HighlightCard.svelte +64 -0
- package/src/HighlightCard/index.js +2 -0
- package/src/Select/Select.stories.svelte +12 -0
- package/src/Select/Select.svelte +6 -1
- package/src/styles/_vars.scss +7 -8
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<style>
|
|
2
|
+
/* Load SWR.de fonts for preview: */
|
|
3
|
+
@font-face {
|
|
4
|
+
font-family: 'SWR-VAR-Text';
|
|
5
|
+
src: url('https://www.swr.de/assets/fonts/swr_type/SWR_VAR_WEB/SWR-VAR-Text.woff2')
|
|
6
|
+
format('woff2');
|
|
7
|
+
}
|
|
8
|
+
@font-face {
|
|
9
|
+
font-family: 'SWR-VAR-Sans';
|
|
10
|
+
src: url('https://www.swr.de/assets/fonts/swr_type/SWR_VAR_WEB/SWR-VAR-Sans.woff2')
|
|
11
|
+
format('woff2');
|
|
12
|
+
}
|
|
13
|
+
</style>
|
package/.storybook/preview.ts
CHANGED
package/package.json
CHANGED
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
"@semantic-release/changelog": "^6.0.3",
|
|
24
24
|
"@semantic-release/git": "^10.0.1",
|
|
25
25
|
"@semantic-release/npm": "^12.0.1",
|
|
26
|
-
"@storybook/addon-essentials": "^8.
|
|
27
|
-
"@storybook/addon-interactions": "^8.
|
|
28
|
-
"@storybook/addon-links": "^8.
|
|
26
|
+
"@storybook/addon-essentials": "^8.4.5",
|
|
27
|
+
"@storybook/addon-interactions": "^8.4.5",
|
|
28
|
+
"@storybook/addon-links": "^8.4.5",
|
|
29
29
|
"@storybook/addon-svelte-csf": "^4.1.7",
|
|
30
|
-
"@storybook/blocks": "^8.
|
|
31
|
-
"@storybook/builder-vite": "^8.
|
|
32
|
-
"@storybook/svelte": "^8.
|
|
33
|
-
"@storybook/sveltekit": "^8.
|
|
34
|
-
"@storybook/test": "^8.
|
|
30
|
+
"@storybook/blocks": "^8.4.5",
|
|
31
|
+
"@storybook/builder-vite": "^8.4.5",
|
|
32
|
+
"@storybook/svelte": "^8.4.5",
|
|
33
|
+
"@storybook/sveltekit": "^8.4.5",
|
|
34
|
+
"@storybook/test": "^8.4.5",
|
|
35
35
|
"@storybook/test-runner": "^0.19.1",
|
|
36
36
|
"@sveltejs/adapter-auto": "^3.0.0",
|
|
37
37
|
"@sveltejs/kit": "^2.0.0",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"http-server": "^14.1.1",
|
|
41
41
|
"sass-embedded": "^1.78.0",
|
|
42
42
|
"semantic-release": "^24.1.2",
|
|
43
|
-
"storybook": "^8.
|
|
43
|
+
"storybook": "^8.4.5",
|
|
44
44
|
"svelte": "^4.2.7",
|
|
45
45
|
"svelte-check": "^4.0.0",
|
|
46
46
|
"svelte-select": "^5.8.3",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"svelte": "./src/index.js"
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
|
-
"version": "1.
|
|
64
|
+
"version": "1.3.0"
|
|
65
65
|
}
|
|
@@ -169,7 +169,7 @@ Data should be provided as array of objects. Each object contains the informatio
|
|
|
169
169
|
position: absolute;
|
|
170
170
|
top: 100%;
|
|
171
171
|
border: 1px solid currentColor;
|
|
172
|
-
background: $
|
|
172
|
+
background: $color-violetblue;
|
|
173
173
|
border-bottom-left-radius: $border-radius-input;
|
|
174
174
|
border-bottom-right-radius: $border-radius-input;
|
|
175
175
|
border-top: 0;
|
|
@@ -218,7 +218,7 @@ Data should be provided as array of objects. Each object contains the informatio
|
|
|
218
218
|
}
|
|
219
219
|
&:hover,
|
|
220
220
|
&:focus {
|
|
221
|
-
color: $
|
|
221
|
+
color: $color-activeorange;
|
|
222
222
|
cursor: pointer;
|
|
223
223
|
}
|
|
224
224
|
}
|
package/src/Button/Button.svelte
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script context="module">
|
|
2
|
+
import Card from './Card.svelte';
|
|
3
|
+
|
|
4
|
+
export const meta = {
|
|
5
|
+
title: 'Input Components/Card',
|
|
6
|
+
component: Card
|
|
7
|
+
};
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import { Story, Template } from '@storybook/addon-svelte-csf';
|
|
12
|
+
import {
|
|
13
|
+
userEvent,
|
|
14
|
+
within,
|
|
15
|
+
expect,
|
|
16
|
+
getByTestId,
|
|
17
|
+
getAllByLabelText,
|
|
18
|
+
getByText
|
|
19
|
+
} from '@storybook/test';
|
|
20
|
+
import { hasContext } from 'svelte';
|
|
21
|
+
import Input from '../Input/Input.svelte';
|
|
22
|
+
|
|
23
|
+
let component;
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<Story name="Basic card">
|
|
27
|
+
<Card>
|
|
28
|
+
<h1>Any content</h1>
|
|
29
|
+
<p>can be added to a basic <code>Card</code> component.</p>
|
|
30
|
+
</Card>
|
|
31
|
+
</Story>
|
package/src/Card/Card.svelte
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
<style lang="scss">
|
|
6
6
|
@import '../styles/base.scss';
|
|
7
7
|
.card {
|
|
8
|
+
@extend %copy;
|
|
8
9
|
width: auto;
|
|
9
10
|
max-width: $app-max-width;
|
|
10
11
|
color: white;
|
|
11
|
-
background: $
|
|
12
|
+
background: $color-violetblue;
|
|
12
13
|
border-radius: $border-radius-container;
|
|
13
14
|
margin: 0 1rem;
|
|
14
15
|
padding: 1.5rem;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script context="module">
|
|
2
|
+
import HighlightCard from './HighlightCard.svelte';
|
|
3
|
+
|
|
4
|
+
export const meta = {
|
|
5
|
+
title: 'Input Components/HighlightCard',
|
|
6
|
+
component: HighlightCard
|
|
7
|
+
};
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import { Story, Template } from '@storybook/addon-svelte-csf';
|
|
12
|
+
import {
|
|
13
|
+
userEvent,
|
|
14
|
+
within,
|
|
15
|
+
expect,
|
|
16
|
+
getByTestId,
|
|
17
|
+
getAllByLabelText,
|
|
18
|
+
getByText
|
|
19
|
+
} from '@storybook/test';
|
|
20
|
+
import { hasContext } from 'svelte';
|
|
21
|
+
|
|
22
|
+
let component;
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<Story name="Basic HighlightCard">
|
|
26
|
+
<HighlightCard
|
|
27
|
+
topline="Die letzte Großspende liegt bei"
|
|
28
|
+
highlight="375.000"
|
|
29
|
+
highlightSecondary="Euro"
|
|
30
|
+
subline="Der Betrag ging am 7. Januar von Dr. Kim Musterperson ein."
|
|
31
|
+
/>
|
|
32
|
+
</Story>
|
|
33
|
+
|
|
34
|
+
<Story name="Basic HighlightCard">
|
|
35
|
+
<div class="columns">
|
|
36
|
+
<HighlightCard
|
|
37
|
+
topline="Im aktuellen Jahr wurden bisher"
|
|
38
|
+
highlight="375.000"
|
|
39
|
+
highlightSecondary="€"
|
|
40
|
+
subline="an Parteien gespendet."
|
|
41
|
+
/>
|
|
42
|
+
<HighlightCard
|
|
43
|
+
topline="Die letzte Großspende liegt bei"
|
|
44
|
+
highlight="37.500"
|
|
45
|
+
highlightSecondary="€"
|
|
46
|
+
subline="Der Betrag ging am 7. Januar von Dr. Kim Musterperson ein."
|
|
47
|
+
/>
|
|
48
|
+
</div>
|
|
49
|
+
</Story>
|
|
50
|
+
|
|
51
|
+
<style>
|
|
52
|
+
.columns {
|
|
53
|
+
display: flex;
|
|
54
|
+
margin-top: 2rem;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:global(.columns > *) {
|
|
58
|
+
flex: 1;
|
|
59
|
+
}
|
|
60
|
+
</style>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Card from '../Card/Card.svelte';
|
|
3
|
+
|
|
4
|
+
export let topline = '';
|
|
5
|
+
export let highlight = '';
|
|
6
|
+
export let highlightSecondary = '';
|
|
7
|
+
export let subline = '';
|
|
8
|
+
export let alignCards = true;
|
|
9
|
+
export let maxWidth = '500px';
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Card>
|
|
13
|
+
<div class="card-wrapper">
|
|
14
|
+
{#if topline}
|
|
15
|
+
<div class="top">
|
|
16
|
+
{@html topline}
|
|
17
|
+
</div>
|
|
18
|
+
{/if}
|
|
19
|
+
<div class="middle">
|
|
20
|
+
<span class="underline">
|
|
21
|
+
{highlight}
|
|
22
|
+
</span>
|
|
23
|
+
{highlightSecondary}
|
|
24
|
+
</div>
|
|
25
|
+
<div class="bottom">
|
|
26
|
+
{@html subline}
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</Card>
|
|
30
|
+
|
|
31
|
+
<style lang="scss">
|
|
32
|
+
@import '../styles/base.scss';
|
|
33
|
+
|
|
34
|
+
.card-wrapper {
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
height: 100%;
|
|
38
|
+
min-height: 200px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.top {
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: flex-end;
|
|
44
|
+
flex: 1;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.middle {
|
|
48
|
+
font-family: $swr-sans;
|
|
49
|
+
font-size: 60px;
|
|
50
|
+
font-weight: 700;
|
|
51
|
+
padding-bottom: 0.2em;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.bottom {
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: flex-start;
|
|
57
|
+
flex: 1;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.underline {
|
|
61
|
+
width: fit-content;
|
|
62
|
+
background: linear-gradient(to bottom, transparent 90%, $color-activeorange 90%);
|
|
63
|
+
}
|
|
64
|
+
</style>
|
|
@@ -33,6 +33,11 @@
|
|
|
33
33
|
type: { name: 'boolean', required: false },
|
|
34
34
|
defaultValue: 'false'
|
|
35
35
|
},
|
|
36
|
+
clearable: {
|
|
37
|
+
description: 'Show a button to clear the input',
|
|
38
|
+
type: { name: 'boolean', required: false },
|
|
39
|
+
defaultValue: 'false'
|
|
40
|
+
},
|
|
36
41
|
value: {
|
|
37
42
|
description: 'The currently selected option',
|
|
38
43
|
type: { name: 'any', required: false }
|
|
@@ -74,6 +79,7 @@
|
|
|
74
79
|
name="Simple"
|
|
75
80
|
args={{
|
|
76
81
|
inputId: 'select',
|
|
82
|
+
clearable: true,
|
|
77
83
|
items: [
|
|
78
84
|
{ value: 'chocolate', label: 'Chocolate' },
|
|
79
85
|
{ value: 'cake', label: 'Cake' },
|
|
@@ -99,6 +105,12 @@
|
|
|
99
105
|
await userEvent.type(select, 'Ice{enter}');
|
|
100
106
|
expect(selectedItem).toEqual({ value: 'ice-cream', label: 'Ice Cream' });
|
|
101
107
|
});
|
|
108
|
+
|
|
109
|
+
await step('Tapping the clear button clears the input', async () => {
|
|
110
|
+
const clearButton = document.querySelector('.clear-select');
|
|
111
|
+
await userEvent.click(clearButton);
|
|
112
|
+
expect(selectedItem).toEqual(undefined);
|
|
113
|
+
});
|
|
102
114
|
}}
|
|
103
115
|
/>
|
|
104
116
|
|
package/src/Select/Select.svelte
CHANGED
|
@@ -43,6 +43,11 @@
|
|
|
43
43
|
*/
|
|
44
44
|
export let groupHeaderSelectable: boolean = false;
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Enable clearing the input
|
|
48
|
+
*/
|
|
49
|
+
export let clearable: boolean = true;
|
|
50
|
+
|
|
46
51
|
export let value: Option | undefined;
|
|
47
52
|
</script>
|
|
48
53
|
|
|
@@ -53,7 +58,7 @@ based on https://github.com/rob-balfre/svelte-select
|
|
|
53
58
|
@component
|
|
54
59
|
-->
|
|
55
60
|
|
|
56
|
-
<Select {items} {groupBy} id={inputId} {placeholder} {groupHeaderSelectable} bind:value>
|
|
61
|
+
<Select {items} {groupBy} id={inputId} {placeholder} {groupHeaderSelectable} {clearable} bind:value>
|
|
57
62
|
<svelte:fragment slot="item" let:item>
|
|
58
63
|
<slot name="item" {item}>
|
|
59
64
|
{item.label}
|
package/src/styles/_vars.scss
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
$
|
|
2
|
-
$
|
|
3
|
-
$
|
|
4
|
-
$
|
|
5
|
-
$
|
|
6
|
-
$
|
|
7
|
-
$
|
|
8
|
-
$orange: #ff3300;
|
|
1
|
+
$color-black: #0c0c0c;
|
|
2
|
+
$color-violetblue: #1d0b40;
|
|
3
|
+
$color-violetblue-hover: #2d155d;
|
|
4
|
+
$color-violet: #5920c0;
|
|
5
|
+
$color-blue: #3053d9;
|
|
6
|
+
$color-warmgrey: #dbd5cd;
|
|
7
|
+
$color-activeorange: #ff3300;
|
|
9
8
|
|
|
10
9
|
$border-radius-container: 8px;
|
|
11
10
|
$border-radius-input: 4px;
|