@swr-data-lab/components 1.13.2 → 1.13.4

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.
@@ -35,12 +35,6 @@ let { project, charts, baseUrl } = $props();
35
35
  </main>
36
36
 
37
37
  <style>
38
- :global(*) {
39
- margin: 0;
40
- padding: 0;
41
- box-sizing: border-box;
42
- color: inherit;
43
- }
44
38
  main {
45
39
  display: flex;
46
40
  justify-content: center;
@@ -11,5 +11,24 @@ const { position = 'bottom-right', customAttribution } = $props();
11
11
  })}
12
12
  />
13
13
 
14
- <style>
15
- </style>
14
+ <style>:global(.maplibregl-ctrl.maplibregl-ctrl-attrib) {
15
+ font-size: var(--fs-small-3);
16
+ letter-spacing: 0.005em;
17
+ word-spacing: 0.005em;
18
+ font-family: var(--swr-sans);
19
+ }
20
+ :global(.maplibregl-ctrl-attrib.maplibregl-compact-show) :global(.maplibregl-ctrl-attrib-inner) {
21
+ display: block;
22
+ }
23
+ :global(.maplibregl-ctrl-attrib-button) {
24
+ display: none;
25
+ }
26
+ :global(.maplibregl-ctrl-attrib) :global(a) {
27
+ color: inherit;
28
+ text-decoration: none;
29
+ text-underline-offset: 0.2em;
30
+ }
31
+ :global(.maplibregl-ctrl-attrib) :global(a:hover) {
32
+ color: inherit;
33
+ text-decoration: underline;
34
+ }</style>
@@ -21,5 +21,135 @@ const geocoder = new MaplibreGeocoder(geocoderAPI, {
21
21
 
22
22
  <MapControl control={geocoder} position="top-left" />
23
23
 
24
- <style>
25
- </style>
24
+ <style>:global(.maplibregl-ctrl-geocoder) {
25
+ background-color: #fff;
26
+ position: relative;
27
+ width: 100%;
28
+ z-index: 1;
29
+ font-family: var(--swr-sans);
30
+ font-size: var(--fs-small-1);
31
+ border-radius: var(--br-small);
32
+ border: 1px solid rgba(0, 0, 0, 0.75);
33
+ box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.075);
34
+ }
35
+ :global(.maplibre-gl-geocoder--error) {
36
+ font-size: var(--fs-small-2);
37
+ color: var(--gray-dark-2);
38
+ padding: 0.4em 0.65em;
39
+ }
40
+ :global(.maplibregl-ctrl-geocoder--input) {
41
+ width: 100%;
42
+ height: 100%;
43
+ font-family: inherit;
44
+ font-size: inherit;
45
+ background-color: transparent;
46
+ color: var(--gray-dark-5);
47
+ border: 0;
48
+ height: 1.85em;
49
+ padding: 0 1.85em;
50
+ padding-top: 0.1em;
51
+ text-overflow: ellipsis;
52
+ white-space: nowrap;
53
+ overflow: hidden;
54
+ }
55
+ :global(.maplibregl-ctrl-geocoder--input::placeholder) {
56
+ opacity: 1;
57
+ color: var(--gray-dark-2);
58
+ }
59
+ :global(.maplibregl-ctrl-geocoder--input:focus) {
60
+ color: var(--gray-dark-5);
61
+ outline: 0;
62
+ }
63
+ :global(.maplibregl-ctrl-geocoder) :global(.maplibregl-ctrl-geocoder--pin-right) > :global(*) {
64
+ display: none;
65
+ position: absolute;
66
+ z-index: 2;
67
+ right: 0.5em;
68
+ top: 50%;
69
+ transform: translateY(-50%);
70
+ border: 0;
71
+ }
72
+ :global(.maplibregl-ctrl-geocoder) :global(.suggestions) {
73
+ background: white;
74
+ border: 1px solid rgba(0, 0, 0, 0.75);
75
+ box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
76
+ border-radius: var(--br-small);
77
+ left: 0;
78
+ list-style: none;
79
+ position: absolute;
80
+ width: 100%;
81
+ top: calc(100% + 0.5em);
82
+ z-index: 1000;
83
+ overflow: hidden;
84
+ }
85
+ :global(.maplibregl-ctrl-bottom-left) :global(.suggestions),
86
+ :global(.maplibregl-ctrl-bottom-right) :global(.suggestions) {
87
+ top: auto;
88
+ bottom: 100%;
89
+ }
90
+ :global(.maplibregl-ctrl-geocoder) :global(.suggestions) > :global(li) > :global(a) {
91
+ cursor: default;
92
+ display: block;
93
+ padding: 0.5em 0.75em;
94
+ color: var(--gray-dark-5);
95
+ padding-bottom: 0.5em;
96
+ border-bottom: 1px solid var(--gray-light-3);
97
+ }
98
+ :global(.maplibregl-ctrl-geocoder) :global(.suggestions) > :global(li:last-child) > :global(a) {
99
+ border-bottom: 0;
100
+ }
101
+ :global(.maplibregl-ctrl-geocoder) :global(.suggestions) > :global(.active) > :global(a),
102
+ :global(.maplibregl-ctrl-geocoder) :global(.suggestions) > :global(li) > :global(a:hover) {
103
+ background: var(--gray-light-5);
104
+ text-decoration: none;
105
+ cursor: pointer;
106
+ }
107
+ :global(.maplibregl-ctrl-geocoder) :global(.suggestions) > :global(.active) :global(.maplibregl-ctrl-geocoder--result-title),
108
+ :global(.maplibregl-ctrl-geocoder) :global(.suggestions) > :global(li) > :global(a:hover) :global(.maplibregl-ctrl-geocoder--result-title) {
109
+ text-decoration: underline;
110
+ }
111
+ :global(.maplibregl-ctrl-geocoder--suggestion) {
112
+ display: flex;
113
+ flex-direction: row;
114
+ align-items: center;
115
+ }
116
+ :global(.maplibregl-ctrl-geocoder--suggestion-info) {
117
+ display: flex;
118
+ flex-direction: column;
119
+ }
120
+ :global(.maplibregl-ctrl-geocoder--suggestion-match) {
121
+ font-weight: bold;
122
+ }
123
+ :global(.maplibregl-ctrl-geocoder--suggestion-title),
124
+ :global(.maplibregl-ctrl-geocoder--suggestion-address),
125
+ :global(.maplibregl-ctrl-geocoder--result-address) {
126
+ text-overflow: ellipsis;
127
+ overflow: hidden;
128
+ white-space: nowrap;
129
+ }
130
+ :global(.maplibregl-ctrl-geocoder--result-icon) {
131
+ display: none;
132
+ }
133
+ :global(.maplibregl-ctrl-geocoder--result-title) {
134
+ font-weight: 600;
135
+ letter-spacing: 0;
136
+ }
137
+ :global(.maplibregl-ctrl-geocoder--result-address) {
138
+ font-size: var(--fs-small-2);
139
+ color: var(--gray-dark-2);
140
+ line-height: 1.3;
141
+ }
142
+ :global(.maplibregl-ctrl-geocoder--icon) {
143
+ display: inline-block;
144
+ position: absolute;
145
+ top: 50%;
146
+ transform: translateY(-50%);
147
+ height: 1em;
148
+ }
149
+ :global(.maplibregl-ctrl-geocoder--icon-close) {
150
+ right: 0;
151
+ }
152
+ :global(.maplibregl-ctrl-geocoder--icon-search) {
153
+ left: 0.5em;
154
+ height: 1.5em;
155
+ }</style>
@@ -72,20 +72,146 @@ $effect(() => {
72
72
  {/if}
73
73
  </div>
74
74
 
75
- <style>
76
- .container {
77
- width: 100%;
78
- height: 100%;
79
- }
75
+ <style>.container {
76
+ width: 100%;
77
+ height: 100%;
78
+ }
79
+
80
+ .debug {
81
+ position: absolute;
82
+ top: 0;
83
+ right: 0;
84
+ background: rgba(0, 0, 0, 0.9);
85
+ color: white;
86
+ z-index: 1000;
87
+ padding: 2px;
88
+ font-family: monospace;
89
+ }
80
90
 
81
- .debug {
82
- position: absolute;
83
- top: 0;
84
- right: 0;
85
- background: rgba(0, 0, 0, 0.9);
86
- color: white;
87
- z-index: 1000;
88
- padding: 2px;
89
- font-family: monospace;
90
- }
91
- </style>
91
+ :global(.maplibregl-map) {
92
+ overflow: hidden;
93
+ position: relative;
94
+ }
95
+ :global(.maplibregl-canvas) {
96
+ left: 0;
97
+ position: absolute;
98
+ top: 0;
99
+ }
100
+ :global(.maplibregl-map:fullscreen) {
101
+ height: 100%;
102
+ width: 100%;
103
+ }
104
+ :global(.maplibregl-canvas-container.maplibregl-interactive) {
105
+ cursor: grab;
106
+ user-select: none;
107
+ }
108
+ :global(.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer) {
109
+ cursor: pointer;
110
+ }
111
+ :global(.maplibregl-canvas-container.maplibregl-interactive:active) {
112
+ cursor: grabbing;
113
+ }
114
+ :global(.maplibregl-canvas-container.maplibregl-touch-zoom-rotate),
115
+ :global(.maplibregl-canvas-container.maplibregl-touch-zoom-rotate) :global(.maplibregl-canvas) {
116
+ touch-action: pan-x pan-y;
117
+ }
118
+ :global(.maplibregl-canvas-container.maplibregl-touch-drag-pan),
119
+ :global(.maplibregl-canvas-container.maplibregl-touch-drag-pan) :global(.maplibregl-canvas) {
120
+ touch-action: pinch-zoom;
121
+ }
122
+ :global(.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan),
123
+ :global(.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan) :global(.maplibregl-canvas) {
124
+ touch-action: none;
125
+ }
126
+ :global(.maplibregl-ctrl-bottom-left),
127
+ :global(.maplibregl-ctrl-bottom-right),
128
+ :global(.maplibregl-ctrl-top-left),
129
+ :global(.maplibregl-ctrl-top-right) {
130
+ position: absolute;
131
+ z-index: 2;
132
+ display: flex;
133
+ flex-flow: column;
134
+ gap: 0.75em;
135
+ align-items: flex-start;
136
+ }
137
+ :global(.maplibregl-ctrl-top-left) {
138
+ left: 0.5em;
139
+ top: 0.5em;
140
+ }
141
+ :global(.maplibregl-ctrl-top-right) {
142
+ right: 0;
143
+ top: 0;
144
+ }
145
+ :global(.maplibregl-ctrl-bottom-left) {
146
+ bottom: 0.5em;
147
+ left: 0.5em;
148
+ }
149
+ :global(.maplibregl-ctrl-bottom-right) {
150
+ bottom: 0.5em;
151
+ right: 0.5em;
152
+ }
153
+ :global(.maplibregl-ctrl) {
154
+ pointer-events: auto;
155
+ transform: translate(0);
156
+ }
157
+ :global(.maplibregl-ctrl-group) {
158
+ background: white;
159
+ border: 1px solid rgba(0, 0, 0, 0.75);
160
+ box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.075);
161
+ border-radius: var(--br-small);
162
+ overflow: hidden;
163
+ }
164
+ :global(.maplibregl-ctrl-group) :global(button) {
165
+ background-color: transparent;
166
+ border: 0;
167
+ box-sizing: border-box;
168
+ cursor: pointer;
169
+ display: block;
170
+ height: 29px;
171
+ outline: none;
172
+ padding: 0;
173
+ width: 29px;
174
+ }
175
+ :global(.maplibregl-ctrl-group) :global(button) + :global(button) {
176
+ border-top: 1px solid rgba(0, 0, 0, 0.35);
177
+ }
178
+ :global(.maplibregl-ctrl) :global(button) :global(.maplibregl-ctrl-icon) {
179
+ background-position: 50%;
180
+ background-repeat: no-repeat;
181
+ display: block;
182
+ height: 100%;
183
+ width: 100%;
184
+ }
185
+ :global(.maplibregl-ctrl) :global(button:disabled) {
186
+ cursor: not-allowed;
187
+ }
188
+ :global(.maplibregl-ctrl) :global(button:disabled) :global(.maplibregl-ctrl-icon) {
189
+ opacity: 0.5;
190
+ }
191
+ :global(.maplibregl-ctrl) :global(button:not(:disabled):hover) {
192
+ background-color: var(--gray-light-5);
193
+ }
194
+ :global(.maplibregl-ctrl-group) :global(button:focus:focus-visible) {
195
+ box-shadow: 0 0 2px 2px #0096ff;
196
+ }
197
+ :global(.maplibregl-ctrl-group) :global(button:focus:not(:focus-visible)) {
198
+ box-shadow: none;
199
+ }
200
+ :global(.maplibregl-ctrl-group) :global(button:focus:first-child) {
201
+ border-radius: 4px 4px 0 0;
202
+ }
203
+ :global(.maplibregl-ctrl-group) :global(button:focus:last-child) {
204
+ border-radius: 0 0 4px 4px;
205
+ }
206
+ :global(.maplibregl-ctrl-group) :global(button:focus:only-child) {
207
+ border-radius: inherit;
208
+ }
209
+ :global(.maplibregl-marker) {
210
+ left: 0;
211
+ top: 0;
212
+ position: absolute;
213
+ will-change: transform;
214
+ }
215
+ :global(.maplibregl-marker) :global(path) {
216
+ fill: var(--violet-dark-5);
217
+ }</style>
@@ -5,5 +5,12 @@ const { showCompass = false, visualizePitch = false, position = 'bottom-left' }
5
5
 
6
6
  <MapControl control={new maplibre.NavigationControl({ showCompass, visualizePitch })} {position} />
7
7
 
8
- <style>
9
- </style>
8
+ <style>:global(button.maplibregl-ctrl-zoom-out) :global(.maplibregl-ctrl-icon) {
9
+ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E%3C/svg%3E");
10
+ }
11
+ :global(button.maplibregl-ctrl-zoom-in) :global(.maplibregl-ctrl-icon) {
12
+ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E%3C/svg%3E");
13
+ }
14
+ :global(button.maplibregl-ctrl-compass) :global(.maplibregl-ctrl-icon) {
15
+ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E%3Cpath d='m10.5 14 4-8 4 8h-8z'/%3E%3Cpath d='m10.5 16 4 8 4-8h-8z' fill='%23ccc'/%3E%3C/svg%3E");
16
+ }</style>
@@ -5,5 +5,10 @@ let { maxWidth = 100, unit = 'metric', position = 'bottom-left' } = $props();
5
5
 
6
6
  <MapControl control={new maplibre.ScaleControl({ maxWidth, unit })} {position} />
7
7
 
8
- <style>
9
- </style>
8
+ <style>:global(.maplibregl-ctrl-scale) {
9
+ color: inherit;
10
+ border-bottom: 1px solid currentColor;
11
+ font-weight: 400;
12
+ font-size: var(--fs-small-3);
13
+ font-family: var(--swr-text);
14
+ }</style>
@@ -29,18 +29,100 @@ onDestroy(() => tooltip.remove());
29
29
  {@render children?.()}
30
30
  </div>
31
31
 
32
- <style>
33
- .container {
34
- background: white;
35
- padding: 0.75em;
36
- border-radius: 2px;
37
- border: 1px solid rgba(0, 0, 0, 0.75);
38
- border-radius: var(--br-small);
39
- filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.1));
40
- pointer-events: none;
41
- }
32
+ <style>.container {
33
+ background: white;
34
+ padding: 0.75em;
35
+ border-radius: 2px;
36
+ border: 1px solid rgba(0, 0, 0, 0.75);
37
+ border-radius: var(--br-small);
38
+ filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.1));
39
+ pointer-events: none;
40
+ }
42
41
 
43
- .mouseEvents {
44
- pointer-events: all;
45
- }
46
- </style>
42
+ .mouseEvents {
43
+ pointer-events: all;
44
+ }
45
+
46
+ :global(.maplibregl-popup) {
47
+ top: 0;
48
+ left: 0;
49
+ display: flex;
50
+ position: absolute;
51
+ will-change: transform;
52
+ }
53
+ :global(.maplibregl-popup-anchor-top),
54
+ :global(.maplibregl-popup-anchor-top-left),
55
+ :global(.maplibregl-popup-anchor-top-right) {
56
+ flex-direction: column;
57
+ }
58
+ :global(.maplibregl-popup-anchor-bottom),
59
+ :global(.maplibregl-popup-anchor-bottom-left),
60
+ :global(.maplibregl-popup-anchor-bottom-right) {
61
+ flex-direction: column-reverse;
62
+ }
63
+ :global(.maplibregl-popup-anchor-left) {
64
+ flex-direction: row;
65
+ }
66
+ :global(.maplibregl-popup-anchor-right) {
67
+ flex-direction: row-reverse;
68
+ }
69
+ :global(.maplibregl-popup-anchor-bottom) :global(.maplibregl-popup-tip) {
70
+ transform: translateY(50%) rotate(45deg);
71
+ align-self: center;
72
+ }
73
+ :global(.maplibregl-popup-anchor-top) :global(.maplibregl-popup-tip) {
74
+ transform: translateY(-50%) rotate(-135deg);
75
+ align-self: center;
76
+ }
77
+ :global(.maplibregl-popup-anchor-left) :global(.maplibregl-popup-tip) {
78
+ transform: translateX(-50%) rotate(135deg);
79
+ align-self: center;
80
+ }
81
+ :global(.maplibregl-popup-anchor-top-left) :global(.maplibregl-popup-tip) {
82
+ transform: translateY(1em) translateX(-50%) rotate(135deg);
83
+ }
84
+ :global(.maplibregl-popup-anchor-bottom-left) :global(.maplibregl-popup-tip) {
85
+ transform: translateY(-1em) translateX(-50%) rotate(135deg);
86
+ }
87
+ :global(.maplibregl-popup-anchor-right) :global(.maplibregl-popup-tip) {
88
+ transform: translateX(50%) rotate(-45deg);
89
+ align-self: center;
90
+ }
91
+ :global(.maplibregl-popup-anchor-top-right) :global(.maplibregl-popup-tip) {
92
+ transform: translateX(-1em) translateY(-50%) rotate(-135deg);
93
+ align-self: flex-end;
94
+ }
95
+ :global(.maplibregl-popup-anchor-bottom-right) :global(.maplibregl-popup-tip) {
96
+ transform: translateX(-1em) translateY(50%) rotate(45deg);
97
+ align-self: flex-end;
98
+ }
99
+ :global(.maplibregl-popup-close-button) {
100
+ position: absolute;
101
+ top: 0.5em;
102
+ right: 0.5em;
103
+ cursor: pointer;
104
+ border-radius: 2px;
105
+ display: flex;
106
+ justify-content: center;
107
+ align-items: center;
108
+ padding-bottom: 0.15em;
109
+ font-size: 1.25rem;
110
+ width: 1.1em;
111
+ height: 1.1em;
112
+ z-index: 100;
113
+ background: white;
114
+ border: 1px solid var(--gray-dark-5);
115
+ }
116
+ :global(.maplibregl-popup-close-button:hover),
117
+ :global(.maplibregl-popup-close-button:focus) {
118
+ background: var(--gray-light-5);
119
+ }
120
+ :global(.maplibregl-popup-tip) {
121
+ width: 0.65rem;
122
+ height: 0.65rem;
123
+ background: white;
124
+ position: absolute;
125
+ border-right: 1px solid rgba(0, 0, 0, 0.75);
126
+ border-bottom: 1px solid rgba(0, 0, 0, 0.75);
127
+ z-index: 10;
128
+ }</style>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@swr-data-lab/components",
3
3
  "description": "SWR Data Lab component library",
4
- "version": "1.13.2",
4
+ "version": "1.13.4",
5
5
  "author": "SWR Data Lab",
6
6
  "license": "UNLICENSED",
7
7
  "type": "module",
@@ -1,17 +0,0 @@
1
- import { Story, Meta, Primary, Controls, Stories } from '@storybook/addon-docs/blocks';
2
-
3
- import * as ChartFooterStories from './ChartFooter.stories.svelte';
4
-
5
- <Meta of={ChartFooterStories}/>
6
-
7
- # Chart Footer
8
-
9
- Standard chart footer.
10
-
11
- - Nest arbitrary HTML inside component to render your notes
12
- - Use `one-up` layout unless your footnotes fit two lines or fewer.
13
- - Use `<Middot/>` to separate sentences
14
-
15
- <Controls />
16
-
17
- <Stories/>
@@ -1,16 +0,0 @@
1
- import { Story, Meta, Primary, Controls, Stories } from '@storybook/addon-docs/blocks';
2
-
3
- import * as ChartHeaderStories from './ChartHeader.stories.svelte';
4
-
5
- <Meta of={ChartHeaderStories}/>
6
-
7
- # Chart header
8
-
9
- Standard chart header.
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)
12
- - Any nested HTML will render under the description (useful for i.e colour keys and interactives controls).
13
-
14
- <Controls />
15
-
16
- <Stories/>
@@ -1,13 +0,0 @@
1
- import { Story, Meta, Primary, Controls, Stories } from '@storybook/addon-docs/blocks';
2
-
3
- import * as ChartListStories from './ChartList.stories.svelte';
4
-
5
- <Meta of={ChartListStories} />
6
-
7
- # Chart List
8
-
9
- Utility component for displaying a list of charts with associated embed URLs during development (typically on the `/` route of your Svelte project).
10
-
11
- <Stories />
12
-
13
- <Controls />
@@ -1,110 +0,0 @@
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"
8
-
9
- <Meta title='Design Tokens'/>
10
-
11
- # Design Tokens
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
-
27
- ## Usage
28
-
29
- ### Web
30
-
31
- The `<DesignTokens>` component makes colours, type sizes and other design tokens available to its children as CSS variables.
32
-
33
- ```html
34
- <script>
35
- import DesignTokens from "@swr-data-lab/components"
36
- </script>
37
-
38
- <DesignTokens>
39
- <p>I'm a sample paragraph</p>
40
- </DesignTokens>
41
-
42
- <style>
43
- p {
44
- color: var(--violet-dark-1) // this works
45
- }
46
- </style>
47
- ```
48
-
49
- You can also import `tokens` directly to use them in Javascript:
50
-
51
- ```jsx
52
- import tokens from "@swr-data-lab/components"
53
- import { scaleThreshold } from 'd3-scale';
54
- const sampleScale = scaleThreshold([0, 10], tokens.scales.red_blue);
55
- ```
56
-
57
- ### Figma
58
-
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).
60
-
61
-
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}/>
75
-
76
- #### Note
77
- <Canvas of={NoteStories.Default}/>
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
87
- <ColorPalette>
88
- {["violet", "plum", "pink", "red", "orange", "yellow", "apple" , "forest","teal", "blue", "gray"].map((el, i) => {
89
- return(
90
- <ColorItem
91
- title={`${el.split("")[0].toUpperCase()}${el.slice(1)}`}
92
- colors={shades[el]}
93
- />
94
- )
95
- })}
96
- </ColorPalette>
97
-
98
- ### Linear Scales
99
- ### Categorical Scales
100
- ### Divergent Scales
101
-
102
- <ColorPalette>
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
- />)
109
- })}
110
- </ColorPalette>
@@ -1,13 +0,0 @@
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/>
package/dist/Intro.mdx DELETED
@@ -1,7 +0,0 @@
1
- import { Meta } from '@storybook/addon-docs/blocks';
2
-
3
- <Meta title="About" />
4
-
5
- # SWR Data Lab Components
6
-
7
- Experimental component library for SWR Data Lab interactives.
@@ -1,25 +0,0 @@
1
- import { Story, Meta, Primary, Controls, Stories} from '@storybook/addon-docs/blocks';
2
-
3
- import * as SelectStories from './Select.stories.svelte';
4
-
5
- <Meta of={SelectStories}/>
6
-
7
- # Select
8
-
9
- This component is a select input with a search feature and various options such as grouped items, multi-select etc. based on [svelte-select](https://github.com/rob-balfre/svelte-select).
10
-
11
- Select items passed to the `items` prop must be of type `SelectItem`:
12
-
13
- ```ts
14
- interface SelectItem {
15
- value: string;
16
- label: string;
17
- group?: string;
18
- details?: any;
19
- }
20
- ```
21
-
22
- <Controls/>
23
-
24
- <Stories/>
25
-
@@ -1,13 +0,0 @@
1
- import { Story, Meta, Primary, Controls, Stories} from '@storybook/addon-docs/blocks';
2
-
3
- import * as SwictherStories from './Switcher.stories.svelte';
4
-
5
- <Meta of={SwictherStories}/>
6
-
7
- # Switcher
8
-
9
- Radio-like form component to choose exactly one of a given set of options.
10
-
11
- <Controls/>
12
-
13
- <Stories/>
@@ -1,12 +0,0 @@
1
- import { Meta } from '@storybook/addon-docs/blocks';
2
- import { Story, Primary, Controls, Stories } from '@storybook/addon-docs/blocks';
3
- import * as MapControlStories from './MapControl.stories.svelte';
4
-
5
- <Meta of={MapControlStories} />
6
-
7
- # MapControl
8
-
9
- Base component used by all other built-in control components. Also useful for building application-specific controls (see demo below).
10
-
11
- <Stories />
12
- <Controls />
@@ -1,86 +0,0 @@
1
- import { Story, Meta, Primary, Controls, Stories } from '@storybook/addon-docs/blocks';
2
- import Mermaid from '../../../.storybook/blocks/Mermaid';
3
- import SWRDataLabLight from './SWRDataLabLight';
4
- import * as MapStyleStories from './SWRDataLabLight.stories.svelte';
5
-
6
- <Meta of={MapStyleStories} />
7
-
8
- # SWR Data Lab Light
9
-
10
- Light-themed general-purpose basemap using SWR colours and typefaces based on
11
- [versatiles-greybeard](https://github.com/versatiles-org/versatiles-style).
12
-
13
- - Data sources
14
- - Vector data: [versatiles-osm](https://download.versatiles.org/) in the [Shortbread schema](https://shortbread-tiles.org/) served from `tiles.versatiles.org`
15
- - Typefaces: SWR Sans served from `https://static.datenhub.net/maps/fonts/`.
16
- - Layer count: {SWRDataLabLight.layers.length}
17
-
18
- <Story of={MapStyleStories.Default} />
19
-
20
- <br />
21
-
22
- ### Design Notes
23
-
24
- We take a two-step design approach:
25
-
26
- 1. Sort the geographic data we want to present into semantic groups like "Admin Boundaries", "Roads" or "Transit" (inspired by Mapbox's [Style Components](https://docs.mapbox.com/studio-manual/guides/components/)).
27
- 2. Derive physical layers (ie. `MapLayerSpecification`) from these groups and interleave them to produce a convincing image
28
- 3. Use shared design tokens to style each physical layer
29
-
30
- <Mermaid chart={`
31
- block-beta
32
- columns 10
33
-
34
- classDef admin fill:#e5dbf5;
35
- classDef buildings fill:#FFBA35;
36
- classDef roads fill:#FFD584;
37
- classDef transit fill:#C5F0B1;
38
- classDef walking fill:#65D62B;
39
- classDef landuse fill:#eee;
40
-
41
- block:semantic:6
42
- columns 1
43
- columns 1
44
- s_admin["Admin"]
45
- s_buildings["Buildings"]
46
- s_roads["Roads"]
47
- s_transit["Transit"]
48
- s_walking["Walking + Cycling"]
49
- s_landuse["Landuse"]
50
- end
51
-
52
- block:actual:10
53
- columns 1
54
- a_admin_labels["Admin Labels"]
55
- a_walking_labels["Walking (Labels)"]
56
- a_transit_labels["Transit (Labels)"]
57
- a_roads_labels["Roads (Labels)"]
58
- a_admin0["Admin 0 (Countries)"]
59
- a_admin1["Admin 1 (States/Provinces)"]
60
- a_admin2["Admin 2 (Districts)"]
61
- a_buildings["Buildings"]
62
- a_walking_bridge["Walking (Bridge)"]
63
- a_transit_bridge["Transit (Bridge)"]
64
- a_roads_bridge["Roads (Bridge)"]
65
- a_walking_surface["Walking (Surface)"]
66
- a_transit_surface["Transit (Surface)"]
67
- a_roads_surface["Roads (Surface)"]
68
- a_walking_tunnel["Walking (Tunnel)"]
69
- a_transit_tunnel["Transit (Tunnel)"]
70
- a_roads_tunnel["Roads (Tunnel)"]
71
- a_land["Land"]
72
- a_ocean["Ocean"]
73
- a_background["Background"]
74
- end
75
-
76
- class s_admin,a_admin0,a_admin1,a_admin2,a_admin_labels admin
77
- class s_buildings,a_buildings buildings
78
- class s_roads,a_roads_bridge,a_roads_surface,a_roads_tunnel,a_roads_labels roads
79
- class s_transit,a_transit_bridge,a_transit_surface,a_transit_tunnel,a_transit_labels transit
80
- class s_walking,a_walking_bridge,a_walking_surface,a_walking_tunnel,a_walking_labels walking
81
- class s_landuse,a_land,a_ocean,a_background landuse
82
- `}/>
83
-
84
- ### References
85
-
86
- - [Foundational Map Design | BUILD with Mapbox ](https://www.youtube.com/watch?v=QDfj9oGVZmE)
@@ -1,91 +0,0 @@
1
- import { Meta } from '@storybook/addon-docs/blocks';
2
- import { Story, Primary, Controls, Stories } from '@storybook/addon-docs/blocks';
3
- import * as MapStories from './Map/Map.stories.svelte';
4
- import * as MapStyleStories from './MapStyle/SWRDataLabLight.stories.svelte';
5
-
6
- <Meta title="Maplibre" />
7
-
8
- # Maplibre
9
-
10
- Lightweight svelte components and basemaps for rendering custom slippy maps using the [versatiles](https://docs.versatiles.org/) stack.
11
-
12
- Based on [prior work](https://github.com/SWRdata/frontend_svelte_p012_spritpreise/blob/main/src/lib/components/Map/Map.svelte) from [Michael Kreil](https://github.com/MichaelKreil), [Jakob Bauer](https://github.com/AgricolaJKB), [dimfield](https://github.com/dimfeld/svelte-maplibre) and [MIRUNE](https://github.com/MIERUNE/svelte-maplibre-gl).
13
-
14
- <Story of={MapStyleStories.Default} />
15
-
16
- <br />
17
-
18
- ## Usage
19
-
20
- This example initialises a map using the SWRDataLabLight style, adds an additional vector tile source and renders it as a vector layer.
21
-
22
- ```jsx
23
- <script>
24
- import {
25
- Map,
26
- VectorLayer,
27
- AttributionControl,
28
- VectorTileSource,
29
- SWRDataLabLight,
30
- DesignTokens
31
- } from '@swr-data-lab/components';
32
- </script>
33
-
34
- <DesignTokens>
35
- <div class='container'>
36
- <Map style={SWRDataLabLight}>
37
- <VectorTileSource
38
- id='ev-infra-source'
39
- url='https://static.datenhub.net/data/p108_e_auto_check/ev_infra_merged.versatiles?tiles/{z}/{x}/{y}'>
40
- </VectorTileSource>
41
- <VectorLayer
42
- sourceId='ev-infra-source'
43
- sourceLayer='coverage'
44
- id='ev-infra-outline'
45
- type='line'
46
- paint={{'line-width': 1, 'line-color': 'red'}}>
47
- </VectorLayer>
48
- <AttributionControl />
49
- </Map>
50
- </div>
51
- </DesignTokens>
52
-
53
- <style>
54
- .container {
55
- width: 100%;
56
- height: 600px;
57
- }
58
- </style>
59
- ```
60
-
61
- ## Available components
62
-
63
- ### Sources
64
-
65
- - **[VectorTileSource](?path=/docs/maplibre-source-vectortilesource--docs)**: Loads a vector tile source supplied by a tileserver
66
-
67
- ### Layers
68
-
69
- - **[VectorLayer](?path=/docs/maplibre-layer-vectorlayer--docs)**: Renders a layer from a vector tile source.
70
-
71
- ### Controls
72
-
73
- - **[ScaleControl](?path=/docs/maplibre-control-scalecontrol--docs)**: Renders a dynamic scalebar
74
- - **[NavigationControl](?path=/docs/maplibre-control-navigationcontrol--docs)**: Renders zoom buttons and optional compass
75
- - **[GeocoderControl](?path=/docs/maplibre-control-geocodercontrol--docs)**: Renders a search input using [maplibre-gl-geocoder](https://github.com/maplibre/maplibre-gl-geocoder) and any supported forward geocoding service (currently [maptiler](https://www.maptiler.com/) only)
76
- - **[AttributionControl](?path=/docs/maplibre-control-attributioncontrol--docs)**: Renders maplibre's default attribution control
77
- - **[Custom controls](?path=/docs/maplibre-control-mapcontrol--docs)**: Renders arbitrary HTML inside maplibre's layout
78
-
79
- ### Misc
80
-
81
- - **[Tooltip](?path=/docs/maplibre-extras-tooltip--docs)**
82
- - **[WithLinkLocation](?path=/docs/maplibre-extras-withlinklocation--docs)**: Derive the maps `initialLocation` from a URL parameter via forward geocoding
83
-
84
- ### Styles
85
-
86
- - **[SWR Data Lab Light](?path=/docs/maplibre-style-swr-data-lab-light--docs)**: Light-themed basemap using SWR colours and typefaces
87
- - Any valid MapLibre style specification, such as [versatiles-style](https://github.com/versatiles-org/versatiles-style) (see [demo](?path=/story/map-map--alternate-style))
88
-
89
- ## Known issues
90
-
91
- - Firefox throws warning `WebGL warning: texImage: Alpha-premult and y-flip are deprecated for non-DOM-Element uploads`: Known [upstream mapligre-gl issue](https://github.com/maplibre/maplibre-gl-js/issues/2030) (safe to ignore)
@@ -1,19 +0,0 @@
1
- import { Story, Meta, Primary, Controls, Stories } from '@storybook/addon-docs/blocks';
2
-
3
- import * as VectorTileSourceStories from './VectorTileSource.stories.svelte';
4
-
5
- <Meta of={VectorTileSourceStories} />
6
-
7
- # VectorTileSource
8
-
9
- Loads tiled vector data from a tileserver. Any mablibre-supported tileserver will work, but we'll typically use tiles served by `versatiles-rs` or `versatiles-node-static-proxy`.
10
-
11
- ```jsx
12
- <Map>
13
- <VectorTileSource
14
- url="https://static.datenhub.net/rent_merged.versatiles?tiles/{z}/{x}/{y}"
15
- id="chargers"
16
- />
17
- <VectorLayer sourceId="chargers" />
18
- </Map>
19
- ```
@@ -1,11 +0,0 @@
1
- import { Story, Meta, Primary, Controls, Stories } from '@storybook/addon-docs/blocks';
2
-
3
- import * as WithLinkLocationStories from './WithLinkLocation.stories.svelte';
4
-
5
- <Meta of={WithLinkLocationStories} />
6
-
7
- # WithLinkLocation
8
-
9
- <Controls />
10
-
11
- <Stories />