@onsvisual/svelte-components 1.0.0-next.5 → 1.0.0-next.7

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 (95) hide show
  1. package/dist/datavis/DataTile/DataTile.stories.svelte +14 -0
  2. package/dist/datavis/DataTile/DataTile.svelte +23 -4
  3. package/dist/datavis/DataTile/DataTile.svelte.d.ts +4 -0
  4. package/dist/datavis/DataTile/Sparkline.svelte +117 -0
  5. package/dist/datavis/DataTile/Sparkline.svelte.d.ts +27 -0
  6. package/dist/datavis/Table/Table.svelte +6 -0
  7. package/dist/datavis/Table/Table.svelte.d.ts +2 -0
  8. package/dist/decorators/Divider/Divider.svelte +8 -3
  9. package/dist/decorators/Divider/Divider.svelte.d.ts +2 -0
  10. package/dist/decorators/Icon/Icon.stories.svelte +25 -0
  11. package/dist/{inputs/Button/Icon.svelte.d.ts → decorators/Icon/Icon.stories.svelte.d.ts} +2 -6
  12. package/dist/{inputs/Button → decorators/Icon}/Icon.svelte +20 -3
  13. package/dist/decorators/Icon/Icon.svelte.d.ts +29 -0
  14. package/dist/decorators/Icon/docs/component.md +12 -0
  15. package/dist/inputs/Button/Button.svelte +9 -4
  16. package/dist/inputs/Button/Button.svelte.d.ts +6 -4
  17. package/dist/inputs/Checkbox/Checkbox.svelte +6 -1
  18. package/dist/inputs/Checkbox/Checkbox.svelte.d.ts +2 -0
  19. package/dist/inputs/Checkboxes/Checkboxes.svelte +6 -1
  20. package/dist/inputs/Checkboxes/Checkboxes.svelte.d.ts +2 -0
  21. package/dist/inputs/Dropdown/Dropdown.svelte +6 -1
  22. package/dist/inputs/Dropdown/Dropdown.svelte.d.ts +2 -0
  23. package/dist/inputs/ErrorPanel/ErrorPanel.svelte +6 -1
  24. package/dist/inputs/ErrorPanel/ErrorPanel.svelte.d.ts +2 -0
  25. package/dist/inputs/ErrorSummary/ErrorSummary.svelte +6 -1
  26. package/dist/inputs/ErrorSummary/ErrorSummary.svelte.d.ts +2 -0
  27. package/dist/inputs/Input/Input.svelte +6 -1
  28. package/dist/inputs/Input/Input.svelte.d.ts +2 -0
  29. package/dist/inputs/Radios/Radios.svelte +6 -1
  30. package/dist/inputs/Radios/Radios.svelte.d.ts +2 -0
  31. package/dist/inputs/Select/Select.svelte +6 -1
  32. package/dist/inputs/Select/Select.svelte.d.ts +2 -0
  33. package/dist/inputs/Textarea/Textarea.svelte +6 -1
  34. package/dist/inputs/Textarea/Textarea.svelte.d.ts +2 -0
  35. package/dist/layout/Accordion/Accordion.svelte +1 -1
  36. package/dist/layout/Accordion/Accordion.svelte.d.ts +2 -2
  37. package/dist/layout/Breadcrumb/Breadcrumb.svelte +6 -1
  38. package/dist/layout/Breadcrumb/Breadcrumb.svelte.d.ts +4 -2
  39. package/dist/layout/Card/Card.svelte +1 -1
  40. package/dist/layout/Card/Card.svelte.d.ts +2 -2
  41. package/dist/layout/Contents/Contents.svelte +6 -1
  42. package/dist/layout/Contents/Contents.svelte.d.ts +2 -0
  43. package/dist/layout/DescriptionList/DescriptionList.svelte +6 -1
  44. package/dist/layout/DescriptionList/DescriptionList.svelte.d.ts +2 -0
  45. package/dist/layout/Details/Details.svelte +6 -1
  46. package/dist/layout/Details/Details.svelte.d.ts +2 -0
  47. package/dist/layout/DocumentList/DocumentList.svelte +6 -1
  48. package/dist/layout/DocumentList/DocumentList.svelte.d.ts +2 -0
  49. package/dist/layout/Footer/Footer.svelte +1 -1
  50. package/dist/layout/Footer/Footer.svelte.d.ts +4 -4
  51. package/dist/layout/Grid/Grid.svelte +3 -3
  52. package/dist/layout/Grid/Grid.svelte.d.ts +2 -2
  53. package/dist/layout/Header/Header.svelte +1 -1
  54. package/dist/layout/Header/Header.svelte.d.ts +4 -4
  55. package/dist/layout/Hero/Hero.stories.svelte +2 -1
  56. package/dist/layout/Hero/Hero.svelte +9 -8
  57. package/dist/layout/Hero/Hero.svelte.d.ts +8 -6
  58. package/dist/layout/Highlight/Highlight.svelte +15 -22
  59. package/dist/layout/Highlight/Highlight.svelte.d.ts +6 -6
  60. package/dist/layout/Image/Image.svelte +6 -1
  61. package/dist/layout/Image/Image.svelte.d.ts +2 -0
  62. package/dist/layout/List/List.svelte +6 -1
  63. package/dist/layout/List/List.svelte.d.ts +2 -0
  64. package/dist/layout/NavSections/NavSection.svelte +1 -1
  65. package/dist/layout/NavSections/NavSection.svelte.d.ts +2 -2
  66. package/dist/layout/NavSections/NavSections.svelte +3 -3
  67. package/dist/layout/NavSections/NavSections.svelte.d.ts +2 -2
  68. package/dist/layout/Notice/Notice.svelte +6 -1
  69. package/dist/layout/Notice/Notice.svelte.d.ts +2 -0
  70. package/dist/layout/PhaseBanner/PhaseBanner.svelte +6 -1
  71. package/dist/layout/PhaseBanner/PhaseBanner.svelte.d.ts +2 -0
  72. package/dist/layout/RelatedContent/RelatedContent.svelte +6 -1
  73. package/dist/layout/RelatedContent/RelatedContent.svelte.d.ts +2 -0
  74. package/dist/layout/Scroller/Scroller.svelte +6 -1
  75. package/dist/layout/Scroller/Scroller.svelte.d.ts +2 -0
  76. package/dist/layout/Scroller/ScrollerSection.svelte +6 -1
  77. package/dist/layout/Scroller/ScrollerSection.svelte.d.ts +2 -0
  78. package/dist/layout/Section/Section.svelte +3 -3
  79. package/dist/layout/Section/Section.svelte.d.ts +2 -2
  80. package/dist/layout/ShareButtons/ShareButtons.svelte +8 -3
  81. package/dist/layout/ShareButtons/ShareButtons.svelte.d.ts +2 -0
  82. package/dist/layout/Summary/Summary.svelte +6 -1
  83. package/dist/layout/Summary/Summary.svelte.d.ts +2 -0
  84. package/dist/layout/Tabs/Tabs.svelte +6 -1
  85. package/dist/layout/Tabs/Tabs.svelte.d.ts +2 -0
  86. package/dist/templates/intro.mdx +1 -1
  87. package/dist/wrappers/Container/Container.svelte +41 -28
  88. package/dist/wrappers/Container/Container.svelte.d.ts +8 -4
  89. package/dist/wrappers/Container/docs/component.md +4 -2
  90. package/dist/wrappers/Theme/Theme.svelte +4 -4
  91. package/dist/wrappers/Theme/Theme.svelte.d.ts +6 -6
  92. package/dist/wrappers/Theme/docs/component.md +1 -1
  93. package/dist/wrappers/Theme/themes.d.ts +28 -0
  94. package/dist/wrappers/Theme/themes.js +2 -1
  95. package/package.json +3 -1
@@ -3,6 +3,7 @@
3
3
  import { withComponentDocs } from "../../js/withParams.js";
4
4
  import DataTile from "./DataTile.svelte";
5
5
  import componentDocs from "./docs/component.md?raw";
6
+ import data from "../demo-data/data-scatter.js";
6
7
 
7
8
  const { Story } = defineMeta({
8
9
  title: "Data visualisation/DataTile",
@@ -26,3 +27,16 @@
26
27
  source: "Source: ONS"
27
28
  }}
28
29
  />
30
+
31
+ <Story
32
+ name="Sparkline"
33
+ args={{
34
+ title: "Example sparkline",
35
+ subtitle: "Value in £ million",
36
+ mode: "sparkline",
37
+ data: data.map((d) => ({ x: d.year, y: d.value })),
38
+ value: "down 2.47",
39
+ caption: `Change from 1979 to 2016`,
40
+ source: "Source: ONS"
41
+ }}
42
+ />
@@ -1,11 +1,17 @@
1
1
  <script>
2
2
  import Card from "../../layout/Card/Card.svelte";
3
+ import Sparkline from "./Sparkline.svelte";
3
4
 
4
5
  /**
5
6
  * Title of card
6
7
  * @type {string}
7
8
  */
8
9
  export let title = "";
10
+ /**
11
+ * Optional: Subtitle of card
12
+ * @type {string}
13
+ */
14
+ export let subtitle = "";
9
15
  /**
10
16
  * Optional: URL link for card title
11
17
  * @type {string}
@@ -36,16 +42,29 @@
36
42
  * @type {string}
37
43
  */
38
44
  export let source = "";
45
+ /**
46
+ * Optional: Set an additional CSS class for the component
47
+ * @type {string}
48
+ */
49
+ export let cls = "";
39
50
  </script>
40
51
 
41
- <Card {title} {href} mode="featured">
52
+ <Card {title} {href} mode="featured" {cls}>
53
+ {#if subtitle}
54
+ <p class="ons-u-fs-s">{subtitle}</p>
55
+ {/if}
56
+ {#if mode === "sparkline" && data}
57
+ <Sparkline {data} />
58
+ {/if}
42
59
  {#if value}
43
- <p class="headline-figures__figure ons-u-fs-3xl ons-u-fs-2xl@m">{value}</p>
60
+ <p class="headline-figures__figure ons-u-fs-3xl ons-u-fs-2xl@m ons-u-mb-no">{value}</p>
44
61
  {/if}
45
62
  {#if caption}
46
- <p class="headline-figures__supporting-text ons-u-fs-r">{@html caption}</p>
63
+ <p class="headline-figures__supporting-text ons-u-fs-r ons-u-mt-2xs ons-u-mb-no">
64
+ {@html caption}
65
+ </p>
47
66
  {/if}
48
67
  {#if source}
49
- <p class="ons-u-fs-s">{source}</p>
68
+ <p class="ons-u-fs-s ons-u-mt-s ons-u-mb-no">{source}</p>
50
69
  {/if}
51
70
  </Card>
@@ -2,6 +2,7 @@
2
2
  /** @typedef {typeof __propDef.events} DataTileEvents */
3
3
  /** @typedef {typeof __propDef.slots} DataTileSlots */
4
4
  export default class DataTile extends SvelteComponentTyped<{
5
+ cls?: string | undefined;
5
6
  caption?: string | undefined;
6
7
  data?: object[] | null | undefined;
7
8
  source?: string | undefined;
@@ -9,6 +10,7 @@ export default class DataTile extends SvelteComponentTyped<{
9
10
  href?: string | undefined;
10
11
  mode?: "number" | "sparkline" | "bar" | undefined;
11
12
  value?: string | number | undefined;
13
+ subtitle?: string | undefined;
12
14
  }, {
13
15
  [evt: string]: CustomEvent<any>;
14
16
  }, {}> {
@@ -19,6 +21,7 @@ export type DataTileSlots = typeof __propDef.slots;
19
21
  import { SvelteComponentTyped } from "svelte";
20
22
  declare const __propDef: {
21
23
  props: {
24
+ cls?: string | undefined;
22
25
  caption?: string | undefined;
23
26
  data?: object[] | null | undefined;
24
27
  source?: string | undefined;
@@ -26,6 +29,7 @@ declare const __propDef: {
26
29
  href?: string | undefined;
27
30
  mode?: "number" | "sparkline" | "bar" | undefined;
28
31
  value?: string | number | undefined;
32
+ subtitle?: string | undefined;
29
33
  };
30
34
  events: {
31
35
  [evt: string]: CustomEvent<any>;
@@ -0,0 +1,117 @@
1
+ <script>
2
+ import { scaleLinear } from "d3-scale";
3
+ import { line } from "d3-shape";
4
+
5
+ /**
6
+ * Array of data in the format [{x: value, y: value}, etc]
7
+ * @type {object[]}
8
+ */
9
+ export let data;
10
+ /**
11
+ * Key for the X values
12
+ * @type {string}
13
+ */
14
+ export let xKey = "x";
15
+ /**
16
+ * Key for the Y values
17
+ * @type {string}
18
+ */
19
+ export let yKey = "y";
20
+
21
+ function minMax(data, key) {
22
+ const values = data.map((d) => d[key]);
23
+ return [Math.min(...values), Math.max(...values)];
24
+ }
25
+
26
+ const xDomain = [data[0][xKey], data[data.length - 1][xKey]];
27
+ const yDomain = minMax(data, yKey);
28
+
29
+ const xScale = scaleLinear().domain(xDomain).range([0, 100]);
30
+ const yScale = scaleLinear().domain(yDomain).range([100, 0]);
31
+ const lineFn = line()
32
+ .x((d) => xScale(d[xKey]))
33
+ .y((d) => yScale(d[yKey]));
34
+ </script>
35
+
36
+ <div class="sparkline-container">
37
+ <div
38
+ class="sparkline-point"
39
+ style={[data[data.length - 1]].map((d) => `right: 0; top: ${yScale(d[yKey])}%;`)[0]}
40
+ ></div>
41
+ <svg class="sparkline-chart" viewBox="0 0 100 100" preserveAspectRatio="none">
42
+ <path class="sparkline" d={lineFn(data)} />
43
+ </svg>
44
+ </div>
45
+ <div class="x-ticks">
46
+ {#each [data[0], data[data.length - 1]] as tick, i}
47
+ <div class="x-tick x-tick--{i === 0 ? 'start' : 'end'}">
48
+ <span class="ons-u-fs-s">{tick[xKey]}</span><br /><span class="x-tick--value"
49
+ >{tick[yKey]}</span
50
+ >
51
+ </div>
52
+ {/each}
53
+ </div>
54
+
55
+ <style>
56
+ .sparkline-container {
57
+ display: block;
58
+ height: 100px;
59
+ width: 100%;
60
+ position: relative;
61
+ }
62
+ .sparkline-chart {
63
+ display: block;
64
+ position: absolute;
65
+ height: 100%;
66
+ width: 100%;
67
+ overflow: visible;
68
+ }
69
+ .sparkline-point {
70
+ position: absolute;
71
+ display: inline-block;
72
+ width: 10px;
73
+ height: 10px;
74
+ border-radius: 50%;
75
+ background: var(--ons-color-branded);
76
+ transform: translate(50%, -50%);
77
+ }
78
+ .sparkline {
79
+ fill: none;
80
+ stroke: var(--ons-color-branded);
81
+ stroke-width: 2.5px;
82
+ vector-effect: non-scaling-stroke;
83
+ }
84
+ .x-ticks {
85
+ display: flex;
86
+ width: 100%;
87
+ flex-direction: row;
88
+ justify-content: space-between;
89
+ margin-bottom: 6px;
90
+ }
91
+ .x-tick {
92
+ position: relative;
93
+ padding-top: 10px;
94
+ line-height: 1.1;
95
+ }
96
+ .x-tick--value {
97
+ color: var(--ons-color-branded);
98
+ font-size: 1.25rem;
99
+ font-weight: bold;
100
+ }
101
+ .x-tick::before {
102
+ position: absolute;
103
+ content: " ";
104
+ height: 10px;
105
+ top: 0;
106
+ }
107
+ .x-tick--end {
108
+ text-align: right;
109
+ }
110
+ .x-tick--start::before {
111
+ border-left: 1px solid var(--ons-color-borders);
112
+ }
113
+ .x-tick--end::before {
114
+ right: 0;
115
+ border-right: 1px solid var(--ons-color-borders);
116
+ }
117
+ </style>
@@ -0,0 +1,27 @@
1
+ /** @typedef {typeof __propDef.props} SparklineProps */
2
+ /** @typedef {typeof __propDef.events} SparklineEvents */
3
+ /** @typedef {typeof __propDef.slots} SparklineSlots */
4
+ export default class Sparkline extends SvelteComponentTyped<{
5
+ data: object[];
6
+ xKey?: string | undefined;
7
+ yKey?: string | undefined;
8
+ }, {
9
+ [evt: string]: CustomEvent<any>;
10
+ }, {}> {
11
+ }
12
+ export type SparklineProps = typeof __propDef.props;
13
+ export type SparklineEvents = typeof __propDef.events;
14
+ export type SparklineSlots = typeof __propDef.slots;
15
+ import { SvelteComponentTyped } from "svelte";
16
+ declare const __propDef: {
17
+ props: {
18
+ data: object[];
19
+ xKey?: string | undefined;
20
+ yKey?: string | undefined;
21
+ };
22
+ events: {
23
+ [evt: string]: CustomEvent<any>;
24
+ };
25
+ slots: {};
26
+ };
27
+ export {};
@@ -39,12 +39,18 @@
39
39
  Array.isArray(data) && data[0] ? Object.keys(data[0]).map((key) => ({ key, label: key })) : [];
40
40
  let _data = [...data];
41
41
  let sort = columns.map((c) => "none");
42
+ /**
43
+ * Optional: Set an additional CSS class for the component
44
+ * @type {string}
45
+ */
46
+ export let cls = "";
42
47
 
43
48
  $: sortable = columns.map((d) => d.sortable).includes(true);
44
49
  $: formatters = columns.map((d) => formatter(d.dp));
45
50
  </script>
46
51
 
47
52
  <div
53
+ class={cls}
48
54
  style:overflow={typeof height === "number" ? "auto" : null}
49
55
  style:height={typeof height === "number" ? `${height}px` : null}
50
56
  style:display={typeof height !== "number" ? "contents" : null}
@@ -2,6 +2,7 @@
2
2
  /** @typedef {typeof __propDef.events} TableEvents */
3
3
  /** @typedef {typeof __propDef.slots} TableSlots */
4
4
  export default class Table extends SvelteComponentTyped<{
5
+ cls?: string | undefined;
5
6
  height?: number | "auto" | undefined;
6
7
  data?: object[] | undefined;
7
8
  title?: string | undefined;
@@ -19,6 +20,7 @@ export type TableSlots = typeof __propDef.slots;
19
20
  import { SvelteComponentTyped } from "svelte";
20
21
  declare const __propDef: {
21
22
  props: {
23
+ cls?: string | undefined;
22
24
  height?: number | "auto" | undefined;
23
25
  data?: object[] | undefined;
24
26
  title?: string | undefined;
@@ -17,18 +17,23 @@
17
17
  */
18
18
  export let mode = "dark";
19
19
  /**
20
- * Optional margin above section
20
+ * Adds margin above section
21
21
  * @type {boolean}
22
22
  */
23
23
  export let marginTop = !!hr;
24
24
  /**
25
- * Optional margin below section
25
+ * Adds margin below section
26
26
  * @type {boolean}
27
27
  */
28
28
  export let marginBottom = true;
29
+ /**
30
+ * Optional: Set an additional CSS class for the component
31
+ * @type {string}
32
+ */
33
+ export let cls = "";
29
34
  </script>
30
35
 
31
- <Container {width} {marginTop} {marginBottom}>
36
+ <Container {width} {marginTop} {marginBottom} {cls}>
32
37
  <hr
33
38
  class="ons-u-mt-no"
34
39
  class:ons-u-vh={!hr}
@@ -2,6 +2,7 @@
2
2
  /** @typedef {typeof __propDef.events} DividerEvents */
3
3
  /** @typedef {typeof __propDef.slots} DividerSlots */
4
4
  export default class Divider extends SvelteComponentTyped<{
5
+ cls?: string | undefined;
5
6
  width?: "narrow" | "medium" | "wide" | "wider" | "full" | undefined;
6
7
  marginTop?: boolean | undefined;
7
8
  marginBottom?: boolean | undefined;
@@ -17,6 +18,7 @@ export type DividerSlots = typeof __propDef.slots;
17
18
  import { SvelteComponentTyped } from "svelte";
18
19
  declare const __propDef: {
19
20
  props: {
21
+ cls?: string | undefined;
20
22
  width?: "narrow" | "medium" | "wide" | "wider" | "full" | undefined;
21
23
  marginTop?: boolean | undefined;
22
24
  marginBottom?: boolean | undefined;
@@ -0,0 +1,25 @@
1
+ <script module>
2
+ import { defineMeta } from "@storybook/addon-svelte-csf";
3
+ import { withComponentDocs } from "../../js/withParams.js";
4
+ import Icon from "./Icon.svelte";
5
+ import componentDocs from "./docs/component.md?raw";
6
+
7
+ const { Story } = defineMeta({
8
+ title: "Decorators/Icon",
9
+ component: Icon,
10
+ tags: ["autodocs"],
11
+ argTypes: {
12
+ type: {
13
+ control: { type: "select" }
14
+ },
15
+ size: {
16
+ control: { type: "select" }
17
+ }
18
+ },
19
+ parameters: withComponentDocs(componentDocs)
20
+ });
21
+ </script>
22
+
23
+ <Story name="Arrow icon" args={{ type: "arrow" }} />
24
+
25
+ <Story name="Search icon, large" args={{ type: "search", size: "3xl" }} />
@@ -2,9 +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?: string | undefined;
6
- marginLeft?: boolean | undefined;
7
- marginRight?: boolean | undefined;
5
+ [x: string]: never;
8
6
  }, {
9
7
  [evt: string]: CustomEvent<any>;
10
8
  }, {}> {
@@ -15,9 +13,7 @@ export type IconSlots = typeof __propDef.slots;
15
13
  import { SvelteComponentTyped } from "svelte";
16
14
  declare const __propDef: {
17
15
  props: {
18
- type?: string | undefined;
19
- marginLeft?: boolean | undefined;
20
- marginRight?: boolean | undefined;
16
+ [x: string]: never;
21
17
  };
22
18
  events: {
23
19
  [evt: string]: CustomEvent<any>;
@@ -1,6 +1,23 @@
1
1
  <script>
2
+ /**
3
+ * Set the type of icon
4
+ * @type {"arrow"|"external"|"signout"|"print"|"download"|"tick"|"search"}
5
+ */
2
6
  export let type = "arrow";
7
+ /**
8
+ * Set the size of the icon
9
+ * @type {"s"|"m"|"l"|"xl"|"2xl"|"3xl"|null}
10
+ */
11
+ export let size = null;
12
+ /**
13
+ * Add a small margin on the left of the icon
14
+ * @type {boolean}
15
+ */
3
16
  export let marginLeft = false;
17
+ /**
18
+ * Add a small margin on the right of the icon
19
+ * @type {boolean}
20
+ */
4
21
  export let marginRight = false;
5
22
 
6
23
  const paths = {
@@ -8,13 +25,13 @@
8
25
  d: "m10 .2-.9.9c-.1.1-.1.4 0 .5l4 4H.6c-.2 0-.4.2-.4.4v1.2c0 .2.2.4.4.4h12.5l-3.9 3.7c-.2.2-.2.4 0 .6l.8.9c.2.2.4.2.6 0L16.8 7c.2-.2.2-.4 0-.6L10.7.3c-.3-.2-.5-.2-.7-.1z",
9
26
  viewBox: "0 0 17 13"
10
27
  },
11
- externalLink: {
28
+ external: {
12
29
  d: "M13.5,9H13a.5.5,0,0,0-.5.5v3h-9v-9h3A.5.5,0,0,0,7,3V2.5A.5.5,0,0,0,6.5,2h-4a.5.5,0,0,0-.5.5v11a.5.5,0,0,0,.5.5h11a.5.5,0,0,0,.5-.5v-4A.5.5,0,0,0,13.5,9Z M8.83,7.88a.51.51,0,0,0,.71,0l2.31-2.32,1.28,1.28A.51.51,0,0,0,14,6.49v-4a.52.52,0,0,0-.5-.5h-4A.51.51,0,0,0,9,2.52a.58.58,0,0,0,.14.33l1.28,1.28L8.12,6.46a.51.51,0,0,0,0,.71Z",
13
30
  viewBox: "2 2 12 12"
14
31
  },
15
32
  signout: {
16
33
  d: "M13.85,7.65l-2.5-2.5a.5.5,0,0,0-.71,0,.48.48,0,0,0-.15.36V7h-3a.5.5,0,0,0-.5.5v1a.5.5,0,0,0,.5.5h3v1.5A.49.49,0,0,0,11,11a.48.48,0,0,0,.34-.14l2.51-2.5a.49.49,0,0,0,0-.68Z M8.5,14h-6a.5.5,0,0,1-.5-.5V2.5A.5.5,0,0,1,2.5,2h6a.5.5,0,0,1,.5.5V3a.5.5,0,0,1-.5.5h-5v9h5A.5.5,0,0,1,9,13v.5A.5.5,0,0,1,8.5,14Z",
17
- viewBox: "0 0 12 12"
34
+ viewBox: "2 2 12 12"
18
35
  },
19
36
  print: {
20
37
  d: "M17 4H3C1.3 4 0 5.2 0 6.8v5.5h4V16h12v-3.7h4V6.8C20 5.2 18.7 4 17 4zm-3 10H6V9h8v5zm3-6a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm-1-8H4v3h12V0z",
@@ -37,7 +54,7 @@
37
54
 
38
55
  {#if paths[type]}
39
56
  <svg
40
- class="ons-icon"
57
+ class="ons-icon {size ? `ons-icon--${size}` : ''}"
41
58
  class:ons-u-ml-2xs={marginLeft}
42
59
  class:ons-u-mr-2xs={marginRight}
43
60
  viewBox={paths[type].viewBox}
@@ -0,0 +1,29 @@
1
+ /** @typedef {typeof __propDef.props} IconProps */
2
+ /** @typedef {typeof __propDef.events} IconEvents */
3
+ /** @typedef {typeof __propDef.slots} IconSlots */
4
+ export default class Icon extends SvelteComponentTyped<{
5
+ type?: "search" | "arrow" | "external" | "signout" | "print" | "download" | "tick" | undefined;
6
+ size?: "s" | "m" | "l" | "xl" | "2xl" | "3xl" | null | undefined;
7
+ marginLeft?: boolean | undefined;
8
+ marginRight?: boolean | undefined;
9
+ }, {
10
+ [evt: string]: CustomEvent<any>;
11
+ }, {}> {
12
+ }
13
+ export type IconProps = typeof __propDef.props;
14
+ export type IconEvents = typeof __propDef.events;
15
+ export type IconSlots = typeof __propDef.slots;
16
+ import { SvelteComponentTyped } from "svelte";
17
+ declare const __propDef: {
18
+ props: {
19
+ type?: "search" | "arrow" | "external" | "signout" | "print" | "download" | "tick" | undefined;
20
+ size?: "s" | "m" | "l" | "xl" | "2xl" | "3xl" | null | undefined;
21
+ marginLeft?: boolean | undefined;
22
+ marginRight?: boolean | undefined;
23
+ };
24
+ events: {
25
+ [evt: string]: CustomEvent<any>;
26
+ };
27
+ slots: {};
28
+ };
29
+ export {};
@@ -0,0 +1,12 @@
1
+ A component to visually highlight text. Can be used for inline text or to provide a "badge".
2
+
3
+ Consists of a `<mark>` element with a custom background color, where the highlighted text will automatically appear black or white to maximise contrast.
4
+
5
+ <!-- prettier-ignore -->
6
+ ```html
7
+ <script>
8
+ import { Em } from "@onsvisual/svelte-components";
9
+ </script>
10
+
11
+ <Em color="steelblue">Highlighted text</Em>
12
+ ```
@@ -1,6 +1,6 @@
1
1
  <script>
2
2
  import { createEventDispatcher } from "svelte";
3
- import Icon from "./Icon.svelte";
3
+ import Icon from "../../decorators/Icon/Icon.svelte";
4
4
 
5
5
  const dispatch = createEventDispatcher();
6
6
 
@@ -26,7 +26,7 @@
26
26
  export let small = false;
27
27
  /**
28
28
  * Icon on button, eg. "arrow", "search"
29
- * @type {string}
29
+ * @type {"arrow"|"external"|"signout"|"print"|"download"|"tick"|"search"}
30
30
  */
31
31
  export let icon = "";
32
32
  /**
@@ -54,6 +54,11 @@
54
54
  * @type {string}
55
55
  */
56
56
  export let download = "";
57
+ /**
58
+ * Optional: Set an additional CSS class for the component
59
+ * @type {string}
60
+ */
61
+ export let cls = "";
57
62
  </script>
58
63
 
59
64
  {#if href}
@@ -61,7 +66,7 @@
61
66
  href={!disabled ? href : null}
62
67
  role="button"
63
68
  {download}
64
- class="ons-btn ons-btn--link ons-js-submit-btn"
69
+ class="ons-btn ons-btn--link ons-js-submit-btn {cls}"
65
70
  class:ons-btn--small={small}
66
71
  class:ons-btn--secondary={variant === "secondary"}
67
72
  class:ons-btn--ghost={variant === "ghost"}
@@ -91,7 +96,7 @@
91
96
  {:else}
92
97
  <button
93
98
  {type}
94
- class="ons-btn"
99
+ class="ons-btn {cls}"
95
100
  class:ons-btn--small={small}
96
101
  class:ons-btn--secondary={variant === "secondary"}
97
102
  class:ons-btn--ghost={variant === "ghost"}
@@ -2,16 +2,17 @@
2
2
  /** @typedef {typeof __propDef.events} ButtonEvents */
3
3
  /** @typedef {typeof __propDef.slots} ButtonSlots */
4
4
  export default class Button extends SvelteComponentTyped<{
5
+ cls?: string | undefined;
5
6
  small?: boolean | undefined;
6
7
  href?: string | undefined;
8
+ download?: string | undefined;
7
9
  type?: "button" | "reset" | "sumbit" | undefined;
8
10
  variant?: "secondary" | "primary" | "ghost" | undefined;
9
- icon?: string | undefined;
11
+ icon?: "search" | "arrow" | "external" | "signout" | "print" | "download" | "tick" | undefined;
10
12
  iconPosition?: "before" | "after" | undefined;
11
13
  disabled?: boolean | undefined;
12
14
  hideLabel?: boolean | undefined;
13
15
  arialabel?: string | undefined;
14
- download?: string | undefined;
15
16
  }, {
16
17
  click: CustomEvent<any>;
17
18
  } & {
@@ -27,16 +28,17 @@ export type ButtonSlots = typeof __propDef.slots;
27
28
  import { SvelteComponentTyped } from "svelte";
28
29
  declare const __propDef: {
29
30
  props: {
31
+ cls?: string | undefined;
30
32
  small?: boolean | undefined;
31
33
  href?: string | undefined;
34
+ download?: string | undefined;
32
35
  type?: "button" | "reset" | "sumbit" | undefined;
33
36
  variant?: "secondary" | "primary" | "ghost" | undefined;
34
- icon?: string | undefined;
37
+ icon?: "search" | "arrow" | "external" | "signout" | "print" | "download" | "tick" | undefined;
35
38
  iconPosition?: "before" | "after" | undefined;
36
39
  disabled?: boolean | undefined;
37
40
  hideLabel?: boolean | undefined;
38
41
  arialabel?: string | undefined;
39
- download?: string | undefined;
40
42
  };
41
43
  events: {
42
44
  click: CustomEvent<any>;
@@ -53,6 +53,11 @@
53
53
  * @type {boolean}
54
54
  */
55
55
  export let compact = false;
56
+ /**
57
+ * Optional: Set an additional CSS class for the component
58
+ * @type {string}
59
+ */
60
+ export let cls = "";
56
61
 
57
62
  const checkboxes = getContext("checkboxes");
58
63
 
@@ -96,7 +101,7 @@
96
101
  </script>
97
102
 
98
103
  <span
99
- class="ons-checkboxes__item"
104
+ class="ons-checkboxes__item {cls}"
100
105
  class:ons-checkboxes__item--ghost={variant === "ghost"}
101
106
  class:ons-checkboxes__item--no-border={compact}
102
107
  >
@@ -4,6 +4,7 @@
4
4
  export default class Checkbox extends SvelteComponentTyped<{
5
5
  id: string;
6
6
  label: string;
7
+ cls?: string | undefined;
7
8
  group?: object[] | null | undefined;
8
9
  compact?: boolean | undefined;
9
10
  variant?: "default" | "ghost" | undefined;
@@ -26,6 +27,7 @@ declare const __propDef: {
26
27
  props: {
27
28
  id: string;
28
29
  label: string;
30
+ cls?: string | undefined;
29
31
  group?: object[] | null | undefined;
30
32
  compact?: boolean | undefined;
31
33
  variant?: "default" | "ghost" | undefined;
@@ -30,12 +30,17 @@
30
30
  * @type {object[]}
31
31
  */
32
32
  export let value = [];
33
+ /**
34
+ * Optional: Set an additional CSS class for the component
35
+ * @type {string}
36
+ */
37
+ export let cls = "";
33
38
 
34
39
  const checkboxes = writable([]);
35
40
  setContext("checkboxes", checkboxes);
36
41
  </script>
37
42
 
38
- <fieldset class="ons-fieldset">
43
+ <fieldset class="ons-fieldset {cls}">
39
44
  {#if title}
40
45
  <legend class="ons-fieldset__legend ons-u-mb-no">
41
46
  <span class="ons-fieldset__legend-title ons-u-pb-no" class:ons-u-vh={hideTitle}>{title}</span>
@@ -2,6 +2,7 @@
2
2
  /** @typedef {typeof __propDef.events} CheckboxesEvents */
3
3
  /** @typedef {typeof __propDef.slots} CheckboxesSlots */
4
4
  export default class Checkboxes extends SvelteComponentTyped<{
5
+ cls?: string | undefined;
5
6
  label?: string | undefined;
6
7
  title?: string | undefined;
7
8
  compact?: boolean | undefined;
@@ -22,6 +23,7 @@ export type CheckboxesSlots = typeof __propDef.slots;
22
23
  import { SvelteComponentTyped } from "svelte";
23
24
  declare const __propDef: {
24
25
  props: {
26
+ cls?: string | undefined;
25
27
  label?: string | undefined;
26
28
  title?: string | undefined;
27
29
  compact?: boolean | undefined;
@@ -33,9 +33,14 @@
33
33
  * @type {object[]}
34
34
  */
35
35
  export let options = [];
36
+ /**
37
+ * Optional: Set an additional CSS class for the component
38
+ * @type {string}
39
+ */
40
+ export let cls = "";
36
41
  </script>
37
42
 
38
- <div class="ons-field">
43
+ <div class="ons-field {cls}">
39
44
  {#if label}
40
45
  <label class="ons-label" for={id} class:ons-u-vh={hideLabel}>{label}</label>
41
46
  {/if}
@@ -2,6 +2,7 @@
2
2
  /** @typedef {typeof __propDef.events} DropdownEvents */
3
3
  /** @typedef {typeof __propDef.slots} DropdownSlots */
4
4
  export default class Dropdown extends SvelteComponentTyped<{
5
+ cls?: string | undefined;
5
6
  id?: string | undefined;
6
7
  label?: string | undefined;
7
8
  value?: object | null | undefined;
@@ -20,6 +21,7 @@ export type DropdownSlots = typeof __propDef.slots;
20
21
  import { SvelteComponentTyped } from "svelte";
21
22
  declare const __propDef: {
22
23
  props: {
24
+ cls?: string | undefined;
23
25
  id?: string | undefined;
24
26
  label?: string | undefined;
25
27
  value?: object | null | undefined;