@onsvisual/svelte-components 1.0.0-next.6 → 1.0.0-next.8
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/datavis/{DataTile/DataTile.stories.svelte → DataCard/DataCard.stories.svelte} +17 -3
- package/dist/datavis/DataCard/DataCard.stories.svelte.d.ts +23 -0
- package/dist/datavis/{DataTile/DataTile.svelte → DataCard/DataCard.svelte} +17 -3
- package/dist/datavis/{DataTile/DataTile.svelte.d.ts → DataCard/DataCard.svelte.d.ts} +9 -7
- package/dist/datavis/DataCard/Sparkline.svelte +117 -0
- package/dist/datavis/DataCard/Sparkline.svelte.d.ts +27 -0
- package/dist/datavis/DataCard/docs/component.md +17 -0
- package/dist/decorators/Icon/Icon.stories.svelte +27 -0
- package/dist/{inputs/Button/Icon.svelte.d.ts → decorators/Icon/Icon.stories.svelte.d.ts} +2 -6
- package/dist/{inputs/Button → decorators/Icon}/Icon.svelte +39 -4
- package/dist/decorators/Icon/Icon.svelte.d.ts +31 -0
- package/dist/decorators/Icon/docs/component.md +10 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +7 -1
- package/dist/inputs/Button/Button.svelte +2 -2
- package/dist/inputs/Button/Button.svelte.d.ts +4 -4
- package/dist/inputs/Checkbox/Checkbox.svelte.d.ts +2 -2
- package/dist/inputs/Input/Input.svelte.d.ts +2 -2
- package/dist/inputs/Textarea/Textarea.svelte.d.ts +2 -2
- package/dist/intro.mdx +4 -4
- package/dist/layout/Header/Header.svelte +6 -2
- package/dist/layout/Tabs/Tabs.svelte +1 -0
- package/dist/layout/Timeline/Timeline.stories.svelte +44 -0
- package/dist/layout/Timeline/Timeline.stories.svelte.d.ts +23 -0
- package/dist/layout/Timeline/Timeline.svelte +17 -0
- package/dist/layout/Timeline/Timeline.svelte.d.ts +27 -0
- package/dist/layout/Timeline/TimelineItem.svelte +14 -0
- package/dist/layout/Timeline/TimelineItem.svelte.d.ts +27 -0
- package/dist/layout/Timeline/docs/component.md +27 -0
- package/dist/layout/Timeline/docs/example.md +20 -0
- package/package.json +3 -1
- package/dist/datavis/DataTile/DataTile.stories.svelte.d.ts +0 -23
- package/dist/datavis/DataTile/docs/component.md +0 -17
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<script module>
|
|
2
2
|
import { defineMeta } from "@storybook/addon-svelte-csf";
|
|
3
3
|
import { withComponentDocs } from "../../js/withParams.js";
|
|
4
|
-
import
|
|
4
|
+
import DataCard from "./DataCard.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
|
-
title: "Data visualisation/
|
|
9
|
-
component:
|
|
9
|
+
title: "Data visualisation/DataCard",
|
|
10
|
+
component: DataCard,
|
|
10
11
|
tags: ["autodocs"],
|
|
11
12
|
argTypes: {
|
|
12
13
|
mode: {
|
|
@@ -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
|
+
/>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} DataCardProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} DataCardEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} DataCardSlots */
|
|
4
|
+
export default class DataCard extends SvelteComponentTyped<{
|
|
5
|
+
[x: string]: never;
|
|
6
|
+
}, {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
}, {}> {
|
|
9
|
+
}
|
|
10
|
+
export type DataCardProps = typeof __propDef.props;
|
|
11
|
+
export type DataCardEvents = typeof __propDef.events;
|
|
12
|
+
export type DataCardSlots = typeof __propDef.slots;
|
|
13
|
+
import { SvelteComponentTyped } from "svelte";
|
|
14
|
+
declare const __propDef: {
|
|
15
|
+
props: {
|
|
16
|
+
[x: string]: never;
|
|
17
|
+
};
|
|
18
|
+
events: {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
};
|
|
21
|
+
slots: {};
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -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}
|
|
@@ -44,13 +50,21 @@
|
|
|
44
50
|
</script>
|
|
45
51
|
|
|
46
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}
|
|
47
59
|
{#if value}
|
|
48
|
-
<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>
|
|
49
61
|
{/if}
|
|
50
62
|
{#if caption}
|
|
51
|
-
<p class="headline-figures__supporting-text ons-u-fs-r">
|
|
63
|
+
<p class="headline-figures__supporting-text ons-u-fs-r ons-u-mt-2xs ons-u-mb-no">
|
|
64
|
+
{@html caption}
|
|
65
|
+
</p>
|
|
52
66
|
{/if}
|
|
53
67
|
{#if source}
|
|
54
|
-
<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>
|
|
55
69
|
{/if}
|
|
56
70
|
</Card>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props}
|
|
2
|
-
/** @typedef {typeof __propDef.events}
|
|
3
|
-
/** @typedef {typeof __propDef.slots}
|
|
4
|
-
export default class
|
|
1
|
+
/** @typedef {typeof __propDef.props} DataCardProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} DataCardEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} DataCardSlots */
|
|
4
|
+
export default class DataCard extends SvelteComponentTyped<{
|
|
5
5
|
cls?: string | undefined;
|
|
6
6
|
caption?: string | undefined;
|
|
7
7
|
data?: object[] | null | undefined;
|
|
@@ -10,13 +10,14 @@ export default class DataTile extends SvelteComponentTyped<{
|
|
|
10
10
|
href?: string | undefined;
|
|
11
11
|
mode?: "number" | "sparkline" | "bar" | undefined;
|
|
12
12
|
value?: string | number | undefined;
|
|
13
|
+
subtitle?: string | undefined;
|
|
13
14
|
}, {
|
|
14
15
|
[evt: string]: CustomEvent<any>;
|
|
15
16
|
}, {}> {
|
|
16
17
|
}
|
|
17
|
-
export type
|
|
18
|
-
export type
|
|
19
|
-
export type
|
|
18
|
+
export type DataCardProps = typeof __propDef.props;
|
|
19
|
+
export type DataCardEvents = typeof __propDef.events;
|
|
20
|
+
export type DataCardSlots = typeof __propDef.slots;
|
|
20
21
|
import { SvelteComponentTyped } from "svelte";
|
|
21
22
|
declare const __propDef: {
|
|
22
23
|
props: {
|
|
@@ -28,6 +29,7 @@ declare const __propDef: {
|
|
|
28
29
|
href?: string | undefined;
|
|
29
30
|
mode?: "number" | "sparkline" | "bar" | undefined;
|
|
30
31
|
value?: string | number | undefined;
|
|
32
|
+
subtitle?: string | undefined;
|
|
31
33
|
};
|
|
32
34
|
events: {
|
|
33
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 {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
A component for presenting key facts and figures as a grid of "cards".
|
|
2
|
+
|
|
3
|
+
Note: This component is experimental. Its attributes and options are likely to change. The intention is to include a range of simple chart types.
|
|
4
|
+
|
|
5
|
+
<!-- prettier-ignore -->
|
|
6
|
+
```html
|
|
7
|
+
<script>
|
|
8
|
+
import { DataCard } from "@onsvisual/svelte-components";
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<DataCard
|
|
12
|
+
title="Consumer Price Index (CPI)",
|
|
13
|
+
value="up 2.5%",
|
|
14
|
+
caption="in 12 months to December 2024",
|
|
15
|
+
source="Source: ONS"
|
|
16
|
+
/>
|
|
17
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
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="Arrow pointing down" args={{ type: "arrow", rotation: 90 }} />
|
|
26
|
+
|
|
27
|
+
<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
|
-
|
|
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
|
-
|
|
19
|
-
marginLeft?: boolean | undefined;
|
|
20
|
-
marginRight?: boolean | undefined;
|
|
16
|
+
[x: string]: never;
|
|
21
17
|
};
|
|
22
18
|
events: {
|
|
23
19
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,20 +1,54 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
/**
|
|
3
|
+
* Set the type of icon
|
|
4
|
+
* @type {"arrow"|"carret"|"cross"|"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
|
+
* Rotation
|
|
14
|
+
* @type {number}
|
|
15
|
+
*/
|
|
16
|
+
export let rotation = 0;
|
|
17
|
+
/**
|
|
18
|
+
* Add a small margin on the left of the icon
|
|
19
|
+
* @type {boolean}
|
|
20
|
+
*/
|
|
3
21
|
export let marginLeft = false;
|
|
22
|
+
/**
|
|
23
|
+
* Add a small margin on the right of the icon
|
|
24
|
+
* @type {boolean}
|
|
25
|
+
*/
|
|
4
26
|
export let marginRight = false;
|
|
5
27
|
|
|
6
28
|
const paths = {
|
|
7
29
|
arrow: {
|
|
8
|
-
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-.
|
|
30
|
+
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
31
|
viewBox: "0 0 17 13"
|
|
10
32
|
},
|
|
11
|
-
|
|
33
|
+
chevron: {
|
|
34
|
+
d: "M5.74,14.28l-.57-.56a.5.5,0,0,1,0-.71h0l5-5-5-5a.5.5,0,0,1,0-.71h0l.57-.56a.5.5,0,0,1,.71,0h0l5.93,5.93a.5.5,0,0,1,0,.7L6.45,14.28a.5.5,0,0,1-.71,0Z",
|
|
35
|
+
viewBox: "0 0 8 13"
|
|
36
|
+
},
|
|
37
|
+
carret: {
|
|
38
|
+
d: "M1.37.15 4.5 5.1 4.5-5.1a.37.37 0 0 1 .6 0l.7.7a.45.45 0 0 1 0 .5l-5.5 6.2a.37.37 0 0 1-.6 0l-5.5-6.1a.64.64 0 0 1 0-.6l.7-.7a.64.64 0 0 1 .6 0Z",
|
|
39
|
+
viewBox: "0 0 11.75 7.7"
|
|
40
|
+
},
|
|
41
|
+
cross: {
|
|
42
|
+
d: "M12 1.2086L10.7914 0L6 4.79155L1.20857 0L0 1.2086L4.79143 6.00015L0 10.7917L1.20857 12.0003L6 7.20875L10.7914 12.0003L12 10.7917L7.20857 6.00015L12 1.2086Z",
|
|
43
|
+
viewBox: "0 0 12 12"
|
|
44
|
+
},
|
|
45
|
+
external: {
|
|
12
46
|
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
47
|
viewBox: "2 2 12 12"
|
|
14
48
|
},
|
|
15
49
|
signout: {
|
|
16
50
|
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: "
|
|
51
|
+
viewBox: "2 2 12 12"
|
|
18
52
|
},
|
|
19
53
|
print: {
|
|
20
54
|
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,13 +71,14 @@
|
|
|
37
71
|
|
|
38
72
|
{#if paths[type]}
|
|
39
73
|
<svg
|
|
40
|
-
class="ons-icon"
|
|
74
|
+
class="ons-icon {size ? `ons-icon--${size}` : ''}"
|
|
41
75
|
class:ons-u-ml-2xs={marginLeft}
|
|
42
76
|
class:ons-u-mr-2xs={marginRight}
|
|
43
77
|
viewBox={paths[type].viewBox}
|
|
44
78
|
xmlns="http://www.w3.org/2000/svg"
|
|
45
79
|
focusable="false"
|
|
46
80
|
fill="currentColor"
|
|
81
|
+
style:transform={rotation ? `rotate(${rotation}deg)` : null}
|
|
47
82
|
>
|
|
48
83
|
<path d={paths[type].d}></path>
|
|
49
84
|
</svg>
|
|
@@ -0,0 +1,31 @@
|
|
|
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" | "carret" | "cross" | "external" | "signout" | "print" | "download" | "tick" | undefined;
|
|
6
|
+
size?: "s" | "m" | "l" | "xl" | "2xl" | "3xl" | null | undefined;
|
|
7
|
+
rotation?: number | undefined;
|
|
8
|
+
marginLeft?: boolean | undefined;
|
|
9
|
+
marginRight?: boolean | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
}, {}> {
|
|
13
|
+
}
|
|
14
|
+
export type IconProps = typeof __propDef.props;
|
|
15
|
+
export type IconEvents = typeof __propDef.events;
|
|
16
|
+
export type IconSlots = typeof __propDef.slots;
|
|
17
|
+
import { SvelteComponentTyped } from "svelte";
|
|
18
|
+
declare const __propDef: {
|
|
19
|
+
props: {
|
|
20
|
+
type?: "search" | "arrow" | "carret" | "cross" | "external" | "signout" | "print" | "download" | "tick" | undefined;
|
|
21
|
+
size?: "s" | "m" | "l" | "xl" | "2xl" | "3xl" | null | undefined;
|
|
22
|
+
rotation?: number | undefined;
|
|
23
|
+
marginLeft?: boolean | undefined;
|
|
24
|
+
marginRight?: boolean | undefined;
|
|
25
|
+
};
|
|
26
|
+
events: {
|
|
27
|
+
[evt: string]: CustomEvent<any>;
|
|
28
|
+
};
|
|
29
|
+
slots: {};
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Make use of pre-defined icons in your projects. The icon fill is set to `currentColor`, so will render in the same colour as the surrounding text.
|
|
2
|
+
|
|
3
|
+
<!-- prettier-ignore -->
|
|
4
|
+
```html
|
|
5
|
+
<script>
|
|
6
|
+
import { Icon } from "@onsvisual/svelte-components";
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<Icon type="arrow" size="3xl"/>
|
|
10
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -11,12 +11,15 @@ export { default as Breadcrumb } from "./layout/Breadcrumb/Breadcrumb.svelte";
|
|
|
11
11
|
export { default as Card } from "./layout/Card/Card.svelte";
|
|
12
12
|
export { default as Contents } from "./layout/Contents/Contents.svelte";
|
|
13
13
|
export { default as DescriptionList } from "./layout/DescriptionList/DescriptionList.svelte";
|
|
14
|
+
export { default as DocumentList } from "./layout/DocumentList/DocumentList.svelte";
|
|
15
|
+
export { default as Document } from "./layout/DocumentList/Document.svelte";
|
|
14
16
|
export { default as ErrorPage } from "./layout/ErrorPage/ErrorPage.svelte";
|
|
15
17
|
export { default as Footer } from "./layout/Footer/Footer.svelte";
|
|
16
18
|
export { default as Grid } from "./layout/Grid/Grid.svelte";
|
|
17
19
|
export { default as GridCell } from "./layout/Grid/GridCell.svelte";
|
|
18
20
|
export { default as Header } from "./layout/Header/Header.svelte";
|
|
19
21
|
export { default as Highlight } from "./layout/Highlight/Highlight.svelte";
|
|
22
|
+
export { default as Image } from "./layout/Image/Image.svelte";
|
|
20
23
|
export { default as List } from "./layout/List/List.svelte";
|
|
21
24
|
export { default as Li } from "./layout/List/Li.svelte";
|
|
22
25
|
export { default as NavSection } from "./layout/NavSections/NavSection.svelte";
|
|
@@ -32,6 +35,8 @@ export { default as SkipLink } from "./layout/SkipLink/SkipLink.svelte";
|
|
|
32
35
|
export { default as Summary } from "./layout/Summary/Summary.svelte";
|
|
33
36
|
export { default as Tabs } from "./layout/Tabs/Tabs.svelte";
|
|
34
37
|
export { default as Tab } from "./layout/Tabs/Tab.svelte";
|
|
38
|
+
export { default as Timeline } from "./layout/Timeline/Timeline.svelte";
|
|
39
|
+
export { default as TimelineItem } from "./layout/Timeline/TimelineItem.svelte";
|
|
35
40
|
export { default as Button } from "./inputs/Button/Button.svelte";
|
|
36
41
|
export { default as Checkbox } from "./inputs/Checkbox/Checkbox.svelte";
|
|
37
42
|
export { default as Checkboxes } from "./inputs/Checkboxes/Checkboxes.svelte";
|
|
@@ -45,8 +50,9 @@ export { default as Textarea } from "./inputs/Textarea/Textarea.svelte";
|
|
|
45
50
|
export { default as Blockquote } from "./decorators/Blockquote/Blockquote.svelte";
|
|
46
51
|
export { default as Divider } from "./decorators/Divider/Divider.svelte";
|
|
47
52
|
export { default as Em } from "./decorators/Em/Em.svelte";
|
|
53
|
+
export { default as Icon } from "./decorators/Icon/Icon.svelte";
|
|
48
54
|
export { default as Indent } from "./decorators/Indent/Indent.svelte";
|
|
49
|
-
export { default as
|
|
55
|
+
export { default as DataCard } from "./datavis/DataCard/DataCard.svelte";
|
|
50
56
|
export { default as Table } from "./datavis/Table/Table.svelte";
|
|
51
57
|
export { default as AnalyticsBanner, analyticsEvent } from "./layout/AnalyticsBanner/AnalyticsBanner.svelte";
|
|
52
58
|
export { default as Details, default as Twisty } from "./layout/Details/Details.svelte";
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,8 @@ export { default as Contents } from "./layout/Contents/Contents.svelte";
|
|
|
20
20
|
export { default as DescriptionList } from "./layout/DescriptionList/DescriptionList.svelte";
|
|
21
21
|
export { default as Details } from "./layout/Details/Details.svelte";
|
|
22
22
|
export { default as Twisty } from "./layout/Details/Details.svelte"; // Alias for Details
|
|
23
|
+
export { default as DocumentList } from "./layout/DocumentList/DocumentList.svelte";
|
|
24
|
+
export { default as Document } from "./layout/DocumentList/Document.svelte";
|
|
23
25
|
export { default as ErrorPage } from "./layout/ErrorPage/ErrorPage.svelte";
|
|
24
26
|
export { default as Footer } from "./layout/Footer/Footer.svelte";
|
|
25
27
|
export { default as Grid } from "./layout/Grid/Grid.svelte";
|
|
@@ -28,6 +30,7 @@ export { default as Header } from "./layout/Header/Header.svelte";
|
|
|
28
30
|
export { default as Hero } from "./layout/Hero/Hero.svelte";
|
|
29
31
|
export { default as Titleblock } from "./layout/Hero/Hero.svelte"; // Alias for Hero
|
|
30
32
|
export { default as Highlight } from "./layout/Highlight/Highlight.svelte";
|
|
33
|
+
export { default as Image } from "./layout/Image/Image.svelte";
|
|
31
34
|
export { default as List } from "./layout/List/List.svelte";
|
|
32
35
|
export { default as Li } from "./layout/List/Li.svelte";
|
|
33
36
|
export { default as NavSection } from "./layout/NavSections/NavSection.svelte";
|
|
@@ -43,6 +46,8 @@ export { default as SkipLink } from "./layout/SkipLink/SkipLink.svelte";
|
|
|
43
46
|
export { default as Summary } from "./layout/Summary/Summary.svelte";
|
|
44
47
|
export { default as Tabs } from "./layout/Tabs/Tabs.svelte";
|
|
45
48
|
export { default as Tab } from "./layout/Tabs/Tab.svelte";
|
|
49
|
+
export { default as Timeline } from "./layout/Timeline/Timeline.svelte";
|
|
50
|
+
export { default as TimelineItem } from "./layout/Timeline/TimelineItem.svelte";
|
|
46
51
|
|
|
47
52
|
// Inputs
|
|
48
53
|
export { default as Button } from "./inputs/Button/Button.svelte";
|
|
@@ -62,8 +67,9 @@ export { default as Textarea } from "./inputs/Textarea/Textarea.svelte";
|
|
|
62
67
|
export { default as Blockquote } from "./decorators/Blockquote/Blockquote.svelte";
|
|
63
68
|
export { default as Divider } from "./decorators/Divider/Divider.svelte";
|
|
64
69
|
export { default as Em } from "./decorators/Em/Em.svelte";
|
|
70
|
+
export { default as Icon } from "./decorators/Icon/Icon.svelte";
|
|
65
71
|
export { default as Indent } from "./decorators/Indent/Indent.svelte";
|
|
66
72
|
|
|
67
73
|
// Data visualisation
|
|
68
|
-
export { default as
|
|
74
|
+
export { default as DataCard } from "./datavis/DataCard/DataCard.svelte";
|
|
69
75
|
export { default as Table } from "./datavis/Table/Table.svelte";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { createEventDispatcher } from "svelte";
|
|
3
|
-
import Icon from "
|
|
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 {
|
|
29
|
+
* @type {"arrow"|"external"|"signout"|"print"|"download"|"tick"|"search"}
|
|
30
30
|
*/
|
|
31
31
|
export let icon = "";
|
|
32
32
|
/**
|
|
@@ -5,14 +5,14 @@ export default class Button extends SvelteComponentTyped<{
|
|
|
5
5
|
cls?: string | undefined;
|
|
6
6
|
small?: boolean | undefined;
|
|
7
7
|
href?: string | undefined;
|
|
8
|
+
download?: string | undefined;
|
|
8
9
|
type?: "button" | "reset" | "sumbit" | undefined;
|
|
9
10
|
variant?: "secondary" | "primary" | "ghost" | undefined;
|
|
10
|
-
icon?:
|
|
11
|
+
icon?: "search" | "arrow" | "external" | "signout" | "print" | "download" | "tick" | undefined;
|
|
11
12
|
iconPosition?: "before" | "after" | undefined;
|
|
12
13
|
disabled?: boolean | undefined;
|
|
13
14
|
hideLabel?: boolean | undefined;
|
|
14
15
|
arialabel?: string | undefined;
|
|
15
|
-
download?: string | undefined;
|
|
16
16
|
}, {
|
|
17
17
|
click: CustomEvent<any>;
|
|
18
18
|
} & {
|
|
@@ -31,14 +31,14 @@ declare const __propDef: {
|
|
|
31
31
|
cls?: string | undefined;
|
|
32
32
|
small?: boolean | undefined;
|
|
33
33
|
href?: string | undefined;
|
|
34
|
+
download?: string | undefined;
|
|
34
35
|
type?: "button" | "reset" | "sumbit" | undefined;
|
|
35
36
|
variant?: "secondary" | "primary" | "ghost" | undefined;
|
|
36
|
-
icon?:
|
|
37
|
+
icon?: "search" | "arrow" | "external" | "signout" | "print" | "download" | "tick" | undefined;
|
|
37
38
|
iconPosition?: "before" | "after" | undefined;
|
|
38
39
|
disabled?: boolean | undefined;
|
|
39
40
|
hideLabel?: boolean | undefined;
|
|
40
41
|
arialabel?: string | undefined;
|
|
41
|
-
download?: string | undefined;
|
|
42
42
|
};
|
|
43
43
|
events: {
|
|
44
44
|
click: CustomEvent<any>;
|
|
@@ -7,9 +7,9 @@ export default class Checkbox extends SvelteComponentTyped<{
|
|
|
7
7
|
cls?: string | undefined;
|
|
8
8
|
group?: object[] | null | undefined;
|
|
9
9
|
compact?: boolean | undefined;
|
|
10
|
+
description?: string | undefined;
|
|
10
11
|
variant?: "default" | "ghost" | undefined;
|
|
11
12
|
disabled?: boolean | undefined;
|
|
12
|
-
description?: string | undefined;
|
|
13
13
|
checked?: boolean | undefined;
|
|
14
14
|
item?: object | undefined;
|
|
15
15
|
groupName?: string | undefined;
|
|
@@ -30,9 +30,9 @@ declare const __propDef: {
|
|
|
30
30
|
cls?: string | undefined;
|
|
31
31
|
group?: object[] | null | undefined;
|
|
32
32
|
compact?: boolean | undefined;
|
|
33
|
+
description?: string | undefined;
|
|
33
34
|
variant?: "default" | "ghost" | undefined;
|
|
34
35
|
disabled?: boolean | undefined;
|
|
35
|
-
description?: string | undefined;
|
|
36
36
|
checked?: boolean | undefined;
|
|
37
37
|
item?: object | undefined;
|
|
38
38
|
groupName?: string | undefined;
|
|
@@ -10,8 +10,8 @@ export default class Input extends SvelteComponentTyped<{
|
|
|
10
10
|
error?: boolean | undefined;
|
|
11
11
|
numeric?: boolean | undefined;
|
|
12
12
|
value?: string | undefined;
|
|
13
|
-
hideLabel?: boolean | undefined;
|
|
14
13
|
description?: string | undefined;
|
|
14
|
+
hideLabel?: boolean | undefined;
|
|
15
15
|
charLimit?: number | undefined;
|
|
16
16
|
prefix?: string | undefined;
|
|
17
17
|
suffix?: string | undefined;
|
|
@@ -36,8 +36,8 @@ declare const __propDef: {
|
|
|
36
36
|
error?: boolean | undefined;
|
|
37
37
|
numeric?: boolean | undefined;
|
|
38
38
|
value?: string | undefined;
|
|
39
|
-
hideLabel?: boolean | undefined;
|
|
40
39
|
description?: string | undefined;
|
|
40
|
+
hideLabel?: boolean | undefined;
|
|
41
41
|
charLimit?: number | undefined;
|
|
42
42
|
prefix?: string | undefined;
|
|
43
43
|
suffix?: string | undefined;
|
|
@@ -7,8 +7,8 @@ export default class Textarea extends SvelteComponentTyped<{
|
|
|
7
7
|
width?: number | undefined;
|
|
8
8
|
label?: string | undefined;
|
|
9
9
|
value?: string | undefined;
|
|
10
|
-
hideLabel?: boolean | undefined;
|
|
11
10
|
description?: string | undefined;
|
|
11
|
+
hideLabel?: boolean | undefined;
|
|
12
12
|
charLimit?: number | null | undefined;
|
|
13
13
|
rows?: number | undefined;
|
|
14
14
|
}, {
|
|
@@ -26,8 +26,8 @@ declare const __propDef: {
|
|
|
26
26
|
width?: number | undefined;
|
|
27
27
|
label?: string | undefined;
|
|
28
28
|
value?: string | undefined;
|
|
29
|
-
hideLabel?: boolean | undefined;
|
|
30
29
|
description?: string | undefined;
|
|
30
|
+
hideLabel?: boolean | undefined;
|
|
31
31
|
charLimit?: number | null | undefined;
|
|
32
32
|
rows?: number | undefined;
|
|
33
33
|
};
|
package/dist/intro.mdx
CHANGED
|
@@ -21,9 +21,9 @@ import { Meta } from "@storybook/addon-docs/blocks";
|
|
|
21
21
|
</a>
|
|
22
22
|
</p>
|
|
23
23
|
|
|
24
|
-
A library of ONS-branded
|
|
24
|
+
A library of ONS-branded components for any Svelte or SvelteKit project.
|
|
25
25
|
|
|
26
|
-
The components and styles in this library
|
|
26
|
+
The components and styles in this library are built on the HTML and CSS of the [ONS Design System](https://service-manual.ons.gov.uk/design-system/), but with a number of tweaks and additions to make them suitable for a range of interactive data visualisation and data journalism projects.
|
|
27
27
|
|
|
28
28
|
## Installing the components
|
|
29
29
|
|
|
@@ -31,7 +31,7 @@ There are two ways to start a new project using these components.
|
|
|
31
31
|
|
|
32
32
|
### 1. Use a ready-made template
|
|
33
33
|
|
|
34
|
-
When you start a project
|
|
34
|
+
When you start a project with one of the following templates, @onsvisual/svelte-components will already be installed:
|
|
35
35
|
|
|
36
36
|
- [sveltekit-starter](https://github.com/ONSvisual/sveltekit-starter)
|
|
37
37
|
- [robo-article](https://github.com/ONSvisual/robo-article)
|
|
@@ -47,7 +47,7 @@ npm install @onsvisual/svelte-components --save-dev
|
|
|
47
47
|
|
|
48
48
|
## Using the components
|
|
49
49
|
|
|
50
|
-
When using the components, you need to import both the desired component and the global CSS styles. In a SvelteKit project it is best to import the CSS in
|
|
50
|
+
When using the components, you need to import both the desired component and the global CSS styles. In a SvelteKit project it is best to import the CSS in the top-level **+layout.svelte** file in your **src/routes** folder, which will apply it to all pages/components in the project.
|
|
51
51
|
|
|
52
52
|
{/* prettier-ignore */}
|
|
53
53
|
```html
|
|
@@ -847,9 +847,13 @@
|
|
|
847
847
|
class="ons-grid ons-grid-flex ons-grid-flex--between ons-grid-flex--vertical-center ons-grid-flex--no-wrap ons-grid--gutterless"
|
|
848
848
|
>
|
|
849
849
|
<div class="ons-grid__col ons-col-auto ons-u-flex-shrink">
|
|
850
|
-
|
|
850
|
+
{#if titleHref}
|
|
851
|
+
<a class="ons-header__title-link" href={titleHref}>
|
|
852
|
+
<div class="ons-header__title">{title}</div>
|
|
853
|
+
</a>
|
|
854
|
+
{:else}
|
|
851
855
|
<div class="ons-header__title">{title}</div>
|
|
852
|
-
|
|
856
|
+
{/if}
|
|
853
857
|
</div>
|
|
854
858
|
</div>
|
|
855
859
|
</div>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from "@storybook/addon-svelte-csf";
|
|
3
|
+
import { withComponentDocs, withStoryDocs } from "../../js/withParams.js";
|
|
4
|
+
import Timeline from "./Timeline.svelte";
|
|
5
|
+
import TimelineItem from "./TimelineItem.svelte";
|
|
6
|
+
import componentDocs from "./docs/component.md?raw";
|
|
7
|
+
import exampleDocs from "./docs/example.md?raw";
|
|
8
|
+
|
|
9
|
+
const { Story } = defineMeta({
|
|
10
|
+
title: "Layout/Timeline",
|
|
11
|
+
component: Timeline,
|
|
12
|
+
tags: ["autodocs"],
|
|
13
|
+
argTypes: {},
|
|
14
|
+
parameters: withComponentDocs(componentDocs)
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const items = [
|
|
18
|
+
{
|
|
19
|
+
title: "November 2020",
|
|
20
|
+
content: "ONS to provide you with content for magazines and publications"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
title: "January to March 2021",
|
|
24
|
+
content: "ONS to provide a range of press releases for external use"
|
|
25
|
+
},
|
|
26
|
+
{ title: "February to April 2021", content: "Promote your local Census Support Centres" }
|
|
27
|
+
];
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<Story name="Default" args={{ items }} />
|
|
31
|
+
|
|
32
|
+
<Story name="Individually defined timeline items" asChild parameters={withStoryDocs(exampleDocs)}>
|
|
33
|
+
<Timeline>
|
|
34
|
+
<TimelineItem title="November 2020">
|
|
35
|
+
<p>ONS to provide you with content for magazines and publications</p>
|
|
36
|
+
</TimelineItem>
|
|
37
|
+
<TimelineItem title="January to March 2021">
|
|
38
|
+
<p>ONS to provide a range of press releases for external use</p>
|
|
39
|
+
</TimelineItem>
|
|
40
|
+
<TimelineItem title="February to April 2021">
|
|
41
|
+
<p>Promote your local Census Support Centres</p>
|
|
42
|
+
</TimelineItem>
|
|
43
|
+
</Timeline>
|
|
44
|
+
</Story>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} TimelineProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} TimelineEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} TimelineSlots */
|
|
4
|
+
export default class Timeline extends SvelteComponentTyped<{
|
|
5
|
+
[x: string]: never;
|
|
6
|
+
}, {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
}, {}> {
|
|
9
|
+
}
|
|
10
|
+
export type TimelineProps = typeof __propDef.props;
|
|
11
|
+
export type TimelineEvents = typeof __propDef.events;
|
|
12
|
+
export type TimelineSlots = typeof __propDef.slots;
|
|
13
|
+
import { SvelteComponentTyped } from "svelte";
|
|
14
|
+
declare const __propDef: {
|
|
15
|
+
props: {
|
|
16
|
+
[x: string]: never;
|
|
17
|
+
};
|
|
18
|
+
events: {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
};
|
|
21
|
+
slots: {};
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import TimelineItem from "./TimelineItem.svelte";
|
|
3
|
+
/**
|
|
4
|
+
* Timeline items in the format {title, content}, where content can be an HTML string
|
|
5
|
+
* @type {object[]}
|
|
6
|
+
*/
|
|
7
|
+
export let items = [];
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<div class="ons-timeline">
|
|
11
|
+
<slot />
|
|
12
|
+
{#each items as item}
|
|
13
|
+
<TimelineItem title={item.title}>
|
|
14
|
+
{@html item.content}
|
|
15
|
+
</TimelineItem>
|
|
16
|
+
{/each}
|
|
17
|
+
</div>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} TimelineProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} TimelineEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} TimelineSlots */
|
|
4
|
+
export default class Timeline extends SvelteComponentTyped<{
|
|
5
|
+
items?: object[] | undefined;
|
|
6
|
+
}, {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
}, {
|
|
9
|
+
default: {};
|
|
10
|
+
}> {
|
|
11
|
+
}
|
|
12
|
+
export type TimelineProps = typeof __propDef.props;
|
|
13
|
+
export type TimelineEvents = typeof __propDef.events;
|
|
14
|
+
export type TimelineSlots = typeof __propDef.slots;
|
|
15
|
+
import { SvelteComponentTyped } from "svelte";
|
|
16
|
+
declare const __propDef: {
|
|
17
|
+
props: {
|
|
18
|
+
items?: object[] | undefined;
|
|
19
|
+
};
|
|
20
|
+
events: {
|
|
21
|
+
[evt: string]: CustomEvent<any>;
|
|
22
|
+
};
|
|
23
|
+
slots: {
|
|
24
|
+
default: {};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/**
|
|
3
|
+
* Title of timeline item
|
|
4
|
+
* @type {string}
|
|
5
|
+
*/
|
|
6
|
+
export let title = "";
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<div class="ons-timeline__item">
|
|
10
|
+
<h2 class="ons-timeline__heading">{title}</h2>
|
|
11
|
+
<div class="ons-timeline__content">
|
|
12
|
+
<slot />
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} TimelineItemProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} TimelineItemEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} TimelineItemSlots */
|
|
4
|
+
export default class TimelineItem extends SvelteComponentTyped<{
|
|
5
|
+
title?: string | undefined;
|
|
6
|
+
}, {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
}, {
|
|
9
|
+
default: {};
|
|
10
|
+
}> {
|
|
11
|
+
}
|
|
12
|
+
export type TimelineItemProps = typeof __propDef.props;
|
|
13
|
+
export type TimelineItemEvents = typeof __propDef.events;
|
|
14
|
+
export type TimelineItemSlots = typeof __propDef.slots;
|
|
15
|
+
import { SvelteComponentTyped } from "svelte";
|
|
16
|
+
declare const __propDef: {
|
|
17
|
+
props: {
|
|
18
|
+
title?: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
events: {
|
|
21
|
+
[evt: string]: CustomEvent<any>;
|
|
22
|
+
};
|
|
23
|
+
slots: {
|
|
24
|
+
default: {};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
A component to display a linear record of past and future events.
|
|
2
|
+
|
|
3
|
+
Based on [this ONS Design System component](https://service-manual.ons.gov.uk/design-system/components/timeline).
|
|
4
|
+
|
|
5
|
+
<!-- prettier-ignore -->
|
|
6
|
+
```html
|
|
7
|
+
<script>
|
|
8
|
+
import { Timeline } from "@onsvisual/svelte-components";
|
|
9
|
+
|
|
10
|
+
const items = [
|
|
11
|
+
{
|
|
12
|
+
title: "November 2020",
|
|
13
|
+
content: "ONS to provide you with content for magazines and publications"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
title: "January to March 2021",
|
|
17
|
+
content: "ONS to provide a range of press releases for external use"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
title: "February to April 2021",
|
|
21
|
+
content: "Promote your local Census Support Centres"
|
|
22
|
+
}
|
|
23
|
+
];
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<Timeline {items}>
|
|
27
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
In this example, the timeline items are defined explicitly.
|
|
2
|
+
|
|
3
|
+
<!-- prettier-ignore -->
|
|
4
|
+
```html
|
|
5
|
+
<script>
|
|
6
|
+
import { Timeline, TimelineItem } from "@onsvisual/svelte-components";
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<Timeline>
|
|
10
|
+
<TimelineItem title="November 2020">
|
|
11
|
+
<p>ONS to provide you with content for magazines and publications</p>
|
|
12
|
+
</TimelineItem>
|
|
13
|
+
<TimelineItem title="January to March 2021">
|
|
14
|
+
<p>ONS to provide a range of press releases for external use</p>
|
|
15
|
+
</TimelineItem>
|
|
16
|
+
<TimelineItem title="February to April 2021">
|
|
17
|
+
<p>Promote your local Census Support Centres</p>
|
|
18
|
+
</TimelineItem>
|
|
19
|
+
</Timeline>
|
|
20
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onsvisual/svelte-components",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.8",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite dev",
|
|
6
6
|
"build": "npm run build:package && npm run build:docs",
|
|
@@ -61,6 +61,8 @@
|
|
|
61
61
|
"@vitest/browser": "3.2.3",
|
|
62
62
|
"@vitest/coverage-v8": "3.2.3",
|
|
63
63
|
"csso": "^5.0.5",
|
|
64
|
+
"d3-scale": "^4.0.2",
|
|
65
|
+
"d3-shape": "^3.2.0",
|
|
64
66
|
"eslint": "^9.18.0",
|
|
65
67
|
"eslint-config-prettier": "^10.0.1",
|
|
66
68
|
"eslint-plugin-storybook": "^9.0.11",
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} DataTileProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} DataTileEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} DataTileSlots */
|
|
4
|
-
export default class DataTile extends SvelteComponentTyped<{
|
|
5
|
-
[x: string]: never;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {}> {
|
|
9
|
-
}
|
|
10
|
-
export type DataTileProps = typeof __propDef.props;
|
|
11
|
-
export type DataTileEvents = typeof __propDef.events;
|
|
12
|
-
export type DataTileSlots = typeof __propDef.slots;
|
|
13
|
-
import { SvelteComponentTyped } from "svelte";
|
|
14
|
-
declare const __propDef: {
|
|
15
|
-
props: {
|
|
16
|
-
[x: string]: never;
|
|
17
|
-
};
|
|
18
|
-
events: {
|
|
19
|
-
[evt: string]: CustomEvent<any>;
|
|
20
|
-
};
|
|
21
|
-
slots: {};
|
|
22
|
-
};
|
|
23
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
A component for presenting key facts and figures in a tile grid.
|
|
2
|
-
|
|
3
|
-
Note: This component will be extended to include bar charts and sparklines.
|
|
4
|
-
|
|
5
|
-
<!-- prettier-ignore -->
|
|
6
|
-
```html
|
|
7
|
-
<script>
|
|
8
|
-
import { DataTile } from "@onsvisual/svelte-components";
|
|
9
|
-
</script>
|
|
10
|
-
|
|
11
|
-
<DataTile
|
|
12
|
-
title="Consumer Price Index (CPI)",
|
|
13
|
-
value="up 2.5%",
|
|
14
|
-
caption="in 12 months to December 2024",
|
|
15
|
-
source="Source: ONS"
|
|
16
|
-
/>
|
|
17
|
-
```
|