@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,697 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
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";
|
|
3
|
+
import { c as SpecimenFrame, l as TooltipPill } from "./_overlays-specimens-Dpn6oiyH.js";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Button, IconButton, Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger, Tooltip, TooltipProvider } from "@orbitcommerce/constellation";
|
|
7
|
+
import { ArchiveIcon, CopyIcon, DotsThreeIcon, EnvelopeSimpleIcon, FloppyDiskIcon, InfoIcon, KeyboardIcon, LinkSimpleIcon, MagnifyingGlassIcon, PrinterIcon, SidebarSimpleIcon, TrashIcon, TruckIcon } from "@orbitcommerce/constellation/icons";
|
|
8
|
+
//#region src/pages/components/tooltip.tsx
|
|
9
|
+
function Preview() {
|
|
10
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
11
|
+
className: "tooltip-still",
|
|
12
|
+
children: [/* @__PURE__ */ jsx(TooltipPill, {
|
|
13
|
+
shortcut: ["mod", "P"],
|
|
14
|
+
children: "Print packing slip"
|
|
15
|
+
}), /* @__PURE__ */ jsx(IconButton, {
|
|
16
|
+
label: "Print packing slip",
|
|
17
|
+
variant: "secondary",
|
|
18
|
+
tabIndex: -1,
|
|
19
|
+
children: /* @__PURE__ */ jsx(PrinterIcon, {})
|
|
20
|
+
})]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function OrderToolbar() {
|
|
24
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
25
|
+
className: "tooltip-toolbar",
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
28
|
+
content: "Print packing slip",
|
|
29
|
+
shortcut: ["mod", "P"],
|
|
30
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
31
|
+
label: "Print packing slip",
|
|
32
|
+
children: /* @__PURE__ */ jsx(PrinterIcon, {})
|
|
33
|
+
})
|
|
34
|
+
}),
|
|
35
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
36
|
+
content: "Email customer",
|
|
37
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
38
|
+
label: "Email customer",
|
|
39
|
+
children: /* @__PURE__ */ jsx(EnvelopeSimpleIcon, {})
|
|
40
|
+
})
|
|
41
|
+
}),
|
|
42
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
43
|
+
content: "Copy order link",
|
|
44
|
+
shortcut: [
|
|
45
|
+
"mod",
|
|
46
|
+
"shift",
|
|
47
|
+
"C"
|
|
48
|
+
],
|
|
49
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
50
|
+
label: "Copy order link",
|
|
51
|
+
children: /* @__PURE__ */ jsx(LinkSimpleIcon, {})
|
|
52
|
+
})
|
|
53
|
+
}),
|
|
54
|
+
/* @__PURE__ */ jsx("span", {
|
|
55
|
+
className: "tooltip-toolbar__rule",
|
|
56
|
+
"aria-hidden": "true"
|
|
57
|
+
}),
|
|
58
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
59
|
+
content: "Archive order",
|
|
60
|
+
shortcut: ["E"],
|
|
61
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
62
|
+
label: "Archive order",
|
|
63
|
+
children: /* @__PURE__ */ jsx(ArchiveIcon, {})
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/** Tooltips held open for review. Real tooltips; `hideWhenDetached` hides them once their trigger scrolls out of view. */
|
|
70
|
+
function HeldOpen() {
|
|
71
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
72
|
+
className: "tooltip-held",
|
|
73
|
+
children: [/* @__PURE__ */ jsx(Tooltip, {
|
|
74
|
+
content: "Print packing slip",
|
|
75
|
+
shortcut: ["mod", "P"],
|
|
76
|
+
open: true,
|
|
77
|
+
hideWhenDetached: true,
|
|
78
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
79
|
+
label: "Print packing slip",
|
|
80
|
+
variant: "secondary",
|
|
81
|
+
children: /* @__PURE__ */ jsx(PrinterIcon, {})
|
|
82
|
+
})
|
|
83
|
+
}), /* @__PURE__ */ jsx(Tooltip, {
|
|
84
|
+
content: "Saves your changes without publishing them",
|
|
85
|
+
side: "bottom",
|
|
86
|
+
open: true,
|
|
87
|
+
hideWhenDetached: true,
|
|
88
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Save draft" })
|
|
89
|
+
})]
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function MoreActions() {
|
|
93
|
+
const [open, setOpen] = useState(false);
|
|
94
|
+
return /* @__PURE__ */ jsxs(Menu, {
|
|
95
|
+
open,
|
|
96
|
+
onOpenChange: setOpen,
|
|
97
|
+
children: [/* @__PURE__ */ jsx(Tooltip, {
|
|
98
|
+
content: "More actions",
|
|
99
|
+
disabled: open,
|
|
100
|
+
children: /* @__PURE__ */ jsx(MenuTrigger, {
|
|
101
|
+
asChild: true,
|
|
102
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
103
|
+
label: "More actions",
|
|
104
|
+
variant: "secondary",
|
|
105
|
+
children: /* @__PURE__ */ jsx(DotsThreeIcon, { weight: "bold" })
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
}), /* @__PURE__ */ jsxs(MenuContent, {
|
|
109
|
+
align: "end",
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
112
|
+
icon: /* @__PURE__ */ jsx(TruckIcon, {}),
|
|
113
|
+
children: "Mark as fulfilled"
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
116
|
+
icon: /* @__PURE__ */ jsx(CopyIcon, {}),
|
|
117
|
+
children: "Duplicate order"
|
|
118
|
+
}),
|
|
119
|
+
/* @__PURE__ */ jsx(MenuSeparator, {}),
|
|
120
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
121
|
+
icon: /* @__PURE__ */ jsx(TrashIcon, {}),
|
|
122
|
+
tone: "critical",
|
|
123
|
+
children: "Delete order"
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
})]
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function ProviderToolbar() {
|
|
130
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
131
|
+
className: "tooltip-toolbar",
|
|
132
|
+
children: [
|
|
133
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
134
|
+
content: "Save",
|
|
135
|
+
shortcut: ["mod", "S"],
|
|
136
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
137
|
+
label: "Save",
|
|
138
|
+
children: /* @__PURE__ */ jsx(FloppyDiskIcon, {})
|
|
139
|
+
})
|
|
140
|
+
}),
|
|
141
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
142
|
+
content: "Duplicate",
|
|
143
|
+
shortcut: [
|
|
144
|
+
"mod",
|
|
145
|
+
"shift",
|
|
146
|
+
"D"
|
|
147
|
+
],
|
|
148
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
149
|
+
label: "Duplicate",
|
|
150
|
+
children: /* @__PURE__ */ jsx(CopyIcon, {})
|
|
151
|
+
})
|
|
152
|
+
}),
|
|
153
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
154
|
+
content: "Print packing slip",
|
|
155
|
+
shortcut: ["mod", "P"],
|
|
156
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
157
|
+
label: "Print packing slip",
|
|
158
|
+
children: /* @__PURE__ */ jsx(PrinterIcon, {})
|
|
159
|
+
})
|
|
160
|
+
}),
|
|
161
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
162
|
+
content: "Archive order",
|
|
163
|
+
shortcut: ["E"],
|
|
164
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
165
|
+
label: "Archive order",
|
|
166
|
+
children: /* @__PURE__ */ jsx(ArchiveIcon, {})
|
|
167
|
+
})
|
|
168
|
+
})
|
|
169
|
+
]
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function Page() {
|
|
173
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
174
|
+
title: "Tooltip",
|
|
175
|
+
status: "stable",
|
|
176
|
+
importNames: ["Tooltip", "TooltipProvider"],
|
|
177
|
+
lead: "A short label on an inverse pill that names a control, usually an icon button, and can show its keyboard shortcut. It grows out of its trigger on hover or keyboard focus, and never holds anything you need to read to get on.",
|
|
178
|
+
children: [
|
|
179
|
+
/* @__PURE__ */ jsx(Section, {
|
|
180
|
+
id: "basics",
|
|
181
|
+
title: "Basics",
|
|
182
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
183
|
+
"Wrap the control in a ",
|
|
184
|
+
/* @__PURE__ */ jsx("code", { children: "Tooltip" }),
|
|
185
|
+
" and give it ",
|
|
186
|
+
/* @__PURE__ */ jsx("code", { children: "content" }),
|
|
187
|
+
". The pill grows out of its trigger in 140ms, drifting 3px away from it, with no arrow: the growth shows where it came from. Hover or tab along the toolbar."
|
|
188
|
+
] }),
|
|
189
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
190
|
+
minHeight: 200,
|
|
191
|
+
code: `
|
|
192
|
+
<Tooltip content="Print packing slip" shortcut={['mod', 'P']}>
|
|
193
|
+
<IconButton label="Print packing slip"><PrinterIcon /></IconButton>
|
|
194
|
+
</Tooltip>
|
|
195
|
+
<Tooltip content="Email customer">
|
|
196
|
+
<IconButton label="Email customer"><EnvelopeSimpleIcon /></IconButton>
|
|
197
|
+
</Tooltip>
|
|
198
|
+
<Tooltip content="Copy order link" shortcut={['mod', 'shift', 'C']}>
|
|
199
|
+
<IconButton label="Copy order link"><LinkSimpleIcon /></IconButton>
|
|
200
|
+
</Tooltip>
|
|
201
|
+
<Tooltip content="Archive order" shortcut={['E']}>
|
|
202
|
+
<IconButton label="Archive order"><ArchiveIcon /></IconButton>
|
|
203
|
+
</Tooltip>`,
|
|
204
|
+
children: /* @__PURE__ */ jsx(OrderToolbar, {})
|
|
205
|
+
})
|
|
206
|
+
}),
|
|
207
|
+
/* @__PURE__ */ jsx(Section, {
|
|
208
|
+
id: "both-themes",
|
|
209
|
+
title: "In both themes",
|
|
210
|
+
description: /* @__PURE__ */ jsx("p", { children: "Held open for review: real tooltips, one with keycaps and one long enough to wrap. It is an inverse pill: graphite with frost text in light, and pale with ink text in dark, so it stands off either page. One line is an exact pill; wrapped text becomes a softly rounded rectangle." }),
|
|
211
|
+
children: /* @__PURE__ */ jsx(ThemePair, {
|
|
212
|
+
minHeight: 240,
|
|
213
|
+
children: /* @__PURE__ */ jsx(HeldOpen, {})
|
|
214
|
+
})
|
|
215
|
+
}),
|
|
216
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
217
|
+
id: "sides",
|
|
218
|
+
title: "Sides",
|
|
219
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
220
|
+
/* @__PURE__ */ jsx("code", { children: "side" }),
|
|
221
|
+
" picks where it prefers to open: ",
|
|
222
|
+
/* @__PURE__ */ jsx("code", { children: "top" }),
|
|
223
|
+
" (the default), ",
|
|
224
|
+
/* @__PURE__ */ jsx("code", { children: "right" }),
|
|
225
|
+
",",
|
|
226
|
+
" ",
|
|
227
|
+
/* @__PURE__ */ jsx("code", { children: "bottom" }),
|
|
228
|
+
" or ",
|
|
229
|
+
/* @__PURE__ */ jsx("code", { children: "left" }),
|
|
230
|
+
". It flips to the other side when there is no room and keeps 8px inside the window. Use ",
|
|
231
|
+
/* @__PURE__ */ jsx("code", { children: "right" }),
|
|
232
|
+
" beside a folded sidebar and ",
|
|
233
|
+
/* @__PURE__ */ jsx("code", { children: "bottom" }),
|
|
234
|
+
" under a header."
|
|
235
|
+
] }),
|
|
236
|
+
children: [/* @__PURE__ */ jsxs(Example, {
|
|
237
|
+
minHeight: 200,
|
|
238
|
+
code: `
|
|
239
|
+
<Tooltip content="Opens above"><Button>Top</Button></Tooltip>
|
|
240
|
+
<Tooltip content="Opens to the right" side="right"><Button>Right</Button></Tooltip>
|
|
241
|
+
<Tooltip content="Opens below" side="bottom"><Button>Bottom</Button></Tooltip>
|
|
242
|
+
<Tooltip content="Opens to the left" side="left"><Button>Left</Button></Tooltip>`,
|
|
243
|
+
children: [
|
|
244
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
245
|
+
content: "Opens above",
|
|
246
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Top" })
|
|
247
|
+
}),
|
|
248
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
249
|
+
content: "Opens to the right",
|
|
250
|
+
side: "right",
|
|
251
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Right" })
|
|
252
|
+
}),
|
|
253
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
254
|
+
content: "Opens below",
|
|
255
|
+
side: "bottom",
|
|
256
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Bottom" })
|
|
257
|
+
}),
|
|
258
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
259
|
+
content: "Opens to the left",
|
|
260
|
+
side: "left",
|
|
261
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Left" })
|
|
262
|
+
})
|
|
263
|
+
]
|
|
264
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
265
|
+
title: "Alignment",
|
|
266
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
267
|
+
/* @__PURE__ */ jsx("code", { children: "align" }),
|
|
268
|
+
" lines the pill up with the ",
|
|
269
|
+
/* @__PURE__ */ jsx("code", { children: "start" }),
|
|
270
|
+
", ",
|
|
271
|
+
/* @__PURE__ */ jsx("code", { children: "center" }),
|
|
272
|
+
" (the default) or",
|
|
273
|
+
" ",
|
|
274
|
+
/* @__PURE__ */ jsx("code", { children: "end" }),
|
|
275
|
+
" of its trigger. It matters on wide triggers."
|
|
276
|
+
] }),
|
|
277
|
+
children: /* @__PURE__ */ jsxs(Example, {
|
|
278
|
+
minHeight: 180,
|
|
279
|
+
code: `
|
|
280
|
+
<Tooltip content="Lined up with the start" align="start"><Button>Start</Button></Tooltip>
|
|
281
|
+
<Tooltip content="Centred on the trigger"><Button>Centre</Button></Tooltip>
|
|
282
|
+
<Tooltip content="Lined up with the end" align="end"><Button>End</Button></Tooltip>`,
|
|
283
|
+
children: [
|
|
284
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
285
|
+
content: "Lined up with the start",
|
|
286
|
+
align: "start",
|
|
287
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
288
|
+
className: "tooltip-wide",
|
|
289
|
+
children: "Start"
|
|
290
|
+
})
|
|
291
|
+
}),
|
|
292
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
293
|
+
content: "Centred on the trigger",
|
|
294
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
295
|
+
className: "tooltip-wide",
|
|
296
|
+
children: "Centre"
|
|
297
|
+
})
|
|
298
|
+
}),
|
|
299
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
300
|
+
content: "Lined up with the end",
|
|
301
|
+
align: "end",
|
|
302
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
303
|
+
className: "tooltip-wide",
|
|
304
|
+
children: "End"
|
|
305
|
+
})
|
|
306
|
+
})
|
|
307
|
+
]
|
|
308
|
+
})
|
|
309
|
+
})]
|
|
310
|
+
}),
|
|
311
|
+
/* @__PURE__ */ jsx(Section, {
|
|
312
|
+
id: "shortcuts",
|
|
313
|
+
title: "Shortcuts",
|
|
314
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
315
|
+
/* @__PURE__ */ jsx("code", { children: "shortcut" }),
|
|
316
|
+
" adds keycaps after the text, restyled for the inverse pill. Keys take friendly names that read right on every platform: ",
|
|
317
|
+
/* @__PURE__ */ jsx("code", { children: "mod" }),
|
|
318
|
+
" is ⌘ on a Mac and Ctrl elsewhere, and ",
|
|
319
|
+
/* @__PURE__ */ jsx("code", { children: "shift" }),
|
|
320
|
+
",",
|
|
321
|
+
" ",
|
|
322
|
+
/* @__PURE__ */ jsx("code", { children: "alt" }),
|
|
323
|
+
", ",
|
|
324
|
+
/* @__PURE__ */ jsx("code", { children: "enter" }),
|
|
325
|
+
", ",
|
|
326
|
+
/* @__PURE__ */ jsx("code", { children: "esc" }),
|
|
327
|
+
" and the arrows become their symbols on a Mac. Single letters are capitalised. The caps are only drawn: bind the keys in the app."
|
|
328
|
+
] }),
|
|
329
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
330
|
+
minHeight: 200,
|
|
331
|
+
code: `
|
|
332
|
+
<Tooltip content="Save" shortcut={['mod', 'S']}>…</Tooltip>
|
|
333
|
+
<Tooltip content="Search" shortcut={['mod', 'K']}>…</Tooltip>
|
|
334
|
+
<Tooltip content="Duplicate" shortcut={['mod', 'shift', 'D']}>…</Tooltip>
|
|
335
|
+
<Tooltip content="Collapse sidebar" shortcut={['[']}>…</Tooltip>
|
|
336
|
+
<Tooltip content="Keyboard shortcuts" shortcut={['?']}>…</Tooltip>`,
|
|
337
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
338
|
+
className: "tooltip-toolbar",
|
|
339
|
+
children: [
|
|
340
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
341
|
+
content: "Save",
|
|
342
|
+
shortcut: ["mod", "S"],
|
|
343
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
344
|
+
label: "Save",
|
|
345
|
+
children: /* @__PURE__ */ jsx(FloppyDiskIcon, {})
|
|
346
|
+
})
|
|
347
|
+
}),
|
|
348
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
349
|
+
content: "Search",
|
|
350
|
+
shortcut: ["mod", "K"],
|
|
351
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
352
|
+
label: "Search",
|
|
353
|
+
children: /* @__PURE__ */ jsx(MagnifyingGlassIcon, {})
|
|
354
|
+
})
|
|
355
|
+
}),
|
|
356
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
357
|
+
content: "Duplicate",
|
|
358
|
+
shortcut: [
|
|
359
|
+
"mod",
|
|
360
|
+
"shift",
|
|
361
|
+
"D"
|
|
362
|
+
],
|
|
363
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
364
|
+
label: "Duplicate",
|
|
365
|
+
children: /* @__PURE__ */ jsx(CopyIcon, {})
|
|
366
|
+
})
|
|
367
|
+
}),
|
|
368
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
369
|
+
content: "Collapse sidebar",
|
|
370
|
+
shortcut: ["["],
|
|
371
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
372
|
+
label: "Collapse sidebar",
|
|
373
|
+
children: /* @__PURE__ */ jsx(SidebarSimpleIcon, {})
|
|
374
|
+
})
|
|
375
|
+
}),
|
|
376
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
377
|
+
content: "Keyboard shortcuts",
|
|
378
|
+
shortcut: ["?"],
|
|
379
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
380
|
+
label: "Keyboard shortcuts",
|
|
381
|
+
children: /* @__PURE__ */ jsx(KeyboardIcon, {})
|
|
382
|
+
})
|
|
383
|
+
})
|
|
384
|
+
]
|
|
385
|
+
})
|
|
386
|
+
})
|
|
387
|
+
}),
|
|
388
|
+
/* @__PURE__ */ jsx(Section, {
|
|
389
|
+
id: "long-text",
|
|
390
|
+
title: "Long text",
|
|
391
|
+
description: /* @__PURE__ */ jsx("p", { children: "A tooltip stops at 260px and wraps, balancing its lines. Keep it to a short phrase; a sentence is the most it should ever hold." }),
|
|
392
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
393
|
+
minHeight: 200,
|
|
394
|
+
code: `
|
|
395
|
+
<Tooltip content="Includes stock in transit between your warehouses">
|
|
396
|
+
<IconButton label="About stock counts"><InfoIcon /></IconButton>
|
|
397
|
+
</Tooltip>`,
|
|
398
|
+
children: /* @__PURE__ */ jsx(Tooltip, {
|
|
399
|
+
content: "Includes stock in transit between your warehouses",
|
|
400
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
401
|
+
label: "About stock counts",
|
|
402
|
+
variant: "secondary",
|
|
403
|
+
children: /* @__PURE__ */ jsx(InfoIcon, {})
|
|
404
|
+
})
|
|
405
|
+
})
|
|
406
|
+
})
|
|
407
|
+
}),
|
|
408
|
+
/* @__PURE__ */ jsx(Section, {
|
|
409
|
+
id: "delay",
|
|
410
|
+
title: "Delay",
|
|
411
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
412
|
+
"A tooltip waits 350ms under a resting pointer before it opens, so sweeping across the page does not set off a trail of them. ",
|
|
413
|
+
/* @__PURE__ */ jsx("code", { children: "delayDuration" }),
|
|
414
|
+
" changes the wait for one tooltip; 0 opens it at once. Keyboard focus never waits."
|
|
415
|
+
] }),
|
|
416
|
+
children: /* @__PURE__ */ jsxs(Example, {
|
|
417
|
+
minHeight: 180,
|
|
418
|
+
code: `
|
|
419
|
+
<Tooltip content="Opens at once" delayDuration={0}><Button>No delay</Button></Tooltip>
|
|
420
|
+
<Tooltip content="Opens after 350ms"><Button>Default</Button></Tooltip>
|
|
421
|
+
<Tooltip content="Opens after 700ms" delayDuration={700}><Button>Slow</Button></Tooltip>`,
|
|
422
|
+
children: [
|
|
423
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
424
|
+
content: "Opens at once",
|
|
425
|
+
delayDuration: 0,
|
|
426
|
+
children: /* @__PURE__ */ jsx(Button, { children: "No delay" })
|
|
427
|
+
}),
|
|
428
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
429
|
+
content: "Opens after 350ms",
|
|
430
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Default" })
|
|
431
|
+
}),
|
|
432
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
433
|
+
content: "Opens after 700ms",
|
|
434
|
+
delayDuration: 700,
|
|
435
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Slow" })
|
|
436
|
+
})
|
|
437
|
+
]
|
|
438
|
+
})
|
|
439
|
+
}),
|
|
440
|
+
/* @__PURE__ */ jsx(Section, {
|
|
441
|
+
id: "provider",
|
|
442
|
+
title: "Provider",
|
|
443
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
444
|
+
/* @__PURE__ */ jsx("code", { children: "TooltipProvider" }),
|
|
445
|
+
" shares timing between the tooltips inside it. Once one has opened, moving to a neighbour within 150ms (",
|
|
446
|
+
/* @__PURE__ */ jsx("code", { children: "skipDelayDuration" }),
|
|
447
|
+
") opens it straight away with a quick fade instead of the grow, which is what makes a toolbar feel quick. Wrap the app once; these docs do. A tooltip outside any provider brings its own with the same defaults."
|
|
448
|
+
] }),
|
|
449
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
450
|
+
code: `
|
|
451
|
+
// Once, near the root of the app
|
|
452
|
+
<TooltipProvider>
|
|
453
|
+
<App />
|
|
454
|
+
</TooltipProvider>
|
|
455
|
+
|
|
456
|
+
// A toolbar where every tooltip waits the full delay
|
|
457
|
+
<TooltipProvider skipDelayDuration={0}>
|
|
458
|
+
<Toolbar />
|
|
459
|
+
</TooltipProvider>`,
|
|
460
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
461
|
+
className: "tooltip-rows",
|
|
462
|
+
children: [
|
|
463
|
+
/* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx(ProviderToolbar, {}) }),
|
|
464
|
+
/* @__PURE__ */ jsx("p", {
|
|
465
|
+
className: "tooltip-pair-label",
|
|
466
|
+
children: "Shared timing: sweep along, and each next tooltip opens at once"
|
|
467
|
+
}),
|
|
468
|
+
/* @__PURE__ */ jsx(TooltipProvider, {
|
|
469
|
+
skipDelayDuration: 0,
|
|
470
|
+
children: /* @__PURE__ */ jsx(ProviderToolbar, {})
|
|
471
|
+
}),
|
|
472
|
+
/* @__PURE__ */ jsx("p", {
|
|
473
|
+
className: "tooltip-pair-label",
|
|
474
|
+
children: "skipDelayDuration={0}: each one waits its full delay"
|
|
475
|
+
})
|
|
476
|
+
]
|
|
477
|
+
})
|
|
478
|
+
})
|
|
479
|
+
}),
|
|
480
|
+
/* @__PURE__ */ jsx(Section, {
|
|
481
|
+
id: "disabled",
|
|
482
|
+
title: "Disabled",
|
|
483
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
484
|
+
/* @__PURE__ */ jsx("code", { children: "disabled" }),
|
|
485
|
+
" keeps a tooltip closed without unmounting anything, so the trigger keeps focus. Use it while a menu from the same trigger is open, so the label does not sit on top of the menu. A tooltip with empty ",
|
|
486
|
+
/* @__PURE__ */ jsx("code", { children: "content" }),
|
|
487
|
+
" never opens either, which suits a label that only sometimes applies."
|
|
488
|
+
] }),
|
|
489
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
490
|
+
minHeight: 260,
|
|
491
|
+
code: `
|
|
492
|
+
const [open, setOpen] = useState(false)
|
|
493
|
+
|
|
494
|
+
<Menu open={open} onOpenChange={setOpen}>
|
|
495
|
+
<Tooltip content="More actions" disabled={open}>
|
|
496
|
+
<MenuTrigger asChild>
|
|
497
|
+
<IconButton label="More actions" variant="secondary">
|
|
498
|
+
<DotsThreeIcon weight="bold" />
|
|
499
|
+
</IconButton>
|
|
500
|
+
</MenuTrigger>
|
|
501
|
+
</Tooltip>
|
|
502
|
+
<MenuContent align="end">…</MenuContent>
|
|
503
|
+
</Menu>`,
|
|
504
|
+
children: /* @__PURE__ */ jsx(MoreActions, {})
|
|
505
|
+
})
|
|
506
|
+
}),
|
|
507
|
+
/* @__PURE__ */ jsx(Section, {
|
|
508
|
+
id: "keyboard-and-touch",
|
|
509
|
+
title: "Keyboard and touch",
|
|
510
|
+
description: /* @__PURE__ */ jsx("p", { children: "How a tooltip opens and closes beyond the mouse." }),
|
|
511
|
+
children: /* @__PURE__ */ jsx(DocTable, {
|
|
512
|
+
columns: ["", "What happens"],
|
|
513
|
+
rows: [
|
|
514
|
+
["Keyboard focus", "Opens at once, with no delay. Moving focus away closes it."],
|
|
515
|
+
["Tabbing to a trigger off screen", "The trigger scrolls into view and its tooltip stays open. (The underlying Radix tooltip closes when its trigger scrolls; this one stays open when keyboard focus has only just opened it.)"],
|
|
516
|
+
["Escape", "Closes it and leaves focus on the trigger."],
|
|
517
|
+
["Pressing the trigger", "Closes it, and a click does not reopen it until the pointer leaves and comes back."],
|
|
518
|
+
["Moving onto the tooltip", "It stays open, so it can be read at a large zoom. disableHoverableContent on the provider turns this off."],
|
|
519
|
+
["Touch", "Never opens: there is no hover, and a tap runs the control. Anything only in a tooltip is lost on a phone."]
|
|
520
|
+
]
|
|
521
|
+
})
|
|
522
|
+
}),
|
|
523
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
524
|
+
id: "guidelines",
|
|
525
|
+
title: "When not to use one",
|
|
526
|
+
children: [/* @__PURE__ */ jsx(DoDont, {
|
|
527
|
+
do: {
|
|
528
|
+
children: /* @__PURE__ */ jsxs(SpecimenFrame, {
|
|
529
|
+
className: "tooltip-still",
|
|
530
|
+
children: [/* @__PURE__ */ jsx(TooltipPill, {
|
|
531
|
+
shortcut: ["mod", "P"],
|
|
532
|
+
children: "Print packing slip"
|
|
533
|
+
}), /* @__PURE__ */ jsx(IconButton, {
|
|
534
|
+
label: "Print packing slip",
|
|
535
|
+
variant: "secondary",
|
|
536
|
+
children: /* @__PURE__ */ jsx(PrinterIcon, {})
|
|
537
|
+
})]
|
|
538
|
+
}),
|
|
539
|
+
caption: "Name an icon-only control, and show its shortcut. The label says what pressing it does."
|
|
540
|
+
},
|
|
541
|
+
dont: {
|
|
542
|
+
children: /* @__PURE__ */ jsxs(SpecimenFrame, {
|
|
543
|
+
className: "tooltip-still",
|
|
544
|
+
children: [/* @__PURE__ */ jsx(TooltipPill, { children: "Add a payment method before you can publish" }), /* @__PURE__ */ jsx(Button, {
|
|
545
|
+
variant: "primary",
|
|
546
|
+
disabled: true,
|
|
547
|
+
children: "Publish"
|
|
548
|
+
})]
|
|
549
|
+
}),
|
|
550
|
+
caption: "A disabled button cannot be hovered or focused, so this never shows, and touch users never see a tooltip at all. Say it on the page."
|
|
551
|
+
}
|
|
552
|
+
}), /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
553
|
+
"Never put essential information in a tooltip: why something is off, a price, an error or a warning belongs on the page.",
|
|
554
|
+
"Nothing interactive inside. A link or a button in a tooltip cannot be reached.",
|
|
555
|
+
"A few words in sentence case, with no full stop. If it needs a second sentence, it wants to be on the page.",
|
|
556
|
+
"Do not repeat a visible label. A button that says \"Export\" needs no tooltip saying \"Export\".",
|
|
557
|
+
"Match the tooltip to the icon button's label, so what people see and what screen readers say agree."
|
|
558
|
+
] })]
|
|
559
|
+
}),
|
|
560
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
561
|
+
id: "accessibility",
|
|
562
|
+
title: "Accessibility",
|
|
563
|
+
children: [/* @__PURE__ */ jsx(Guidelines, { items: [
|
|
564
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
565
|
+
"Built on Radix Tooltip. While it is open the tooltip has ",
|
|
566
|
+
/* @__PURE__ */ jsx("code", { children: "role=\"tooltip\"" }),
|
|
567
|
+
" and the trigger points at it with ",
|
|
568
|
+
/* @__PURE__ */ jsx("code", { children: "aria-describedby" }),
|
|
569
|
+
", so its text is read as the trigger's description. The trigger's own name (an ",
|
|
570
|
+
/* @__PURE__ */ jsx("code", { children: "IconButton" }),
|
|
571
|
+
"'s ",
|
|
572
|
+
/* @__PURE__ */ jsx("code", { children: "label" }),
|
|
573
|
+
") is still what names it."
|
|
574
|
+
] }),
|
|
575
|
+
"It opens on keyboard focus as well as hover, closes on Escape, and stays open while the pointer moves onto it.",
|
|
576
|
+
"Symbol keycaps carry spoken names, so ⌘ is read as \"Command\".",
|
|
577
|
+
"The trigger must take a ref and props: the kit's buttons do. Wrap anything else in an element that can.",
|
|
578
|
+
"With reduced motion it fades in and out without growing or drifting."
|
|
579
|
+
] }), /* @__PURE__ */ jsxs(Note, {
|
|
580
|
+
title: "Known issue: tooltips on menu triggers",
|
|
581
|
+
children: [
|
|
582
|
+
"The tooltip and the menu both mark the trigger with ",
|
|
583
|
+
/* @__PURE__ */ jsx("code", { children: "data-state" }),
|
|
584
|
+
" and the tooltip's wins, so a trigger wrapped in both loses its pressed look while its menu is open. When the menu closes and focus returns to the trigger, its tooltip also opens again, even after a mouse choice."
|
|
585
|
+
]
|
|
586
|
+
})]
|
|
587
|
+
}),
|
|
588
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
589
|
+
id: "props",
|
|
590
|
+
title: "Props",
|
|
591
|
+
children: [/* @__PURE__ */ jsx(PropsTable, {
|
|
592
|
+
title: "Tooltip",
|
|
593
|
+
rows: [
|
|
594
|
+
{
|
|
595
|
+
name: "content",
|
|
596
|
+
type: "ReactNode",
|
|
597
|
+
required: true,
|
|
598
|
+
description: "What it says. Keep it short; nothing interactive. Empty content never opens."
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
name: "children",
|
|
602
|
+
type: "ReactElement",
|
|
603
|
+
required: true,
|
|
604
|
+
description: "The trigger. It must take a ref and props, as the kit's buttons do."
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
name: "side",
|
|
608
|
+
type: "'top' | 'right' | 'bottom' | 'left'",
|
|
609
|
+
default: "'top'",
|
|
610
|
+
description: "Preferred side. Flips when there is no room."
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
name: "align",
|
|
614
|
+
type: "'start' | 'center' | 'end'",
|
|
615
|
+
default: "'center'",
|
|
616
|
+
description: "Which part of the trigger it lines up with."
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
name: "shortcut",
|
|
620
|
+
type: "string[]",
|
|
621
|
+
description: "Keycaps after the text, e.g. ['mod', 'K']."
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
name: "disabled",
|
|
625
|
+
type: "boolean",
|
|
626
|
+
default: "false",
|
|
627
|
+
description: "Keeps it closed, e.g. while a menu from the same trigger is open."
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
name: "delayDuration",
|
|
631
|
+
type: "number",
|
|
632
|
+
description: "Hover wait in ms for this tooltip. Defaults to the provider's 350."
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
name: "open",
|
|
636
|
+
type: "boolean",
|
|
637
|
+
description: "Controlled open state."
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
name: "defaultOpen",
|
|
641
|
+
type: "boolean",
|
|
642
|
+
default: "false",
|
|
643
|
+
description: "Starting state when uncontrolled."
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
name: "onOpenChange",
|
|
647
|
+
type: "(open: boolean) => void",
|
|
648
|
+
description: "Called when it opens or closes."
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
name: "sideOffset",
|
|
652
|
+
type: "number",
|
|
653
|
+
default: "6",
|
|
654
|
+
description: "Gap from the trigger in px."
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
name: "collisionPadding",
|
|
658
|
+
type: "number",
|
|
659
|
+
default: "8",
|
|
660
|
+
description: "Space kept from the edges of the window."
|
|
661
|
+
}
|
|
662
|
+
]
|
|
663
|
+
}), /* @__PURE__ */ jsx(PropsTable, {
|
|
664
|
+
title: "TooltipProvider",
|
|
665
|
+
rows: [
|
|
666
|
+
{
|
|
667
|
+
name: "children",
|
|
668
|
+
type: "ReactNode",
|
|
669
|
+
required: true,
|
|
670
|
+
description: "The app, or a toolbar."
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
name: "delayDuration",
|
|
674
|
+
type: "number",
|
|
675
|
+
default: "350",
|
|
676
|
+
description: "Hover wait in ms before the first tooltip opens."
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
name: "skipDelayDuration",
|
|
680
|
+
type: "number",
|
|
681
|
+
default: "150",
|
|
682
|
+
description: "Window in ms in which moving to another trigger opens its tooltip at once."
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
name: "disableHoverableContent",
|
|
686
|
+
type: "boolean",
|
|
687
|
+
default: "false",
|
|
688
|
+
description: "Close as soon as the pointer leaves the trigger, even towards the tooltip."
|
|
689
|
+
}
|
|
690
|
+
]
|
|
691
|
+
})]
|
|
692
|
+
})
|
|
693
|
+
]
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
//#endregion
|
|
697
|
+
export { Page, Preview };
|