@onsvisual/svelte-components 0.0.4 → 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.
Files changed (27) hide show
  1. package/dist/@types/datavis/Table/Table.svelte.d.ts +33 -0
  2. package/dist/@types/index.d.ts +17 -2
  3. package/dist/@types/inputs/Dropdown/Dropdown.svelte.d.ts +2 -2
  4. package/dist/@types/inputs/Input/Input.svelte.d.ts +4 -4
  5. package/dist/@types/inputs/Select/Select.svelte.d.ts +4 -4
  6. package/dist/@types/inputs/Textarea/Textarea.svelte.d.ts +2 -2
  7. package/dist/@types/layout/Accordion/AccordionItem.svelte.d.ts +2 -2
  8. package/dist/@types/layout/Hero/Hero.svelte.d.ts +2 -2
  9. package/dist/@types/layout/List/List.svelte.d.ts +27 -0
  10. package/dist/@types/layout/NavSections/NavSection.svelte.d.ts +31 -0
  11. package/dist/@types/layout/NavSections/NavSections.svelte.d.ts +43 -0
  12. package/dist/@types/layout/NavSections/SectionBacklink.svelte.d.ts +23 -0
  13. package/dist/@types/layout/Scroller/ScrollerSection.svelte.d.ts +2 -2
  14. package/dist/@types/layout/Section/Section.svelte.d.ts +2 -2
  15. package/dist/@types/layout/TitleBlock/TitleBlock.svelte.d.ts +24 -4
  16. package/dist/datavis/Table/Table.svelte +129 -0
  17. package/dist/index.js +21 -2
  18. package/dist/layout/List/List.svelte +32 -0
  19. package/dist/layout/NavSections/NavSection.svelte +51 -0
  20. package/dist/layout/NavSections/NavSections.svelte +92 -0
  21. package/dist/layout/NavSections/SectionBacklink.svelte +31 -0
  22. package/dist/layout/TitleBlock/TitleBlock.svelte +97 -0
  23. package/dist/wrappers/Embed/Embed.svelte +4 -2
  24. package/dist/wrappers/Theme/Theme.svelte +1 -1
  25. package/package.json +7 -2
  26. /package/dist/@types/{layout → decorators}/Divider/Divider.svelte.d.ts +0 -0
  27. /package/dist/{layout → decorators}/Divider/Divider.svelte +0 -0
@@ -0,0 +1,33 @@
1
+ /** @typedef {typeof __propDef.props} TableProps */
2
+ /** @typedef {typeof __propDef.events} TableEvents */
3
+ /** @typedef {typeof __propDef.slots} TableSlots */
4
+ export default class Table extends SvelteComponentTyped<{
5
+ compact?: boolean;
6
+ title?: string;
7
+ responsive?: boolean;
8
+ rowHover?: boolean;
9
+ data?: any[];
10
+ columns?: any[];
11
+ }, {
12
+ [evt: string]: CustomEvent<any>;
13
+ }, {}> {
14
+ }
15
+ export type TableProps = typeof __propDef.props;
16
+ export type TableEvents = typeof __propDef.events;
17
+ export type TableSlots = typeof __propDef.slots;
18
+ import { SvelteComponentTyped } from "svelte";
19
+ declare const __propDef: {
20
+ props: {
21
+ compact?: boolean;
22
+ title?: string;
23
+ responsive?: boolean;
24
+ rowHover?: boolean;
25
+ data?: any[];
26
+ columns?: any[];
27
+ };
28
+ events: {
29
+ [evt: string]: CustomEvent<any>;
30
+ };
31
+ slots: {};
32
+ };
33
+ export {};
@@ -1,12 +1,27 @@
1
- export { default as Theme } from "./wrappers/Theme/Theme.svelte";
2
1
  export { default as Container } from "./wrappers/Container/Container.svelte";
2
+ export { default as Embed } from "./wrappers/Embed/Embed.svelte";
3
+ export { default as Main } from "./wrappers/Main/Main.svelte";
4
+ export { default as Theme } from "./wrappers/Theme/Theme.svelte";
3
5
  export { default as Accordion } from "./layout/Accordion/Accordion.svelte";
6
+ export { default as Filler } from "./layout/Filler/Filler.svelte";
4
7
  export { default as Footer } from "./layout/Footer/Footer.svelte";
8
+ export { default as Grid } from "./layout/Grid/Grid.svelte";
5
9
  export { default as Header } from "./layout/Header/Header.svelte";
10
+ export { default as Hero } from "./layout/Hero/Hero.svelte";
11
+ export { default as List } from "./layout/List/List.svelte";
12
+ export { default as NavSection } from "./layout/NavSections/NavSection.svelte";
13
+ export { default as NavSections } from "./layout/NavSections/NavSections.svelte";
14
+ export { default as Scoller } from "./layout/Scoller/Scoller.svelte";
15
+ export { default as ScollerSection } from "./layout/Scoller/ScollerSection.svelte";
16
+ export { default as Section } from "./layout/Section/Section.svelte";
17
+ export { default as TitleBlock } from "./layout/TitleBlock/TitleBlock.svelte";
6
18
  export { default as Twisty } from "./layout/Twisty/Twisty.svelte";
7
19
  export { default as Button } from "./inputs/Button/Button.svelte";
8
20
  export { default as Dropdown } from "./inputs/Dropdown/Dropdown.svelte";
9
- export { default as Em } from "./decorators/Em/Em.svelte";
10
21
  export { default as Input } from "./inputs/Input/Input.svelte";
11
22
  export { default as Select } from "./inputs/Select/Select.svelte";
12
23
  export { default as Textarea } from "./inputs/Textarea/Textarea.svelte";
24
+ export { default as Blockquote } from "./decorators/Blockquote/Blockquote.svelte";
25
+ export { default as Divider } from "./decorators/Divider/Divider.svelte";
26
+ export { default as Em } from "./decorators/Em/Em.svelte";
27
+ export { default as Table } from "./datavis/Table/Table.svelte";
@@ -2,8 +2,8 @@
2
2
  /** @typedef {typeof __propDef.events} DropdownEvents */
3
3
  /** @typedef {typeof __propDef.slots} DropdownSlots */
4
4
  export default class Dropdown extends SvelteComponentTyped<{
5
- label?: string;
6
5
  id?: string;
6
+ label?: string;
7
7
  hideLabel?: boolean;
8
8
  placeholder?: string;
9
9
  value?: any;
@@ -20,8 +20,8 @@ export type DropdownSlots = typeof __propDef.slots;
20
20
  import { SvelteComponentTyped } from "svelte";
21
21
  declare const __propDef: {
22
22
  props: {
23
- label?: string;
24
23
  id?: string;
24
+ label?: string;
25
25
  hideLabel?: boolean;
26
26
  placeholder?: string;
27
27
  value?: object;
@@ -3,8 +3,9 @@
3
3
  /** @typedef {typeof __propDef.slots} InputSlots */
4
4
  export default class Input extends SvelteComponentTyped<{
5
5
  width?: number;
6
- label?: string;
7
6
  id?: string;
7
+ label?: string;
8
+ numeric?: boolean;
8
9
  hideLabel?: boolean;
9
10
  value?: string;
10
11
  description?: string;
@@ -13,7 +14,6 @@ export default class Input extends SvelteComponentTyped<{
13
14
  suffix?: string;
14
15
  unitLabel?: string;
15
16
  pattern?: string;
16
- numeric?: boolean;
17
17
  error?: boolean;
18
18
  }, {
19
19
  change: CustomEvent<any>;
@@ -28,8 +28,9 @@ import { SvelteComponentTyped } from "svelte";
28
28
  declare const __propDef: {
29
29
  props: {
30
30
  width?: number;
31
- label?: string;
32
31
  id?: string;
32
+ label?: string;
33
+ numeric?: boolean;
33
34
  hideLabel?: boolean;
34
35
  value?: string;
35
36
  description?: string;
@@ -38,7 +39,6 @@ declare const __propDef: {
38
39
  suffix?: string;
39
40
  unitLabel?: string;
40
41
  pattern?: string;
41
- numeric?: boolean;
42
42
  error?: boolean;
43
43
  };
44
44
  events: {
@@ -3,13 +3,13 @@
3
3
  /** @typedef {typeof __propDef.slots} SelectSlots */
4
4
  export default class Select extends SvelteComponentTyped<{
5
5
  width?: number;
6
- label?: string;
7
6
  id?: string;
7
+ label?: string;
8
+ mode?: "default" | "search";
8
9
  hideLabel?: boolean;
9
10
  placeholder?: string;
10
11
  value?: any;
11
12
  options?: any[];
12
- mode?: "default" | "search";
13
13
  multiple?: boolean;
14
14
  maxSelected?: number;
15
15
  clearable?: boolean;
@@ -36,13 +36,13 @@ import { SvelteComponentTyped } from "svelte";
36
36
  declare const __propDef: {
37
37
  props: {
38
38
  width?: number;
39
- label?: string;
40
39
  id?: string;
40
+ label?: string;
41
+ mode?: "default" | "search";
41
42
  hideLabel?: boolean;
42
43
  placeholder?: string;
43
44
  value?: object;
44
45
  options?: any[];
45
- mode?: "default" | "search";
46
46
  multiple?: boolean;
47
47
  maxSelected?: number;
48
48
  clearable?: boolean;
@@ -3,8 +3,8 @@
3
3
  /** @typedef {typeof __propDef.slots} TextareaSlots */
4
4
  export default class Textarea extends SvelteComponentTyped<{
5
5
  width?: number;
6
- label?: string;
7
6
  id?: string;
7
+ label?: string;
8
8
  hideLabel?: boolean;
9
9
  value?: string;
10
10
  description?: string;
@@ -21,8 +21,8 @@ import { SvelteComponentTyped } from "svelte";
21
21
  declare const __propDef: {
22
22
  props: {
23
23
  width?: number;
24
- label?: string;
25
24
  id?: string;
25
+ label?: string;
26
26
  hideLabel?: boolean;
27
27
  value?: string;
28
28
  description?: string;
@@ -2,9 +2,9 @@
2
2
  /** @typedef {typeof __propDef.events} AccordionItemEvents */
3
3
  /** @typedef {typeof __propDef.slots} AccordionItemSlots */
4
4
  export default class AccordionItem extends SvelteComponentTyped<{
5
+ id?: string;
5
6
  title?: string;
6
7
  open?: boolean;
7
- id?: string;
8
8
  }, {
9
9
  [evt: string]: CustomEvent<any>;
10
10
  }, {
@@ -17,9 +17,9 @@ export type AccordionItemSlots = typeof __propDef.slots;
17
17
  import { SvelteComponentTyped } from "svelte";
18
18
  declare const __propDef: {
19
19
  props: {
20
+ id?: string;
20
21
  title?: string;
21
22
  open?: boolean;
22
- id?: string;
23
23
  };
24
24
  events: {
25
25
  [evt: string]: CustomEvent<any>;
@@ -7,8 +7,8 @@ export default class Hero extends SvelteComponentTyped<{
7
7
  width?: "narrow" | "medium" | "wide" | "full";
8
8
  height?: "full" | "auto" | "tall";
9
9
  themeOverrides?: any;
10
- title?: string;
11
10
  id?: string;
11
+ title?: string;
12
12
  lede?: string;
13
13
  date?: string;
14
14
  }, {
@@ -28,8 +28,8 @@ declare const __propDef: {
28
28
  width?: "narrow" | "medium" | "wide" | "full";
29
29
  height?: "auto" | "tall" | "full";
30
30
  themeOverrides?: object;
31
- title?: string;
32
31
  id?: string;
32
+ title?: string;
33
33
  lede?: string;
34
34
  date?: string;
35
35
  };
@@ -0,0 +1,27 @@
1
+ /** @typedef {typeof __propDef.props} ListProps */
2
+ /** @typedef {typeof __propDef.events} ListEvents */
3
+ /** @typedef {typeof __propDef.slots} ListSlots */
4
+ export default class List extends SvelteComponentTyped<{
5
+ mode?: "number" | "bullet" | "dash" | "bare";
6
+ }, {
7
+ [evt: string]: CustomEvent<any>;
8
+ }, {
9
+ default: {};
10
+ }> {
11
+ }
12
+ export type ListProps = typeof __propDef.props;
13
+ export type ListEvents = typeof __propDef.events;
14
+ export type ListSlots = typeof __propDef.slots;
15
+ import { SvelteComponentTyped } from "svelte";
16
+ declare const __propDef: {
17
+ props: {
18
+ mode?: "bullet" | "dash" | "number" | "bare";
19
+ };
20
+ events: {
21
+ [evt: string]: CustomEvent<any>;
22
+ };
23
+ slots: {
24
+ default: {};
25
+ };
26
+ };
27
+ export {};
@@ -0,0 +1,31 @@
1
+ /** @typedef {typeof __propDef.props} NavSectionProps */
2
+ /** @typedef {typeof __propDef.events} NavSectionEvents */
3
+ /** @typedef {typeof __propDef.slots} NavSectionSlots */
4
+ export default class NavSection extends SvelteComponentTyped<{
5
+ id?: string;
6
+ title?: string;
7
+ hideTitle?: boolean;
8
+ }, {
9
+ [evt: string]: CustomEvent<any>;
10
+ }, {
11
+ default: {};
12
+ }> {
13
+ }
14
+ export type NavSectionProps = typeof __propDef.props;
15
+ export type NavSectionEvents = typeof __propDef.events;
16
+ export type NavSectionSlots = typeof __propDef.slots;
17
+ import { SvelteComponentTyped } from "svelte";
18
+ declare const __propDef: {
19
+ props: {
20
+ id?: string;
21
+ title?: string;
22
+ hideTitle?: boolean;
23
+ };
24
+ events: {
25
+ [evt: string]: CustomEvent<any>;
26
+ };
27
+ slots: {
28
+ default: {};
29
+ };
30
+ };
31
+ export {};
@@ -0,0 +1,43 @@
1
+ /** @typedef {typeof __propDef.props} NavSectionsProps */
2
+ /** @typedef {typeof __propDef.events} NavSectionsEvents */
3
+ /** @typedef {typeof __propDef.slots} NavSectionsSlots */
4
+ export default class NavSections extends SvelteComponentTyped<{
5
+ tocId?: string;
6
+ contentsLabel?: string;
7
+ noContents?: boolean;
8
+ }, {
9
+ [evt: string]: CustomEvent<any>;
10
+ }, {
11
+ header: {};
12
+ 'before-nav': {};
13
+ 'after-nav': {};
14
+ before: {};
15
+ default: {};
16
+ after: {};
17
+ footer: {};
18
+ }> {
19
+ }
20
+ export type NavSectionsProps = typeof __propDef.props;
21
+ export type NavSectionsEvents = typeof __propDef.events;
22
+ export type NavSectionsSlots = typeof __propDef.slots;
23
+ import { SvelteComponentTyped } from "svelte";
24
+ declare const __propDef: {
25
+ props: {
26
+ tocId?: string;
27
+ contentsLabel?: string;
28
+ noContents?: boolean;
29
+ };
30
+ events: {
31
+ [evt: string]: CustomEvent<any>;
32
+ };
33
+ slots: {
34
+ header: {};
35
+ 'before-nav': {};
36
+ 'after-nav': {};
37
+ before: {};
38
+ default: {};
39
+ after: {};
40
+ footer: {};
41
+ };
42
+ };
43
+ export {};
@@ -0,0 +1,23 @@
1
+ /** @typedef {typeof __propDef.props} SectionBacklinkProps */
2
+ /** @typedef {typeof __propDef.events} SectionBacklinkEvents */
3
+ /** @typedef {typeof __propDef.slots} SectionBacklinkSlots */
4
+ export default class SectionBacklink extends SvelteComponentTyped<{
5
+ tocId?: string;
6
+ }, {
7
+ [evt: string]: CustomEvent<any>;
8
+ }, {}> {
9
+ }
10
+ export type SectionBacklinkProps = typeof __propDef.props;
11
+ export type SectionBacklinkEvents = typeof __propDef.events;
12
+ export type SectionBacklinkSlots = typeof __propDef.slots;
13
+ import { SvelteComponentTyped } from "svelte";
14
+ declare const __propDef: {
15
+ props: {
16
+ tocId?: string;
17
+ };
18
+ events: {
19
+ [evt: string]: CustomEvent<any>;
20
+ };
21
+ slots: {};
22
+ };
23
+ export {};
@@ -3,8 +3,8 @@
3
3
  /** @typedef {typeof __propDef.slots} ScrollerSectionSlots */
4
4
  export default class ScrollerSection extends SvelteComponentTyped<{
5
5
  theme?: "light" | "dark" | "lightblue";
6
- title?: string;
7
6
  id?: string;
7
+ title?: string;
8
8
  hideTitle?: boolean;
9
9
  }, {
10
10
  [evt: string]: CustomEvent<any>;
@@ -19,8 +19,8 @@ import { SvelteComponentTyped } from "svelte";
19
19
  declare const __propDef: {
20
20
  props: {
21
21
  theme?: "light" | "dark" | "lightblue";
22
- title?: string;
23
22
  id?: string;
23
+ title?: string;
24
24
  hideTitle?: boolean;
25
25
  };
26
26
  events: {
@@ -7,8 +7,8 @@ export default class Section extends SvelteComponentTyped<{
7
7
  marginTop?: boolean;
8
8
  marginBottom?: boolean;
9
9
  themeOverrides?: any;
10
- title?: string;
11
10
  id?: string;
11
+ title?: string;
12
12
  hideTitle?: boolean;
13
13
  }, {
14
14
  [evt: string]: CustomEvent<any>;
@@ -27,8 +27,8 @@ declare const __propDef: {
27
27
  marginTop?: boolean;
28
28
  marginBottom?: boolean;
29
29
  themeOverrides?: object;
30
- title?: string;
31
30
  id?: string;
31
+ title?: string;
32
32
  hideTitle?: boolean;
33
33
  };
34
34
  events: {
@@ -2,10 +2,20 @@
2
2
  /** @typedef {typeof __propDef.events} TitleBlockEvents */
3
3
  /** @typedef {typeof __propDef.slots} TitleBlockSlots */
4
4
  export default class TitleBlock extends SvelteComponentTyped<{
5
- [x: string]: never;
5
+ theme?: "light" | "dark" | "lightblue";
6
+ background?: string;
7
+ themeOverrides?: any;
8
+ title?: string;
9
+ meta?: any[];
10
+ natStatBadge?: boolean;
11
+ censusLogo?: boolean;
6
12
  }, {
7
13
  [evt: string]: CustomEvent<any>;
8
- }, {}> {
14
+ }, {
15
+ before: {};
16
+ brand: {};
17
+ after: {};
18
+ }> {
9
19
  }
10
20
  export type TitleBlockProps = typeof __propDef.props;
11
21
  export type TitleBlockEvents = typeof __propDef.events;
@@ -13,11 +23,21 @@ export type TitleBlockSlots = typeof __propDef.slots;
13
23
  import { SvelteComponentTyped } from "svelte";
14
24
  declare const __propDef: {
15
25
  props: {
16
- [x: string]: never;
26
+ theme?: "light" | "dark" | "lightblue";
27
+ background?: string;
28
+ themeOverrides?: object;
29
+ title?: string;
30
+ meta?: any[];
31
+ natStatBadge?: boolean;
32
+ censusLogo?: boolean;
17
33
  };
18
34
  events: {
19
35
  [evt: string]: CustomEvent<any>;
20
36
  };
21
- slots: {};
37
+ slots: {
38
+ before: {};
39
+ brand: {};
40
+ after: {};
41
+ };
22
42
  };
23
43
  export {};
@@ -0,0 +1,129 @@
1
+ <script>
2
+ import { commas, ascending, descending } from "$lib/js/utils.js";
3
+
4
+ /**
5
+ * An optional title for the table
6
+ * @type {string}
7
+ */
8
+ export let title = "";
9
+ /**
10
+ * Make the chart smaller/more compact
11
+ * @type {boolean}
12
+ */
13
+ export let compact = false;
14
+ /**
15
+ * Make the chart responsive (changes layout on narrow screens)
16
+ * @type {boolean}
17
+ */
18
+ export let responsive = false;
19
+ /**
20
+ * Highlight rows on hover
21
+ * @type {boolean}
22
+ */
23
+ export let rowHover = false;
24
+ /**
25
+ * Rows of data
26
+ * @type {array}
27
+ */
28
+ export let data = [];
29
+ /**
30
+ * Optional metadata for formatting columns. Array of {key, label, sortable?, numeric?} objects
31
+ * @type {array}
32
+ */
33
+ export let columns =
34
+ Array.isArray(data) && data[0] ? Object.keys(data[0]).map((key) => ({ key, label: key })) : [];
35
+ let _data = [...data];
36
+ let sort = columns.map((c) => "none");
37
+
38
+ const format = (val, numeric) => (numeric ? commas(val) : val);
39
+ $: sortable = columns.map((d) => d.sortable).includes(true);
40
+ </script>
41
+
42
+ <table
43
+ class="ons-table"
44
+ class:ons-table--sortable="{sortable}"
45
+ class:ons-table--compact="{compact}"
46
+ class:ons-table--responsive="{responsive}"
47
+ class:ons-table--row-hover="{rowHover}"
48
+ data-aria-sort="{sortable ? 'Sort by' : null}"
49
+ data-aria-asc="{sortable ? 'ascending' : null}"
50
+ data-aria-desc="{sortable ? 'descending' : null}"
51
+ >
52
+ {#if title}<caption class="ons-table__caption">{title}</caption>{/if}
53
+ <thead class="ons-table__head">
54
+ <tr class="ons-table__row">
55
+ {#each columns as col, i}
56
+ {#if col.sortable}
57
+ <th
58
+ scope="col"
59
+ class="ons-table__header"
60
+ class:ons-table__header--numeric="{col.numeric}"
61
+ aria-sort="{sort[i]}"
62
+ >
63
+ <button
64
+ aria-label="Sort by {col.label}"
65
+ type="button"
66
+ data-index="{i}"
67
+ class="ons-table__sort-button"
68
+ on:click="{() => {
69
+ sort = sort.map((c, j) =>
70
+ j === i && c === 'ascending' ? 'descending' : j === i ? 'ascending' : 'none'
71
+ );
72
+ _data = _data.sort((a, b) =>
73
+ sort[i] === 'ascending'
74
+ ? ascending(a[col.key], b[col.key])
75
+ : descending(a[col.key], b[col.key])
76
+ );
77
+ }}"
78
+ >
79
+ {col.label}<svg
80
+ class="ons-svg-icon"
81
+ viewBox="0 0 12 19"
82
+ xmlns="http://www.w3.org/2000/svg"
83
+ focusable="false"
84
+ fill="currentColor"
85
+ >
86
+ <path
87
+ class="ons-topTriangle"
88
+ d="M6 0l6 7.2H0L6 0zm0 18.6l6-7.2H0l6 7.2zm0 3.6l6 7.2H0l6-7.2z"></path>
89
+ <path class="ons-bottomTriangle" d="M6 18.6l6-7.2H0l6 7.2zm0 3.6l6 7.2H0l6-7.2z"
90
+ ></path>
91
+ </svg>
92
+ </button>
93
+ </th>
94
+ {:else}
95
+ <th
96
+ scope="col"
97
+ class="ons-table__header"
98
+ class:ons-table__header--numeric="{col.numeric}"
99
+ >
100
+ <span class="ons-table__header-text">{col.label}</span>
101
+ </th>
102
+ {/if}
103
+ {/each}
104
+ </tr>
105
+ </thead>
106
+ <tbody class="ons-table__body">
107
+ {#each _data as row}
108
+ <tr class="ons-table__row">
109
+ {#each columns as col}
110
+ <td
111
+ class="ons-table__cell"
112
+ class:ons-table__cell--numeric="{col.numeric}"
113
+ data-th="{col.label}">{format(row[col.key], col.numeric)}</td
114
+ >
115
+ {/each}
116
+ </tr>
117
+ {/each}
118
+ </tbody>
119
+ </table>
120
+
121
+ <style>
122
+ .ons-table__sort-button {
123
+ color: var(--link, --ons-color-text-link) !important;
124
+ }
125
+ .ons-table__sort-button:hover {
126
+ color: var(--link-hover, --ons-color-text-link-hover) !important;
127
+ -webkit-text-decoration: underline solid var(--link-hover, --ons-color-text-link-hover) 2px !important;
128
+ text-decoration: underline solid var(--link-hover, --ons-color-text-link-hover) 2px !important;
129
+ }</style>
package/dist/index.js CHANGED
@@ -1,17 +1,36 @@
1
1
  // Wrappers
2
- export { default as Theme } from "./wrappers/Theme/Theme.svelte";
3
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
8
  export { default as Accordion } from "./layout/Accordion/Accordion.svelte";
9
+ export { default as Filler } from "./layout/Filler/Filler.svelte";
7
10
  export { default as Footer } from "./layout/Footer/Footer.svelte";
11
+ export { default as Grid } from "./layout/Grid/Grid.svelte";
8
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";
9
21
  export { default as Twisty } from "./layout/Twisty/Twisty.svelte";
10
22
 
11
23
  // Inputs
12
24
  export { default as Button } from "./inputs/Button/Button.svelte";
13
25
  export { default as Dropdown } from "./inputs/Dropdown/Dropdown.svelte";
14
- export { default as Em } from "./decorators/Em/Em.svelte";
15
26
  export { default as Input } from "./inputs/Input/Input.svelte";
16
27
  export { default as Select } from "./inputs/Select/Select.svelte";
17
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,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>
@@ -0,0 +1,97 @@
1
+ <script>
2
+ import Container from "$lib/wrappers/Container/Container.svelte";
3
+ import Meta from "./Meta.svelte";
4
+
5
+ /**
6
+ * Sets the title/headline
7
+ * @type {string}
8
+ */
9
+ export let title = "Page title";
10
+ /**
11
+ * Include "national statistic" badge
12
+ * @type {boolean}
13
+ */
14
+ export let natStatBadge = false;
15
+ /**
16
+ * Include Census logo
17
+ * @type {boolean}
18
+ */
19
+ export let censusLogo = false;
20
+ /**
21
+ * Array of {key, value} objects containing page metadata
22
+ * @type {array}
23
+ */
24
+ export let meta = [];
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
+ * Overrides the background CSS for the section
37
+ * @type {string}
38
+ */
39
+ export let background = null;
40
+ </script>
41
+
42
+ <Container theme="{theme}" themeOverrides="{themeOverrides}" background="{background}">
43
+ <section class="ons-u-mb-xl">
44
+ <slot name="before" />
45
+ <div class="ons-grid">
46
+ <div class="ons-grid__col ons-col-10@m">
47
+ <h1 class="ons-u-fs-xxxl ons-u-mt-s ons-u-mb-m ons-u-pb-no ons-u-pt-no">
48
+ {title}
49
+ </h1>
50
+ </div>
51
+ {#if natStatBadge}
52
+ <div class="ons-grid__col ons-col-2@m">
53
+ <div
54
+ class="ons-grid--flex ons-grid--between@m ons-u-mt-s@m ons-u-mb-m@xxs ons-u-flex-jc-fe@m"
55
+ >
56
+ <a
57
+ href="https://uksa.statisticsauthority.gov.uk/about-the-authority/uk-statistical-system/types-of-official-statistics/"
58
+ class="national-statistics__link ons-u-fs-xxxl"
59
+ >
60
+ <img
61
+ src="//cdn.ons.gov.uk/assets/images/ons-logo/kitemark/uksa-kitemark.svg"
62
+ alt="UK Statistics Authority Kitemark"
63
+ class="national-statistics__logo"
64
+ />
65
+ </a>
66
+ </div>
67
+ </div>
68
+ {/if}
69
+ </div>
70
+ <slot name="brand" />
71
+ {#if censusLogo}
72
+ <div class="ons-grid ons-u-mb-m">
73
+ <div class="ons-grid__col">
74
+ <img
75
+ src="https://cdn.ons.gov.uk/assets/images/census-logo/logo-census-2021-purple-landscape.svg"
76
+ title="Census 2021"
77
+ alt="Census 2021"
78
+ class="header__svg-logo margin-right--1"
79
+ focusable="false"
80
+ width="167"
81
+ height="32"
82
+ />
83
+ </div>
84
+ </div>
85
+ {/if}
86
+ <Meta meta="{meta}" />
87
+ <slot name="after" />
88
+ </section>
89
+ </Container>
90
+
91
+ <style>
92
+ /* :global(.ons-page__container) {
93
+ overflow: auto;
94
+ } */
95
+ .ons-grid__col {
96
+ vertical-align: bottom;
97
+ }</style>
@@ -13,9 +13,11 @@
13
13
  });
14
14
  </script>
15
15
 
16
- <slot />
16
+ <div class="embed-container" style:display="content">
17
+ <slot />
18
+ </div>
17
19
 
18
20
  <style>
19
- :global(.ons-container) {
21
+ .embed-container :global(.ons-container) {
20
22
  padding: 0 !important;
21
23
  }</style>
@@ -56,7 +56,7 @@
56
56
  </svelte:head>
57
57
 
58
58
  {#if style}
59
- <div class="theme-wrapper" style="{style}">
59
+ <div class="theme-wrapper" style="{style}" style:display="content">
60
60
  <slot />
61
61
  </div>
62
62
  {:else}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://onsvisual.github.io/svelte-components",
@@ -116,7 +116,9 @@
116
116
  "./actions/cssVariables": "./dist/actions/cssVariables/index.js",
117
117
  "./actions/resizeObserver": "./dist/actions/resizeObserver/index.js",
118
118
  "./css/main.css": "./dist/css/main.css",
119
+ "./datavis/Table/Table.svelte": "./dist/datavis/Table/Table.svelte",
119
120
  "./decorators/Blockquote/Blockquote.svelte": "./dist/decorators/Blockquote/Blockquote.svelte",
121
+ "./decorators/Divider/Divider.svelte": "./dist/decorators/Divider/Divider.svelte",
120
122
  "./decorators/Em/Em.svelte": "./dist/decorators/Em/Em.svelte",
121
123
  "./globals.d.ts": "./dist/globals.d.ts",
122
124
  "./inputs/Button/Button.svelte": "./dist/inputs/Button/Button.svelte",
@@ -130,7 +132,6 @@
130
132
  "./js/withParams": "./dist/js/withParams.js",
131
133
  "./layout/Accordion/Accordion.svelte": "./dist/layout/Accordion/Accordion.svelte",
132
134
  "./layout/Accordion/AccordionItem.svelte": "./dist/layout/Accordion/AccordionItem.svelte",
133
- "./layout/Divider/Divider.svelte": "./dist/layout/Divider/Divider.svelte",
134
135
  "./layout/Filler/Filler.svelte": "./dist/layout/Filler/Filler.svelte",
135
136
  "./layout/Footer/Footer.svelte": "./dist/layout/Footer/Footer.svelte",
136
137
  "./layout/Footer/ONSLogo.svelte": "./dist/layout/Footer/ONSLogo.svelte",
@@ -138,6 +139,10 @@
138
139
  "./layout/Header/Header.svelte": "./dist/layout/Header/Header.svelte",
139
140
  "./layout/Header/ONSLogo.svelte": "./dist/layout/Header/ONSLogo.svelte",
140
141
  "./layout/Hero/Hero.svelte": "./dist/layout/Hero/Hero.svelte",
142
+ "./layout/List/List.svelte": "./dist/layout/List/List.svelte",
143
+ "./layout/NavSections/NavSection.svelte": "./dist/layout/NavSections/NavSection.svelte",
144
+ "./layout/NavSections/NavSections.svelte": "./dist/layout/NavSections/NavSections.svelte",
145
+ "./layout/NavSections/SectionBacklink.svelte": "./dist/layout/NavSections/SectionBacklink.svelte",
141
146
  "./layout/Scroller/Scroller.svelte": "./dist/layout/Scroller/Scroller.svelte",
142
147
  "./layout/Scroller/ScrollerSection.svelte": "./dist/layout/Scroller/ScrollerSection.svelte",
143
148
  "./layout/Section/Section.svelte": "./dist/layout/Section/Section.svelte",