@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,518 @@
|
|
|
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 { t as Playground } from "./Playground-CNbBbErC.js";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Button } from "@orbitcommerce/constellation";
|
|
8
|
+
import { ArrowSquareOutIcon, CaretDownIcon, DownloadSimpleIcon, PlusIcon, TrashIcon } from "@orbitcommerce/constellation/icons";
|
|
9
|
+
//#region src/pages/components/button.tsx
|
|
10
|
+
function Preview() {
|
|
11
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
12
|
+
style: {
|
|
13
|
+
display: "flex",
|
|
14
|
+
gap: 8
|
|
15
|
+
},
|
|
16
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
17
|
+
variant: "primary",
|
|
18
|
+
icon: /* @__PURE__ */ jsx(PlusIcon, {}),
|
|
19
|
+
children: "Create order"
|
|
20
|
+
}), /* @__PURE__ */ jsx(Button, { children: "Export" })]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function SaveButton() {
|
|
24
|
+
const [saving, setSaving] = useState(false);
|
|
25
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
26
|
+
variant: "primary",
|
|
27
|
+
loading: saving,
|
|
28
|
+
onClick: () => {
|
|
29
|
+
setSaving(true);
|
|
30
|
+
window.setTimeout(() => setSaving(false), 2400);
|
|
31
|
+
},
|
|
32
|
+
children: saving ? "Saving" : "Save changes"
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
var PLAYGROUND = [
|
|
36
|
+
{
|
|
37
|
+
prop: "children",
|
|
38
|
+
type: "text",
|
|
39
|
+
default: "Save changes"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
prop: "variant",
|
|
43
|
+
type: "select",
|
|
44
|
+
options: [
|
|
45
|
+
"primary",
|
|
46
|
+
"secondary",
|
|
47
|
+
"soft",
|
|
48
|
+
"ghost",
|
|
49
|
+
"inverse",
|
|
50
|
+
"critical"
|
|
51
|
+
],
|
|
52
|
+
default: "primary",
|
|
53
|
+
toAttr: (v) => `variant="${v}"`
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
prop: "size",
|
|
57
|
+
type: "select",
|
|
58
|
+
options: [
|
|
59
|
+
"xs",
|
|
60
|
+
"sm",
|
|
61
|
+
"md",
|
|
62
|
+
"lg"
|
|
63
|
+
],
|
|
64
|
+
default: "md"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
prop: "icon",
|
|
68
|
+
type: "boolean",
|
|
69
|
+
default: false,
|
|
70
|
+
toAttr: (v) => v ? "icon={<PlusIcon />}" : null
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
prop: "iconEnd",
|
|
74
|
+
type: "boolean",
|
|
75
|
+
default: false,
|
|
76
|
+
toAttr: (v) => v ? "iconEnd={<CaretDownIcon />}" : null
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
prop: "loading",
|
|
80
|
+
type: "boolean",
|
|
81
|
+
default: false
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
prop: "disabled",
|
|
85
|
+
type: "boolean",
|
|
86
|
+
default: false
|
|
87
|
+
}
|
|
88
|
+
];
|
|
89
|
+
function Page() {
|
|
90
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
91
|
+
title: "Button",
|
|
92
|
+
status: "stable",
|
|
93
|
+
importNames: ["Button"],
|
|
94
|
+
lead: "A pill that starts an action. The primary pill carries Orbit's comet: light that passes once around it on hover and stays in orbit while the action runs.",
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ jsx(Section, {
|
|
97
|
+
id: "playground",
|
|
98
|
+
title: "Playground",
|
|
99
|
+
description: /* @__PURE__ */ jsx("p", { children: "Change the props and watch the pill. Hover the primary to send the comet round; turn on loading to keep it in orbit." }),
|
|
100
|
+
children: /* @__PURE__ */ jsx(Playground, {
|
|
101
|
+
component: "Button",
|
|
102
|
+
childrenProp: "children",
|
|
103
|
+
controls: PLAYGROUND,
|
|
104
|
+
render: (v) => /* @__PURE__ */ jsx(Button, {
|
|
105
|
+
variant: v.variant,
|
|
106
|
+
size: v.size,
|
|
107
|
+
loading: Boolean(v.loading),
|
|
108
|
+
disabled: Boolean(v.disabled),
|
|
109
|
+
icon: v.icon ? /* @__PURE__ */ jsx(PlusIcon, {}) : void 0,
|
|
110
|
+
iconEnd: v.iconEnd ? /* @__PURE__ */ jsx(CaretDownIcon, {}) : void 0,
|
|
111
|
+
children: String(v.children)
|
|
112
|
+
})
|
|
113
|
+
})
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
116
|
+
id: "variants",
|
|
117
|
+
title: "Variants",
|
|
118
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
119
|
+
"Six materials, one shape. ",
|
|
120
|
+
/* @__PURE__ */ jsx("code", { children: "secondary" }),
|
|
121
|
+
" is the default. Use ",
|
|
122
|
+
/* @__PURE__ */ jsx("code", { children: "primary" }),
|
|
123
|
+
" once per view, for the action the page exists for."
|
|
124
|
+
] }),
|
|
125
|
+
children: [/* @__PURE__ */ jsxs(Example, {
|
|
126
|
+
code: `
|
|
127
|
+
<Button variant="primary" icon={<PlusIcon />}>Create order</Button>
|
|
128
|
+
<Button>Export</Button>
|
|
129
|
+
<Button variant="soft">Duplicate</Button>
|
|
130
|
+
<Button variant="ghost">Cancel</Button>
|
|
131
|
+
<Button variant="inverse">Publish theme</Button>
|
|
132
|
+
<Button variant="critical" icon={<TrashIcon />}>Delete product</Button>`,
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ jsx(Button, {
|
|
135
|
+
variant: "primary",
|
|
136
|
+
icon: /* @__PURE__ */ jsx(PlusIcon, {}),
|
|
137
|
+
children: "Create order"
|
|
138
|
+
}),
|
|
139
|
+
/* @__PURE__ */ jsx(Button, { children: "Export" }),
|
|
140
|
+
/* @__PURE__ */ jsx(Button, {
|
|
141
|
+
variant: "soft",
|
|
142
|
+
children: "Duplicate"
|
|
143
|
+
}),
|
|
144
|
+
/* @__PURE__ */ jsx(Button, {
|
|
145
|
+
variant: "ghost",
|
|
146
|
+
children: "Cancel"
|
|
147
|
+
}),
|
|
148
|
+
/* @__PURE__ */ jsx(Button, {
|
|
149
|
+
variant: "inverse",
|
|
150
|
+
children: "Publish theme"
|
|
151
|
+
}),
|
|
152
|
+
/* @__PURE__ */ jsx(Button, {
|
|
153
|
+
variant: "critical",
|
|
154
|
+
icon: /* @__PURE__ */ jsx(TrashIcon, {}),
|
|
155
|
+
children: "Delete product"
|
|
156
|
+
})
|
|
157
|
+
]
|
|
158
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
159
|
+
title: "When to use each",
|
|
160
|
+
children: /* @__PURE__ */ jsx(DocTable, {
|
|
161
|
+
columns: ["Variant", "Use it for"],
|
|
162
|
+
rows: [
|
|
163
|
+
[/* @__PURE__ */ jsx("code", { children: "primary" }), "The one action the view exists for: Save, Create order, Publish. Hover sends the comet round once."],
|
|
164
|
+
[/* @__PURE__ */ jsx("code", { children: "secondary" }), "Everything else that matters. The default."],
|
|
165
|
+
[/* @__PURE__ */ jsx("code", { children: "soft" }), "Quiet actions that repeat down a page or sit in a toolbar."],
|
|
166
|
+
[/* @__PURE__ */ jsx("code", { children: "ghost" }), "Cancel, dismiss, and actions beside a primary that should not compete with it."],
|
|
167
|
+
[/* @__PURE__ */ jsx("code", { children: "inverse" }), "A strong call on a busy or photographic surface, where teal would clash."],
|
|
168
|
+
[/* @__PURE__ */ jsx("code", { children: "critical" }), "Actions that destroy something. Confirm first with a ConfirmDialog."]
|
|
169
|
+
]
|
|
170
|
+
})
|
|
171
|
+
})]
|
|
172
|
+
}),
|
|
173
|
+
/* @__PURE__ */ jsx(Section, {
|
|
174
|
+
id: "both-themes",
|
|
175
|
+
title: "In both themes",
|
|
176
|
+
description: /* @__PURE__ */ jsx("p", { children: "Every variant, light and dark side by side. In dark, primary turns mint and its label turns ink." }),
|
|
177
|
+
children: /* @__PURE__ */ jsxs(ThemePair, { children: [
|
|
178
|
+
/* @__PURE__ */ jsx(Button, {
|
|
179
|
+
variant: "primary",
|
|
180
|
+
children: "Save changes"
|
|
181
|
+
}),
|
|
182
|
+
/* @__PURE__ */ jsx(Button, { children: "Export" }),
|
|
183
|
+
/* @__PURE__ */ jsx(Button, {
|
|
184
|
+
variant: "soft",
|
|
185
|
+
children: "Duplicate"
|
|
186
|
+
}),
|
|
187
|
+
/* @__PURE__ */ jsx(Button, {
|
|
188
|
+
variant: "ghost",
|
|
189
|
+
children: "Cancel"
|
|
190
|
+
}),
|
|
191
|
+
/* @__PURE__ */ jsx(Button, {
|
|
192
|
+
variant: "inverse",
|
|
193
|
+
children: "Publish"
|
|
194
|
+
}),
|
|
195
|
+
/* @__PURE__ */ jsx(Button, {
|
|
196
|
+
variant: "critical",
|
|
197
|
+
children: "Delete"
|
|
198
|
+
})
|
|
199
|
+
] })
|
|
200
|
+
}),
|
|
201
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
202
|
+
id: "sizes",
|
|
203
|
+
title: "Sizes",
|
|
204
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
205
|
+
"Heights snap to the control scale shared by every control in the kit, so a button, a search field and a segmented control line up in any toolbar: ",
|
|
206
|
+
/* @__PURE__ */ jsx("code", { children: "xs" }),
|
|
207
|
+
" 24px, ",
|
|
208
|
+
/* @__PURE__ */ jsx("code", { children: "sm" }),
|
|
209
|
+
" 30px, ",
|
|
210
|
+
/* @__PURE__ */ jsx("code", { children: "md" }),
|
|
211
|
+
" 36px (default), ",
|
|
212
|
+
/* @__PURE__ */ jsx("code", { children: "lg" }),
|
|
213
|
+
" 44px."
|
|
214
|
+
] }),
|
|
215
|
+
children: [/* @__PURE__ */ jsxs(Example, {
|
|
216
|
+
code: `
|
|
217
|
+
<Button variant="primary" size="lg">Start selling</Button>
|
|
218
|
+
<Button variant="primary">Save changes</Button>
|
|
219
|
+
<Button variant="primary" size="sm">Save</Button>
|
|
220
|
+
<Button variant="primary" size="xs">Apply</Button>`,
|
|
221
|
+
children: [
|
|
222
|
+
/* @__PURE__ */ jsx(Button, {
|
|
223
|
+
variant: "primary",
|
|
224
|
+
size: "lg",
|
|
225
|
+
children: "Start selling"
|
|
226
|
+
}),
|
|
227
|
+
/* @__PURE__ */ jsx(Button, {
|
|
228
|
+
variant: "primary",
|
|
229
|
+
children: "Save changes"
|
|
230
|
+
}),
|
|
231
|
+
/* @__PURE__ */ jsx(Button, {
|
|
232
|
+
variant: "primary",
|
|
233
|
+
size: "sm",
|
|
234
|
+
children: "Save"
|
|
235
|
+
}),
|
|
236
|
+
/* @__PURE__ */ jsx(Button, {
|
|
237
|
+
variant: "primary",
|
|
238
|
+
size: "xs",
|
|
239
|
+
children: "Apply"
|
|
240
|
+
})
|
|
241
|
+
]
|
|
242
|
+
}), /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
243
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("code", { children: "lg" }), " for a page's single call to action and for touch-first screens."] }),
|
|
244
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("code", { children: "md" }), " in forms, dialogs and page headers."] }),
|
|
245
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("code", { children: "sm" }), " in the top bar, table toolbars and cards."] }),
|
|
246
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("code", { children: "xs" }), " inside dense rows only, never as a page's main action."] })
|
|
247
|
+
] })]
|
|
248
|
+
}),
|
|
249
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
250
|
+
id: "icons",
|
|
251
|
+
title: "With icons",
|
|
252
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
253
|
+
/* @__PURE__ */ jsx("code", { children: "icon" }),
|
|
254
|
+
" leads, ",
|
|
255
|
+
/* @__PURE__ */ jsx("code", { children: "iconEnd" }),
|
|
256
|
+
" trails. A trailing caret means the button opens a menu; a trailing arrow-out means it leaves Orbit. Icons are 16px in ",
|
|
257
|
+
/* @__PURE__ */ jsx("code", { children: "md" }),
|
|
258
|
+
" and scale with the size."
|
|
259
|
+
] }),
|
|
260
|
+
children: [/* @__PURE__ */ jsxs(Example, {
|
|
261
|
+
code: `
|
|
262
|
+
<Button icon={<DownloadSimpleIcon />}>Download CSV</Button>
|
|
263
|
+
<Button iconEnd={<CaretDownIcon />}>Last 30 days</Button>
|
|
264
|
+
<Button variant="soft" iconEnd={<ArrowSquareOutIcon />}>View store</Button>`,
|
|
265
|
+
children: [
|
|
266
|
+
/* @__PURE__ */ jsx(Button, {
|
|
267
|
+
icon: /* @__PURE__ */ jsx(DownloadSimpleIcon, {}),
|
|
268
|
+
children: "Download CSV"
|
|
269
|
+
}),
|
|
270
|
+
/* @__PURE__ */ jsx(Button, {
|
|
271
|
+
iconEnd: /* @__PURE__ */ jsx(CaretDownIcon, {}),
|
|
272
|
+
children: "Last 30 days"
|
|
273
|
+
}),
|
|
274
|
+
/* @__PURE__ */ jsx(Button, {
|
|
275
|
+
variant: "soft",
|
|
276
|
+
iconEnd: /* @__PURE__ */ jsx(ArrowSquareOutIcon, {}),
|
|
277
|
+
children: "View store"
|
|
278
|
+
})
|
|
279
|
+
]
|
|
280
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
281
|
+
className: "doc-section__description",
|
|
282
|
+
children: [
|
|
283
|
+
"For a button that is only an icon, use ",
|
|
284
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
285
|
+
to: "/components/icon-button",
|
|
286
|
+
children: "Icon button"
|
|
287
|
+
}),
|
|
288
|
+
": it requires a label."
|
|
289
|
+
]
|
|
290
|
+
})]
|
|
291
|
+
}),
|
|
292
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
293
|
+
id: "loading",
|
|
294
|
+
title: "Loading",
|
|
295
|
+
description: /* @__PURE__ */ jsx("p", { children: "While the action runs, the comet stays in orbit around the pill and the leading icon becomes an Orbit spinner. The button keeps focus and ignores repeat presses. Press it to see." }),
|
|
296
|
+
children: [/* @__PURE__ */ jsxs(Example, {
|
|
297
|
+
code: `
|
|
298
|
+
const [saving, setSaving] = useState(false)
|
|
299
|
+
|
|
300
|
+
<Button variant="primary" loading={saving} onClick={save}>
|
|
301
|
+
{saving ? 'Saving' : 'Save changes'}
|
|
302
|
+
</Button>
|
|
303
|
+
<Button loading>Syncing catalogue</Button>`,
|
|
304
|
+
children: [/* @__PURE__ */ jsx(SaveButton, {}), /* @__PURE__ */ jsx(Button, {
|
|
305
|
+
loading: true,
|
|
306
|
+
children: "Syncing catalogue"
|
|
307
|
+
})]
|
|
308
|
+
}), /* @__PURE__ */ jsxs(Note, {
|
|
309
|
+
title: "Why not disabled?",
|
|
310
|
+
children: [
|
|
311
|
+
"A disabled button drops focus, so a keyboard user is thrown back to the top of the page mid-save. Loading uses ",
|
|
312
|
+
/* @__PURE__ */ jsx("code", { children: "aria-disabled" }),
|
|
313
|
+
" and ",
|
|
314
|
+
/* @__PURE__ */ jsx("code", { children: "aria-busy" }),
|
|
315
|
+
" instead: focus stays put and screen readers hear that it is busy."
|
|
316
|
+
]
|
|
317
|
+
})]
|
|
318
|
+
}),
|
|
319
|
+
/* @__PURE__ */ jsx(Section, {
|
|
320
|
+
id: "disabled",
|
|
321
|
+
title: "Disabled",
|
|
322
|
+
description: /* @__PURE__ */ jsx("p", { children: "Use sparingly. A disabled button does not say why, so prefer leaving it enabled and explaining the problem when it is pressed. When you must disable, say why nearby." }),
|
|
323
|
+
children: /* @__PURE__ */ jsxs(Example, {
|
|
324
|
+
code: `
|
|
325
|
+
<Button variant="primary" disabled>Publish</Button>
|
|
326
|
+
<Button disabled>Export</Button>`,
|
|
327
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
328
|
+
variant: "primary",
|
|
329
|
+
disabled: true,
|
|
330
|
+
children: "Publish"
|
|
331
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
332
|
+
disabled: true,
|
|
333
|
+
children: "Export"
|
|
334
|
+
})]
|
|
335
|
+
})
|
|
336
|
+
}),
|
|
337
|
+
/* @__PURE__ */ jsx(Section, {
|
|
338
|
+
id: "as-link",
|
|
339
|
+
title: "As a link",
|
|
340
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
341
|
+
"When the button goes somewhere rather than doing something, render the link itself with",
|
|
342
|
+
" ",
|
|
343
|
+
/* @__PURE__ */ jsx("code", { children: "asChild" }),
|
|
344
|
+
". It keeps the link's semantics (open in new tab, copy address) and the pill's look."
|
|
345
|
+
] }),
|
|
346
|
+
children: /* @__PURE__ */ jsxs(Example, {
|
|
347
|
+
code: `
|
|
348
|
+
import { Link } from 'react-router'
|
|
349
|
+
|
|
350
|
+
<Button asChild variant="primary">
|
|
351
|
+
<Link to="/orders/new">Create order</Link>
|
|
352
|
+
</Button>
|
|
353
|
+
<Button asChild iconEnd={<ArrowSquareOutIcon />}>
|
|
354
|
+
<a href="https://example.co.uk" target="_blank" rel="noreferrer">View store</a>
|
|
355
|
+
</Button>`,
|
|
356
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
357
|
+
asChild: true,
|
|
358
|
+
variant: "primary",
|
|
359
|
+
children: /* @__PURE__ */ jsx("a", {
|
|
360
|
+
href: "#as-link",
|
|
361
|
+
children: "Create order"
|
|
362
|
+
})
|
|
363
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
364
|
+
asChild: true,
|
|
365
|
+
iconEnd: /* @__PURE__ */ jsx(ArrowSquareOutIcon, {}),
|
|
366
|
+
children: /* @__PURE__ */ jsx("a", {
|
|
367
|
+
href: "#as-link",
|
|
368
|
+
children: "View store"
|
|
369
|
+
})
|
|
370
|
+
})]
|
|
371
|
+
})
|
|
372
|
+
}),
|
|
373
|
+
/* @__PURE__ */ jsx(Section, {
|
|
374
|
+
id: "full-width",
|
|
375
|
+
title: "Full width",
|
|
376
|
+
description: /* @__PURE__ */ jsx("p", { children: "Fills its container. For narrow panels, sheets on phones and the foot of a card." }),
|
|
377
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
378
|
+
align: "fill",
|
|
379
|
+
code: `<Button variant="primary" fullWidth>Continue to payment</Button>`,
|
|
380
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
381
|
+
style: {
|
|
382
|
+
maxWidth: 360,
|
|
383
|
+
margin: "0 auto"
|
|
384
|
+
},
|
|
385
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
386
|
+
variant: "primary",
|
|
387
|
+
fullWidth: true,
|
|
388
|
+
children: "Continue to payment"
|
|
389
|
+
})
|
|
390
|
+
})
|
|
391
|
+
})
|
|
392
|
+
}),
|
|
393
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
394
|
+
id: "guidelines",
|
|
395
|
+
title: "Guidelines",
|
|
396
|
+
children: [
|
|
397
|
+
/* @__PURE__ */ jsx(DoDont, {
|
|
398
|
+
do: {
|
|
399
|
+
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
|
|
400
|
+
variant: "ghost",
|
|
401
|
+
children: "Cancel"
|
|
402
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
403
|
+
variant: "primary",
|
|
404
|
+
children: "Save changes"
|
|
405
|
+
})] }),
|
|
406
|
+
caption: "One primary per view, and name the action: what happens when it is pressed."
|
|
407
|
+
},
|
|
408
|
+
dont: {
|
|
409
|
+
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
|
|
410
|
+
variant: "primary",
|
|
411
|
+
children: "OK"
|
|
412
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
413
|
+
variant: "primary",
|
|
414
|
+
children: "Submit"
|
|
415
|
+
})] }),
|
|
416
|
+
caption: "Two primaries compete, and \"OK\" or \"Submit\" makes people read around the button to learn what it does."
|
|
417
|
+
}
|
|
418
|
+
}),
|
|
419
|
+
/* @__PURE__ */ jsx(DoDont, {
|
|
420
|
+
do: {
|
|
421
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
422
|
+
variant: "critical",
|
|
423
|
+
children: "Delete 3 products"
|
|
424
|
+
}),
|
|
425
|
+
caption: "Critical for destruction, with the count, so the scale of the action is clear."
|
|
426
|
+
},
|
|
427
|
+
dont: {
|
|
428
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
429
|
+
variant: "critical",
|
|
430
|
+
children: "Archive"
|
|
431
|
+
}),
|
|
432
|
+
caption: "Red for something reversible teaches people to ignore red."
|
|
433
|
+
}
|
|
434
|
+
}),
|
|
435
|
+
/* @__PURE__ */ jsx(Guidelines, { items: [
|
|
436
|
+
"Sentence case, a verb first, two or three words: \"Create order\", \"Save changes\", \"Send invoice\".",
|
|
437
|
+
"Keep an action's name through the flow: a \"Publish\" button leads to a \"Published\" message, not \"Saved\".",
|
|
438
|
+
"Order pairs with the primary last (on the right), and the way out before it.",
|
|
439
|
+
"Never put two buttons with the same label on one screen."
|
|
440
|
+
] })
|
|
441
|
+
]
|
|
442
|
+
}),
|
|
443
|
+
/* @__PURE__ */ jsx(Section, {
|
|
444
|
+
id: "accessibility",
|
|
445
|
+
title: "Accessibility",
|
|
446
|
+
children: /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
447
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
448
|
+
"Renders a native ",
|
|
449
|
+
/* @__PURE__ */ jsx("code", { children: "button" }),
|
|
450
|
+
" with ",
|
|
451
|
+
/* @__PURE__ */ jsx("code", { children: "type=\"button\"" }),
|
|
452
|
+
", so it never submits a form by accident. Pass ",
|
|
453
|
+
/* @__PURE__ */ jsx("code", { children: "type=\"submit\"" }),
|
|
454
|
+
" when it should."
|
|
455
|
+
] }),
|
|
456
|
+
"The focus ring is teal, 2px, offset from the pill, and shows for keyboard focus only.",
|
|
457
|
+
"The comet respects reduced motion: it holds still as a lit arc instead of travelling.",
|
|
458
|
+
"Icons inside are hidden from assistive tech; the label names the button."
|
|
459
|
+
] })
|
|
460
|
+
}),
|
|
461
|
+
/* @__PURE__ */ jsx(Section, {
|
|
462
|
+
id: "props",
|
|
463
|
+
title: "Props",
|
|
464
|
+
description: /* @__PURE__ */ jsx("p", { children: "Also accepts every native button attribute." }),
|
|
465
|
+
children: /* @__PURE__ */ jsx(PropsTable, { rows: [
|
|
466
|
+
{
|
|
467
|
+
name: "variant",
|
|
468
|
+
type: "'primary' | 'secondary' | 'soft' | 'ghost' | 'inverse' | 'critical'",
|
|
469
|
+
default: "'secondary'",
|
|
470
|
+
description: "The pill's material. One primary per view."
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
name: "size",
|
|
474
|
+
type: "'xs' | 'sm' | 'md' | 'lg'",
|
|
475
|
+
default: "'md'",
|
|
476
|
+
description: "Height from the control scale: 24, 30, 36 or 44px."
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
name: "icon",
|
|
480
|
+
type: "ReactNode",
|
|
481
|
+
description: "Leading icon. Replaced by a spinner while loading."
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
name: "iconEnd",
|
|
485
|
+
type: "ReactNode",
|
|
486
|
+
description: "Trailing icon, e.g. a caret for a menu."
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
name: "loading",
|
|
490
|
+
type: "boolean",
|
|
491
|
+
default: "false",
|
|
492
|
+
description: "Keeps the comet in orbit, shows a spinner and ignores presses, without dropping focus."
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
name: "fullWidth",
|
|
496
|
+
type: "boolean",
|
|
497
|
+
default: "false",
|
|
498
|
+
description: "Stretch to the container."
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
name: "asChild",
|
|
502
|
+
type: "boolean",
|
|
503
|
+
default: "false",
|
|
504
|
+
description: "Render the child element (a link) with button styling."
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
name: "disabled",
|
|
508
|
+
type: "boolean",
|
|
509
|
+
default: "false",
|
|
510
|
+
description: "Native disabled. Prefer explaining over disabling."
|
|
511
|
+
}
|
|
512
|
+
] })
|
|
513
|
+
})
|
|
514
|
+
]
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
//#endregion
|
|
518
|
+
export { Page, Preview };
|