@onsvisual/svelte-components 1.0.29 → 1.0.31

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.
@@ -1,7 +1,7 @@
1
1
  <script>
2
2
  /**
3
3
  * Set the type of icon
4
- * @type {"arrow"|"carret"|"cross"|"external"|"signout"|"print"|"download"|"tick"|"search"}
4
+ * @type {"arrow"|"carret"|"cross"|"external"|"signout"|"print"|"download"|"tick"|"search"|"pin"|"cog"}
5
5
  */
6
6
  export let type = "arrow";
7
7
  /**
@@ -65,6 +65,14 @@
65
65
  search: {
66
66
  d: "M11.86 10.23 8.62 6.99a4.63 4.63 0 1 0-6.34 1.64 4.55 4.55 0 0 0 2.36.64 4.65 4.65 0 0 0 2.33-.65l3.24 3.23a.46.46 0 0 0 .65 0l1-1a.48.48 0 0 0 0-.62Zm-5-3.32a3.28 3.28 0 0 1-2.31.93 3.22 3.22 0 1 1 2.35-.93Z",
67
67
  viewBox: "0 0 12 12"
68
+ },
69
+ pin: {
70
+ d: "M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7m0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5Z",
71
+ viewBox: "0 0 24 24"
72
+ },
73
+ cog: {
74
+ d: "M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6Z",
75
+ viewBox: "0 0 24 24"
68
76
  }
69
77
  };
70
78
  </script>
@@ -2,7 +2,7 @@
2
2
  /** @typedef {typeof __propDef.events} IconEvents */
3
3
  /** @typedef {typeof __propDef.slots} IconSlots */
4
4
  export default class Icon extends SvelteComponentTyped<{
5
- type?: "search" | "arrow" | "carret" | "cross" | "external" | "signout" | "print" | "download" | "tick" | undefined;
5
+ type?: "search" | "arrow" | "carret" | "cross" | "external" | "signout" | "print" | "download" | "tick" | "pin" | "cog" | undefined;
6
6
  size?: "s" | "m" | "l" | "xl" | "2xl" | "3xl" | null | undefined;
7
7
  rotation?: number | undefined;
8
8
  marginLeft?: boolean | undefined;
@@ -17,7 +17,7 @@ export type IconSlots = typeof __propDef.slots;
17
17
  import { SvelteComponentTyped } from "svelte";
18
18
  declare const __propDef: {
19
19
  props: {
20
- type?: "search" | "arrow" | "carret" | "cross" | "external" | "signout" | "print" | "download" | "tick" | undefined;
20
+ type?: "search" | "arrow" | "carret" | "cross" | "external" | "signout" | "print" | "download" | "tick" | "pin" | "cog" | undefined;
21
21
  size?: "s" | "m" | "l" | "xl" | "2xl" | "3xl" | null | undefined;
22
22
  rotation?: number | undefined;
23
23
  marginLeft?: boolean | undefined;
@@ -19,7 +19,6 @@
19
19
  control: { type: "select" }
20
20
  },
21
21
  icon: {
22
- options: ["", "arrow", "search", "download", "tick", "print", "externalLink"],
23
22
  control: { type: "select" }
24
23
  },
25
24
  iconPosition: {
@@ -20,6 +20,16 @@
20
20
  * @type {string|null}
21
21
  */
22
22
  export let href = null;
23
+ /**
24
+ * File name if link is used for a file download (only if href is also specified)
25
+ * @type {string|null}
26
+ */
27
+ export let download = null;
28
+ /**
29
+ * Don't scroll when link is followed (only if href is also specified)
30
+ * @type {boolean}
31
+ */
32
+ export let noScroll = false;
23
33
  /**
24
34
  * Make button smaller
25
35
  * @type {boolean}
@@ -27,7 +37,7 @@
27
37
  export let small = false;
28
38
  /**
29
39
  * Icon on button, eg. "arrow", "search"
30
- * @type {"arrow"|"external"|"signout"|"print"|"download"|"tick"|"search"|null}
40
+ * @type {"arrow"|"carret"|"cross"|"external"|"signout"|"print"|"download"|"tick"|"search"|"pin"|"cog"|null}
31
41
  */
32
42
  export let icon = null;
33
43
  /**
@@ -46,15 +56,10 @@
46
56
  */
47
57
  export let hideLabel = false;
48
58
  /**
49
- * aria label for button
59
+ * Aria label for button
50
60
  * @type {string|null}
51
61
  */
52
62
  export let arialabel = null;
53
- /**
54
- * filename if link is used for a file download
55
- * @type {string|null}
56
- */
57
- export let download = null;
58
63
  /**
59
64
  * Set a colour for the button
60
65
  * @type {string|null}
@@ -79,6 +84,7 @@
79
84
  class:ons-btn--disabled={disabled}
80
85
  on:click={(e) => dispatch("click", e)}
81
86
  aria-label={arialabel}
87
+ data-sveltekit-noscroll={noScroll}
82
88
  >
83
89
  <span
84
90
  class="ons-btn__inner"
@@ -9,7 +9,8 @@ export default class Button extends SvelteComponentTyped<{
9
9
  download?: string | null | undefined;
10
10
  type?: "button" | "reset" | "sumbit" | undefined;
11
11
  variant?: "secondary" | "primary" | "ghost" | undefined;
12
- icon?: "search" | "arrow" | "external" | "signout" | "print" | "download" | "tick" | null | undefined;
12
+ noScroll?: boolean | undefined;
13
+ icon?: "search" | "arrow" | "carret" | "cross" | "external" | "signout" | "print" | "download" | "tick" | "pin" | "cog" | null | undefined;
13
14
  iconPosition?: "before" | "after" | undefined;
14
15
  disabled?: boolean | undefined;
15
16
  hideLabel?: boolean | undefined;
@@ -36,7 +37,8 @@ declare const __propDef: {
36
37
  download?: string | null | undefined;
37
38
  type?: "button" | "reset" | "sumbit" | undefined;
38
39
  variant?: "secondary" | "primary" | "ghost" | undefined;
39
- icon?: "search" | "arrow" | "external" | "signout" | "print" | "download" | "tick" | null | undefined;
40
+ noScroll?: boolean | undefined;
41
+ icon?: "search" | "arrow" | "carret" | "cross" | "external" | "signout" | "print" | "download" | "tick" | "pin" | "cog" | null | undefined;
40
42
  iconPosition?: "before" | "after" | undefined;
41
43
  disabled?: boolean | undefined;
42
44
  hideLabel?: boolean | undefined;
@@ -15,3 +15,30 @@ This component will display a cookie banner and export a function that allows yo
15
15
  <AnalyticsBanner analyticsId="{id_string}" />
16
16
  <!-- Rest of page content -->
17
17
  ```
18
+
19
+ `AnalyticsBanner` can also take props.
20
+
21
+ ```
22
+ const analyticsProps = {
23
+ contentTitle: "Weekly deaths dashboard",
24
+ releaseDate: data.dates.current.replaceAll("-", ""),
25
+ nextReleaseDate: data.dates.next.replaceAll("-", ""),
26
+ outputSeries: "weeklyprovisionalfiguresondeathsregisteredinenglandandwales",
27
+ contentType: "dashboard",
28
+ };
29
+
30
+ <AnalyticsBanner {analyticsProps}/>
31
+ ```
32
+
33
+ An example analytics events. See this [doc](https://officenationalstatistics.sharepoint.com/:w:/r/sites/digpub/_layouts/15/Doc.aspx?sourcedoc=%7BBA405554-4040-4B61-9559-851F5C55DA39%7D&file=Google%20Analytics%20-%20GTM%20requirements.docx&action=default&mobileredirect=true) for more details (need to be on network).
34
+
35
+ ```javascript
36
+ analyticsEvent({
37
+ event: "interaction",
38
+ interactionType: "accordion",
39
+ interactionValue: e?.detail?.open ? "open" : "close",
40
+ label,
41
+ sectionTitle,
42
+ sectionNumber
43
+ });
44
+ ```
@@ -6,17 +6,20 @@
6
6
  import componentDocs from "./docs/component.md?raw";
7
7
  import { lipsum } from "../../js/utils.js";
8
8
 
9
+ const parameters = { ...withComponentDocs(componentDocs), layout: "fullscreen" };
10
+ parameters.docs.story = { inline: false, iframeHeight: 600 };
11
+
9
12
  const { Story } = defineMeta({
10
13
  title: "Layout/NavSections",
11
14
  component: NavSections,
12
15
  tags: ["autodocs"],
13
16
  argTypes: {},
14
- parameters: withComponentDocs(componentDocs)
17
+ parameters
15
18
  });
16
19
  </script>
17
20
 
18
21
  {#snippet template(args)}
19
- <NavSections>
22
+ <NavSections {...args}>
20
23
  <NavSection title="Section one">
21
24
  <p>
22
25
  {lipsum()}
@@ -1,8 +1,6 @@
1
- Use this layou component to allow users to quickly jump to sections of a long page of content.
1
+ Use this component to allow users to quickly jump to named sections within a long page of content.
2
2
 
3
- As the user scrolls down the page, the table of contents will remain accessible at the top of the viewport and will highlight the subheading of the section in view.
4
-
5
- Note: These examples will not preview correctly in the iframes on this page. You can select the examples from the menu instead.
3
+ As the user scrolls down the page, a table of contents will remain visible on the left of the viewport and will highlight the subheading of the section currently in view.
6
4
 
7
5
  <!-- prettier-ignore -->
8
6
  ```html
@@ -7,16 +7,15 @@
7
7
  import Em from "../../decorators/Em/Em.svelte";
8
8
  import componentDocs from "./docs/component.md?raw";
9
9
 
10
+ const parameters = { ...withComponentDocs(componentDocs), layout: "fullscreen" };
11
+ parameters.docs.story = { inline: false, iframeHeight: 600 };
12
+
10
13
  const { Story } = defineMeta({
11
14
  title: "Layout/Scroller",
12
15
  component: Scroller,
13
16
  tags: ["autodocs"],
14
17
  argTypes: {},
15
- parameters: {
16
- ...withComponentDocs(componentDocs),
17
- layout: "fullscreen",
18
- docs: { story: { inline: false, iframeHeight: 600 } }
19
- }
18
+ parameters
20
19
  });
21
20
  </script>
22
21
 
@@ -1,6 +1,4 @@
1
- Components for adding scrollytelling sections to a feature article.
2
-
3
- Note: These examples will not preview correctly in the iframes on this page. You can select the examples from the menu instead.
1
+ Components for adding interactive scrollytelling sections to a feature article.
4
2
 
5
3
  <!-- prettier-ignore -->
6
4
  ```html
@@ -18,16 +18,15 @@
18
18
  import ScrollerSection from "../../layout/Scroller/ScrollerSection.svelte";
19
19
  import Footer from "../../layout/Footer/Footer.svelte";
20
20
 
21
+ const parameters = { ...withComponentDocs(componentDocs), layout: "fullscreen" };
22
+ parameters.docs.story = { inline: false, iframeHeight: 600 };
23
+
21
24
  const { Story } = defineMeta({
22
25
  title: "Templates/Feature article",
23
26
  component: Header,
24
27
  tags: ["autodocs"],
25
28
  argTypes: {},
26
- parameters: {
27
- ...withComponentDocs(componentDocs),
28
- layout: "fullscreen",
29
- docs: { story: { inline: false, iframeHeight: 600 } }
30
- }
29
+ parameters
31
30
  });
32
31
  </script>
33
32
 
@@ -27,7 +27,7 @@
27
27
  observer.observe(el);
28
28
  });
29
29
 
30
- onDestroy(() => observer.unobserve(el));
30
+ onDestroy(() => observer?.unobserve?.(el));
31
31
  </script>
32
32
 
33
33
  <div bind:this={el}>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "npm run build:package && npm run build:docs",