@onsvisual/svelte-components 0.0.2 → 0.0.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.
- package/README.md +5 -3
- package/dist/@types/decorators/Blockquote/Blockquote.svelte.d.ts +27 -0
- package/dist/@types/index.d.ts +12 -12
- package/dist/@types/js/docsPage.d.ts +25 -0
- package/dist/@types/js/withParams.d.ts +15 -0
- package/dist/@types/layout/Divider/Divider.svelte.d.ts +33 -0
- package/dist/@types/layout/Filler/Filler.svelte.d.ts +41 -0
- package/dist/@types/layout/Grid/Grid.svelte.d.ts +45 -0
- package/dist/@types/layout/Hero/Hero.svelte.d.ts +43 -0
- package/dist/@types/layout/Scroller/Scroller.svelte.d.ts +51 -0
- package/dist/@types/layout/Scroller/ScrollerSection.svelte.d.ts +33 -0
- package/dist/@types/layout/Section/Section.svelte.d.ts +41 -0
- package/dist/@types/layout/TitleBlock/Meta.svelte.d.ts +23 -0
- package/dist/@types/layout/TitleBlock/TitleBlock.svelte.d.ts +23 -0
- package/dist/@types/wrappers/Embed/Embed.svelte.d.ts +27 -0
- package/dist/@types/wrappers/Main/Main.svelte.d.ts +27 -0
- package/dist/css/main.css +4 -55
- package/dist/decorators/Blockquote/Blockquote.svelte +27 -0
- package/dist/index.js +15 -13
- package/dist/js/docsPage.js +13 -0
- package/dist/js/utils.js +3 -0
- package/dist/js/withParams.js +46 -0
- package/dist/{components/layout → layout}/Accordion/AccordionItem.svelte +1 -1
- package/dist/layout/Divider/Divider.svelte +53 -0
- package/dist/layout/Filler/Filler.svelte +66 -0
- package/dist/{components/layout → layout}/Footer/Footer.svelte +1 -1
- package/dist/layout/Grid/Grid.svelte +111 -0
- package/dist/{components/layout → layout}/Header/Header.svelte +1 -1
- package/dist/layout/Hero/Hero.svelte +74 -0
- package/dist/layout/Scroller/Scroller.svelte +336 -0
- package/dist/layout/Scroller/ScrollerSection.svelte +61 -0
- package/dist/layout/Section/Section.svelte +65 -0
- package/dist/layout/TitleBlock/Meta.svelte +26 -0
- package/dist/layout/TitleBlock/TitleBlock.svelte +0 -0
- package/dist/{components/layout → wrappers}/Container/Container.svelte +4 -2
- package/dist/wrappers/Embed/Embed.svelte +21 -0
- package/dist/wrappers/Main/Main.svelte +3 -0
- package/package.json +34 -19
- /package/dist/@types/{components/ui → decorators}/Em/Em.svelte.d.ts +0 -0
- /package/dist/@types/{components/ui → inputs}/Button/Button.svelte.d.ts +0 -0
- /package/dist/@types/{components/ui → inputs}/Button/Icon.svelte.d.ts +0 -0
- /package/dist/@types/{components/ui → inputs}/Dropdown/Dropdown.svelte.d.ts +0 -0
- /package/dist/@types/{components/ui → inputs}/Input/Input.svelte.d.ts +0 -0
- /package/dist/@types/{components/ui → inputs}/Select/Select.svelte.d.ts +0 -0
- /package/dist/@types/{components/ui → inputs}/Textarea/Textarea.svelte.d.ts +0 -0
- /package/dist/@types/{components/layout → layout}/Accordion/Accordion.svelte.d.ts +0 -0
- /package/dist/@types/{components/layout → layout}/Accordion/AccordionItem.svelte.d.ts +0 -0
- /package/dist/@types/{components/layout → layout}/Footer/Footer.svelte.d.ts +0 -0
- /package/dist/@types/{components/layout → layout}/Footer/ONSLogo.svelte.d.ts +0 -0
- /package/dist/@types/{components/layout → layout}/Header/Header.svelte.d.ts +0 -0
- /package/dist/@types/{components/layout → layout}/Header/ONSLogo.svelte.d.ts +0 -0
- /package/dist/@types/{components/layout → layout}/Twisty/Twisty.svelte.d.ts +0 -0
- /package/dist/@types/{components/layout → wrappers}/Container/Container.svelte.d.ts +0 -0
- /package/dist/@types/{components/layout → wrappers}/Theme/Theme.svelte.d.ts +0 -0
- /package/dist/@types/{components/layout → wrappers}/Theme/themes.d.ts +0 -0
- /package/dist/{components/ui → decorators}/Em/Em.svelte +0 -0
- /package/dist/{components/ui → inputs}/Button/Button.svelte +0 -0
- /package/dist/{components/ui → inputs}/Button/Icon.svelte +0 -0
- /package/dist/{components/ui → inputs}/Dropdown/Dropdown.svelte +0 -0
- /package/dist/{components/ui → inputs}/Input/Input.svelte +0 -0
- /package/dist/{components/ui → inputs}/Select/Select.svelte +0 -0
- /package/dist/{components/ui → inputs}/Textarea/Textarea.svelte +0 -0
- /package/dist/{components/layout → layout}/Accordion/Accordion.svelte +0 -0
- /package/dist/{components/layout → layout}/Footer/ONSLogo.svelte +0 -0
- /package/dist/{components/layout → layout}/Header/ONSLogo.svelte +0 -0
- /package/dist/{components/layout → layout}/Twisty/Twisty.svelte +0 -0
- /package/dist/{components/layout → wrappers}/Theme/Theme.svelte +0 -0
- /package/dist/{components/layout → wrappers}/Theme/themes.js +0 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
<script context="module">
|
|
2
|
+
// Based on svelte-scroller by Rich Harris
|
|
3
|
+
// https://github.com/sveltejs/svelte-scroller
|
|
4
|
+
// Extended to allow for split-screen mode, section IDs and on:change event
|
|
5
|
+
const handlers = [];
|
|
6
|
+
let manager;
|
|
7
|
+
|
|
8
|
+
if (typeof window !== "undefined") {
|
|
9
|
+
const run_all = () => handlers.forEach((fn) => fn());
|
|
10
|
+
|
|
11
|
+
window.addEventListener("scroll", run_all);
|
|
12
|
+
window.addEventListener("resize", run_all);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (typeof IntersectionObserver !== "undefined") {
|
|
16
|
+
const map = new Map();
|
|
17
|
+
|
|
18
|
+
const observer = new IntersectionObserver(
|
|
19
|
+
(entries, observer) => {
|
|
20
|
+
entries.forEach((entry) => {
|
|
21
|
+
const update = map.get(entry.target);
|
|
22
|
+
const index = handlers.indexOf(update);
|
|
23
|
+
|
|
24
|
+
if (entry.isIntersecting) {
|
|
25
|
+
if (index === -1) handlers.push(update);
|
|
26
|
+
} else {
|
|
27
|
+
update();
|
|
28
|
+
if (index !== -1) handlers.splice(index, 1);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
rootMargin: "400px 0px", // TODO why 400?
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
manager = {
|
|
38
|
+
add: ({ outer, update }) => {
|
|
39
|
+
const { top, bottom } = outer.getBoundingClientRect();
|
|
40
|
+
|
|
41
|
+
if (top < window.innerHeight && bottom > 0) handlers.push(update);
|
|
42
|
+
|
|
43
|
+
map.set(outer, update);
|
|
44
|
+
observer.observe(outer);
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
remove: ({ outer, update }) => {
|
|
48
|
+
const index = handlers.indexOf(update);
|
|
49
|
+
if (index !== -1) handlers.splice(index, 1);
|
|
50
|
+
|
|
51
|
+
map.delete(outer);
|
|
52
|
+
observer.unobserve(outer);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
manager = {
|
|
57
|
+
add: ({ update }) => {
|
|
58
|
+
handlers.push(update);
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
remove: ({ update }) => {
|
|
62
|
+
const index = handlers.indexOf(update);
|
|
63
|
+
if (index !== -1) handlers.splice(index, 1);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<script>
|
|
70
|
+
import { onMount, createEventDispatcher } from "svelte";
|
|
71
|
+
const dispatch = createEventDispatcher();
|
|
72
|
+
|
|
73
|
+
// config
|
|
74
|
+
/**
|
|
75
|
+
* Sets the unique ID of the scroller
|
|
76
|
+
* @type {string}
|
|
77
|
+
*/
|
|
78
|
+
export let id = null;
|
|
79
|
+
/**
|
|
80
|
+
* Enables splitscreen view (captions appear on left on larger screens)
|
|
81
|
+
* @type {boolean}
|
|
82
|
+
*/
|
|
83
|
+
export let splitscreen = false;
|
|
84
|
+
/**
|
|
85
|
+
* Adds a margin under the scroller section
|
|
86
|
+
* @type {boolean}
|
|
87
|
+
*/
|
|
88
|
+
export let marginBottom = true;
|
|
89
|
+
/**
|
|
90
|
+
* Set the threshold for the transition between scroller sections (0-1)
|
|
91
|
+
* @type {number}
|
|
92
|
+
*/
|
|
93
|
+
export let threshold = 0.7;
|
|
94
|
+
|
|
95
|
+
let top = 0;
|
|
96
|
+
let bottom = 1;
|
|
97
|
+
let query = "section";
|
|
98
|
+
let parallax = false;
|
|
99
|
+
|
|
100
|
+
// bindings
|
|
101
|
+
/**
|
|
102
|
+
* Binding: Total number of sections within scroller
|
|
103
|
+
* @type {number}
|
|
104
|
+
*/
|
|
105
|
+
export let count = 0;
|
|
106
|
+
/**
|
|
107
|
+
* Binding: Current section index (number)
|
|
108
|
+
* @type {number}
|
|
109
|
+
*/
|
|
110
|
+
export let index = 0;
|
|
111
|
+
/**
|
|
112
|
+
* Binding: Current section id, if it has one set
|
|
113
|
+
* @type {string}
|
|
114
|
+
*/
|
|
115
|
+
export let sectionId = null; // ID for current section within scroller
|
|
116
|
+
/**
|
|
117
|
+
* Binding: The progress between the start of current scroller section and next (0-1)
|
|
118
|
+
* @type {number}
|
|
119
|
+
*/
|
|
120
|
+
export let offset = 0;
|
|
121
|
+
/**
|
|
122
|
+
* Binding: The progress through the whole scroller (0-1)
|
|
123
|
+
* @type {number}
|
|
124
|
+
*/
|
|
125
|
+
export let progress = 0;
|
|
126
|
+
/**
|
|
127
|
+
* Binding: Whether the scroller is visible on screen or not
|
|
128
|
+
* @type {boolean}
|
|
129
|
+
*/
|
|
130
|
+
export let visible = false;
|
|
131
|
+
|
|
132
|
+
let outer;
|
|
133
|
+
let foreground;
|
|
134
|
+
let background;
|
|
135
|
+
let left;
|
|
136
|
+
let sections;
|
|
137
|
+
let wh = 0;
|
|
138
|
+
let fixed;
|
|
139
|
+
let offset_top = 0;
|
|
140
|
+
let width = 1;
|
|
141
|
+
let height;
|
|
142
|
+
let inverted;
|
|
143
|
+
|
|
144
|
+
$: top_px = Math.round(top * wh);
|
|
145
|
+
$: bottom_px = Math.round(bottom * wh);
|
|
146
|
+
$: threshold_px = Math.round(threshold * wh);
|
|
147
|
+
|
|
148
|
+
$: top, bottom, threshold, parallax, update();
|
|
149
|
+
|
|
150
|
+
$: style = `
|
|
151
|
+
position: ${fixed ? "fixed" : "absolute"};
|
|
152
|
+
top: 0;
|
|
153
|
+
transform: translate(0, ${offset_top}px);
|
|
154
|
+
z-index: ${inverted ? 3 : 1};
|
|
155
|
+
`;
|
|
156
|
+
|
|
157
|
+
$: widthStyle = fixed ? `width:${width}px;` : "";
|
|
158
|
+
|
|
159
|
+
onMount(() => {
|
|
160
|
+
sections = foreground.querySelectorAll(query);
|
|
161
|
+
count = sections.length;
|
|
162
|
+
|
|
163
|
+
update();
|
|
164
|
+
|
|
165
|
+
const scroller = { outer, update };
|
|
166
|
+
|
|
167
|
+
manager.add(scroller);
|
|
168
|
+
return () => manager.remove(scroller);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
function update() {
|
|
172
|
+
if (!foreground) return;
|
|
173
|
+
|
|
174
|
+
// re-measure outer container
|
|
175
|
+
const bcr = outer.getBoundingClientRect();
|
|
176
|
+
left = bcr.left;
|
|
177
|
+
width = bcr.right - left;
|
|
178
|
+
|
|
179
|
+
// determine fix state
|
|
180
|
+
const fg = foreground.getBoundingClientRect();
|
|
181
|
+
const bg = background.getBoundingClientRect();
|
|
182
|
+
|
|
183
|
+
visible = fg.top < wh && fg.bottom > 0;
|
|
184
|
+
|
|
185
|
+
const foreground_height = fg.bottom - fg.top;
|
|
186
|
+
const background_height = bg.bottom - bg.top;
|
|
187
|
+
|
|
188
|
+
const available_space = bottom_px - top_px;
|
|
189
|
+
progress = (top_px - fg.top) / (foreground_height - available_space);
|
|
190
|
+
|
|
191
|
+
if (progress <= 0) {
|
|
192
|
+
offset_top = 0;
|
|
193
|
+
fixed = false;
|
|
194
|
+
} else if (progress >= 1) {
|
|
195
|
+
offset_top = parallax
|
|
196
|
+
? foreground_height - background_height
|
|
197
|
+
: foreground_height - available_space;
|
|
198
|
+
fixed = false;
|
|
199
|
+
} else {
|
|
200
|
+
offset_top = parallax
|
|
201
|
+
? Math.round(top_px - progress * (background_height - available_space))
|
|
202
|
+
: top_px;
|
|
203
|
+
fixed = true;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
for (let i = 0; i < sections.length; i++) {
|
|
207
|
+
const section = sections[i];
|
|
208
|
+
const { top } = section.getBoundingClientRect();
|
|
209
|
+
|
|
210
|
+
const next = sections[i + 1];
|
|
211
|
+
const bottom = next ? next.getBoundingClientRect().top : fg.bottom;
|
|
212
|
+
|
|
213
|
+
offset = (threshold_px - top) / (bottom - top);
|
|
214
|
+
if (bottom >= threshold_px) {
|
|
215
|
+
if (index !== i) {
|
|
216
|
+
index = i;
|
|
217
|
+
sectionId = section.dataset.id ? section.dataset.id : null;
|
|
218
|
+
dispatch("change", { id, index, sectionId });
|
|
219
|
+
}
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
</script>
|
|
225
|
+
|
|
226
|
+
<svelte:window bind:innerHeight="{wh}" />
|
|
227
|
+
|
|
228
|
+
<svelte-scroller-outer id="{id}" bind:this="{outer}" class:splitscreen="{splitscreen}">
|
|
229
|
+
<svelte-scroller-background-container class="background-container" style="{style}{widthStyle}">
|
|
230
|
+
<svelte-scroller-background bind:this="{background}">
|
|
231
|
+
<slot name="background" />
|
|
232
|
+
</svelte-scroller-background>
|
|
233
|
+
</svelte-scroller-background-container>
|
|
234
|
+
|
|
235
|
+
<svelte-scroller-foreground bind:this="{foreground}">
|
|
236
|
+
<slot name="foreground" />
|
|
237
|
+
</svelte-scroller-foreground>
|
|
238
|
+
</svelte-scroller-outer>
|
|
239
|
+
|
|
240
|
+
{#if marginBottom}
|
|
241
|
+
<div class="ons-spacer"></div>
|
|
242
|
+
{/if}
|
|
243
|
+
|
|
244
|
+
<style>
|
|
245
|
+
svelte-scroller-outer {
|
|
246
|
+
display: block;
|
|
247
|
+
position: relative;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
svelte-scroller-background {
|
|
251
|
+
display: block;
|
|
252
|
+
position: relative;
|
|
253
|
+
width: 100%;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
svelte-scroller-foreground {
|
|
257
|
+
display: block;
|
|
258
|
+
position: relative;
|
|
259
|
+
z-index: 2;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
svelte-scroller-foreground::after {
|
|
263
|
+
content: " ";
|
|
264
|
+
display: block;
|
|
265
|
+
clear: both;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
svelte-scroller-background-container {
|
|
269
|
+
display: block;
|
|
270
|
+
position: absolute;
|
|
271
|
+
width: 100%;
|
|
272
|
+
max-width: 100%;
|
|
273
|
+
pointer-events: none;
|
|
274
|
+
/* height: 100%; */
|
|
275
|
+
|
|
276
|
+
/* in theory this helps prevent jumping */
|
|
277
|
+
will-change: transform;
|
|
278
|
+
/* -webkit-transform: translate3d(0, 0, 0);
|
|
279
|
+
-moz-transform: translate3d(0, 0, 0);
|
|
280
|
+
transform: translate3d(0, 0, 0); */
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
svelte-scroller-background-container {
|
|
284
|
+
pointer-events: all !important;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
:global([slot="foreground"] section) {
|
|
288
|
+
padding: 70vh 0 100vh 0;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
:global([slot="foreground"] section + section) {
|
|
292
|
+
padding: 0 0 100vh 0;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
:global([slot="foreground"] section:last-of-type) {
|
|
296
|
+
padding: 0 0 70vh 0;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
:global([slot="foreground"] section > div) {
|
|
300
|
+
position: relative;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
:global([slot="foreground"] section > div:before) {
|
|
304
|
+
background-color: var(--background, white);
|
|
305
|
+
opacity: 80%;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
:global([slot="foreground"] section div p) {
|
|
309
|
+
margin: 0;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
:global([slot="foreground"] section div p + p) {
|
|
313
|
+
margin-top: 30px;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
:global([slot="foreground"] section div h2),
|
|
317
|
+
:global([slot="foreground"] section div h3) {
|
|
318
|
+
margin: 10px 0 20px 0;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
@media (min-width: 992px) {
|
|
322
|
+
.splitscreen svelte-scroller-background {
|
|
323
|
+
width: calc(100% - 480px) !important;
|
|
324
|
+
min-width: 65%;
|
|
325
|
+
margin: 0 0 0 auto;
|
|
326
|
+
}
|
|
327
|
+
:global(.splitscreen [slot="foreground"] section div::before) {
|
|
328
|
+
opacity: 0;
|
|
329
|
+
}
|
|
330
|
+
:global(.splitscreen [slot="foreground"] section) {
|
|
331
|
+
width: 480px;
|
|
332
|
+
max-width: 35%;
|
|
333
|
+
margin: 0 auto 0 0;
|
|
334
|
+
background-color: var(--background, white);
|
|
335
|
+
}
|
|
336
|
+
}</style>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
import Container from "$lib/wrappers/Container/Container.svelte";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Sets the unique ID of the section
|
|
7
|
+
* @type {string}
|
|
8
|
+
*/
|
|
9
|
+
export let id = null;
|
|
10
|
+
/**
|
|
11
|
+
* Sets a predefined theme
|
|
12
|
+
* @type {"light"|"dark"|"lightblue"}
|
|
13
|
+
*/
|
|
14
|
+
export let theme = null;
|
|
15
|
+
/**
|
|
16
|
+
* Sets the title of the section
|
|
17
|
+
* @type {string}
|
|
18
|
+
*/
|
|
19
|
+
export let title = "";
|
|
20
|
+
/**
|
|
21
|
+
* Allows the h2 title tag for the section to be visually hidden
|
|
22
|
+
* @type {boolean}
|
|
23
|
+
*/
|
|
24
|
+
export let hideTitle = false;
|
|
25
|
+
|
|
26
|
+
let section;
|
|
27
|
+
let background;
|
|
28
|
+
|
|
29
|
+
onMount(() => {
|
|
30
|
+
background = getComputedStyle(section).getPropertyValue("--background").replaceAll('"', "");
|
|
31
|
+
console.log(section, getComputedStyle(section), background);
|
|
32
|
+
});
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<section data-id="{id}" bind:this="{section}">
|
|
36
|
+
<Container theme="{theme}" width="narrow" background="none">
|
|
37
|
+
<div class="ons-scroller-section" style:--background="{background}">
|
|
38
|
+
{#if title && !hideTitle}
|
|
39
|
+
<h2 class="section-title">{title}</h2>
|
|
40
|
+
{/if}
|
|
41
|
+
<slot />
|
|
42
|
+
</div>
|
|
43
|
+
</Container>
|
|
44
|
+
</section>
|
|
45
|
+
|
|
46
|
+
<style>
|
|
47
|
+
.ons-scroller-section {
|
|
48
|
+
position: relative;
|
|
49
|
+
}
|
|
50
|
+
.ons-scroller-section::after {
|
|
51
|
+
content: " ";
|
|
52
|
+
position: absolute;
|
|
53
|
+
z-index: -1;
|
|
54
|
+
top: 0;
|
|
55
|
+
bottom: 0;
|
|
56
|
+
left: 0;
|
|
57
|
+
right: 0;
|
|
58
|
+
margin: -1rem;
|
|
59
|
+
background: var(--background, white);
|
|
60
|
+
opacity: 90%;
|
|
61
|
+
}</style>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { slugify } from "$lib/js/utils.js";
|
|
3
|
+
import Container from "$lib/wrappers/Container/Container.svelte";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Sets the unique ID of the section
|
|
7
|
+
* @type {string}
|
|
8
|
+
*/
|
|
9
|
+
export let id = null;
|
|
10
|
+
/**
|
|
11
|
+
* Sets the width of the container
|
|
12
|
+
* @type {"narrow"|"medium"|"wide"|"full"}
|
|
13
|
+
*/
|
|
14
|
+
export let width = "narrow";
|
|
15
|
+
/**
|
|
16
|
+
* Sets the title of the section
|
|
17
|
+
* @type {string}
|
|
18
|
+
*/
|
|
19
|
+
export let title = "";
|
|
20
|
+
/**
|
|
21
|
+
* Allows the h2 title tag for the section to be visually hidden
|
|
22
|
+
* @type {boolean}
|
|
23
|
+
*/
|
|
24
|
+
export let hideTitle = false;
|
|
25
|
+
/**
|
|
26
|
+
* Sets a predefined theme
|
|
27
|
+
* @type {"light"|"dark"|"lightblue"}
|
|
28
|
+
*/
|
|
29
|
+
export let theme = null;
|
|
30
|
+
/**
|
|
31
|
+
* Define additional props to override the base theme
|
|
32
|
+
* @type {object}
|
|
33
|
+
*/
|
|
34
|
+
export let themeOverrides = null;
|
|
35
|
+
/**
|
|
36
|
+
* Optional margin above section
|
|
37
|
+
* @type {boolean}
|
|
38
|
+
*/
|
|
39
|
+
export let marginTop = false;
|
|
40
|
+
/**
|
|
41
|
+
* Optional margin below section
|
|
42
|
+
* @type {boolean}
|
|
43
|
+
*/
|
|
44
|
+
export let marginBottom = true;
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<Container
|
|
48
|
+
theme="{theme}"
|
|
49
|
+
themeOverrides="{themeOverrides}"
|
|
50
|
+
width="{width}"
|
|
51
|
+
marginTop="{marginTop}"
|
|
52
|
+
marginBottom="{marginBottom}"
|
|
53
|
+
>
|
|
54
|
+
<section id="{id ? id : slugify(title)}" aria-label="{title}" class="ons-feature__section">
|
|
55
|
+
{#if title && !hideTitle}
|
|
56
|
+
<h2 class="section-title">{title}</h2>
|
|
57
|
+
{/if}
|
|
58
|
+
<slot />
|
|
59
|
+
</section>
|
|
60
|
+
</Container>
|
|
61
|
+
|
|
62
|
+
<style>
|
|
63
|
+
:global(.ons-feature__section > p:last-child) {
|
|
64
|
+
margin-bottom: 0;
|
|
65
|
+
}</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { validDate, formatDate } from "$lib/js/utils.js";
|
|
3
|
+
export let meta = null;
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
{#if Array.isArray(meta)}
|
|
7
|
+
<dl
|
|
8
|
+
class="ons-metadata metadata__list ons-grid ons-grid--gutterless ons-u-cf ons-u-mb-m"
|
|
9
|
+
title="Dataset ID and release date information"
|
|
10
|
+
aria-label="Dataset ID and release date information"
|
|
11
|
+
>
|
|
12
|
+
{#each meta as m, i}
|
|
13
|
+
<div class="ons-grid__col ons-col-{m.col ? m.col : 12}@m" class:ons-u-mt-xs="{i !== 0}">
|
|
14
|
+
<dt class="ons-metadata__term ons-u-mr-xs">{m.key}:</dt>
|
|
15
|
+
<dd class="ons-metadata__value ons-u-f-no">
|
|
16
|
+
{#if validDate(m.value)}
|
|
17
|
+
<time datetime="{new Date(m.value).toISOString()}">{formatDate(m.value)}</time>
|
|
18
|
+
{#if m.extra}{@html m.extra}{/if}
|
|
19
|
+
{:else}
|
|
20
|
+
{@html m.value}
|
|
21
|
+
{/if}
|
|
22
|
+
</dd>
|
|
23
|
+
</div>
|
|
24
|
+
{/each}
|
|
25
|
+
</dl>
|
|
26
|
+
{/if}
|
|
File without changes
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
export let background = null;
|
|
39
39
|
</script>
|
|
40
40
|
|
|
41
|
-
{#if marginTop}<div class="ons-spacer"></div>{/if}
|
|
42
41
|
{#if width === "narrow"}
|
|
43
42
|
<Theme theme="{theme}" background="{background}" overrides="{themeOverrides}">
|
|
44
43
|
<div
|
|
@@ -46,9 +45,11 @@
|
|
|
46
45
|
class:ons-page__container--tall-height="{height === 'tall'}"
|
|
47
46
|
class:ons-page__container--full-height="{height === 'full'}"
|
|
48
47
|
>
|
|
48
|
+
{#if marginTop}<div class="ons-spacer"></div>{/if}
|
|
49
49
|
<div class="ons-page__container--narrow">
|
|
50
50
|
<slot />
|
|
51
51
|
</div>
|
|
52
|
+
{#if marginBottom}<div class="ons-spacer"></div>{/if}
|
|
52
53
|
</div>
|
|
53
54
|
</Theme>
|
|
54
55
|
{:else}
|
|
@@ -60,11 +61,12 @@
|
|
|
60
61
|
class:ons-page__container--tall-height="{height === 'tall'}"
|
|
61
62
|
class:ons-page__container--full-height="{height === 'full'}"
|
|
62
63
|
>
|
|
64
|
+
{#if marginTop}<div class="ons-spacer"></div>{/if}
|
|
63
65
|
<slot />
|
|
66
|
+
{#if marginBottom}<div class="ons-spacer"></div>{/if}
|
|
64
67
|
</div>
|
|
65
68
|
</Theme>
|
|
66
69
|
{/if}
|
|
67
|
-
{#if marginBottom}<div class="ons-spacer"></div>{/if}
|
|
68
70
|
|
|
69
71
|
<style>
|
|
70
72
|
.ons-page__container {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
import pym from "pym.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Binding for pymChild element (can be used to send messages to parent of iframe)
|
|
7
|
+
* @type {object}
|
|
8
|
+
*/
|
|
9
|
+
export let pymChild = null;
|
|
10
|
+
|
|
11
|
+
onMount(() => {
|
|
12
|
+
pymChild = new pym.Child({ polling: 1000 });
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<slot />
|
|
17
|
+
|
|
18
|
+
<style>
|
|
19
|
+
:global(.ons-container) {
|
|
20
|
+
padding: 0 !important;
|
|
21
|
+
}</style>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onsvisual/svelte-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://onsvisual.github.io/svelte-components",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"start": "storybook dev -p 3000",
|
|
13
13
|
"new": "node ./bin/newComponent/index.cjs",
|
|
14
|
-
"build:package": "node ./bin/buildPackage/index.js",
|
|
14
|
+
"build:package": "node ./bin/buildPackage/index.js && node ./bin/postprocess/css-merge.js",
|
|
15
15
|
"build:chromatic": "storybook build -o docs",
|
|
16
16
|
"build:docs": "storybook build -o docs && touch ./docs/.nojekyll",
|
|
17
17
|
"build": "npm-run-all build:package build:docs",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"babel-loader": "^9.1.2",
|
|
60
60
|
"change-case": "^4.1.2",
|
|
61
61
|
"chromatic": "^6.19.9",
|
|
62
|
+
"csso": "^5.0.5",
|
|
62
63
|
"eslint": "^8.42.0",
|
|
63
64
|
"eslint-config-prettier": "^8.8.0",
|
|
64
65
|
"eslint-plugin-n": "^16.0.0",
|
|
@@ -114,26 +115,40 @@
|
|
|
114
115
|
"./package.json": "./package.json",
|
|
115
116
|
"./actions/cssVariables": "./dist/actions/cssVariables/index.js",
|
|
116
117
|
"./actions/resizeObserver": "./dist/actions/resizeObserver/index.js",
|
|
117
|
-
"./components/layout/Accordion/Accordion.svelte": "./dist/components/layout/Accordion/Accordion.svelte",
|
|
118
|
-
"./components/layout/Accordion/AccordionItem.svelte": "./dist/components/layout/Accordion/AccordionItem.svelte",
|
|
119
|
-
"./components/layout/Container/Container.svelte": "./dist/components/layout/Container/Container.svelte",
|
|
120
|
-
"./components/layout/Footer/Footer.svelte": "./dist/components/layout/Footer/Footer.svelte",
|
|
121
|
-
"./components/layout/Footer/ONSLogo.svelte": "./dist/components/layout/Footer/ONSLogo.svelte",
|
|
122
|
-
"./components/layout/Header/Header.svelte": "./dist/components/layout/Header/Header.svelte",
|
|
123
|
-
"./components/layout/Header/ONSLogo.svelte": "./dist/components/layout/Header/ONSLogo.svelte",
|
|
124
|
-
"./components/layout/Theme/Theme.svelte": "./dist/components/layout/Theme/Theme.svelte",
|
|
125
|
-
"./components/layout/Theme/themes": "./dist/components/layout/Theme/themes.js",
|
|
126
|
-
"./components/layout/Twisty/Twisty.svelte": "./dist/components/layout/Twisty/Twisty.svelte",
|
|
127
|
-
"./components/ui/Button/Button.svelte": "./dist/components/ui/Button/Button.svelte",
|
|
128
|
-
"./components/ui/Button/Icon.svelte": "./dist/components/ui/Button/Icon.svelte",
|
|
129
|
-
"./components/ui/Dropdown/Dropdown.svelte": "./dist/components/ui/Dropdown/Dropdown.svelte",
|
|
130
|
-
"./components/ui/Em/Em.svelte": "./dist/components/ui/Em/Em.svelte",
|
|
131
|
-
"./components/ui/Input/Input.svelte": "./dist/components/ui/Input/Input.svelte",
|
|
132
|
-
"./components/ui/Select/Select.svelte": "./dist/components/ui/Select/Select.svelte",
|
|
133
|
-
"./components/ui/Textarea/Textarea.svelte": "./dist/components/ui/Textarea/Textarea.svelte",
|
|
134
118
|
"./css/main.css": "./dist/css/main.css",
|
|
119
|
+
"./decorators/Blockquote/Blockquote.svelte": "./dist/decorators/Blockquote/Blockquote.svelte",
|
|
120
|
+
"./decorators/Em/Em.svelte": "./dist/decorators/Em/Em.svelte",
|
|
135
121
|
"./globals.d.ts": "./dist/globals.d.ts",
|
|
122
|
+
"./inputs/Button/Button.svelte": "./dist/inputs/Button/Button.svelte",
|
|
123
|
+
"./inputs/Button/Icon.svelte": "./dist/inputs/Button/Icon.svelte",
|
|
124
|
+
"./inputs/Dropdown/Dropdown.svelte": "./dist/inputs/Dropdown/Dropdown.svelte",
|
|
125
|
+
"./inputs/Input/Input.svelte": "./dist/inputs/Input/Input.svelte",
|
|
126
|
+
"./inputs/Select/Select.svelte": "./dist/inputs/Select/Select.svelte",
|
|
127
|
+
"./inputs/Textarea/Textarea.svelte": "./dist/inputs/Textarea/Textarea.svelte",
|
|
128
|
+
"./js/docsPage": "./dist/js/docsPage.js",
|
|
136
129
|
"./js/utils": "./dist/js/utils.js",
|
|
130
|
+
"./js/withParams": "./dist/js/withParams.js",
|
|
131
|
+
"./layout/Accordion/Accordion.svelte": "./dist/layout/Accordion/Accordion.svelte",
|
|
132
|
+
"./layout/Accordion/AccordionItem.svelte": "./dist/layout/Accordion/AccordionItem.svelte",
|
|
133
|
+
"./layout/Divider/Divider.svelte": "./dist/layout/Divider/Divider.svelte",
|
|
134
|
+
"./layout/Filler/Filler.svelte": "./dist/layout/Filler/Filler.svelte",
|
|
135
|
+
"./layout/Footer/Footer.svelte": "./dist/layout/Footer/Footer.svelte",
|
|
136
|
+
"./layout/Footer/ONSLogo.svelte": "./dist/layout/Footer/ONSLogo.svelte",
|
|
137
|
+
"./layout/Grid/Grid.svelte": "./dist/layout/Grid/Grid.svelte",
|
|
138
|
+
"./layout/Header/Header.svelte": "./dist/layout/Header/Header.svelte",
|
|
139
|
+
"./layout/Header/ONSLogo.svelte": "./dist/layout/Header/ONSLogo.svelte",
|
|
140
|
+
"./layout/Hero/Hero.svelte": "./dist/layout/Hero/Hero.svelte",
|
|
141
|
+
"./layout/Scroller/Scroller.svelte": "./dist/layout/Scroller/Scroller.svelte",
|
|
142
|
+
"./layout/Scroller/ScrollerSection.svelte": "./dist/layout/Scroller/ScrollerSection.svelte",
|
|
143
|
+
"./layout/Section/Section.svelte": "./dist/layout/Section/Section.svelte",
|
|
144
|
+
"./layout/TitleBlock/Meta.svelte": "./dist/layout/TitleBlock/Meta.svelte",
|
|
145
|
+
"./layout/TitleBlock/TitleBlock.svelte": "./dist/layout/TitleBlock/TitleBlock.svelte",
|
|
146
|
+
"./layout/Twisty/Twisty.svelte": "./dist/layout/Twisty/Twisty.svelte",
|
|
147
|
+
"./wrappers/Container/Container.svelte": "./dist/wrappers/Container/Container.svelte",
|
|
148
|
+
"./wrappers/Embed/Embed.svelte": "./dist/wrappers/Embed/Embed.svelte",
|
|
149
|
+
"./wrappers/Main/Main.svelte": "./dist/wrappers/Main/Main.svelte",
|
|
150
|
+
"./wrappers/Theme/Theme.svelte": "./dist/wrappers/Theme/Theme.svelte",
|
|
151
|
+
"./wrappers/Theme/themes": "./dist/wrappers/Theme/themes.js",
|
|
137
152
|
".": "./dist/index.js"
|
|
138
153
|
},
|
|
139
154
|
"svelte": "./dist/index.js",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|