@onsvisual/svelte-components 0.0.24 → 0.0.26

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.
@@ -3,7 +3,7 @@
3
3
  /** @typedef {typeof __propDef.slots} DividerSlots */
4
4
  export default class Divider extends SvelteComponentTyped<{
5
5
  theme?: "light" | "dark" | "lightblue";
6
- width?: "narrow" | "medium" | "wide" | "full";
6
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
7
7
  marginTop?: boolean;
8
8
  marginBottom?: boolean;
9
9
  themeOverrides?: any;
@@ -19,7 +19,7 @@ import { SvelteComponentTyped } from "svelte";
19
19
  declare const __propDef: {
20
20
  props: {
21
21
  theme?: "light" | "dark" | "lightblue";
22
- width?: "narrow" | "medium" | "wide" | "full";
22
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
23
23
  marginTop?: boolean;
24
24
  marginBottom?: boolean;
25
25
  themeOverrides?: object;
@@ -3,7 +3,7 @@ export function analyticsEvent(props: any): void;
3
3
  /** @typedef {typeof __propDef.events} AnalyticsBannerEvents */
4
4
  /** @typedef {typeof __propDef.slots} AnalyticsBannerSlots */
5
5
  export default class AnalyticsBanner extends SvelteComponentTyped<{
6
- width?: "medium" | "wide";
6
+ width?: "wide" | "wider";
7
7
  analyticsId?: string;
8
8
  analyticsProps?: any;
9
9
  usageCookies?: boolean;
@@ -17,7 +17,7 @@ export type AnalyticsBannerSlots = typeof __propDef.slots;
17
17
  import { SvelteComponentTyped } from "svelte";
18
18
  declare const __propDef: {
19
19
  props: {
20
- width?: "medium" | "wide";
20
+ width?: "wide" | "wider";
21
21
  analyticsId?: string;
22
22
  analyticsProps?: object;
23
23
  usageCookies?: boolean;
@@ -4,7 +4,7 @@
4
4
  export default class Breadcrumb extends SvelteComponentTyped<{
5
5
  theme?: "light" | "dark" | "lightblue";
6
6
  background?: string;
7
- width?: "narrow" | "medium" | "wide" | "full";
7
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
8
8
  themeOverrides?: any;
9
9
  links?: any[];
10
10
  }, {
@@ -19,7 +19,7 @@ declare const __propDef: {
19
19
  props: {
20
20
  theme?: "light" | "dark" | "lightblue";
21
21
  background?: string;
22
- width?: "narrow" | "medium" | "wide" | "full";
22
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
23
23
  themeOverrides?: object;
24
24
  links?: any[];
25
25
  };
@@ -5,7 +5,7 @@ export default class Cards extends SvelteComponentTyped<{
5
5
  theme?: "light" | "dark" | "lightblue";
6
6
  id?: string;
7
7
  cls?: string;
8
- width?: "narrow" | "medium" | "wide" | "full";
8
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
9
9
  height?: string | number;
10
10
  marginTop?: boolean;
11
11
  marginBottom?: boolean;
@@ -30,7 +30,7 @@ declare const __propDef: {
30
30
  theme?: "light" | "dark" | "lightblue";
31
31
  id?: string;
32
32
  cls?: string;
33
- width?: "narrow" | "medium" | "wide" | "full";
33
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
34
34
  height?: number | string;
35
35
  marginTop?: boolean;
36
36
  marginBottom?: boolean;
@@ -6,7 +6,7 @@ export default class Hero extends SvelteComponentTyped<{
6
6
  id?: string;
7
7
  cls?: string;
8
8
  background?: string;
9
- width?: "narrow" | "medium" | "wide" | "full";
9
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
10
10
  height?: "full" | "auto" | "tall";
11
11
  themeOverrides?: any;
12
12
  title?: string;
@@ -28,7 +28,7 @@ declare const __propDef: {
28
28
  id?: string;
29
29
  cls?: string;
30
30
  background?: string;
31
- width?: "narrow" | "medium" | "wide" | "full";
31
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
32
32
  height?: "auto" | "tall" | "full";
33
33
  themeOverrides?: object;
34
34
  title?: string;
@@ -5,7 +5,7 @@ export default class Highlight extends SvelteComponentTyped<{
5
5
  theme?: "light" | "dark" | "lightblue";
6
6
  id?: string;
7
7
  background?: string;
8
- width?: "narrow" | "medium" | "wide" | "full";
8
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
9
9
  height?: "full" | "auto" | "tall";
10
10
  marginTop?: boolean;
11
11
  marginBottom?: boolean;
@@ -25,7 +25,7 @@ declare const __propDef: {
25
25
  theme?: "light" | "dark" | "lightblue";
26
26
  id?: string;
27
27
  background?: string;
28
- width?: "narrow" | "medium" | "wide" | "full";
28
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
29
29
  height?: "auto" | "tall" | "full";
30
30
  marginTop?: boolean;
31
31
  marginBottom?: boolean;
@@ -2,7 +2,14 @@
2
2
  /** @typedef {typeof __propDef.events} NavSectionsEvents */
3
3
  /** @typedef {typeof __propDef.slots} NavSectionsSlots */
4
4
  export default class NavSections extends SvelteComponentTyped<{
5
- tocId?: string;
5
+ theme?: "light" | "dark" | "lightblue";
6
+ id?: string;
7
+ cls?: string;
8
+ background?: string;
9
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
10
+ marginTop?: boolean;
11
+ marginBottom?: boolean;
12
+ themeOverrides?: any;
6
13
  contentsLabel?: string;
7
14
  noContents?: boolean;
8
15
  }, {
@@ -23,7 +30,14 @@ export type NavSectionsSlots = typeof __propDef.slots;
23
30
  import { SvelteComponentTyped } from "svelte";
24
31
  declare const __propDef: {
25
32
  props: {
26
- tocId?: string;
33
+ theme?: "light" | "dark" | "lightblue";
34
+ id?: string;
35
+ cls?: string;
36
+ background?: string;
37
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
38
+ marginTop?: boolean;
39
+ marginBottom?: boolean;
40
+ themeOverrides?: object;
27
41
  contentsLabel?: string;
28
42
  noContents?: boolean;
29
43
  };
@@ -6,7 +6,7 @@ export default class Section extends SvelteComponentTyped<{
6
6
  id?: string;
7
7
  cls?: string;
8
8
  background?: string;
9
- width?: "narrow" | "medium" | "wide" | "full";
9
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
10
10
  marginTop?: boolean;
11
11
  marginBottom?: boolean;
12
12
  themeOverrides?: any;
@@ -28,7 +28,7 @@ declare const __propDef: {
28
28
  id?: string;
29
29
  cls?: string;
30
30
  background?: string;
31
- width?: "narrow" | "medium" | "wide" | "full";
31
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
32
32
  marginTop?: boolean;
33
33
  marginBottom?: boolean;
34
34
  themeOverrides?: object;
@@ -3,7 +3,7 @@
3
3
  /** @typedef {typeof __propDef.slots} ShareButtonsSlots */
4
4
  export default class ShareButtons extends SvelteComponentTyped<{
5
5
  theme?: "light" | "dark" | "lightblue";
6
- width?: "narrow" | "medium" | "wide" | "full";
6
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
7
7
  marginTop?: boolean;
8
8
  marginBottom?: boolean;
9
9
  themeOverrides?: any;
@@ -19,7 +19,7 @@ import { SvelteComponentTyped } from "svelte";
19
19
  declare const __propDef: {
20
20
  props: {
21
21
  theme?: "light" | "dark" | "lightblue";
22
- width?: "narrow" | "medium" | "wide" | "full";
22
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
23
23
  marginTop?: boolean;
24
24
  marginBottom?: boolean;
25
25
  themeOverrides?: object;
@@ -6,7 +6,7 @@ export default class Container extends SvelteComponentTyped<{
6
6
  id?: string;
7
7
  cls?: string;
8
8
  background?: string;
9
- width?: "narrow" | "medium" | "wide" | "full";
9
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
10
10
  height?: "full" | "auto" | "tall";
11
11
  marginTop?: boolean;
12
12
  marginBottom?: boolean;
@@ -27,7 +27,7 @@ declare const __propDef: {
27
27
  id?: string;
28
28
  cls?: string;
29
29
  background?: string;
30
- width?: "narrow" | "medium" | "wide" | "full";
30
+ width?: "narrow" | "medium" | "wide" | "wider" | "full";
31
31
  height?: "auto" | "tall" | "full";
32
32
  marginTop?: boolean;
33
33
  marginBottom?: boolean;
@@ -8,9 +8,9 @@
8
8
  export let hr = "narrow";
9
9
  /**
10
10
  * Sets the width of the container
11
- * @type {"narrow"|"medium"|"wide"|"full"}
11
+ * @type {"narrow"|"medium"|"wide"|"wider"|"full"}
12
12
  */
13
- export let width = "medium";
13
+ export let width = "wide";
14
14
  /**
15
15
  * Sets a predefined theme
16
16
  * @type {"light"|"dark"|"lightblue"}
@@ -26,9 +26,9 @@
26
26
  export let usageCookies = false;
27
27
  /**
28
28
  * Set the width of the banner
29
- * @type {"medium"|"wide"}
29
+ * @type {"wide"|"wider"}
30
30
  */
31
- export let width = "medium";
31
+ export let width = "wide";
32
32
 
33
33
  let live; // Don't run analytics unless page is live on ONS site (re-set in the onMount function)
34
34
  let showBanner = false;
@@ -163,7 +163,7 @@
163
163
  >
164
164
  <div
165
165
  class="ons-container ons-cookies-banner__primary"
166
- class:ons-page__container--wide="{width === 'wide'}"
166
+ class:ons-page__container--wider="{width === 'wider'}"
167
167
  >
168
168
  <div class="ons-grid">
169
169
  <div class="ons-grid__col ons-col-8@m">
@@ -217,7 +217,7 @@
217
217
  {:else}
218
218
  <div
219
219
  class="ons-container ons-cookies-banner__confirmation"
220
- class:ons-page__container--wide="{width === 'wide'}"
220
+ class:ons-page__container--wider="{width === 'wider'}"
221
221
  >
222
222
  <div
223
223
  class="ons-grid ons-grid--flex ons-grid--between ons-grid--gutterless ons-grid--no-wrap@s ons-grid--vertical-center"
@@ -251,6 +251,6 @@
251
251
  /* padding: 0; */
252
252
  background: none !important;
253
253
  }
254
- .ons-page__container--wide {
254
+ .ons-page__container--wider {
255
255
  max-width: 1240px;
256
256
  }</style>
@@ -8,9 +8,9 @@
8
8
  export let links = [];
9
9
  /**
10
10
  * Sets the width of the container
11
- * @type {"narrow"|"medium"|"wide"|"full"}
11
+ * @type {"narrow"|"medium"|"wide"|"wider"|"full"}
12
12
  */
13
- export let width = "medium";
13
+ export let width = "wide";
14
14
  /**
15
15
  * Sets a predefined theme
16
16
  * @type {"light"|"dark"|"lightblue"}
@@ -14,9 +14,9 @@
14
14
  export let cls = "ons-cards";
15
15
  /**
16
16
  * Sets the width of the section
17
- * @type {"narrow"|"medium"|"wide"|"full"}
17
+ * @type {"narrow"|"medium"|"wide"|"wider"|"full"}
18
18
  */
19
- export let width = "medium";
19
+ export let width = "wide";
20
20
  /**
21
21
  * Sets the title of the section
22
22
  * @type {string}
@@ -1,4 +1,6 @@
1
1
  <script>
2
+ import { setContext } from "svelte";
3
+ import { writable } from "svelte/store";
2
4
  import Container from "../../wrappers/Container/Container.svelte";
3
5
 
4
6
  /**
@@ -70,9 +72,30 @@
70
72
  let gridClass = !colwidth || colwidth === "full" ? "" : `grid-${colwidth}`;
71
73
  let rowHeight = height === "full" ? "100vh" : !Number.isNaN(height) ? height + "px" : height;
72
74
  let gridGap = !Number.isNaN(gap) ? gap + "px" : gap;
75
+
76
+ const defs = {
77
+ narrow: { w: 180, c: 4 },
78
+ medium: { w: 280, c: 3 },
79
+ wide: { w: 400, c: 2 },
80
+ full: { w: "100%", c: 1 },
81
+ };
82
+
83
+ let w;
84
+
85
+ const cols = writable(defs[colwidth].c);
86
+
87
+ $: columns =
88
+ colwidth == "full"
89
+ ? 1
90
+ : w
91
+ ? Math.floor((w + gap) / (defs[colwidth].w + gap))
92
+ : defs[colwidth].c;
93
+ $: cols.set(columns);
94
+
95
+ setContext("cols", cols);
73
96
  </script>
74
97
 
75
- <figure aria-label="{caption}">
98
+ <figure aria-label="{caption}" bind:clientWidth="{w}">
76
99
  <Container
77
100
  id="{id}"
78
101
  cls="{cls}"
@@ -122,10 +145,10 @@
122
145
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
123
146
  }
124
147
  .grid-medium {
125
- grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)) !important;
148
+ grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
126
149
  }
127
150
  .grid-wide {
128
- grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)) !important;
151
+ grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)) !important;
129
152
  }
130
153
  :global(.grid > div) {
131
154
  min-height: inherit;
@@ -14,9 +14,9 @@
14
14
  export let cls = null;
15
15
  /**
16
16
  * Sets the width of the section
17
- * @type {"narrow"|"medium"|"wide"|"full"}
17
+ * @type {"narrow"|"medium"|"wide"|"wider"|"full"}
18
18
  */
19
- export let width = "medium";
19
+ export let width = "wide";
20
20
  /**
21
21
  * Sets the minimum height of the section
22
22
  * @type {"auto"|"tall"|"full"}
@@ -8,9 +8,9 @@
8
8
  export let id = null;
9
9
  /**
10
10
  * Sets the width of the section
11
- * @type {"narrow"|"medium"|"wide"|"full"}
11
+ * @type {"narrow"|"medium"|"wide"|"wider"|"full"}
12
12
  */
13
- export let width = "narrow";
13
+ export let width = "medium";
14
14
  /**
15
15
  * Sets the minimum height of the section
16
16
  * @type {"auto"|"tall"|"full"}
@@ -1,26 +1,62 @@
1
1
  <script>
2
2
  import { onMount, setContext } from "svelte";
3
3
  import { writable } from "svelte/store";
4
+ import Container from "../../wrappers/Container/Container.svelte";
4
5
 
5
6
  /**
6
- * A label for the page contents nav
7
+ * ID for back-linking to table of contents
7
8
  * @type {string}
8
9
  */
9
- export let contentsLabel = "Page contents";
10
+ export let id = "toc";
10
11
  /**
11
- * ID for contents nav section (for back links)
12
+ * (Optional) Sets a css class for the section
12
13
  * @type {string}
13
14
  */
14
- export let tocId = "toc";
15
+ export let cls = null;
16
+ /**
17
+ * Sets the width of the container
18
+ * @type {"narrow"|"medium"|"wide"|"wider"|"full"}
19
+ */
20
+ export let width = "wide";
21
+ /**
22
+ * A label for the page contents nav
23
+ * @type {string}
24
+ */
25
+ export let contentsLabel = "Page contents";
15
26
  /**
16
27
  * Don't include table of contents (allows for custom uses of nav panel)
17
28
  * @type {boolean}
18
29
  */
19
30
  export let noContents = false;
31
+ /**
32
+ * Sets a predefined theme
33
+ * @type {"light"|"dark"|"lightblue"}
34
+ */
35
+ export let theme = null;
36
+ /**
37
+ * Define additional props to override the base theme
38
+ * @type {object}
39
+ */
40
+ export let themeOverrides = null;
41
+ /**
42
+ * Overrides the background CSS for the section
43
+ * @type {string}
44
+ */
45
+ export let background = null;
46
+ /**
47
+ * Optional margin above section
48
+ * @type {boolean}
49
+ */
50
+ export let marginTop = false;
51
+ /**
52
+ * Optional margin below section
53
+ * @type {boolean}
54
+ */
55
+ export let marginBottom = true;
20
56
 
21
57
  let active;
22
58
 
23
- setContext("tocId", tocId);
59
+ setContext("tocId", id);
24
60
 
25
61
  const sections = writable([]);
26
62
  setContext("sections", sections);
@@ -49,10 +85,18 @@
49
85
  });
50
86
  </script>
51
87
 
52
- <div class="ons-page__container ons-container">
88
+ <Container
89
+ cls="{cls}"
90
+ theme="{theme}"
91
+ themeOverrides="{themeOverrides}"
92
+ width="{width}"
93
+ marginTop="{marginTop}"
94
+ marginBottom="{marginBottom}"
95
+ background="{background}"
96
+ >
53
97
  <div class="ons-grid ons-js-toc-container ons-u-ml-no">
54
98
  <slot name="header" />
55
- <div class="ons-grid__col ons-col-4@m ons-u-pl-no ons-grid__col--sticky@m" id="{tocId}">
99
+ <div class="ons-grid__col ons-col-4@m ons-u-pl-no ons-grid__col--sticky@m" id="{id}">
56
100
  <aside class="ons-toc-container" role="complementary">
57
101
  <nav class="ons-toc" aria-label="Pages in this guide">
58
102
  <slot name="before-nav" />
@@ -89,4 +133,16 @@
89
133
  </div>
90
134
  <slot name="footer" />
91
135
  </div>
92
- </div>
136
+ </Container>
137
+
138
+ <style>
139
+ @media (min-width: 740px) {
140
+ .ons-col-4\@m {
141
+ max-width: 280px;
142
+ width: 280px;
143
+ }
144
+ .ons-col-8\@m {
145
+ max-width: calc(100% - 280px);
146
+ width: calc(100% - 280px);
147
+ }
148
+ }</style>
@@ -14,7 +14,7 @@
14
14
  export let cls = null;
15
15
  /**
16
16
  * Sets the width of the container
17
- * @type {"narrow"|"medium"|"wide"|"full"}
17
+ * @type {"narrow"|"medium"|"wide"|"wider"|"full"}
18
18
  */
19
19
  export let width = "narrow";
20
20
  /**
@@ -9,7 +9,7 @@
9
9
  export let title = "Share this page";
10
10
  /**
11
11
  * Sets the width of the container
12
- * @type {"narrow"|"medium"|"wide"|"full"}
12
+ * @type {"narrow"|"medium"|"wide"|"wider"|"full"}
13
13
  */
14
14
  export let width = "narrow";
15
15
  /**
@@ -13,9 +13,9 @@
13
13
  export let cls = null;
14
14
  /**
15
15
  * Sets the width of the container
16
- * @type {"narrow"|"medium"|"wide"|"full"}
16
+ * @type {"narrow"|"medium"|"wide"|"wider"|"full"}
17
17
  */
18
- export let width = "medium";
18
+ export let width = "wide";
19
19
  /**
20
20
  * Sets the minimum height of the container relative to the height of the viewport
21
21
  * @type {"auto"|"tall"|"full"}
@@ -51,7 +51,7 @@
51
51
  $: _cls = cls && !(theme || background) ? cls : "";
52
52
  </script>
53
53
 
54
- {#if width === "narrow"}
54
+ {#if ["narrow", "medium"].includes(width)}
55
55
  <Theme
56
56
  id="{id}"
57
57
  cls="{cls}"
@@ -66,7 +66,10 @@
66
66
  class:ons-page__container--full-height="{height === 'full'}"
67
67
  >
68
68
  {#if marginTop}<div class="ons-spacer"></div>{/if}
69
- <div class="ons-page__container--narrow">
69
+ <div
70
+ class:ons-page__container--narrow="{width === 'narrow'}"
71
+ class:ons-page__container--medium="{width === 'medium'}"
72
+ >
70
73
  <slot />
71
74
  </div>
72
75
  {#if marginBottom}<div class="ons-spacer"></div>{/if}
@@ -83,7 +86,7 @@
83
86
  <div
84
87
  id="{_id}"
85
88
  class="ons-page__container ons-container {_cls}"
86
- class:ons-page__container--wide="{width === 'wide'}"
89
+ class:ons-page__container--wider="{width === 'wider'}"
87
90
  class:ons-page__container--full="{width === 'full'}"
88
91
  class:ons-page__container--tall-height="{height === 'tall'}"
89
92
  class:ons-page__container--full-height="{height === 'full'}"
@@ -102,10 +105,14 @@
102
105
  padding-bottom: 0.05px;
103
106
  }
104
107
  .ons-page__container--narrow {
105
- max-width: 640px;
108
+ max-width: 608px;
106
109
  margin: 0 auto 0 0;
107
110
  }
108
- .ons-page__container--wide {
111
+ .ons-page__container--medium {
112
+ max-width: 800px;
113
+ margin: 0 auto 0 0;
114
+ }
115
+ .ons-page__container--wider {
109
116
  max-width: 1240px;
110
117
  }
111
118
  .ons-page__container--full {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://onsvisual.github.io/svelte-components",