@onsvisual/svelte-components 0.0.3 → 0.0.5
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/datavis/Table/Table.svelte.d.ts +33 -0
- package/dist/@types/index.d.ts +27 -12
- package/dist/@types/js/docsPage.d.ts +25 -0
- package/dist/@types/js/withParams.d.ts +15 -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/List/List.svelte.d.ts +27 -0
- package/dist/@types/layout/NavSections/NavSection.svelte.d.ts +31 -0
- package/dist/@types/layout/NavSections/NavSections.svelte.d.ts +43 -0
- package/dist/@types/layout/NavSections/SectionBacklink.svelte.d.ts +23 -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/{components/layout → layout}/TitleBlock/Meta.svelte.d.ts +2 -2
- package/dist/@types/{components/layout → layout}/TitleBlock/TitleBlock.svelte.d.ts +24 -4
- package/dist/datavis/Table/Table.svelte +129 -0
- package/dist/{components/layout → decorators}/Divider/Divider.svelte +1 -1
- package/dist/index.js +31 -12
- 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/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/List/List.svelte +32 -0
- package/dist/layout/NavSections/NavSection.svelte +51 -0
- package/dist/layout/NavSections/NavSections.svelte +92 -0
- package/dist/layout/NavSections/SectionBacklink.svelte +31 -0
- package/dist/layout/Scroller/Scroller.svelte +336 -0
- package/dist/layout/Scroller/ScrollerSection.svelte +61 -0
- package/dist/{components/layout → layout}/Section/Section.svelte +6 -6
- package/dist/layout/TitleBlock/Meta.svelte +26 -0
- package/dist/layout/TitleBlock/TitleBlock.svelte +97 -0
- package/dist/{components/wrappers → wrappers}/Embed/Embed.svelte +4 -2
- package/dist/{components/wrappers → wrappers}/Theme/Theme.svelte +1 -1
- package/package.json +37 -25
- package/dist/components/layout/TitleBlock/Meta.svelte +0 -0
- package/dist/components/layout/TitleBlock/TitleBlock.svelte +0 -0
- package/dist/@types/{components/decorators → decorators}/Blockquote/Blockquote.svelte.d.ts +0 -0
- package/dist/@types/{components/layout → decorators}/Divider/Divider.svelte.d.ts +0 -0
- package/dist/@types/{components/decorators → decorators}/Em/Em.svelte.d.ts +0 -0
- package/dist/@types/{components/inputs → inputs}/Button/Button.svelte.d.ts +0 -0
- package/dist/@types/{components/inputs → inputs}/Button/Icon.svelte.d.ts +0 -0
- package/dist/@types/{components/inputs → inputs}/Dropdown/Dropdown.svelte.d.ts +6 -6
- package/dist/@types/{components/inputs → inputs}/Input/Input.svelte.d.ts +6 -6
- package/dist/@types/{components/inputs → inputs}/Select/Select.svelte.d.ts +8 -8
- package/dist/@types/{components/inputs → inputs}/Textarea/Textarea.svelte.d.ts +4 -4
- package/dist/@types/{components/layout → layout}/Accordion/Accordion.svelte.d.ts +0 -0
- package/dist/@types/{components/layout → layout}/Accordion/AccordionItem.svelte.d.ts +2 -2
- 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}/Section/Section.svelte.d.ts +2 -2
- /package/dist/@types/{components/layout → layout}/Twisty/Twisty.svelte.d.ts +0 -0
- /package/dist/@types/{components/wrappers → wrappers}/Container/Container.svelte.d.ts +0 -0
- /package/dist/@types/{components/wrappers → wrappers}/Embed/Embed.svelte.d.ts +0 -0
- /package/dist/@types/{components/wrappers → wrappers}/Main/Main.svelte.d.ts +0 -0
- /package/dist/@types/{components/wrappers → wrappers}/Theme/Theme.svelte.d.ts +0 -0
- /package/dist/@types/{components/wrappers → wrappers}/Theme/themes.d.ts +0 -0
- /package/dist/{components/decorators → decorators}/Blockquote/Blockquote.svelte +0 -0
- /package/dist/{components/decorators → decorators}/Em/Em.svelte +0 -0
- /package/dist/{components/inputs → inputs}/Button/Button.svelte +0 -0
- /package/dist/{components/inputs → inputs}/Button/Icon.svelte +0 -0
- /package/dist/{components/inputs → inputs}/Dropdown/Dropdown.svelte +0 -0
- /package/dist/{components/inputs → inputs}/Input/Input.svelte +0 -0
- /package/dist/{components/inputs → inputs}/Select/Select.svelte +0 -0
- /package/dist/{components/inputs → 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/wrappers → wrappers}/Container/Container.svelte +0 -0
- /package/dist/{components/wrappers → wrappers}/Main/Main.svelte +0 -0
- /package/dist/{components/wrappers → wrappers}/Theme/themes.js +0 -0
package/dist/index.js
CHANGED
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
// Wrappers
|
|
2
|
-
export { default as
|
|
3
|
-
export { default as
|
|
2
|
+
export { default as Container } from "./wrappers/Container/Container.svelte";
|
|
3
|
+
export { default as Embed } from "./wrappers/Embed/Embed.svelte";
|
|
4
|
+
export { default as Main } from "./wrappers/Main/Main.svelte";
|
|
5
|
+
export { default as Theme } from "./wrappers/Theme/Theme.svelte";
|
|
4
6
|
|
|
5
7
|
// Layout
|
|
6
|
-
export { default as Accordion } from "./
|
|
7
|
-
export { default as
|
|
8
|
-
export { default as
|
|
9
|
-
export { default as
|
|
8
|
+
export { default as Accordion } from "./layout/Accordion/Accordion.svelte";
|
|
9
|
+
export { default as Filler } from "./layout/Filler/Filler.svelte";
|
|
10
|
+
export { default as Footer } from "./layout/Footer/Footer.svelte";
|
|
11
|
+
export { default as Grid } from "./layout/Grid/Grid.svelte";
|
|
12
|
+
export { default as Header } from "./layout/Header/Header.svelte";
|
|
13
|
+
export { default as Hero } from "./layout/Hero/Hero.svelte";
|
|
14
|
+
export { default as List } from "./layout/List/List.svelte";
|
|
15
|
+
export { default as NavSection } from "./layout/NavSections/NavSection.svelte";
|
|
16
|
+
export { default as NavSections } from "./layout/NavSections/NavSections.svelte";
|
|
17
|
+
export { default as Scoller } from "./layout/Scoller/Scoller.svelte";
|
|
18
|
+
export { default as ScollerSection } from "./layout/Scoller/ScollerSection.svelte";
|
|
19
|
+
export { default as Section } from "./layout/Section/Section.svelte";
|
|
20
|
+
export { default as TitleBlock } from "./layout/TitleBlock/TitleBlock.svelte";
|
|
21
|
+
export { default as Twisty } from "./layout/Twisty/Twisty.svelte";
|
|
10
22
|
|
|
11
23
|
// Inputs
|
|
12
|
-
export { default as Button } from "./
|
|
13
|
-
export { default as Dropdown } from "./
|
|
14
|
-
export { default as
|
|
15
|
-
export { default as
|
|
16
|
-
export { default as
|
|
17
|
-
|
|
24
|
+
export { default as Button } from "./inputs/Button/Button.svelte";
|
|
25
|
+
export { default as Dropdown } from "./inputs/Dropdown/Dropdown.svelte";
|
|
26
|
+
export { default as Input } from "./inputs/Input/Input.svelte";
|
|
27
|
+
export { default as Select } from "./inputs/Select/Select.svelte";
|
|
28
|
+
export { default as Textarea } from "./inputs/Textarea/Textarea.svelte";
|
|
29
|
+
|
|
30
|
+
// Decorators
|
|
31
|
+
export { default as Blockquote } from "./decorators/Blockquote/Blockquote.svelte";
|
|
32
|
+
export { default as Divider } from "./decorators/Divider/Divider.svelte";
|
|
33
|
+
export { default as Em } from "./decorators/Em/Em.svelte";
|
|
34
|
+
|
|
35
|
+
// Data visualisation
|
|
36
|
+
export { default as Table } from "./datavis/Table/Table.svelte";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const parameters = {
|
|
2
|
+
viewMode: "docs",
|
|
3
|
+
previewTabs: {
|
|
4
|
+
canvas: { hidden: true },
|
|
5
|
+
},
|
|
6
|
+
toolbar: {
|
|
7
|
+
zoom: { hidden: true },
|
|
8
|
+
eject: { hidden: true },
|
|
9
|
+
fullscreen: { hidden: true },
|
|
10
|
+
"storybook/background": { hidden: true },
|
|
11
|
+
"storybook/outline": { hidden: true },
|
|
12
|
+
},
|
|
13
|
+
};
|
package/dist/js/utils.js
CHANGED
|
@@ -15,7 +15,9 @@ export const slugify = (str, suffix = true) =>
|
|
|
15
15
|
// .concat(suffix ? `-${randomString()}` : "");
|
|
16
16
|
|
|
17
17
|
export const validDate = (str) => {
|
|
18
|
+
if (!str) return false;
|
|
18
19
|
const date = new Date(str);
|
|
20
|
+
// @ts-ignore
|
|
19
21
|
return !isNaN(date);
|
|
20
22
|
};
|
|
21
23
|
|
|
@@ -25,6 +27,7 @@ export const formatDate = (
|
|
|
25
27
|
opts = { year: "numeric", month: "long", day: "2-digit" }
|
|
26
28
|
) => {
|
|
27
29
|
const date = new Date(str);
|
|
30
|
+
// @ts-ignore
|
|
28
31
|
return date.toLocaleDateString(locale, opts);
|
|
29
32
|
};
|
|
30
33
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use custom source code in the "Show code" pull down.
|
|
3
|
+
* @param {object} source Source code object, where key is the language of the source code and value is the code string.
|
|
4
|
+
* @param {object} otherOptions Other props object options, allowing chaining with other methods like withStoryDocs
|
|
5
|
+
* @returns props object including parameters
|
|
6
|
+
*/
|
|
7
|
+
export const withSource = (source, otherOptions = {}) => {
|
|
8
|
+
const language = Object.keys(source)[0];
|
|
9
|
+
const code = source[language];
|
|
10
|
+
const docs = {
|
|
11
|
+
...otherOptions?.parameters?.docs,
|
|
12
|
+
source: { code, language },
|
|
13
|
+
};
|
|
14
|
+
const parameters = { docs };
|
|
15
|
+
return { parameters };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Add custom documentation to a story.
|
|
20
|
+
* @param {string} storyDocs Markdown string of docs
|
|
21
|
+
* @param {object} otherOptions Other props object options, allowing chaining with other methods like withSource
|
|
22
|
+
* @returns props object including parameters
|
|
23
|
+
*/
|
|
24
|
+
export const withStoryDocs = (storyDocs, otherOptions = {}) => {
|
|
25
|
+
const docs = {
|
|
26
|
+
...otherOptions?.parameters?.docs,
|
|
27
|
+
description: { story: storyDocs },
|
|
28
|
+
};
|
|
29
|
+
const parameters = { docs };
|
|
30
|
+
return { parameters };
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Add custom documentation to the top of the component docs page.
|
|
35
|
+
* @param {string} componentDocs Markdown string of docs
|
|
36
|
+
* @param {object} otherOptions Other props object options, allowing chaining with other methods like withSource
|
|
37
|
+
* @returns props object including parameters
|
|
38
|
+
*/
|
|
39
|
+
export const withComponentDocs = (componentDocs, otherOptions = {}) => {
|
|
40
|
+
const docs = {
|
|
41
|
+
...otherOptions?.parameters?.docs,
|
|
42
|
+
description: { component: componentDocs },
|
|
43
|
+
};
|
|
44
|
+
const parameters = { docs };
|
|
45
|
+
return { parameters };
|
|
46
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Container from "$lib/wrappers/Container/Container.svelte";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* (Optional) Sets the unique ID of the section
|
|
6
|
+
* @type {string}
|
|
7
|
+
*/
|
|
8
|
+
export let id = null;
|
|
9
|
+
/**
|
|
10
|
+
* Sets the width of the section
|
|
11
|
+
* @type {"narrow"|"medium"|"wide"|"full"}
|
|
12
|
+
*/
|
|
13
|
+
export let width = "narrow";
|
|
14
|
+
/**
|
|
15
|
+
* Sets the minimum height of the section
|
|
16
|
+
* @type {"auto"|"tall"|"full"}
|
|
17
|
+
*/
|
|
18
|
+
export let height = "tall";
|
|
19
|
+
/**
|
|
20
|
+
* Sets a predefined theme
|
|
21
|
+
* @type {"light"|"dark"|"lightblue"}
|
|
22
|
+
*/
|
|
23
|
+
export let theme = "lightblue";
|
|
24
|
+
/**
|
|
25
|
+
* Define additional props to override the base theme
|
|
26
|
+
* @type {object}
|
|
27
|
+
*/
|
|
28
|
+
export let themeOverrides = null;
|
|
29
|
+
/**
|
|
30
|
+
* Overrides the background CSS for the section
|
|
31
|
+
* @type {string}
|
|
32
|
+
*/
|
|
33
|
+
export let background = null;
|
|
34
|
+
/**
|
|
35
|
+
* Optional margin above section
|
|
36
|
+
* @type {boolean}
|
|
37
|
+
*/
|
|
38
|
+
export let marginTop = false;
|
|
39
|
+
/**
|
|
40
|
+
* Optional margin below section
|
|
41
|
+
* @type {boolean}
|
|
42
|
+
*/
|
|
43
|
+
export let marginBottom = true;
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<Container
|
|
47
|
+
theme="{theme}"
|
|
48
|
+
themeOverrides="{themeOverrides}"
|
|
49
|
+
width="{width}"
|
|
50
|
+
background="{background}"
|
|
51
|
+
marginTop="{marginTop}"
|
|
52
|
+
marginBottom="{marginBottom}"
|
|
53
|
+
height="{height}"
|
|
54
|
+
>
|
|
55
|
+
<section
|
|
56
|
+
class="ons-hero__details ons-feature__filler ons-u-fs-l ons-font-weight__normal"
|
|
57
|
+
id="{id}"
|
|
58
|
+
>
|
|
59
|
+
<slot />
|
|
60
|
+
</section>
|
|
61
|
+
</Container>
|
|
62
|
+
|
|
63
|
+
<style>
|
|
64
|
+
:global(.ons-feature__filler > p + p) {
|
|
65
|
+
margin-top: 30px;
|
|
66
|
+
}</style>
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Container from "$lib/wrappers/Container/Container.svelte";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* (Optional) Sets the unique ID of the section
|
|
6
|
+
* @type {string}
|
|
7
|
+
*/
|
|
8
|
+
export let id = null;
|
|
9
|
+
/**
|
|
10
|
+
* Sets the width of the section
|
|
11
|
+
* @type {"narrow"|"medium"|"wide"|"full"}
|
|
12
|
+
*/
|
|
13
|
+
export let width = "medium";
|
|
14
|
+
/**
|
|
15
|
+
* Sets a predefined theme
|
|
16
|
+
* @type {"light"|"dark"|"lightblue"}
|
|
17
|
+
*/
|
|
18
|
+
export let theme = null;
|
|
19
|
+
/**
|
|
20
|
+
* Define additional props to override the base theme
|
|
21
|
+
* @type {object}
|
|
22
|
+
*/
|
|
23
|
+
export let themeOverrides = null;
|
|
24
|
+
/**
|
|
25
|
+
* Optional margin above section
|
|
26
|
+
* @type {boolean}
|
|
27
|
+
*/
|
|
28
|
+
export let marginTop = false;
|
|
29
|
+
/**
|
|
30
|
+
* Optional margin below section
|
|
31
|
+
* @type {boolean}
|
|
32
|
+
*/
|
|
33
|
+
export let marginBottom = true;
|
|
34
|
+
/**
|
|
35
|
+
* Sets the width of the section
|
|
36
|
+
* @type {"narrow"|"medium"|"wide"|"full"}
|
|
37
|
+
*/
|
|
38
|
+
export let colwidth = "medium"; // narrow | medium | wide | full
|
|
39
|
+
/**
|
|
40
|
+
* (Optional) caption below the grid
|
|
41
|
+
* @type {string}
|
|
42
|
+
*/
|
|
43
|
+
export let caption = "";
|
|
44
|
+
/**
|
|
45
|
+
* Set the minimum height of a grid row (can be a number in pixels, or a valid CSS height, like "100vh")
|
|
46
|
+
* @type {number|string}
|
|
47
|
+
*/
|
|
48
|
+
export let height = 200; // pixel height or "full" for 100vh
|
|
49
|
+
/**
|
|
50
|
+
* Set the grid gap, in pixels
|
|
51
|
+
* @type {number}
|
|
52
|
+
*/
|
|
53
|
+
export let gap = 12;
|
|
54
|
+
|
|
55
|
+
let gridClass = !colwidth || colwidth === "full" ? "" : `grid-${colwidth}`;
|
|
56
|
+
let rowHeight = height === "full" ? "100vh" : !Number.isNaN(height) ? height + "px" : height;
|
|
57
|
+
let gridGap = !Number.isNaN(gap) ? gap + "px" : gap;
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<figure id="{id}" aria-label="{caption}">
|
|
61
|
+
<Container
|
|
62
|
+
theme="{theme}"
|
|
63
|
+
themeOverrides="{themeOverrides}"
|
|
64
|
+
width="{width}"
|
|
65
|
+
height="{['tall', 'full'].includes(height) ? height : 'auto'}"
|
|
66
|
+
marginTop="{marginTop}"
|
|
67
|
+
marginBottom="{!caption ? marginBottom : false}"
|
|
68
|
+
>
|
|
69
|
+
<div class="grid {gridClass}" style:grid-gap="{gridGap}" style:min-height="{rowHeight}">
|
|
70
|
+
<slot />
|
|
71
|
+
</div>
|
|
72
|
+
</Container>
|
|
73
|
+
{#if caption}
|
|
74
|
+
<figcaption>
|
|
75
|
+
<Container
|
|
76
|
+
theme="{theme}"
|
|
77
|
+
themeOverrides="{themeOverrides}"
|
|
78
|
+
width="narrow"
|
|
79
|
+
marginBottom="{marginBottom}"
|
|
80
|
+
>
|
|
81
|
+
<span class="ons-figure__caption">{@html caption}</span>
|
|
82
|
+
</Container>
|
|
83
|
+
</figcaption>
|
|
84
|
+
{/if}
|
|
85
|
+
</figure>
|
|
86
|
+
|
|
87
|
+
<style>
|
|
88
|
+
figure,
|
|
89
|
+
figcaption {
|
|
90
|
+
display: block;
|
|
91
|
+
margin: 0;
|
|
92
|
+
padding: 0;
|
|
93
|
+
}
|
|
94
|
+
.grid {
|
|
95
|
+
display: grid;
|
|
96
|
+
grid-template-columns: repeat(auto-fit, 100%);
|
|
97
|
+
width: 100%;
|
|
98
|
+
margin: 0;
|
|
99
|
+
}
|
|
100
|
+
.grid-narrow {
|
|
101
|
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
|
|
102
|
+
}
|
|
103
|
+
.grid-medium {
|
|
104
|
+
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)) !important;
|
|
105
|
+
}
|
|
106
|
+
.grid-wide {
|
|
107
|
+
grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)) !important;
|
|
108
|
+
}
|
|
109
|
+
:global(.grid > div) {
|
|
110
|
+
min-height: inherit;
|
|
111
|
+
}</style>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { validDate, formatDate } from "$lib/js/utils.js";
|
|
3
|
+
import Container from "$lib/wrappers/Container/Container.svelte";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* (Optional) Sets the unique ID of the section
|
|
7
|
+
* @type {string}
|
|
8
|
+
*/
|
|
9
|
+
export let id = null;
|
|
10
|
+
/**
|
|
11
|
+
* Sets the width of the section
|
|
12
|
+
* @type {"narrow"|"medium"|"wide"|"full"}
|
|
13
|
+
*/
|
|
14
|
+
export let width = "medium";
|
|
15
|
+
/**
|
|
16
|
+
* Sets the minimum height of the section
|
|
17
|
+
* @type {"auto"|"tall"|"full"}
|
|
18
|
+
*/
|
|
19
|
+
export let height = "tall";
|
|
20
|
+
/**
|
|
21
|
+
* Sets the title/headline
|
|
22
|
+
* @type {string}
|
|
23
|
+
*/
|
|
24
|
+
export let title = "Page headline";
|
|
25
|
+
/**
|
|
26
|
+
* Sets the lede (short intro text)
|
|
27
|
+
* @type {string}
|
|
28
|
+
*/
|
|
29
|
+
export let lede = "";
|
|
30
|
+
/**
|
|
31
|
+
* (Optional) Sets the date, using the format "yyyy-mm-dd"
|
|
32
|
+
* @type {string}
|
|
33
|
+
*/
|
|
34
|
+
export let date = null;
|
|
35
|
+
/**
|
|
36
|
+
* Sets a predefined theme
|
|
37
|
+
* @type {"light"|"dark"|"lightblue"}
|
|
38
|
+
*/
|
|
39
|
+
export let theme = "dark";
|
|
40
|
+
/**
|
|
41
|
+
* Define additional props to override the base theme
|
|
42
|
+
* @type {object}
|
|
43
|
+
*/
|
|
44
|
+
export let themeOverrides = null;
|
|
45
|
+
/**
|
|
46
|
+
* Overrides the background CSS for the section
|
|
47
|
+
* @type {string}
|
|
48
|
+
*/
|
|
49
|
+
export let background = "rgb(32, 96, 149)";
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<Container
|
|
53
|
+
theme="{theme}"
|
|
54
|
+
themeOverrides="{themeOverrides}"
|
|
55
|
+
width="{width}"
|
|
56
|
+
background="{background}"
|
|
57
|
+
height="{height}"
|
|
58
|
+
>
|
|
59
|
+
<div id="{id}" class="ons-hero__details ons-grid__col ons-col-8@m ons-col-10@s@m">
|
|
60
|
+
{#if title}
|
|
61
|
+
<header>
|
|
62
|
+
<h1 class="ons-hero__title ons-u-fs-xxxl">{title}</h1>
|
|
63
|
+
</header>
|
|
64
|
+
{/if}
|
|
65
|
+
{#if lede}<p class="ons-hero__text ons-u-fs-l ons-font-weight__normal">{lede}</p>{/if}
|
|
66
|
+
{#if validDate(date)}<p class="ons-hero__text">{formatDate(date)}</p>{/if}
|
|
67
|
+
<slot />
|
|
68
|
+
</div>
|
|
69
|
+
</Container>
|
|
70
|
+
|
|
71
|
+
<style>
|
|
72
|
+
.ons-hero__details {
|
|
73
|
+
padding-left: 0;
|
|
74
|
+
}</style>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Type of list
|
|
6
|
+
* @type {"bullet"|"dash"|"number"|"bare"}
|
|
7
|
+
*/
|
|
8
|
+
export let mode = "bullet"; // dash | bullet | number | bare
|
|
9
|
+
|
|
10
|
+
let el;
|
|
11
|
+
|
|
12
|
+
onMount(() => {
|
|
13
|
+
[...el.children].forEach((c) => {
|
|
14
|
+
if (c.nodeName === "LI") c.className = "ons-list__item";
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
{#if mode === "number"}
|
|
20
|
+
<ol class="ons-list" bind:this="{el}">
|
|
21
|
+
<slot />
|
|
22
|
+
</ol>
|
|
23
|
+
{:else}
|
|
24
|
+
<ul
|
|
25
|
+
class="ons-list"
|
|
26
|
+
class:ons-list--dashed="{mode === 'dash'}"
|
|
27
|
+
class:ons-list--bare="{mode === 'bare'}"
|
|
28
|
+
bind:this="{el}"
|
|
29
|
+
>
|
|
30
|
+
<slot />
|
|
31
|
+
</ul>
|
|
32
|
+
{/if}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onMount, onDestroy, getContext } from "svelte";
|
|
3
|
+
import { slugify } from "$lib/js/utils.js";
|
|
4
|
+
import SectionBacklink from "./SectionBacklink.svelte";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Sets the title of the section
|
|
8
|
+
* @type {string}
|
|
9
|
+
*/
|
|
10
|
+
export let title = "Section title";
|
|
11
|
+
/**
|
|
12
|
+
* Sets the unique ID of the section (if not set, this will be slugified from the title)
|
|
13
|
+
* @type {string}
|
|
14
|
+
*/
|
|
15
|
+
export let id = slugify(title);
|
|
16
|
+
/**
|
|
17
|
+
* Allows the h2 title tag for the section to be visually hidden
|
|
18
|
+
* @type {boolean}
|
|
19
|
+
*/
|
|
20
|
+
export let hideTitle = false;
|
|
21
|
+
|
|
22
|
+
const sections = getContext("sections");
|
|
23
|
+
const observer = getContext("observer");
|
|
24
|
+
const tocId = getContext("tocId");
|
|
25
|
+
|
|
26
|
+
let section;
|
|
27
|
+
|
|
28
|
+
onMount(() => {
|
|
29
|
+
if (sections && observer) {
|
|
30
|
+
$sections = [...$sections, { title, id }];
|
|
31
|
+
$observer.observe(section);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
onDestroy(() => {
|
|
36
|
+
if (sections && observer) {
|
|
37
|
+
$sections = $sections.filter((s) => s.id !== id);
|
|
38
|
+
$observer.unobserve(section);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<section id="{id}" aria-label="{title}" bind:this="{section}">
|
|
44
|
+
{#if title && !hideTitle}
|
|
45
|
+
<h2 class="ons-u-mt-xl ons-u-pb-no ons-u-pt-no">{title}</h2>
|
|
46
|
+
{/if}
|
|
47
|
+
<slot />
|
|
48
|
+
{#if tocId}
|
|
49
|
+
<SectionBacklink tocId="{tocId}" />
|
|
50
|
+
{/if}
|
|
51
|
+
</section>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onMount, setContext } from "svelte";
|
|
3
|
+
import { writable } from "svelte/store";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A label for the page contents nav
|
|
7
|
+
* @type {string}
|
|
8
|
+
*/
|
|
9
|
+
export let contentsLabel = "Page contents";
|
|
10
|
+
/**
|
|
11
|
+
* ID for contents nav section (for back links)
|
|
12
|
+
* @type {string}
|
|
13
|
+
*/
|
|
14
|
+
export let tocId = "toc";
|
|
15
|
+
/**
|
|
16
|
+
* Don't include table of contents (allows for custom uses of nav panel)
|
|
17
|
+
* @type {boolean}
|
|
18
|
+
*/
|
|
19
|
+
export let noContents = false;
|
|
20
|
+
|
|
21
|
+
let active;
|
|
22
|
+
|
|
23
|
+
setContext("tocId", tocId);
|
|
24
|
+
|
|
25
|
+
const sections = writable([]);
|
|
26
|
+
setContext("sections", sections);
|
|
27
|
+
|
|
28
|
+
const observer = writable();
|
|
29
|
+
setContext("observer", observer);
|
|
30
|
+
|
|
31
|
+
onMount(() => {
|
|
32
|
+
if (!noContents) {
|
|
33
|
+
$observer = new IntersectionObserver(
|
|
34
|
+
(entries, observer) => {
|
|
35
|
+
for (let i = 0; i < entries.length; i++) {
|
|
36
|
+
if (entries[i].isIntersecting) {
|
|
37
|
+
active = entries[i].target.id;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
root: null,
|
|
44
|
+
rootMargin: `0% 0% -70% 0%`,
|
|
45
|
+
threshold: 0,
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<div class="ons-page__container ons-container">
|
|
53
|
+
<div class="ons-grid ons-js-toc-container ons-u-ml-no">
|
|
54
|
+
<slot name="header" />
|
|
55
|
+
<div class="ons-grid__col ons-col-4@m ons-u-pl-no ons-grid__col--sticky@m" id="{tocId}">
|
|
56
|
+
<aside class="ons-toc-container" role="complementary">
|
|
57
|
+
<nav class="ons-toc" aria-label="Pages in this guide">
|
|
58
|
+
<slot name="before-nav" />
|
|
59
|
+
{#if !noContents}
|
|
60
|
+
{#if contentsLabel}
|
|
61
|
+
<h2 class="ons-toc__title ons-u-fs-r--b ons-u-mb-s">
|
|
62
|
+
{contentsLabel}
|
|
63
|
+
</h2>
|
|
64
|
+
{/if}
|
|
65
|
+
<ol class="ons-list ons-u-mb-m ons-list--dashed">
|
|
66
|
+
{#each $sections as section}
|
|
67
|
+
<li class="ons-list__item">
|
|
68
|
+
<a
|
|
69
|
+
href="#{section.id}"
|
|
70
|
+
class="ons-list__link"
|
|
71
|
+
class:ons-toc__link-active="{section.id === active}"
|
|
72
|
+
>
|
|
73
|
+
{section.title}
|
|
74
|
+
</a>
|
|
75
|
+
</li>
|
|
76
|
+
{/each}
|
|
77
|
+
</ol>
|
|
78
|
+
{/if}
|
|
79
|
+
<slot name="after-nav" />
|
|
80
|
+
</nav>
|
|
81
|
+
</aside>
|
|
82
|
+
</div>
|
|
83
|
+
<div class="ons-grid__col ons-col-8@m ons-u-pl-no">
|
|
84
|
+
<slot name="before" />
|
|
85
|
+
{#if $observer}
|
|
86
|
+
<slot />
|
|
87
|
+
{/if}
|
|
88
|
+
<slot name="after" />
|
|
89
|
+
</div>
|
|
90
|
+
<slot name="footer" />
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/**
|
|
3
|
+
* ID for contents nav section (for back links)
|
|
4
|
+
* @type {string}
|
|
5
|
+
*/
|
|
6
|
+
export let tocId = "toc";
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<div class="ons-u-mt-l ons-u-d-no@m">
|
|
10
|
+
<div class="ons-back-to">
|
|
11
|
+
<a href="#{tocId}" class="ons-back-to__link">
|
|
12
|
+
<span class="ons-back-to__icon"
|
|
13
|
+
><svg
|
|
14
|
+
class="ons-svg-icon ons-u-mr-xs"
|
|
15
|
+
width="16"
|
|
16
|
+
height="17"
|
|
17
|
+
viewBox="0 0 16 17"
|
|
18
|
+
fill="none"
|
|
19
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
20
|
+
focusable="false"
|
|
21
|
+
aria-hidden="true"
|
|
22
|
+
role="presentation"
|
|
23
|
+
>
|
|
24
|
+
<path
|
|
25
|
+
d="M0 8.07275L1.41 9.48275L7 3.90275V16.0728H9V3.90275L14.58 9.49275L16 8.07275L8 0.0727539L0 8.07275Z"
|
|
26
|
+
fill="currentColor"></path>
|
|
27
|
+
</svg>
|
|
28
|
+
</span>Back to contents</a
|
|
29
|
+
>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|