@onsvisual/svelte-components 1.0.33 → 1.0.35
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/dist/layout/DocumentList/DocumentList.stories.svelte +15 -0
- package/dist/layout/DocumentList/DocumentList.svelte +12 -1
- package/dist/layout/DocumentList/DocumentList.svelte.d.ts +2 -0
- package/dist/layout/Hero/Hero.svelte +3 -1
- package/dist/layout/NavSections/NavSection.svelte +19 -9
- package/dist/layout/NavSections/NavSections.svelte +2 -4
- package/package.json +1 -1
|
@@ -49,12 +49,27 @@
|
|
|
49
49
|
"This handbook explains what the census is, why it matters to everyone and how we can work together to spread the word within your community."
|
|
50
50
|
}
|
|
51
51
|
];
|
|
52
|
+
|
|
53
|
+
const items3 = [
|
|
54
|
+
{
|
|
55
|
+
title: "Including everyone in Census",
|
|
56
|
+
href: "#0",
|
|
57
|
+
meta: "Poster, PDF, 499KB, 1 page"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
title: "Community handbook for Census 2021",
|
|
61
|
+
href: "#0",
|
|
62
|
+
meta: "Booklet,PDF, 3.3MB, 16 pages"
|
|
63
|
+
}
|
|
64
|
+
];
|
|
52
65
|
</script>
|
|
53
66
|
|
|
54
67
|
<Story name="Document list with images" args={{ items: items1 }} />
|
|
55
68
|
|
|
56
69
|
<Story name="Article list with featured item" args={{ items: items2 }} />
|
|
57
70
|
|
|
71
|
+
<Story name="Compact list, no description" args={{ items: items3, compact: true }} />
|
|
72
|
+
|
|
58
73
|
<Story name="Individually defined documents" asChild parameters={withStoryDocs(exampleDocs)}>
|
|
59
74
|
<DocumentList>
|
|
60
75
|
<Document
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* @type {object[]|null}
|
|
6
6
|
*/
|
|
7
7
|
export let items = null;
|
|
8
|
+
/** Compact mode. Removes horizonatal lines between documents
|
|
9
|
+
* @type {boolean}
|
|
10
|
+
*/
|
|
11
|
+
export let compact = false;
|
|
8
12
|
/**
|
|
9
13
|
* Optional: Set an additional CSS class for the component
|
|
10
14
|
* @type {string|null}
|
|
@@ -12,7 +16,7 @@
|
|
|
12
16
|
export let cls = null;
|
|
13
17
|
</script>
|
|
14
18
|
|
|
15
|
-
<ul class="ons-document-list {cls}">
|
|
19
|
+
<ul class="ons-document-list {cls}" class:ons-document-list--compact={compact}>
|
|
16
20
|
<slot />
|
|
17
21
|
{#if Array.isArray(items)}
|
|
18
22
|
{#each items as item}
|
|
@@ -20,3 +24,10 @@
|
|
|
20
24
|
{/each}
|
|
21
25
|
{/if}
|
|
22
26
|
</ul>
|
|
27
|
+
|
|
28
|
+
<style>
|
|
29
|
+
.ons-document-list--compact > :global(.ons-document-list__item) {
|
|
30
|
+
padding-bottom: 0;
|
|
31
|
+
border: none;
|
|
32
|
+
}
|
|
33
|
+
</style>
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/** @typedef {typeof __propDef.slots} DocumentListSlots */
|
|
4
4
|
export default class DocumentList extends SvelteComponentTyped<{
|
|
5
5
|
cls?: string | null | undefined;
|
|
6
|
+
compact?: boolean | undefined;
|
|
6
7
|
items?: object[] | null | undefined;
|
|
7
8
|
}, {
|
|
8
9
|
[evt: string]: CustomEvent<any>;
|
|
@@ -17,6 +18,7 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
17
18
|
declare const __propDef: {
|
|
18
19
|
props: {
|
|
19
20
|
cls?: string | null | undefined;
|
|
21
|
+
compact?: boolean | undefined;
|
|
20
22
|
items?: object[] | null | undefined;
|
|
21
23
|
};
|
|
22
24
|
events: {
|
|
@@ -33,22 +33,32 @@
|
|
|
33
33
|
const observer = getContext("observer");
|
|
34
34
|
const tocId = getContext("tocId");
|
|
35
35
|
|
|
36
|
-
let
|
|
36
|
+
let mounted = false;
|
|
37
|
+
let observed = false;
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
// This allows the table of contents (toc) to render before hydration
|
|
40
|
+
let section = { id, dataset: { title, subsection: String(subsection) } };
|
|
41
|
+
$sections = [...$sections.filter((s) => s.id !== section.id), section];
|
|
42
|
+
|
|
43
|
+
// This allows sections to be highlighted on the toc after hydration,
|
|
44
|
+
// and for sections to be added/removed gracefully from the DOM
|
|
45
|
+
function addToObserver(observer, mounted) {
|
|
46
|
+
if (mounted && observer && !observed) {
|
|
40
47
|
$sections = [...section.parentElement.getElementsByTagName("section")].filter(
|
|
41
48
|
(s) => s.dataset.type === "NavSection"
|
|
42
49
|
);
|
|
43
|
-
|
|
50
|
+
observer.observe(section);
|
|
51
|
+
observed = true;
|
|
44
52
|
}
|
|
45
|
-
}
|
|
53
|
+
}
|
|
54
|
+
$: addToObserver($observer, mounted);
|
|
55
|
+
|
|
56
|
+
onMount(() => (mounted = true));
|
|
46
57
|
|
|
47
58
|
onDestroy(() => {
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
59
|
+
if ($observer) $observer.unobserve(section);
|
|
60
|
+
if ($sections) $sections = $sections.filter((s) => s.id !== id);
|
|
61
|
+
mounted = observed = false;
|
|
52
62
|
});
|
|
53
63
|
</script>
|
|
54
64
|
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
79
|
root: null,
|
|
80
|
-
rootMargin: "-
|
|
80
|
+
rootMargin: "-25% 0px -75%",
|
|
81
81
|
threshold: 0
|
|
82
82
|
}
|
|
83
83
|
);
|
|
@@ -134,9 +134,7 @@
|
|
|
134
134
|
</div>
|
|
135
135
|
<div class="ons-grid__col ons-col-8@m">
|
|
136
136
|
<slot name="before" />
|
|
137
|
-
|
|
138
|
-
<slot />
|
|
139
|
-
{/if}
|
|
137
|
+
<slot />
|
|
140
138
|
<slot name="after" />
|
|
141
139
|
</div>
|
|
142
140
|
</div>
|