@orbitcommerce/constellation-docs 0.0.0-stage → 1.0.0
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/LICENSE.md +6 -0
- package/README.md +6 -2
- package/dist/docs.css +8260 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +308 -0
- package/dist/pages/Playground-CNbBbErC.js +129 -0
- package/dist/pages/_figures-data-BDmScEny.js +606 -0
- package/dist/pages/_foundations-blXWyYh8.js +30 -0
- package/dist/pages/_overlays-specimens-Dpn6oiyH.js +310 -0
- package/dist/pages/alert-BD4e6QTh.js +769 -0
- package/dist/pages/app-shell-KbA-nRqZ.js +1479 -0
- package/dist/pages/area-chart-B91dLcGo.js +562 -0
- package/dist/pages/avatar-DPPHXJAu.js +713 -0
- package/dist/pages/badge-C9JR0thI.js +729 -0
- package/dist/pages/button-D3V912P4.js +518 -0
- package/dist/pages/calendar-DSDZ9nRH.js +630 -0
- package/dist/pages/card-DUggbis3.js +659 -0
- package/dist/pages/checkbox-DwimQaK3.js +365 -0
- package/dist/pages/colour-BwuO8xAv.js +1498 -0
- package/dist/pages/command-palette-xAD7fOg6.js +1243 -0
- package/dist/pages/date-picker-BYSa816m.js +1421 -0
- package/dist/pages/delta-CtAo0eIM.js +574 -0
- package/dist/pages/dialog-BRAf4LMh.js +1451 -0
- package/dist/pages/docs-BNOb7AqR.js +515 -0
- package/dist/pages/empty-state-C-mLrXW2.js +417 -0
- package/dist/pages/figure-tabs-CoPFzzKz.js +460 -0
- package/dist/pages/home-dashboard-CFQwDtC9.js +959 -0
- package/dist/pages/host-B6znjEgQ.js +109 -0
- package/dist/pages/icon-button-C9eSVPPW.js +861 -0
- package/dist/pages/icons-sxkTs5Ob.js +473 -0
- package/dist/pages/input-KF9Gkawf.js +1093 -0
- package/dist/pages/installation-DpsX8G_n.js +445 -0
- package/dist/pages/kbd-cNfDoikz.js +544 -0
- package/dist/pages/live-globe-ClvLn9Lb.js +571 -0
- package/dist/pages/logo-BfGF1Pq9.js +571 -0
- package/dist/pages/menu-by2sgQ09.js +1618 -0
- package/dist/pages/motion-BvTGc2Dk.js +855 -0
- package/dist/pages/orbit-spinner-Dil1Z3Oy.js +332 -0
- package/dist/pages/overview-BPEbZQ6g.js +130 -0
- package/dist/pages/pagination-BBUnGvv5.js +249 -0
- package/dist/pages/popover-Db1gLDpb.js +1136 -0
- package/dist/pages/principles-CeAIOIdt.js +483 -0
- package/dist/pages/radio-group-CkdBWWfG.js +1077 -0
- package/dist/pages/registry-CroHzK9I.js +244 -0
- package/dist/pages/release-Dvo684UJ.js +13 -0
- package/dist/pages/rolling-number-qmvH84Mq.js +529 -0
- package/dist/pages/search-field-BN7MWGQ4.js +693 -0
- package/dist/pages/segmented-control-CTbIpRBW.js +777 -0
- package/dist/pages/select-DguELoRR.js +1429 -0
- package/dist/pages/separator-CPZub9pv.js +351 -0
- package/dist/pages/shape-DKvA0YKr.js +627 -0
- package/dist/pages/skeleton-DLuBhP46.js +561 -0
- package/dist/pages/sparkline-DMMYGbHn.js +668 -0
- package/dist/pages/switch-B-Qe4kcT.js +517 -0
- package/dist/pages/table-AMoODng4.js +607 -0
- package/dist/pages/tabs-B4M-usCV.js +1455 -0
- package/dist/pages/textarea-fTuUZRQb.js +693 -0
- package/dist/pages/toast-CKP03zjy.js +1176 -0
- package/dist/pages/tooltip-CBYil3kt.js +697 -0
- package/dist/pages/typography-PCbg8Bhg.js +735 -0
- package/manifest.json +3125 -0
- package/package.json +35 -4
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as DocLink } from "./host-B6znjEgQ.js";
|
|
3
|
+
import { a as DocTable, d as Section, i as DocPage, l as Note, m as ThemePair, o as Example, p as SubSection, r as DoDont, s as Guidelines, u as PropsTable } from "./docs-BNOb7AqR.js";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Delta, Sparkline } from "@orbitcommerce/constellation";
|
|
6
|
+
//#region src/pages/components/sparkline.tsx
|
|
7
|
+
var ORDERS = [
|
|
8
|
+
14,
|
|
9
|
+
18,
|
|
10
|
+
16,
|
|
11
|
+
21,
|
|
12
|
+
19,
|
|
13
|
+
24,
|
|
14
|
+
22,
|
|
15
|
+
17,
|
|
16
|
+
20,
|
|
17
|
+
25,
|
|
18
|
+
23,
|
|
19
|
+
21,
|
|
20
|
+
26,
|
|
21
|
+
23
|
|
22
|
+
];
|
|
23
|
+
var AVERAGE_ORDER = [
|
|
24
|
+
112,
|
|
25
|
+
118,
|
|
26
|
+
109,
|
|
27
|
+
121,
|
|
28
|
+
126,
|
|
29
|
+
119,
|
|
30
|
+
131,
|
|
31
|
+
128,
|
|
32
|
+
124,
|
|
33
|
+
133,
|
|
34
|
+
137,
|
|
35
|
+
130,
|
|
36
|
+
141,
|
|
37
|
+
140
|
|
38
|
+
];
|
|
39
|
+
var REFUNDS = [
|
|
40
|
+
1,
|
|
41
|
+
0,
|
|
42
|
+
1,
|
|
43
|
+
1,
|
|
44
|
+
2,
|
|
45
|
+
1,
|
|
46
|
+
2,
|
|
47
|
+
2,
|
|
48
|
+
1,
|
|
49
|
+
3,
|
|
50
|
+
2,
|
|
51
|
+
3,
|
|
52
|
+
3,
|
|
53
|
+
4
|
|
54
|
+
];
|
|
55
|
+
var VISITORS = [
|
|
56
|
+
980,
|
|
57
|
+
1040,
|
|
58
|
+
1010,
|
|
59
|
+
1150,
|
|
60
|
+
1090,
|
|
61
|
+
1210,
|
|
62
|
+
1180,
|
|
63
|
+
1120,
|
|
64
|
+
1240,
|
|
65
|
+
1190,
|
|
66
|
+
1260,
|
|
67
|
+
1230,
|
|
68
|
+
1300,
|
|
69
|
+
1284
|
|
70
|
+
];
|
|
71
|
+
var RETURNS = Array.from({ length: 14 }, () => 0);
|
|
72
|
+
var SLOWING = [
|
|
73
|
+
3120,
|
|
74
|
+
3260,
|
|
75
|
+
3010,
|
|
76
|
+
3180,
|
|
77
|
+
2940,
|
|
78
|
+
2990,
|
|
79
|
+
2820,
|
|
80
|
+
2870,
|
|
81
|
+
2760,
|
|
82
|
+
2690,
|
|
83
|
+
2810,
|
|
84
|
+
2640,
|
|
85
|
+
2590,
|
|
86
|
+
2610
|
|
87
|
+
];
|
|
88
|
+
var PRODUCTS = [
|
|
89
|
+
{
|
|
90
|
+
name: "Arden ergonomic chair",
|
|
91
|
+
data: [
|
|
92
|
+
9,
|
|
93
|
+
11,
|
|
94
|
+
10,
|
|
95
|
+
12,
|
|
96
|
+
14,
|
|
97
|
+
13,
|
|
98
|
+
15,
|
|
99
|
+
14,
|
|
100
|
+
17,
|
|
101
|
+
16,
|
|
102
|
+
18,
|
|
103
|
+
17,
|
|
104
|
+
19,
|
|
105
|
+
21
|
|
106
|
+
],
|
|
107
|
+
sales: "£18,240.00"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "Oslo sit-stand desk, oak",
|
|
111
|
+
data: [
|
|
112
|
+
8,
|
|
113
|
+
9,
|
|
114
|
+
8,
|
|
115
|
+
7,
|
|
116
|
+
8,
|
|
117
|
+
7,
|
|
118
|
+
7,
|
|
119
|
+
6,
|
|
120
|
+
7,
|
|
121
|
+
6,
|
|
122
|
+
6,
|
|
123
|
+
7,
|
|
124
|
+
6,
|
|
125
|
+
6
|
|
126
|
+
],
|
|
127
|
+
sales: "£14,980.00"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "Lumen desk lamp",
|
|
131
|
+
data: [
|
|
132
|
+
3,
|
|
133
|
+
4,
|
|
134
|
+
3,
|
|
135
|
+
5,
|
|
136
|
+
4,
|
|
137
|
+
6,
|
|
138
|
+
5,
|
|
139
|
+
7,
|
|
140
|
+
6,
|
|
141
|
+
8,
|
|
142
|
+
7,
|
|
143
|
+
9,
|
|
144
|
+
8,
|
|
145
|
+
9
|
|
146
|
+
],
|
|
147
|
+
sales: "£6,210.00"
|
|
148
|
+
}
|
|
149
|
+
];
|
|
150
|
+
function Preview() {
|
|
151
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
152
|
+
className: "sparkline-preview",
|
|
153
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
154
|
+
className: "sparkline-stat__label",
|
|
155
|
+
children: "Orders"
|
|
156
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
157
|
+
className: "sparkline-preview__row",
|
|
158
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
159
|
+
className: "sparkline-stat__value",
|
|
160
|
+
children: "23"
|
|
161
|
+
}), /* @__PURE__ */ jsx(Sparkline, {
|
|
162
|
+
data: ORDERS,
|
|
163
|
+
width: 104,
|
|
164
|
+
height: 34,
|
|
165
|
+
showEnd: true,
|
|
166
|
+
fill: true
|
|
167
|
+
})]
|
|
168
|
+
})]
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
var TONES = [
|
|
172
|
+
{
|
|
173
|
+
tone: "accent",
|
|
174
|
+
name: "Accent",
|
|
175
|
+
data: ORDERS,
|
|
176
|
+
use: "The default. Any trend that is not itself a status: orders, takings, visitors to a page."
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
tone: "positive",
|
|
180
|
+
name: "Positive",
|
|
181
|
+
data: AVERAGE_ORDER,
|
|
182
|
+
use: "A status that is good news as a whole, such as payments settling or orders dispatched on time."
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
tone: "negative",
|
|
186
|
+
name: "Negative",
|
|
187
|
+
data: REFUNDS,
|
|
188
|
+
use: "A status that is bad news as a whole, such as refunds or failed payments."
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
tone: "neutral",
|
|
192
|
+
name: "Neutral",
|
|
193
|
+
data: VISITORS,
|
|
194
|
+
use: "Context that should sit back: a comparison, a secondary figure, a line in a dense table."
|
|
195
|
+
}
|
|
196
|
+
];
|
|
197
|
+
function StatStrip() {
|
|
198
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
199
|
+
className: "sparkline-strip",
|
|
200
|
+
children: [
|
|
201
|
+
/* @__PURE__ */ jsxs("div", {
|
|
202
|
+
className: "sparkline-stat",
|
|
203
|
+
children: [
|
|
204
|
+
/* @__PURE__ */ jsx("span", {
|
|
205
|
+
className: "sparkline-stat__label",
|
|
206
|
+
children: "Orders"
|
|
207
|
+
}),
|
|
208
|
+
/* @__PURE__ */ jsxs("span", {
|
|
209
|
+
className: "sparkline-stat__row",
|
|
210
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
211
|
+
className: "sparkline-stat__value",
|
|
212
|
+
children: "23"
|
|
213
|
+
}), /* @__PURE__ */ jsx(Sparkline, {
|
|
214
|
+
data: ORDERS,
|
|
215
|
+
showEnd: true,
|
|
216
|
+
fill: true,
|
|
217
|
+
label: "Orders over the last 14 days, rising"
|
|
218
|
+
})]
|
|
219
|
+
}),
|
|
220
|
+
/* @__PURE__ */ jsx(Delta, {
|
|
221
|
+
value: 9.5,
|
|
222
|
+
size: "sm",
|
|
223
|
+
label: "vs last week"
|
|
224
|
+
})
|
|
225
|
+
]
|
|
226
|
+
}),
|
|
227
|
+
/* @__PURE__ */ jsxs("div", {
|
|
228
|
+
className: "sparkline-stat",
|
|
229
|
+
children: [
|
|
230
|
+
/* @__PURE__ */ jsx("span", {
|
|
231
|
+
className: "sparkline-stat__label",
|
|
232
|
+
children: "Average order"
|
|
233
|
+
}),
|
|
234
|
+
/* @__PURE__ */ jsxs("span", {
|
|
235
|
+
className: "sparkline-stat__row",
|
|
236
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
237
|
+
className: "sparkline-stat__value",
|
|
238
|
+
children: "£139.77"
|
|
239
|
+
}), /* @__PURE__ */ jsx(Sparkline, {
|
|
240
|
+
data: AVERAGE_ORDER,
|
|
241
|
+
showEnd: true,
|
|
242
|
+
label: "Average order over the last 14 days, rising"
|
|
243
|
+
})]
|
|
244
|
+
}),
|
|
245
|
+
/* @__PURE__ */ jsx(Delta, {
|
|
246
|
+
value: 4.1,
|
|
247
|
+
size: "sm",
|
|
248
|
+
label: "vs last week"
|
|
249
|
+
})
|
|
250
|
+
]
|
|
251
|
+
}),
|
|
252
|
+
/* @__PURE__ */ jsxs("div", {
|
|
253
|
+
className: "sparkline-stat",
|
|
254
|
+
children: [
|
|
255
|
+
/* @__PURE__ */ jsx("span", {
|
|
256
|
+
className: "sparkline-stat__label",
|
|
257
|
+
children: "Refunds"
|
|
258
|
+
}),
|
|
259
|
+
/* @__PURE__ */ jsxs("span", {
|
|
260
|
+
className: "sparkline-stat__row",
|
|
261
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
262
|
+
className: "sparkline-stat__value",
|
|
263
|
+
children: "4"
|
|
264
|
+
}), /* @__PURE__ */ jsx(Sparkline, {
|
|
265
|
+
data: REFUNDS,
|
|
266
|
+
tone: "negative",
|
|
267
|
+
showEnd: true,
|
|
268
|
+
label: "Refunds over the last 14 days, rising"
|
|
269
|
+
})]
|
|
270
|
+
}),
|
|
271
|
+
/* @__PURE__ */ jsx(Delta, {
|
|
272
|
+
value: 33.3,
|
|
273
|
+
positiveIsGood: false,
|
|
274
|
+
size: "sm",
|
|
275
|
+
label: "vs last week"
|
|
276
|
+
})
|
|
277
|
+
]
|
|
278
|
+
})
|
|
279
|
+
]
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
function Page() {
|
|
283
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
284
|
+
title: "Sparkline",
|
|
285
|
+
status: "new",
|
|
286
|
+
importNames: ["Sparkline"],
|
|
287
|
+
lead: "A tiny trend line that sits beside a figure, in a stat or a table row, to show which way it has been heading. Reach for it when the shape matters more than the values; for values, use an area chart.",
|
|
288
|
+
children: [
|
|
289
|
+
/* @__PURE__ */ jsx(Section, {
|
|
290
|
+
id: "basics",
|
|
291
|
+
title: "Basics",
|
|
292
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
293
|
+
"Pass the values oldest first. The line is a smooth curve that never overshoots the data, drawn 1.5px wide with round caps. ",
|
|
294
|
+
/* @__PURE__ */ jsx("code", { children: "showEnd" }),
|
|
295
|
+
" marks the latest value with a dot and ",
|
|
296
|
+
/* @__PURE__ */ jsx("code", { children: "fill" }),
|
|
297
|
+
" lays a soft wash beneath the line."
|
|
298
|
+
] }),
|
|
299
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
300
|
+
code: `
|
|
301
|
+
<Sparkline data={orders} />
|
|
302
|
+
<Sparkline data={orders} showEnd />
|
|
303
|
+
<Sparkline data={orders} fill />
|
|
304
|
+
<Sparkline data={orders} showEnd fill />`,
|
|
305
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
306
|
+
className: "sparkline-specimens",
|
|
307
|
+
children: [
|
|
308
|
+
{
|
|
309
|
+
caption: "Line",
|
|
310
|
+
props: {}
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
caption: "showEnd",
|
|
314
|
+
props: { showEnd: true }
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
caption: "fill",
|
|
318
|
+
props: { fill: true }
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
caption: "showEnd and fill",
|
|
322
|
+
props: {
|
|
323
|
+
showEnd: true,
|
|
324
|
+
fill: true
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
].map((s) => /* @__PURE__ */ jsxs("figure", {
|
|
328
|
+
className: "sparkline-specimen",
|
|
329
|
+
children: [/* @__PURE__ */ jsx(Sparkline, {
|
|
330
|
+
data: ORDERS,
|
|
331
|
+
...s.props
|
|
332
|
+
}), /* @__PURE__ */ jsx("figcaption", { children: s.caption })]
|
|
333
|
+
}, s.caption))
|
|
334
|
+
})
|
|
335
|
+
})
|
|
336
|
+
}),
|
|
337
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
338
|
+
id: "tones",
|
|
339
|
+
title: "Tones",
|
|
340
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
341
|
+
/* @__PURE__ */ jsx("code", { children: "tone" }),
|
|
342
|
+
" sets the colour by meaning, never by the data. A line does not turn red because it fell: say whether a change is good news with a ",
|
|
343
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
344
|
+
to: "/components/delta",
|
|
345
|
+
children: "Delta"
|
|
346
|
+
}),
|
|
347
|
+
" beside it."
|
|
348
|
+
] }),
|
|
349
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
350
|
+
code: `
|
|
351
|
+
<Sparkline data={orders} showEnd />
|
|
352
|
+
<Sparkline data={averageOrder} tone="positive" showEnd />
|
|
353
|
+
<Sparkline data={refunds} tone="negative" showEnd />
|
|
354
|
+
<Sparkline data={visitors} tone="neutral" showEnd />`,
|
|
355
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
356
|
+
className: "sparkline-specimens",
|
|
357
|
+
children: TONES.map((t) => /* @__PURE__ */ jsxs("figure", {
|
|
358
|
+
className: "sparkline-specimen",
|
|
359
|
+
children: [/* @__PURE__ */ jsx(Sparkline, {
|
|
360
|
+
data: t.data,
|
|
361
|
+
tone: t.tone,
|
|
362
|
+
showEnd: true
|
|
363
|
+
}), /* @__PURE__ */ jsx("figcaption", { children: t.name })]
|
|
364
|
+
}, t.tone))
|
|
365
|
+
})
|
|
366
|
+
}), /* @__PURE__ */ jsx(DocTable, {
|
|
367
|
+
columns: ["Tone", "Use it for"],
|
|
368
|
+
rows: TONES.map((t) => [/* @__PURE__ */ jsx("code", { children: t.tone }), t.use])
|
|
369
|
+
})]
|
|
370
|
+
}),
|
|
371
|
+
/* @__PURE__ */ jsx(Section, {
|
|
372
|
+
id: "both-themes",
|
|
373
|
+
title: "In both themes",
|
|
374
|
+
description: /* @__PURE__ */ jsx("p", { children: "In dark the accent turns mint and the status hues lift, so each line keeps its contrast on the night canvas." }),
|
|
375
|
+
children: /* @__PURE__ */ jsx(ThemePair, { children: /* @__PURE__ */ jsx("div", {
|
|
376
|
+
className: "sparkline-pair",
|
|
377
|
+
children: TONES.map((t) => /* @__PURE__ */ jsx(Sparkline, {
|
|
378
|
+
data: t.data,
|
|
379
|
+
tone: t.tone,
|
|
380
|
+
showEnd: true,
|
|
381
|
+
fill: t.tone === "accent"
|
|
382
|
+
}, t.tone))
|
|
383
|
+
}) })
|
|
384
|
+
}),
|
|
385
|
+
/* @__PURE__ */ jsx(Section, {
|
|
386
|
+
id: "sizes",
|
|
387
|
+
title: "Sizes",
|
|
388
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
389
|
+
/* @__PURE__ */ jsx("code", { children: "width" }),
|
|
390
|
+
" and ",
|
|
391
|
+
/* @__PURE__ */ jsx("code", { children: "height" }),
|
|
392
|
+
" are in pixels, 96 by 28 by default. The stroke stays 1.5px at every size, and the plot insets itself so round caps and the end dot are never clipped."
|
|
393
|
+
] }),
|
|
394
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
395
|
+
code: `
|
|
396
|
+
<Sparkline data={orders} width={64} height={20} />
|
|
397
|
+
<Sparkline data={orders} />
|
|
398
|
+
<Sparkline data={orders} width={160} height={40} showEnd fill />
|
|
399
|
+
<Sparkline data={orders} width={240} height={56} showEnd fill />`,
|
|
400
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
401
|
+
className: "sparkline-specimens sparkline-specimens--sizes",
|
|
402
|
+
children: [
|
|
403
|
+
{
|
|
404
|
+
w: 64,
|
|
405
|
+
h: 20,
|
|
406
|
+
caption: "64 by 20, a table row"
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
w: 96,
|
|
410
|
+
h: 28,
|
|
411
|
+
caption: "96 by 28, the default"
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
w: 160,
|
|
415
|
+
h: 40,
|
|
416
|
+
caption: "160 by 40, a stat",
|
|
417
|
+
rich: true
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
w: 240,
|
|
421
|
+
h: 56,
|
|
422
|
+
caption: "240 by 56, a wide stat",
|
|
423
|
+
rich: true
|
|
424
|
+
}
|
|
425
|
+
].map((s) => /* @__PURE__ */ jsxs("figure", {
|
|
426
|
+
className: "sparkline-specimen",
|
|
427
|
+
children: [/* @__PURE__ */ jsx(Sparkline, {
|
|
428
|
+
data: ORDERS,
|
|
429
|
+
width: s.w,
|
|
430
|
+
height: s.h,
|
|
431
|
+
showEnd: s.rich,
|
|
432
|
+
fill: s.rich
|
|
433
|
+
}), /* @__PURE__ */ jsx("figcaption", { children: s.caption })]
|
|
434
|
+
}, s.w))
|
|
435
|
+
})
|
|
436
|
+
})
|
|
437
|
+
}),
|
|
438
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
439
|
+
id: "in-context",
|
|
440
|
+
title: "In a stat and a table",
|
|
441
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
442
|
+
"Beside a figure, the sparkline shows the shape and the ",
|
|
443
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
444
|
+
to: "/components/delta",
|
|
445
|
+
children: "Delta"
|
|
446
|
+
}),
|
|
447
|
+
" says whether it is good news. Stats sit on a hairline strip rather than in a row of cards, the same way the headline figures do on the home."
|
|
448
|
+
] }),
|
|
449
|
+
children: [
|
|
450
|
+
/* @__PURE__ */ jsx(Example, {
|
|
451
|
+
align: "fill",
|
|
452
|
+
code: `
|
|
453
|
+
<div className="stat">
|
|
454
|
+
<span className="stat__label">Orders</span>
|
|
455
|
+
<span className="stat__row">
|
|
456
|
+
<span className="stat__value">23</span>
|
|
457
|
+
<Sparkline data={orders} showEnd fill label="Orders over the last 14 days, rising" />
|
|
458
|
+
</span>
|
|
459
|
+
<Delta value={9.5} size="sm" label="vs last week" />
|
|
460
|
+
</div>`,
|
|
461
|
+
children: /* @__PURE__ */ jsx(StatStrip, {})
|
|
462
|
+
}),
|
|
463
|
+
/* @__PURE__ */ jsx(SubSection, {
|
|
464
|
+
title: "In a table row",
|
|
465
|
+
description: /* @__PURE__ */ jsx("p", { children: "Small and quiet: 64 by 20, no end dot, so a column of lines reads as texture rather than a row of alarms." }),
|
|
466
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
467
|
+
align: "fill",
|
|
468
|
+
code: `
|
|
469
|
+
<td>
|
|
470
|
+
<Sparkline data={unitsSold} width={64} height={20} label="Units sold over 14 days" />
|
|
471
|
+
</td>`,
|
|
472
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
473
|
+
className: "sparkline-table",
|
|
474
|
+
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
475
|
+
/* @__PURE__ */ jsx("th", {
|
|
476
|
+
scope: "col",
|
|
477
|
+
children: "Product"
|
|
478
|
+
}),
|
|
479
|
+
/* @__PURE__ */ jsx("th", {
|
|
480
|
+
scope: "col",
|
|
481
|
+
children: "Last 14 days"
|
|
482
|
+
}),
|
|
483
|
+
/* @__PURE__ */ jsx("th", {
|
|
484
|
+
scope: "col",
|
|
485
|
+
children: "Sales"
|
|
486
|
+
})
|
|
487
|
+
] }) }), /* @__PURE__ */ jsx("tbody", { children: PRODUCTS.map((p) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
488
|
+
/* @__PURE__ */ jsx("td", { children: p.name }),
|
|
489
|
+
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx(Sparkline, {
|
|
490
|
+
data: p.data,
|
|
491
|
+
width: 64,
|
|
492
|
+
height: 20,
|
|
493
|
+
label: `Units of ${p.name} sold over 14 days`
|
|
494
|
+
}) }),
|
|
495
|
+
/* @__PURE__ */ jsx("td", { children: p.sales })
|
|
496
|
+
] }, p.name)) })]
|
|
497
|
+
})
|
|
498
|
+
})
|
|
499
|
+
}),
|
|
500
|
+
/* @__PURE__ */ jsxs(Note, {
|
|
501
|
+
title: "On another surface",
|
|
502
|
+
children: [
|
|
503
|
+
"The end dot wears a ring of the canvas colour so it stands clear of the line. On a sunken or tinted surface, set ",
|
|
504
|
+
/* @__PURE__ */ jsx("code", { children: "--o-sparkline-surface" }),
|
|
505
|
+
" to that surface's token so the ring matches."
|
|
506
|
+
]
|
|
507
|
+
})
|
|
508
|
+
]
|
|
509
|
+
}),
|
|
510
|
+
/* @__PURE__ */ jsx(Section, {
|
|
511
|
+
id: "edge-cases",
|
|
512
|
+
title: "Flat and missing data",
|
|
513
|
+
description: /* @__PURE__ */ jsx("p", { children: "With fewer than two values, or values that never change, the sparkline draws a level line through the middle, so a quiet fortnight still reads as a line rather than an empty gap. Values that are not finite are skipped." }),
|
|
514
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
515
|
+
code: `
|
|
516
|
+
<Sparkline data={[0, 0, 0, 0, 0, 0, 0]} tone="neutral" />
|
|
517
|
+
<Sparkline data={[]} tone="neutral" />`,
|
|
518
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
519
|
+
className: "sparkline-specimens",
|
|
520
|
+
children: [/* @__PURE__ */ jsxs("figure", {
|
|
521
|
+
className: "sparkline-specimen",
|
|
522
|
+
children: [/* @__PURE__ */ jsx(Sparkline, {
|
|
523
|
+
data: RETURNS,
|
|
524
|
+
tone: "neutral"
|
|
525
|
+
}), /* @__PURE__ */ jsx("figcaption", { children: "No returns all fortnight" })]
|
|
526
|
+
}), /* @__PURE__ */ jsxs("figure", {
|
|
527
|
+
className: "sparkline-specimen",
|
|
528
|
+
children: [/* @__PURE__ */ jsx(Sparkline, {
|
|
529
|
+
data: [],
|
|
530
|
+
tone: "neutral"
|
|
531
|
+
}), /* @__PURE__ */ jsx("figcaption", { children: "No data yet" })]
|
|
532
|
+
})]
|
|
533
|
+
})
|
|
534
|
+
})
|
|
535
|
+
}),
|
|
536
|
+
/* @__PURE__ */ jsx(Section, {
|
|
537
|
+
id: "motion",
|
|
538
|
+
title: "Motion",
|
|
539
|
+
description: /* @__PURE__ */ jsx("p", { children: "The line draws itself in once, left to right, over 600ms when it first appears; the wash settles in after it and the end dot pops at the end of the stroke. When the data changes later, the new line simply replaces the old one. With reduced motion on, the line and the dot fade in instead." })
|
|
540
|
+
}),
|
|
541
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
542
|
+
id: "guidelines",
|
|
543
|
+
title: "Guidelines",
|
|
544
|
+
children: [/* @__PURE__ */ jsx(DoDont, {
|
|
545
|
+
do: {
|
|
546
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
547
|
+
className: "sparkline-dodont",
|
|
548
|
+
children: [
|
|
549
|
+
/* @__PURE__ */ jsx("span", {
|
|
550
|
+
className: "sparkline-stat__label",
|
|
551
|
+
children: "Takings"
|
|
552
|
+
}),
|
|
553
|
+
/* @__PURE__ */ jsxs("span", {
|
|
554
|
+
className: "sparkline-stat__row",
|
|
555
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
556
|
+
className: "sparkline-stat__value",
|
|
557
|
+
children: "£2,610"
|
|
558
|
+
}), /* @__PURE__ */ jsx(Sparkline, {
|
|
559
|
+
data: SLOWING,
|
|
560
|
+
showEnd: true
|
|
561
|
+
})]
|
|
562
|
+
}),
|
|
563
|
+
/* @__PURE__ */ jsx(Delta, {
|
|
564
|
+
value: -16.3,
|
|
565
|
+
size: "sm",
|
|
566
|
+
label: "vs last week"
|
|
567
|
+
})
|
|
568
|
+
]
|
|
569
|
+
}),
|
|
570
|
+
caption: "Keep the accent line whichever way the trend runs, and let the delta say it is bad news."
|
|
571
|
+
},
|
|
572
|
+
dont: {
|
|
573
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
574
|
+
className: "sparkline-dodont",
|
|
575
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
576
|
+
className: "sparkline-stat__label",
|
|
577
|
+
children: "Takings"
|
|
578
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
579
|
+
className: "sparkline-stat__row",
|
|
580
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
581
|
+
className: "sparkline-stat__value",
|
|
582
|
+
children: "£2,610"
|
|
583
|
+
}), /* @__PURE__ */ jsx(Sparkline, {
|
|
584
|
+
data: SLOWING,
|
|
585
|
+
tone: "negative",
|
|
586
|
+
showEnd: true
|
|
587
|
+
})]
|
|
588
|
+
})]
|
|
589
|
+
}),
|
|
590
|
+
caption: "Turning the line red because it fell makes colour follow the data, and a rising line would have to flip to green."
|
|
591
|
+
}
|
|
592
|
+
}), /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
593
|
+
"Give it a label when the line is the only place the trend appears. Leave it decorative when a figure and a delta beside it already say the same thing.",
|
|
594
|
+
"Seven to thirty points reads best. Beyond that the curve smooths into a blur; use an area chart with dates.",
|
|
595
|
+
"Keep the same range across a row of sparklines, such as the last 14 days, and say so once in the heading or a label."
|
|
596
|
+
] })]
|
|
597
|
+
}),
|
|
598
|
+
/* @__PURE__ */ jsx(Section, {
|
|
599
|
+
id: "accessibility",
|
|
600
|
+
title: "Accessibility",
|
|
601
|
+
children: /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
602
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
603
|
+
"Decorative by default: without a ",
|
|
604
|
+
/* @__PURE__ */ jsx("code", { children: "label" }),
|
|
605
|
+
" the SVG is hidden from assistive tech."
|
|
606
|
+
] }),
|
|
607
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
608
|
+
"With a ",
|
|
609
|
+
/* @__PURE__ */ jsx("code", { children: "label" }),
|
|
610
|
+
" it becomes an image with that name. Describe the trend, not the drawing: \"Orders over the last 14 days, rising\"."
|
|
611
|
+
] }),
|
|
612
|
+
"It is never focusable, so it adds no tab stops to a table.",
|
|
613
|
+
"The draw and the pop respect reduced motion: both fade in instead."
|
|
614
|
+
] })
|
|
615
|
+
}),
|
|
616
|
+
/* @__PURE__ */ jsx(Section, {
|
|
617
|
+
id: "props",
|
|
618
|
+
title: "Props",
|
|
619
|
+
description: /* @__PURE__ */ jsx("p", { children: "Also accepts SVG attributes, except width, height, fill and children." }),
|
|
620
|
+
children: /* @__PURE__ */ jsx(PropsTable, { rows: [
|
|
621
|
+
{
|
|
622
|
+
name: "data",
|
|
623
|
+
type: "readonly number[]",
|
|
624
|
+
required: true,
|
|
625
|
+
description: "Values in order, oldest first. Empty or flat data draws a level line."
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
name: "width",
|
|
629
|
+
type: "number",
|
|
630
|
+
default: "96",
|
|
631
|
+
description: "Width in px."
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
name: "height",
|
|
635
|
+
type: "number",
|
|
636
|
+
default: "28",
|
|
637
|
+
description: "Height in px."
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
name: "tone",
|
|
641
|
+
type: "'accent' | 'positive' | 'negative' | 'neutral'",
|
|
642
|
+
default: "'accent'",
|
|
643
|
+
description: "Line colour by meaning. Status tones only for status."
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
name: "showEnd",
|
|
647
|
+
type: "boolean",
|
|
648
|
+
default: "false",
|
|
649
|
+
description: "Marks the latest value with a dot."
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
name: "fill",
|
|
653
|
+
type: "boolean",
|
|
654
|
+
default: "false",
|
|
655
|
+
description: "A soft wash under the line."
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
name: "label",
|
|
659
|
+
type: "string",
|
|
660
|
+
description: "Accessible description of the trend. Decorative when omitted."
|
|
661
|
+
}
|
|
662
|
+
] })
|
|
663
|
+
})
|
|
664
|
+
]
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
//#endregion
|
|
668
|
+
export { Page, Preview };
|