@swr-data-lab/components 1.9.0 → 1.10.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.ts +1 -1
- package/package.json +1 -1
- package/src/Autocomplete/Autocomplete.svelte +4 -2
- package/src/Button/Button.stories.svelte +21 -0
- package/src/Button/Button.svelte +14 -11
- package/src/Caption/Caption.stories.svelte +24 -0
- package/src/Caption/Caption.svelte +29 -0
- package/src/Caption/index.ts +2 -0
- package/src/Card/Card.svelte +5 -3
- package/src/ChartFooter/ChartFooter.svelte +7 -20
- package/src/ChartHeader/ChartHeader.mdx +2 -1
- package/src/ChartHeader/ChartHeader.svelte +9 -16
- package/src/Copy/Copy.stories.svelte +32 -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 +39 -21
- package/src/DesignTokens/{Tokens.js → Tokens.ts} +41 -26
- package/src/Headline/Headline.stories.svelte +17 -0
- package/src/Headline/Headline.svelte +23 -0
- package/src/Headline/index.ts +2 -0
- package/src/HighlightCard/HighlightCard.svelte +1 -2
- package/src/Note/Note.stories.svelte +23 -0
- package/src/Note/Note.svelte +38 -0
- package/src/Note/index.ts +2 -0
- package/src/Switcher/Switcher.svelte +5 -5
- package/src/index.js +0 -1
- package/src/styles/base.scss +9 -26
package/.storybook/preview.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Preview } from "@storybook/svelte";
|
|
|
3
3
|
const preview: Preview = {
|
|
4
4
|
parameters: {
|
|
5
5
|
options: {
|
|
6
|
-
storySort: { order: ['About', 'Design Tokens', "Display", "Chart", ["ChartHeader"], "Form", "Deprecated"] },
|
|
6
|
+
storySort: { order: ['About', 'Design Tokens', "Typography", ["Headline", "Copy", "Caption"], "Display", "Chart", ["ChartHeader"], "Form", "Deprecated"] },
|
|
7
7
|
},
|
|
8
8
|
controls: {
|
|
9
9
|
matchers: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { createEventDispatcher } from 'svelte';
|
|
3
3
|
import Circle from '../assets/times-circle-solid.svg.svelte';
|
|
4
|
+
import Caption from '../Caption/Caption.svelte';
|
|
4
5
|
|
|
5
6
|
export let data = [];
|
|
6
7
|
export let query: string = '';
|
|
@@ -137,7 +138,9 @@ Data should be provided as array of objects. Each object contains the informatio
|
|
|
137
138
|
handleItemClick(i);
|
|
138
139
|
}}
|
|
139
140
|
>
|
|
140
|
-
|
|
141
|
+
<Caption>
|
|
142
|
+
{item.label}
|
|
143
|
+
</Caption>
|
|
141
144
|
</button>
|
|
142
145
|
</li>
|
|
143
146
|
{/each}
|
|
@@ -188,7 +191,6 @@ Data should be provided as array of objects. Each object contains the informatio
|
|
|
188
191
|
}
|
|
189
192
|
|
|
190
193
|
.item {
|
|
191
|
-
@extend %caption;
|
|
192
194
|
padding: 0.5em;
|
|
193
195
|
width: 100%;
|
|
194
196
|
background: transparent;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import Button from './Button.svelte';
|
|
4
|
+
import DesignTokens from '../DesignTokens/DesignTokens.svelte';
|
|
5
|
+
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
title: 'Form/Button',
|
|
8
|
+
component: Button
|
|
9
|
+
});
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Story name="Basic">
|
|
13
|
+
<DesignTokens>
|
|
14
|
+
<Button label="This is a button label"></Button>
|
|
15
|
+
</DesignTokens>
|
|
16
|
+
</Story>
|
|
17
|
+
<Story name="Disabled">
|
|
18
|
+
<DesignTokens>
|
|
19
|
+
<Button disabled label="This button is disabled"></Button>
|
|
20
|
+
</DesignTokens>
|
|
21
|
+
</Story>
|
package/src/Button/Button.svelte
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import Copy from '../Copy/Copy.svelte';
|
|
3
|
+
|
|
2
4
|
interface ButtonProps {
|
|
3
|
-
as: 'button' | 'a';
|
|
4
5
|
label: string;
|
|
6
|
+
as?: 'button' | 'a';
|
|
5
7
|
href?: string;
|
|
6
8
|
disabled?: boolean;
|
|
7
9
|
onclick?: (e: MouseEvent) => any | void;
|
|
@@ -11,31 +13,32 @@
|
|
|
11
13
|
</script>
|
|
12
14
|
|
|
13
15
|
{#if as === 'a'}
|
|
14
|
-
<a class="button" class:disabled {href}>
|
|
16
|
+
<a class="button" class:disabled {href}>
|
|
17
|
+
<Copy weight="bold">
|
|
18
|
+
{label}
|
|
19
|
+
</Copy>
|
|
20
|
+
</a>
|
|
15
21
|
{:else}
|
|
16
|
-
<button class="button" {onclick} {disabled}>
|
|
22
|
+
<button class="button" {onclick} {disabled}>
|
|
23
|
+
<Copy weight="bold">
|
|
24
|
+
{label}
|
|
25
|
+
</Copy>
|
|
26
|
+
</button>
|
|
17
27
|
{/if}
|
|
18
28
|
|
|
19
29
|
<style lang="scss">
|
|
20
|
-
@use '../styles/base.scss';
|
|
21
30
|
.button {
|
|
22
|
-
@extend %copy-bold;
|
|
23
31
|
background: var(--violet-dark-3);
|
|
24
32
|
display: inline-flex;
|
|
25
33
|
align-items: center;
|
|
26
34
|
justify-self: flex-start;
|
|
27
|
-
padding: 0.
|
|
28
|
-
padding-bottom: 0.35em;
|
|
35
|
+
padding: 0.45em 1.25em;
|
|
29
36
|
color: white;
|
|
30
37
|
border: 1px solid rgba(white, 0.1);
|
|
31
38
|
box-shadow: 0px 0px 10px rgba(black, 0.05);
|
|
32
39
|
border-radius: var(--br-small);
|
|
33
40
|
text-shadow: 0px 0px 5px rgba(black, 0.05);
|
|
34
|
-
font-size: 1.2rem;
|
|
35
41
|
text-decoration: none;
|
|
36
|
-
@media (min-width: base.$break-tablet) {
|
|
37
|
-
font-size: 1.4rem;
|
|
38
|
-
}
|
|
39
42
|
&:hover,
|
|
40
43
|
&:focus-visible {
|
|
41
44
|
text-decoration: underline;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script context="module">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import DesignTokens from '../DesignTokens/DesignTokens.svelte';
|
|
4
|
+
|
|
5
|
+
import Caption from './Caption.svelte';
|
|
6
|
+
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
title: 'Typography/Caption',
|
|
9
|
+
component: Caption
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Story name="Default">
|
|
14
|
+
<DesignTokens>
|
|
15
|
+
<Caption>Björn Schittenhelm, Apotheker aus Holzgerlingen (Kreis Böblingen)</Caption>
|
|
16
|
+
</DesignTokens>
|
|
17
|
+
</Story>
|
|
18
|
+
<Story name="Bold">
|
|
19
|
+
<DesignTokens>
|
|
20
|
+
<Caption weight="bold">
|
|
21
|
+
Björn Schittenhelm, Apotheker aus Holzgerlingen (Kreis Böblingen)
|
|
22
|
+
</Caption>
|
|
23
|
+
</DesignTokens>
|
|
24
|
+
</Story>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
interface CaptionProps {
|
|
5
|
+
weight?: 'regular' | 'bold';
|
|
6
|
+
children?: Snippet;
|
|
7
|
+
}
|
|
8
|
+
let { weight = 'regular', children }: CaptionProps = $props();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div class={['container', weight]}>
|
|
12
|
+
{#if children}
|
|
13
|
+
{@render children()}
|
|
14
|
+
{/if}
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<style lang="scss">
|
|
18
|
+
.container {
|
|
19
|
+
font-family: var(--swr-sans);
|
|
20
|
+
font-size: var(--fs-small-2);
|
|
21
|
+
line-height: 1;
|
|
22
|
+
letter-spacing: 0.0045em;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.bold {
|
|
26
|
+
font-weight: 585;
|
|
27
|
+
letter-spacing: 0;
|
|
28
|
+
}
|
|
29
|
+
</style>
|
package/src/Card/Card.svelte
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import Copy from '../Copy/Copy.svelte';
|
|
3
4
|
|
|
4
5
|
interface CardProps {
|
|
5
6
|
children?: Snippet;
|
|
@@ -10,7 +11,9 @@
|
|
|
10
11
|
|
|
11
12
|
<div class="card">
|
|
12
13
|
{#if children}
|
|
13
|
-
|
|
14
|
+
<Copy>
|
|
15
|
+
{@render children()}
|
|
16
|
+
</Copy>
|
|
14
17
|
{/if}
|
|
15
18
|
</div>
|
|
16
19
|
|
|
@@ -18,14 +21,13 @@
|
|
|
18
21
|
@use '../styles/base.scss';
|
|
19
22
|
|
|
20
23
|
.card {
|
|
21
|
-
@extend %copy;
|
|
22
24
|
color: white;
|
|
23
25
|
width: auto;
|
|
24
26
|
max-width: var(--app-max-width);
|
|
25
27
|
background: var(--violet-dark-5);
|
|
26
28
|
border-radius: var(--br-large);
|
|
27
29
|
padding: 1.5rem;
|
|
28
|
-
@media (min-width: base.$
|
|
30
|
+
@media (min-width: base.$bp-m) {
|
|
29
31
|
padding: 2.5rem;
|
|
30
32
|
}
|
|
31
33
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
import Logotype from '../Logotype/Logotype.svelte';
|
|
4
|
+
import Note from '../Note/Note.svelte';
|
|
4
5
|
|
|
5
6
|
interface ChartFooterProps {
|
|
6
7
|
layout: 'one-up' | 'two-up';
|
|
@@ -12,9 +13,9 @@
|
|
|
12
13
|
|
|
13
14
|
<footer class={`container ${layout}`}>
|
|
14
15
|
{#if children}
|
|
15
|
-
<
|
|
16
|
+
<Note>
|
|
16
17
|
{@render children()}
|
|
17
|
-
</
|
|
18
|
+
</Note>
|
|
18
19
|
{/if}
|
|
19
20
|
<Logotype />
|
|
20
21
|
</footer>
|
|
@@ -24,9 +25,9 @@
|
|
|
24
25
|
|
|
25
26
|
.container {
|
|
26
27
|
gap: 0.5rem;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
:global(div) {
|
|
29
|
+
width: 100%;
|
|
30
|
+
}
|
|
30
31
|
}
|
|
31
32
|
.one-up {
|
|
32
33
|
display: flex;
|
|
@@ -36,24 +37,10 @@
|
|
|
36
37
|
.two-up {
|
|
37
38
|
display: grid;
|
|
38
39
|
grid-template-columns: 1fr;
|
|
39
|
-
@media (min-width: base.$
|
|
40
|
+
@media (min-width: base.$bp-s) {
|
|
40
41
|
grid-template-columns: 2.5fr 1fr;
|
|
41
42
|
align-items: last baseline;
|
|
42
43
|
justify-items: flex-end;
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
|
-
.notes {
|
|
46
|
-
width: 100%;
|
|
47
|
-
}
|
|
48
|
-
footer :global(*) {
|
|
49
|
-
margin-bottom: 0;
|
|
50
|
-
color: var(--gray-base);
|
|
51
|
-
}
|
|
52
|
-
footer :global(a),
|
|
53
|
-
footer :global(summary) {
|
|
54
|
-
&:hover,
|
|
55
|
-
&:focus-visible {
|
|
56
|
-
color: var(--gray-dark-3);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
46
|
</style>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Story,
|
|
1
|
+
import { Story, Meta, Primary, Controls, Stories } from '@storybook/blocks';
|
|
2
2
|
|
|
3
3
|
import * as ChartHeaderStories from './ChartHeader.stories.svelte';
|
|
4
4
|
|
|
@@ -8,6 +8,7 @@ import * as ChartHeaderStories from './ChartHeader.stories.svelte';
|
|
|
8
8
|
|
|
9
9
|
Standard chart header.
|
|
10
10
|
|
|
11
|
+
- The slugified `title` is set as the header element's `id` attribute (useful for linking to interactives from in-article table of contents)
|
|
11
12
|
- Any nested HTML will render under the description (useful for i.e colour keys and interactives controls).
|
|
12
13
|
|
|
13
14
|
<Controls />
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import Headline from '../Headline/Headline.svelte';
|
|
4
|
+
import Copy from '../Copy/Copy.svelte';
|
|
5
|
+
import slugify from '../utils/slugify';
|
|
6
|
+
|
|
5
7
|
interface ChartHeaderProps {
|
|
6
8
|
title: string;
|
|
7
9
|
subtitle?: string;
|
|
@@ -11,9 +13,9 @@
|
|
|
11
13
|
</script>
|
|
12
14
|
|
|
13
15
|
<header class="container" id={slugify(title)}>
|
|
14
|
-
<
|
|
16
|
+
<Headline>{title}</Headline>
|
|
15
17
|
{#if subtitle}
|
|
16
|
-
<p class="subtitle">{subtitle}</p>
|
|
18
|
+
<Copy><p class="subtitle">{subtitle}</p></Copy>
|
|
17
19
|
{/if}
|
|
18
20
|
{#if children}
|
|
19
21
|
<div class="content">
|
|
@@ -27,19 +29,10 @@
|
|
|
27
29
|
color: var(--violet-blue);
|
|
28
30
|
font-family: var(--swr-sans);
|
|
29
31
|
}
|
|
30
|
-
.title {
|
|
31
|
-
font-size: var(--fs-large-3);
|
|
32
|
-
line-height: 1.05;
|
|
33
|
-
text-wrap: balance;
|
|
34
|
-
font-weight: 700;
|
|
35
|
-
margin-bottom: 0.2em;
|
|
36
|
-
}
|
|
37
32
|
.subtitle {
|
|
38
33
|
text-wrap: balance;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
margin-bottom: 0;
|
|
43
|
-
}
|
|
34
|
+
}
|
|
35
|
+
.content {
|
|
36
|
+
margin-top: 0.25em;
|
|
44
37
|
}
|
|
45
38
|
</style>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script context="module">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import DesignTokens from '../DesignTokens/DesignTokens.svelte';
|
|
4
|
+
|
|
5
|
+
import Copy from './Copy.svelte';
|
|
6
|
+
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
title: 'Typography/Copy',
|
|
9
|
+
component: Copy
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Story name="Default">
|
|
14
|
+
<DesignTokens>
|
|
15
|
+
<Copy>
|
|
16
|
+
Björn Schittenhelm, Apotheker aus Holzgerlingen (Kreis Böblingen), bedient derzeit
|
|
17
|
+
größtenteils Allergiegeplagte: "Wir gehen nahtlos von der Erkältungssaison in die Pollensaison
|
|
18
|
+
hinein. Wir merken definitiv eine Veränderung über die letzten Jahre: Die Pollensaison wird
|
|
19
|
+
länger, die Grippesaison wird länger und dadurch überlappt sich das Ganze."
|
|
20
|
+
</Copy>
|
|
21
|
+
</DesignTokens>
|
|
22
|
+
</Story>
|
|
23
|
+
<Story name="Bold">
|
|
24
|
+
<DesignTokens>
|
|
25
|
+
<Copy weight="bold">
|
|
26
|
+
Björn Schittenhelm, Apotheker aus Holzgerlingen (Kreis Böblingen), bedient derzeit
|
|
27
|
+
größtenteils Allergiegeplagte: "Wir gehen nahtlos von der Erkältungssaison in die Pollensaison
|
|
28
|
+
hinein. Wir merken definitiv eine Veränderung über die letzten Jahre: Die Pollensaison wird
|
|
29
|
+
länger, die Grippesaison wird länger und dadurch überlappt sich das Ganze."
|
|
30
|
+
</Copy>
|
|
31
|
+
</DesignTokens>
|
|
32
|
+
</Story>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
interface CopyProps {
|
|
5
|
+
weight?: 'regular' | 'bold';
|
|
6
|
+
children?: Snippet;
|
|
7
|
+
}
|
|
8
|
+
let { weight = 'regular', children }: CopyProps = $props();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div class={['container', weight]}>
|
|
12
|
+
{#if children}
|
|
13
|
+
{@render children()}
|
|
14
|
+
{/if}
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<style lang="scss">
|
|
18
|
+
.container {
|
|
19
|
+
font-family: var(--swr-sans);
|
|
20
|
+
font-size: var(--fs-base);
|
|
21
|
+
letter-spacing: 0.005em;
|
|
22
|
+
line-height: 1.475;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.bold {
|
|
26
|
+
font-weight: 585;
|
|
27
|
+
letter-spacing: 0;
|
|
28
|
+
}
|
|
29
|
+
</style>
|
|
@@ -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/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,4 +1,4 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { shades } from './Tokens';
|
|
3
3
|
|
|
4
4
|
const rules = [
|
|
@@ -11,25 +11,7 @@
|
|
|
11
11
|
: `--${key}-${ldb}-${index}: ${value}`;
|
|
12
12
|
})
|
|
13
13
|
.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))'
|
|
14
|
+
})
|
|
33
15
|
];
|
|
34
16
|
</script>
|
|
35
17
|
|
|
@@ -37,9 +19,45 @@
|
|
|
37
19
|
<slot />
|
|
38
20
|
</div>
|
|
39
21
|
|
|
40
|
-
<style>
|
|
22
|
+
<style lang="scss">
|
|
23
|
+
@use '../styles/base.scss';
|
|
24
|
+
|
|
41
25
|
:global(*) {
|
|
42
26
|
margin: 0;
|
|
43
27
|
padding: 0;
|
|
44
28
|
}
|
|
29
|
+
|
|
30
|
+
.container {
|
|
31
|
+
display: contents;
|
|
32
|
+
--fast: 150ms;
|
|
33
|
+
--slow: 300ms;
|
|
34
|
+
--app-max-width: 40rem;
|
|
35
|
+
--br-large: 8px;
|
|
36
|
+
--br-small: 4px;
|
|
37
|
+
--input-height: 2.5rem;
|
|
38
|
+
--swr-text: 'SWR-VAR-Text', sans-serif;
|
|
39
|
+
--swr-sans: 'SWR-VAR-Sans', sans-serif;
|
|
40
|
+
|
|
41
|
+
// Type scale copied 1:1 from swr.de
|
|
42
|
+
|
|
43
|
+
--fs-small-3: 0.75rem;
|
|
44
|
+
--fs-small-2: 0.875rem;
|
|
45
|
+
--fs-small-1: 1rem;
|
|
46
|
+
--fs-base: 1.125rem;
|
|
47
|
+
--fs-large-1: 1.25rem;
|
|
48
|
+
--fs-large-2: 1.5rem;
|
|
49
|
+
--fs-large-3: 1.75rem;
|
|
50
|
+
--fs-large-4: 2.25rem;
|
|
51
|
+
|
|
52
|
+
@media (min-width: base.$bp-m) {
|
|
53
|
+
--fs-small-3: 0.75rem;
|
|
54
|
+
--fs-small-2: 0.875rem;
|
|
55
|
+
--fs-small-1: 1rem;
|
|
56
|
+
--fs-base: 1.25rem;
|
|
57
|
+
--fs-large-1: 1.5rem;
|
|
58
|
+
--fs-large-2: 2rem;
|
|
59
|
+
--fs-large-3: 2.5rem;
|
|
60
|
+
--fs-large-4: 3.5rem;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
45
63
|
</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,17 @@
|
|
|
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
|
+
component: Headline
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Story name="Default">
|
|
14
|
+
<DesignTokens>
|
|
15
|
+
<Headline>Baden-Württemberg heizt überdurchschnittlich viel mit Wärmepumpe</Headline>
|
|
16
|
+
</DesignTokens>
|
|
17
|
+
</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>
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
component: Note
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Story name="Default">
|
|
15
|
+
<DesignTokens>
|
|
16
|
+
<Note>
|
|
17
|
+
Daten: <a href="#1">Zensus 2022</a>
|
|
18
|
+
(Durchschnittsmieten und Einwohnerzahlen),
|
|
19
|
+
<a href="#1">OpenStreetMap</a> (Kartenmaterial) <Middot /> In unserer Darstellung wurde das Zensusgitter
|
|
20
|
+
auf bewohnte Gebiete begrenzt.
|
|
21
|
+
</Note>
|
|
22
|
+
</DesignTokens>
|
|
23
|
+
</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>
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
border: 1px solid currentColor;
|
|
67
67
|
border-radius: var(--br-small);
|
|
68
68
|
|
|
69
|
-
@media (min-width: base.$
|
|
69
|
+
@media (min-width: base.$bp-s) {
|
|
70
70
|
flex-flow: row;
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
text-underline-offset: 0.2em;
|
|
107
107
|
border-bottom: 1px solid currentColor;
|
|
108
108
|
height: 2.25em;
|
|
109
|
-
@media (min-width: base.$
|
|
109
|
+
@media (min-width: base.$bp-s) {
|
|
110
110
|
justify-content: center;
|
|
111
111
|
padding: 0 1em;
|
|
112
112
|
flex-basis: 0;
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
border-right: 1px solid currentColor;
|
|
115
115
|
border-bottom: 0;
|
|
116
116
|
}
|
|
117
|
-
@media (min-width: base.$
|
|
117
|
+
@media (min-width: base.$bp-s) {
|
|
118
118
|
height: 2.5em;
|
|
119
119
|
}
|
|
120
120
|
&:hover,
|
|
@@ -123,9 +123,9 @@
|
|
|
123
123
|
}
|
|
124
124
|
.is-selected & {
|
|
125
125
|
background: rgb(247, 247, 247);
|
|
126
|
-
font-weight:
|
|
126
|
+
font-weight: 600;
|
|
127
127
|
box-shadow: inset 5px 0px 0 0 var(--violet-dark-5);
|
|
128
|
-
@media (min-width: base.$
|
|
128
|
+
@media (min-width: base.$bp-s) {
|
|
129
129
|
box-shadow: inset 0 -3px 0 0 var(--violet-dark-5);
|
|
130
130
|
}
|
|
131
131
|
}
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { default as Card } from './Card/Card.svelte';
|
|
2
|
-
export { default as Container } from './Container/Container.svelte';
|
|
3
2
|
export { default as Autocomplete } from './Autocomplete/Autocomplete.svelte';
|
|
4
3
|
export { default as Switcher } from './Switcher/Switcher.svelte';
|
|
5
4
|
export { default as Input } from './Input/Input.svelte';
|
package/src/styles/base.scss
CHANGED
|
@@ -1,43 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
$
|
|
3
|
-
$
|
|
4
|
-
$
|
|
5
|
-
$
|
|
1
|
+
// Copied 1:1 from swr.de
|
|
2
|
+
$bp-xxs: 320px;
|
|
3
|
+
$bp-xs: 375px;
|
|
4
|
+
$bp-s: 425px;
|
|
5
|
+
$bp-m: 768px;
|
|
6
|
+
$bp-l: 1024px;
|
|
7
|
+
$bp-xl: 1440px;
|
|
6
8
|
|
|
7
9
|
// TODO drop everything below
|
|
8
|
-
|
|
9
|
-
%caption {
|
|
10
|
+
%form-label {
|
|
10
11
|
font-family: var(--swr-sans);
|
|
11
12
|
font-size: 0.9rem;
|
|
12
13
|
line-height: 1;
|
|
13
14
|
letter-spacing: 0.0045em;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
%caption-bold {
|
|
17
|
-
@extend %caption;
|
|
18
|
-
font-weight: 600;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
%form-label {
|
|
22
|
-
@extend %caption;
|
|
23
15
|
display: block;
|
|
24
16
|
margin-bottom: 0.5em;
|
|
25
17
|
}
|
|
26
18
|
|
|
27
|
-
%
|
|
19
|
+
%form-input {
|
|
28
20
|
font-family: var(--swr-sans);
|
|
29
21
|
font-size: 1.1rem;
|
|
30
22
|
line-height: 1.45;
|
|
31
23
|
letter-spacing: 0.0045em;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
%copy-bold {
|
|
35
|
-
@extend %copy;
|
|
36
|
-
font-weight: 600;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
%form-input {
|
|
40
|
-
@extend %copy;
|
|
41
24
|
height: 2.5em;
|
|
42
25
|
width: 100%;
|
|
43
26
|
border: 1px solid currentColor;
|