@passui/react 0.0.0-stage → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +83 -2
  3. package/package.json +96 -5
  4. package/src/appearance/index.ts +2 -0
  5. package/src/appearance/platform.tsx +123 -0
  6. package/src/appearance/theme.tsx +535 -0
  7. package/src/components/ambient/ambient.docs.tsx +68 -0
  8. package/src/components/ambient/ambient.tsx +43 -0
  9. package/src/components/ambient/examples/ambient-images.tsx +30 -0
  10. package/src/components/ambient/examples/ambient-now-playing.tsx +55 -0
  11. package/src/components/ambient/examples/ambient-showcase.tsx +33 -0
  12. package/src/components/ambient/examples/ambient-usage.tsx +19 -0
  13. package/src/components/ambient/index.ts +1 -0
  14. package/src/components/button/button-styles.ts +60 -0
  15. package/src/components/button/button.docs.tsx +116 -0
  16. package/src/components/button/button.tsx +91 -0
  17. package/src/components/button/examples/button-disabled.tsx +19 -0
  18. package/src/components/button/examples/button-icon.tsx +39 -0
  19. package/src/components/button/examples/button-link.tsx +12 -0
  20. package/src/components/button/examples/button-pending.tsx +27 -0
  21. package/src/components/button/examples/button-showcase.tsx +115 -0
  22. package/src/components/button/examples/button-sizes.tsx +12 -0
  23. package/src/components/button/examples/button-usage.tsx +12 -0
  24. package/src/components/button/examples/button-variants.tsx +15 -0
  25. package/src/components/button/examples/button-with-icon.tsx +32 -0
  26. package/src/components/button/examples/icon-button-player.tsx +38 -0
  27. package/src/components/button/examples/icon-button-showcase.tsx +83 -0
  28. package/src/components/button/examples/icon-button-usage.tsx +11 -0
  29. package/src/components/button/examples/icon-button-variants.tsx +39 -0
  30. package/src/components/button/icon-button.docs.tsx +68 -0
  31. package/src/components/button/icon-button.tsx +73 -0
  32. package/src/components/button/pending-spinner.tsx +14 -0
  33. package/src/components/button/use-pending-indicator.ts +27 -0
  34. package/src/components/chip/chip.docs.tsx +37 -0
  35. package/src/components/chip/chip.tsx +35 -0
  36. package/src/components/chip/examples/chip-in-rows.tsx +19 -0
  37. package/src/components/chip/examples/chip-showcase.tsx +51 -0
  38. package/src/components/chip/examples/chip-tones.tsx +13 -0
  39. package/src/components/chip/examples/chip-usage.tsx +5 -0
  40. package/src/components/compact-date-picker/calendar-month.ts +131 -0
  41. package/src/components/compact-date-picker/compact-date-picker.docs.tsx +81 -0
  42. package/src/components/compact-date-picker/compact-date-picker.tsx +438 -0
  43. package/src/components/compact-date-picker/examples/compact-date-picker-showcase.tsx +35 -0
  44. package/src/components/compact-date-picker/examples/compact-date-picker-usage.tsx +22 -0
  45. package/src/components/compact-time-picker/compact-time-picker.docs.tsx +80 -0
  46. package/src/components/compact-time-picker/compact-time-picker.tsx +432 -0
  47. package/src/components/compact-time-picker/examples/compact-time-picker-showcase.tsx +31 -0
  48. package/src/components/compact-time-picker/examples/compact-time-picker-usage.tsx +21 -0
  49. package/src/components/compact-time-picker/time-value.ts +67 -0
  50. package/src/components/content-view/content-view.docs.tsx +61 -0
  51. package/src/components/content-view/content-view.tsx +197 -0
  52. package/src/components/content-view/examples/content-view-header-action.tsx +33 -0
  53. package/src/components/content-view/examples/content-view-showcase.tsx +65 -0
  54. package/src/components/content-view/examples/content-view-stats.tsx +35 -0
  55. package/src/components/content-view/examples/content-view-usage.tsx +14 -0
  56. package/src/components/content-view/index.ts +1 -0
  57. package/src/components/context-menu/conceal-menu-source.ts +33 -0
  58. package/src/components/context-menu/context-menu-host.tsx +445 -0
  59. package/src/components/context-menu/context-menu-store.ts +165 -0
  60. package/src/components/context-menu/context-menu.docs.tsx +92 -0
  61. package/src/components/context-menu/examples/context-menu-checked.tsx +37 -0
  62. package/src/components/context-menu/examples/context-menu-list.tsx +85 -0
  63. package/src/components/context-menu/examples/context-menu-showcase.tsx +56 -0
  64. package/src/components/context-menu/examples/context-menu-toolbar.tsx +63 -0
  65. package/src/components/context-menu/examples/context-menu-usage.tsx +24 -0
  66. package/src/components/context-menu/menu-position.ts +55 -0
  67. package/src/components/context-menu/menu-reveal.ts +75 -0
  68. package/src/components/context-menu/use-context-menu.ts +90 -0
  69. package/src/components/conversation/conversation.docs.tsx +88 -0
  70. package/src/components/conversation/conversation.tsx +279 -0
  71. package/src/components/conversation/examples/conversation-composer.tsx +36 -0
  72. package/src/components/conversation/examples/conversation-days.tsx +48 -0
  73. package/src/components/conversation/examples/conversation-showcase.tsx +71 -0
  74. package/src/components/conversation/examples/conversation-usage.tsx +28 -0
  75. package/src/components/conversation/index.ts +1 -0
  76. package/src/components/date-picker/date-picker.docs.tsx +88 -0
  77. package/src/components/date-picker/date-picker.tsx +103 -0
  78. package/src/components/date-picker/date-value.ts +37 -0
  79. package/src/components/date-picker/examples/date-picker-locales.tsx +41 -0
  80. package/src/components/date-picker/examples/date-picker-past-only.tsx +29 -0
  81. package/src/components/date-picker/examples/date-picker-showcase.tsx +49 -0
  82. package/src/components/date-picker/examples/date-picker-usage.tsx +22 -0
  83. package/src/components/dialog/dialog-host.tsx +156 -0
  84. package/src/components/dialog/dialog-store.ts +56 -0
  85. package/src/components/dialog/dialog.docs.tsx +114 -0
  86. package/src/components/dialog/dialog.tsx +200 -0
  87. package/src/components/dialog/examples/dialog-confirm.tsx +24 -0
  88. package/src/components/dialog/examples/dialog-form.tsx +46 -0
  89. package/src/components/dialog/examples/dialog-inline.tsx +48 -0
  90. package/src/components/dialog/examples/dialog-showcase.tsx +53 -0
  91. package/src/components/dialog/examples/dialog-usage.tsx +31 -0
  92. package/src/components/dialog/index.ts +1 -0
  93. package/src/components/labeled-content/examples/labeled-content-descriptions.tsx +37 -0
  94. package/src/components/labeled-content/examples/labeled-content-showcase.tsx +54 -0
  95. package/src/components/labeled-content/examples/labeled-content-usage.tsx +22 -0
  96. package/src/components/labeled-content/examples/labeled-content-values.tsx +26 -0
  97. package/src/components/labeled-content/examples/labeled-content-wide.tsx +46 -0
  98. package/src/components/labeled-content/labeled-content.docs.tsx +69 -0
  99. package/src/components/labeled-content/labeled-content.tsx +66 -0
  100. package/src/components/locale-switcher/examples/locale-switcher-native-names.tsx +30 -0
  101. package/src/components/locale-switcher/examples/locale-switcher-showcase.tsx +46 -0
  102. package/src/components/locale-switcher/examples/locale-switcher-translated-page.tsx +35 -0
  103. package/src/components/locale-switcher/examples/locale-switcher-usage.tsx +20 -0
  104. package/src/components/locale-switcher/index.ts +1 -0
  105. package/src/components/locale-switcher/locale-switcher.docs.tsx +91 -0
  106. package/src/components/locale-switcher/locale-switcher.tsx +252 -0
  107. package/src/components/picker/examples/picker-details.tsx +44 -0
  108. package/src/components/picker/examples/picker-searchable.tsx +48 -0
  109. package/src/components/picker/examples/picker-showcase.tsx +66 -0
  110. package/src/components/picker/examples/picker-usage.tsx +20 -0
  111. package/src/components/picker/picker.docs.tsx +68 -0
  112. package/src/components/picker/picker.tsx +493 -0
  113. package/src/components/popover/examples/popover-help.tsx +57 -0
  114. package/src/components/popover/examples/popover-menu.tsx +51 -0
  115. package/src/components/popover/examples/popover-showcase.tsx +61 -0
  116. package/src/components/popover/examples/popover-usage.tsx +31 -0
  117. package/src/components/popover/popover.docs.tsx +84 -0
  118. package/src/components/popover/popover.tsx +138 -0
  119. package/src/components/profile-image/examples/profile-image-fallbacks.tsx +29 -0
  120. package/src/components/profile-image/examples/profile-image-group.tsx +34 -0
  121. package/src/components/profile-image/examples/profile-image-showcase.tsx +30 -0
  122. package/src/components/profile-image/examples/profile-image-usage.tsx +14 -0
  123. package/src/components/profile-image/profile-image.docs.tsx +81 -0
  124. package/src/components/profile-image/profile-image.tsx +80 -0
  125. package/src/components/search-field/examples/search-field-filter.tsx +53 -0
  126. package/src/components/search-field/examples/search-field-showcase.tsx +56 -0
  127. package/src/components/search-field/examples/search-field-toolbar.tsx +27 -0
  128. package/src/components/search-field/examples/search-field-usage.tsx +18 -0
  129. package/src/components/search-field/search-field.docs.tsx +58 -0
  130. package/src/components/search-field/search-field.tsx +29 -0
  131. package/src/components/search-list/examples/search-list-dropdown.tsx +53 -0
  132. package/src/components/search-list/examples/search-list-groups.tsx +64 -0
  133. package/src/components/search-list/examples/search-list-showcase.tsx +67 -0
  134. package/src/components/search-list/examples/search-list-usage.tsx +27 -0
  135. package/src/components/search-list/search-list.docs.tsx +87 -0
  136. package/src/components/search-list/search-list.tsx +265 -0
  137. package/src/components/section/examples/section-actions.tsx +35 -0
  138. package/src/components/section/examples/section-groups.tsx +41 -0
  139. package/src/components/section/examples/section-showcase.tsx +63 -0
  140. package/src/components/section/examples/section-usage.tsx +19 -0
  141. package/src/components/section/section.docs.tsx +51 -0
  142. package/src/components/section/section.tsx +41 -0
  143. package/src/components/secure-field/examples/secure-field-new-password.tsx +56 -0
  144. package/src/components/secure-field/examples/secure-field-reveal.tsx +20 -0
  145. package/src/components/secure-field/examples/secure-field-showcase.tsx +62 -0
  146. package/src/components/secure-field/examples/secure-field-usage.tsx +19 -0
  147. package/src/components/secure-field/secure-field.docs.tsx +72 -0
  148. package/src/components/secure-field/secure-field.tsx +10 -0
  149. package/src/components/segmented-control/examples/segmented-control-overflow.tsx +28 -0
  150. package/src/components/segmented-control/examples/segmented-control-showcase.tsx +59 -0
  151. package/src/components/segmented-control/examples/segmented-control-usage.tsx +20 -0
  152. package/src/components/segmented-control/examples/segmented-control-views.tsx +32 -0
  153. package/src/components/segmented-control/segmented-control.docs.tsx +61 -0
  154. package/src/components/segmented-control/segmented-control.tsx +122 -0
  155. package/src/components/sheet/examples/sheet-choices.tsx +58 -0
  156. package/src/components/sheet/examples/sheet-share.tsx +51 -0
  157. package/src/components/sheet/examples/sheet-showcase.tsx +74 -0
  158. package/src/components/sheet/examples/sheet-usage.tsx +32 -0
  159. package/src/components/sheet/modal-environment.ts +113 -0
  160. package/src/components/sheet/sheet-portal.tsx +89 -0
  161. package/src/components/sheet/sheet.docs.tsx +75 -0
  162. package/src/components/sheet/sheet.tsx +112 -0
  163. package/src/components/sheet/use-sheet-focus.ts +130 -0
  164. package/src/components/sidebar/examples/sidebar-groups.tsx +133 -0
  165. package/src/components/sidebar/examples/sidebar-showcase.tsx +123 -0
  166. package/src/components/sidebar/examples/sidebar-unread.tsx +66 -0
  167. package/src/components/sidebar/examples/sidebar-usage.tsx +52 -0
  168. package/src/components/sidebar/sidebar.docs.tsx +135 -0
  169. package/src/components/sidebar/sidebar.tsx +69 -0
  170. package/src/components/stat-tile/examples/stat-tile-filters.tsx +32 -0
  171. package/src/components/stat-tile/examples/stat-tile-grid.tsx +21 -0
  172. package/src/components/stat-tile/examples/stat-tile-showcase.tsx +52 -0
  173. package/src/components/stat-tile/examples/stat-tile-usage.tsx +13 -0
  174. package/src/components/stat-tile/index.ts +1 -0
  175. package/src/components/stat-tile/stat-tile.docs.tsx +60 -0
  176. package/src/components/stat-tile/stat-tile.tsx +68 -0
  177. package/src/components/status-indicator/examples/status-indicator-live.tsx +34 -0
  178. package/src/components/status-indicator/examples/status-indicator-showcase.tsx +39 -0
  179. package/src/components/status-indicator/examples/status-indicator-states.tsx +17 -0
  180. package/src/components/status-indicator/examples/status-indicator-usage.tsx +9 -0
  181. package/src/components/status-indicator/status-indicator.docs.tsx +43 -0
  182. package/src/components/status-indicator/status-indicator.tsx +35 -0
  183. package/src/components/swatch-picker/examples/swatch-picker-accents.tsx +42 -0
  184. package/src/components/swatch-picker/examples/swatch-picker-labels.tsx +45 -0
  185. package/src/components/swatch-picker/examples/swatch-picker-showcase.tsx +70 -0
  186. package/src/components/swatch-picker/examples/swatch-picker-usage.tsx +39 -0
  187. package/src/components/swatch-picker/swatch-picker.docs.tsx +60 -0
  188. package/src/components/swatch-picker/swatch-picker.tsx +96 -0
  189. package/src/components/tab-bar/examples/tab-bar-five-tabs.tsx +66 -0
  190. package/src/components/tab-bar/examples/tab-bar-minimize.tsx +71 -0
  191. package/src/components/tab-bar/examples/tab-bar-showcase.tsx +82 -0
  192. package/src/components/tab-bar/examples/tab-bar-usage.tsx +54 -0
  193. package/src/components/tab-bar/tab-bar.docs.tsx +136 -0
  194. package/src/components/tab-bar/tab-bar.tsx +148 -0
  195. package/src/components/tab-view/examples/tab-view-keyboard.tsx +39 -0
  196. package/src/components/tab-view/examples/tab-view-settings.tsx +56 -0
  197. package/src/components/tab-view/examples/tab-view-showcase.tsx +53 -0
  198. package/src/components/tab-view/examples/tab-view-usage.tsx +23 -0
  199. package/src/components/tab-view/tab-view.docs.tsx +77 -0
  200. package/src/components/tab-view/tab-view.tsx +130 -0
  201. package/src/components/table/examples/table-empty.tsx +53 -0
  202. package/src/components/table/examples/table-invoices.tsx +102 -0
  203. package/src/components/table/examples/table-selection.tsx +150 -0
  204. package/src/components/table/examples/table-showcase.tsx +115 -0
  205. package/src/components/table/examples/table-usage.tsx +67 -0
  206. package/src/components/table/examples/table-wide.tsx +75 -0
  207. package/src/components/table/table.docs.tsx +131 -0
  208. package/src/components/table/table.tsx +149 -0
  209. package/src/components/text-editor/examples/text-editor-comment.tsx +48 -0
  210. package/src/components/text-editor/examples/text-editor-count.tsx +38 -0
  211. package/src/components/text-editor/examples/text-editor-showcase.tsx +58 -0
  212. package/src/components/text-editor/examples/text-editor-usage.tsx +25 -0
  213. package/src/components/text-editor/text-editor.docs.tsx +61 -0
  214. package/src/components/text-editor/text-editor.tsx +19 -0
  215. package/src/components/text-field/examples/text-field-icons.tsx +72 -0
  216. package/src/components/text-field/examples/text-field-showcase.tsx +50 -0
  217. package/src/components/text-field/examples/text-field-usage.tsx +18 -0
  218. package/src/components/text-field/examples/text-field-validation.tsx +27 -0
  219. package/src/components/text-field/text-field.docs.tsx +118 -0
  220. package/src/components/text-field/text-field.tsx +135 -0
  221. package/src/components/toast/examples/toast-action.tsx +32 -0
  222. package/src/components/toast/examples/toast-promise.tsx +45 -0
  223. package/src/components/toast/examples/toast-showcase.tsx +49 -0
  224. package/src/components/toast/examples/toast-usage.tsx +13 -0
  225. package/src/components/toast/toast-store.ts +166 -0
  226. package/src/components/toast/toast.docs.tsx +79 -0
  227. package/src/components/toast/toaster.tsx +374 -0
  228. package/src/components/toggle/examples/toggle-checkboxes.tsx +43 -0
  229. package/src/components/toggle/examples/toggle-settings.tsx +31 -0
  230. package/src/components/toggle/examples/toggle-showcase.tsx +59 -0
  231. package/src/components/toggle/examples/toggle-usage.tsx +13 -0
  232. package/src/components/toggle/toggle.docs.tsx +69 -0
  233. package/src/components/toggle/toggle.tsx +85 -0
  234. package/src/components/tooltip/examples/tooltip-icon-buttons.tsx +27 -0
  235. package/src/components/tooltip/examples/tooltip-shortcuts.tsx +38 -0
  236. package/src/components/tooltip/examples/tooltip-showcase.tsx +44 -0
  237. package/src/components/tooltip/examples/tooltip-usage.tsx +13 -0
  238. package/src/components/tooltip/tooltip-host.tsx +156 -0
  239. package/src/components/tooltip/tooltip.docs.tsx +56 -0
  240. package/src/components/view-controller/examples/view-controller-action.tsx +27 -0
  241. package/src/components/view-controller/examples/view-controller-settings.tsx +31 -0
  242. package/src/components/view-controller/examples/view-controller-showcase.tsx +45 -0
  243. package/src/components/view-controller/examples/view-controller-usage.tsx +19 -0
  244. package/src/components/view-controller/index.ts +1 -0
  245. package/src/components/view-controller/view-controller.docs.tsx +71 -0
  246. package/src/components/view-controller/view-controller.tsx +81 -0
  247. package/src/docs/index.ts +3 -0
  248. package/src/docs/registry.ts +113 -0
  249. package/src/docs/snippet.ts +17 -0
  250. package/src/docs/types.ts +180 -0
  251. package/src/hooks/scroll/minimize-decision.ts +13 -0
  252. package/src/hooks/use-anchored-placement.ts +43 -0
  253. package/src/hooks/use-dismiss.ts +58 -0
  254. package/src/hooks/use-media-query.ts +106 -0
  255. package/src/hooks/use-minimize-on-scroll.ts +92 -0
  256. package/src/hooks/use-visual-viewport.ts +76 -0
  257. package/src/hooks/viewport/types.ts +19 -0
  258. package/src/hooks/viewport/viewport-metrics.ts +25 -0
  259. package/src/icons/icons.tsx +298 -0
  260. package/src/index.ts +78 -0
  261. package/src/lib/anchored-placement.ts +92 -0
  262. package/src/lib/class-names.ts +21 -0
  263. package/src/lib/date.ts +96 -0
  264. package/src/lib/floating-layers.ts +28 -0
  265. package/src/lib/haptics.ts +25 -0
  266. package/src/lib/language.ts +21 -0
  267. package/src/lib/screen-edges.ts +45 -0
  268. package/src/lib/shapes.ts +70 -0
  269. package/src/motion/transitions.ts +30 -0
  270. package/src/styles/base.css +1 -0
  271. package/src/styles/styles.css +3 -0
  272. package/src/styles/theme.css +1 -0
  273. package/src/styles/typeset.css +1 -0
  274. package/src/styles/utilities.css +1 -0
  275. package/src/tokens.ts +1 -0
@@ -0,0 +1,68 @@
1
+ import type { ReactNode } from "react"
2
+ import { cn } from "../../lib/class-names"
3
+
4
+ export type StatTileTone = "critical"
5
+
6
+ type StatTileProps = {
7
+ label: string
8
+ value: number
9
+ /** A quiet line under the number, like "3 signed in now". */
10
+ caption?: ReactNode
11
+ /** Turns the number red once it's above zero. */
12
+ tone?: StatTileTone
13
+ /** Makes the tile a toggle, e.g. a filter. */
14
+ onClick?: () => void
15
+ active?: boolean
16
+ }
17
+
18
+ /** One number with its label, optionally a toggle. */
19
+ export function StatTile({
20
+ label,
21
+ value,
22
+ caption,
23
+ tone,
24
+ onClick,
25
+ active = false,
26
+ }: StatTileProps) {
27
+ const body = (
28
+ <>
29
+ <span className="text-xs text-muted-foreground">
30
+ {label}
31
+ </span>
32
+ <span
33
+ className={cn(
34
+ "text-lg font-semibold tabular-nums tracking-tight",
35
+ tone === "critical" &&
36
+ value > 0 &&
37
+ "text-destructive"
38
+ )}
39
+ >
40
+ {value.toLocaleString("en-US")}
41
+ </span>
42
+ {caption && (
43
+ <span className="text-xs text-muted-foreground">
44
+ {caption}
45
+ </span>
46
+ )}
47
+ </>
48
+ )
49
+ const className =
50
+ "flex min-w-0 flex-col gap-1 rounded-2xl border border-border/35 bg-card p-4 text-left shadow-xs"
51
+
52
+ if (!onClick)
53
+ return <div className={className}>{body}</div>
54
+ return (
55
+ <button
56
+ type="button"
57
+ aria-pressed={active}
58
+ onClick={onClick}
59
+ className={cn(
60
+ className,
61
+ "ring-1 ring-transparent transition-colors hover:bg-muted/60",
62
+ active && "bg-muted/70 ring-foreground/15"
63
+ )}
64
+ >
65
+ {body}
66
+ </button>
67
+ )
68
+ }
@@ -0,0 +1,34 @@
1
+ import { StatusIndicator } from "@passui/react"
2
+ import { TextField } from "@passui/react/text-field"
3
+ import { useRef, useState } from "react"
4
+
5
+ export function StatusIndicatorLive() {
6
+ const [title, setTitle] = useState("Trip to Kyoto")
7
+ const [saving, setSaving] = useState(false)
8
+ const timer =
9
+ useRef<ReturnType<typeof setTimeout>>(undefined)
10
+
11
+ return (
12
+ <div className="flex w-full max-w-sm flex-col gap-3 rounded-4xl bg-elevated p-5 shadow-sm ring-1 ring-separator/60">
13
+ <TextField
14
+ label="Note title"
15
+ value={title}
16
+ onChange={(event) => {
17
+ setTitle(event.target.value)
18
+ // a pretend save that settles a moment later
19
+ setSaving(true)
20
+ clearTimeout(timer.current)
21
+ timer.current = setTimeout(
22
+ () => setSaving(false),
23
+ 900
24
+ )
25
+ }}
26
+ />
27
+ <StatusIndicator
28
+ state={saving ? "syncing" : "saved"}
29
+ >
30
+ {saving ? "Saving" : "Saved"}
31
+ </StatusIndicator>
32
+ </div>
33
+ )
34
+ }
@@ -0,0 +1,39 @@
1
+ import { StatusIndicator } from "@passui/react"
2
+
3
+ const devices = [
4
+ {
5
+ name: "MacBook Pro",
6
+ state: "saved",
7
+ detail: "Up to date",
8
+ },
9
+ {
10
+ name: "iPhone",
11
+ state: "syncing",
12
+ detail: "Syncing 12 notes",
13
+ },
14
+ {
15
+ name: "iPad",
16
+ state: "offline",
17
+ detail: "Last seen yesterday",
18
+ },
19
+ ] as const
20
+
21
+ export function StatusIndicatorShowcase() {
22
+ return (
23
+ <ul className="m-0 flex w-full max-w-sm list-none flex-col divide-y divide-separator/60 overflow-hidden rounded-4xl bg-elevated p-0 shadow-sm ring-1 ring-separator/60">
24
+ {devices.map((device) => (
25
+ <li
26
+ key={device.name}
27
+ className="flex items-center justify-between px-5 py-4"
28
+ >
29
+ <span className="text-subheadline font-semibold text-label">
30
+ {device.name}
31
+ </span>
32
+ <StatusIndicator state={device.state}>
33
+ {device.detail}
34
+ </StatusIndicator>
35
+ </li>
36
+ ))}
37
+ </ul>
38
+ )
39
+ }
@@ -0,0 +1,17 @@
1
+ import { StatusIndicator } from "@passui/react"
2
+
3
+ export function StatusIndicatorStates() {
4
+ return (
5
+ <div className="flex flex-col gap-3 rounded-4xl bg-elevated p-5 shadow-sm ring-1 ring-separator/60">
6
+ <StatusIndicator state="saved">
7
+ All changes saved
8
+ </StatusIndicator>
9
+ <StatusIndicator state="syncing">
10
+ Syncing 3 notes
11
+ </StatusIndicator>
12
+ <StatusIndicator state="offline">
13
+ Offline. Changes save when you reconnect.
14
+ </StatusIndicator>
15
+ </div>
16
+ )
17
+ }
@@ -0,0 +1,9 @@
1
+ import { StatusIndicator } from "@passui/react"
2
+
3
+ export function StatusIndicatorUsage() {
4
+ return (
5
+ <StatusIndicator state="saved">
6
+ All changes saved
7
+ </StatusIndicator>
8
+ )
9
+ }
@@ -0,0 +1,43 @@
1
+ import { StatusIndicatorLive } from "./examples/status-indicator-live"
2
+ import { StatusIndicatorStates } from "./examples/status-indicator-states"
3
+ import { defineDocs } from "../../docs/types"
4
+ import { StatusIndicatorShowcase } from "./examples/status-indicator-showcase"
5
+ import { StatusIndicatorUsage } from "./examples/status-indicator-usage"
6
+ import { StatusIndicator } from "./status-indicator"
7
+
8
+ type DemoProps = {
9
+ state: "saved" | "syncing" | "offline"
10
+ children?: string
11
+ }
12
+
13
+ export const statusIndicatorDocs = defineDocs<DemoProps>()({
14
+ slug: "status-indicator",
15
+ name: "StatusIndicator",
16
+ importPath: "@passui/react",
17
+ controls: {
18
+ state: {
19
+ kind: "select",
20
+ options: {
21
+ saved: true,
22
+ syncing: true,
23
+ offline: true,
24
+ },
25
+ default: "saved",
26
+ },
27
+ children: {
28
+ kind: "text",
29
+ default: "All changes saved",
30
+ },
31
+ },
32
+ render: ({ children, ...values }) => (
33
+ <StatusIndicator {...values}>
34
+ {children}
35
+ </StatusIndicator>
36
+ ),
37
+ usage: StatusIndicatorUsage,
38
+ showcase: StatusIndicatorShowcase,
39
+ examples: [
40
+ { id: "states", component: StatusIndicatorStates },
41
+ { id: "live", component: StatusIndicatorLive },
42
+ ],
43
+ })
@@ -0,0 +1,35 @@
1
+ import { cn } from "../../lib/class-names"
2
+
3
+ const dots = {
4
+ saved: "bg-success",
5
+ syncing: "bg-warning animate-pulse",
6
+ offline: "bg-label-tertiary",
7
+ } as const
8
+
9
+ export function StatusIndicator({
10
+ state,
11
+ children,
12
+ className,
13
+ ...props
14
+ }: React.HTMLAttributes<HTMLSpanElement> & {
15
+ state: keyof typeof dots
16
+ children: React.ReactNode
17
+ }) {
18
+ return (
19
+ <span
20
+ className={cn(
21
+ "flex items-center gap-1.5 text-footnote text-label-tertiary",
22
+ className
23
+ )}
24
+ {...props}
25
+ >
26
+ <span
27
+ className={cn(
28
+ "size-[7px] rounded-full",
29
+ dots[state]
30
+ )}
31
+ />
32
+ {children}
33
+ </span>
34
+ )
35
+ }
@@ -0,0 +1,42 @@
1
+ import { SwatchPicker } from "@passui/react"
2
+ import { Button } from "@passui/react/button"
3
+ import { type AccentId, accents } from "@passui/react/tokens"
4
+ import { type CSSProperties, useState } from "react"
5
+
6
+ // every Passui accent, straight from the tokens
7
+ const options = Object.values(accents).map((accent) => ({
8
+ value: accent.id,
9
+ label: accent.name,
10
+ color: accent.swatch,
11
+ ink: accent.light.accentText,
12
+ }))
13
+
14
+ export function SwatchPickerAccents() {
15
+ const [accent, setAccent] = useState<AccentId>("ocean")
16
+ const colors = accents[accent].light
17
+
18
+ // An app sets data-accent on <html>; this card sets the accent's
19
+ // colors on itself, so the button below shows the choice.
20
+ const style = {
21
+ "--color-accent": colors.accent,
22
+ "--color-on-accent": colors.onAccent,
23
+ "--color-accent-text": colors.accentText,
24
+ } as CSSProperties
25
+
26
+ return (
27
+ <div
28
+ style={style}
29
+ className="flex w-full max-w-sm flex-col items-center gap-5 rounded-4xl bg-elevated p-6 shadow-sm ring-1 ring-separator/60"
30
+ >
31
+ <SwatchPicker
32
+ label="Accent color"
33
+ options={options}
34
+ value={accent}
35
+ onChange={setAccent}
36
+ />
37
+ <Button variant="accent">
38
+ {accents[accent].name}
39
+ </Button>
40
+ </div>
41
+ )
42
+ }
@@ -0,0 +1,45 @@
1
+ import { Chip, SwatchPicker } from "@passui/react"
2
+ import { useState } from "react"
3
+
4
+ const colors = [
5
+ {
6
+ value: "family",
7
+ label: "Green",
8
+ color: "#e3f3eb",
9
+ ink: "#24704f",
10
+ },
11
+ {
12
+ value: "public",
13
+ label: "Blue",
14
+ color: "#e8efff",
15
+ ink: "#2c55b8",
16
+ },
17
+ {
18
+ value: "friends",
19
+ label: "Purple",
20
+ color: "#ede8ff",
21
+ ink: "#5a3fc0",
22
+ },
23
+ ] as const
24
+
25
+ export function SwatchPickerLabels() {
26
+ const [tone, setTone] =
27
+ useState<(typeof colors)[number]["value"]>("family")
28
+
29
+ return (
30
+ <div className="flex w-full max-w-sm flex-col gap-4 rounded-4xl bg-elevated p-6 shadow-sm ring-1 ring-separator/60">
31
+ <div className="flex items-center justify-between">
32
+ <span className="text-subheadline font-medium text-label">
33
+ Tag color
34
+ </span>
35
+ <Chip tone={tone}>Weekend trip</Chip>
36
+ </div>
37
+ <SwatchPicker
38
+ label="Tag color"
39
+ options={[...colors]}
40
+ value={tone}
41
+ onChange={setTone}
42
+ />
43
+ </div>
44
+ )
45
+ }
@@ -0,0 +1,70 @@
1
+ import { Chip, SwatchPicker } from "@passui/react"
2
+ import { useState } from "react"
3
+
4
+ const colours = [
5
+ {
6
+ value: "sky",
7
+ label: "Sky",
8
+ color: "#9fc3ec",
9
+ ink: "#1f4f86",
10
+ },
11
+ {
12
+ value: "mint",
13
+ label: "Mint",
14
+ color: "#a7d8bd",
15
+ ink: "#1f6644",
16
+ },
17
+ {
18
+ value: "sun",
19
+ label: "Sun",
20
+ color: "#f3cf6b",
21
+ ink: "#7a5600",
22
+ },
23
+ {
24
+ value: "rose",
25
+ label: "Rose",
26
+ color: "#f0b3be",
27
+ ink: "#8c2f45",
28
+ },
29
+ {
30
+ value: "lilac",
31
+ label: "Lilac",
32
+ color: "#cbbcf0",
33
+ ink: "#4b348f",
34
+ },
35
+ ]
36
+
37
+ export function SwatchPickerShowcase() {
38
+ const [colour, setColour] = useState("mint")
39
+ const chosen =
40
+ colours.find((option) => option.value === colour) ??
41
+ colours[0]
42
+
43
+ return (
44
+ <section className="flex w-full max-w-sm flex-col gap-5 rounded-4xl bg-elevated p-6 shadow-sm ring-1 ring-separator/60">
45
+ <div
46
+ className="flex h-28 items-end rounded-3xl p-4 transition-colors duration-500"
47
+ style={{ backgroundColor: chosen.color }}
48
+ >
49
+ <span
50
+ className="text-title3 font-bold"
51
+ style={{ color: chosen.ink }}
52
+ >
53
+ Garden notes
54
+ </span>
55
+ </div>
56
+ <div className="flex items-center justify-between">
57
+ <span className="text-subheadline font-semibold text-label">
58
+ Notebook colour
59
+ </span>
60
+ <Chip tone="neutral">{chosen.label}</Chip>
61
+ </div>
62
+ <SwatchPicker
63
+ label="Notebook colour"
64
+ value={colour}
65
+ onChange={setColour}
66
+ options={colours}
67
+ />
68
+ </section>
69
+ )
70
+ }
@@ -0,0 +1,39 @@
1
+ import { SwatchPicker } from "@passui/react"
2
+ import { useState } from "react"
3
+
4
+ export function SwatchPickerUsage() {
5
+ const [colour, setColour] = useState("sky")
6
+ return (
7
+ <SwatchPicker
8
+ label="Label colour"
9
+ value={colour}
10
+ onChange={setColour}
11
+ options={[
12
+ {
13
+ value: "sky",
14
+ label: "Sky",
15
+ color: "#9fc3ec",
16
+ ink: "#1f4f86",
17
+ },
18
+ {
19
+ value: "mint",
20
+ label: "Mint",
21
+ color: "#a7d8bd",
22
+ ink: "#1f6644",
23
+ },
24
+ {
25
+ value: "sun",
26
+ label: "Sun",
27
+ color: "#f3cf6b",
28
+ ink: "#7a5600",
29
+ },
30
+ {
31
+ value: "rose",
32
+ label: "Rose",
33
+ color: "#f0b3be",
34
+ ink: "#8c2f45",
35
+ },
36
+ ]}
37
+ />
38
+ )
39
+ }
@@ -0,0 +1,60 @@
1
+ import { SwatchPickerLabels } from "./examples/swatch-picker-labels"
2
+ import { SwatchPickerAccents } from "./examples/swatch-picker-accents"
3
+ import { useState } from "react"
4
+ import { accents } from "@passui/tokens/accent"
5
+ import { defineDocs } from "../../docs/types"
6
+ import { SwatchPickerShowcase } from "./examples/swatch-picker-showcase"
7
+ import { SwatchPickerUsage } from "./examples/swatch-picker-usage"
8
+ import { SwatchPicker } from "./swatch-picker"
9
+
10
+ type DemoProps = { label: string }
11
+
12
+ function SwatchPickerDemo({ label }: DemoProps) {
13
+ const [accent, setAccent] = useState<string>("blush")
14
+ return (
15
+ <SwatchPicker
16
+ label={label}
17
+ value={accent}
18
+ onChange={setAccent}
19
+ options={Object.values(accents).map((option) => ({
20
+ value: option.id,
21
+ label: option.name,
22
+ color: option.swatch,
23
+ ink: option.light.accentText,
24
+ }))}
25
+ />
26
+ )
27
+ }
28
+
29
+ export const swatchPickerDocs = defineDocs<DemoProps>()({
30
+ slug: "swatch-picker",
31
+ name: "SwatchPicker",
32
+ importPath: "@passui/react",
33
+ controls: {
34
+ label: {
35
+ kind: "text",
36
+ default: "Accent colour",
37
+ required: true,
38
+ },
39
+ },
40
+ render: (values) => <SwatchPickerDemo {...values} />,
41
+ childrenSnippet: () => ({
42
+ imports: ['import { useState } from "react"'],
43
+ setup: [
44
+ 'const [colour, setColour] = useState("blush")',
45
+ ],
46
+ children: "",
47
+ expressionProps: {
48
+ value: "colour",
49
+ onChange: "setColour",
50
+ options:
51
+ '[{ value: "blush", label: "Blush", color: "#f2d4d7", ink: "#9e3b4f" }]',
52
+ },
53
+ }),
54
+ usage: SwatchPickerUsage,
55
+ showcase: SwatchPickerShowcase,
56
+ examples: [
57
+ { id: "accents", component: SwatchPickerAccents },
58
+ { id: "labels", component: SwatchPickerLabels },
59
+ ],
60
+ })
@@ -0,0 +1,96 @@
1
+ import { motion } from "motion/react"
2
+ import { useId } from "react"
3
+ import { CheckIcon } from "../../icons/icons"
4
+ import { cn } from "../../lib/class-names"
5
+ import { haptic } from "../../lib/haptics"
6
+ import { spring } from "../../motion/transitions"
7
+
8
+ /** Colour swatches with a check on the chosen one. */
9
+ export function SwatchPicker<T extends string>({
10
+ value,
11
+ options,
12
+ onChange,
13
+ label,
14
+ }: {
15
+ value: T
16
+ /** `ink` colours the check drawn on the swatch. */
17
+ options: Array<{
18
+ value: T
19
+ label: string
20
+ color: string
21
+ ink: string
22
+ }>
23
+ onChange: (value: T) => void
24
+ label: string
25
+ }) {
26
+ const name = useId()
27
+ return (
28
+ <fieldset className="flex flex-wrap gap-3">
29
+ <legend className="sr-only">{label}</legend>
30
+ {options.map((option) => {
31
+ const selected = option.value === value
32
+ return (
33
+ <label
34
+ key={option.value}
35
+ className="group flex cursor-pointer flex-col items-center gap-1.5"
36
+ >
37
+ <input
38
+ type="radio"
39
+ name={name}
40
+ value={option.value}
41
+ checked={selected}
42
+ onChange={() => {
43
+ haptic("selection")
44
+ onChange(option.value)
45
+ }}
46
+ className="peer sr-only"
47
+ />
48
+ <span
49
+ className={cn(
50
+ "flex size-8 items-center justify-center rounded-full ring-offset-1 ring-offset-elevated transition-[box-shadow,transform] duration-fast group-active:scale-95 peer-focus-visible:ring-2 peer-focus-visible:ring-accent",
51
+ selected
52
+ ? "ring-[1.5px] ring-label/70"
53
+ : "ring-0 group-hover:ring-[1.5px] group-hover:ring-separator"
54
+ )}
55
+ style={{
56
+ background: option.color,
57
+ }}
58
+ >
59
+ {selected && (
60
+ <motion.span
61
+ initial={{
62
+ scale: 0.4,
63
+ opacity: 0,
64
+ }}
65
+ animate={{
66
+ scale: 1,
67
+ opacity: 1,
68
+ }}
69
+ transition={spring.bouncy}
70
+ >
71
+ <CheckIcon
72
+ size={16}
73
+ strokeWidth={2.6}
74
+ style={{
75
+ color: option.ink,
76
+ }}
77
+ />
78
+ </motion.span>
79
+ )}
80
+ </span>
81
+ <span
82
+ className={cn(
83
+ "text-caption2",
84
+ selected
85
+ ? "font-semibold text-label"
86
+ : "text-label-tertiary"
87
+ )}
88
+ >
89
+ {option.label}
90
+ </span>
91
+ </label>
92
+ )
93
+ })}
94
+ </fieldset>
95
+ )
96
+ }
@@ -0,0 +1,66 @@
1
+ import {
2
+ Calendar03Icon,
3
+ Home01Icon,
4
+ InboxIcon,
5
+ LibraryIcon,
6
+ UserIcon,
7
+ } from "@hugeicons/core-free-icons"
8
+ import { HugeiconsIcon } from "@hugeicons/react"
9
+ import { TabBar } from "@passui/react"
10
+ import { useState } from "react"
11
+
12
+ const tabs = [
13
+ {
14
+ id: "home",
15
+ label: "Home",
16
+ icon: <HugeiconsIcon icon={Home01Icon} size={22} />,
17
+ },
18
+ {
19
+ id: "inbox",
20
+ label: "Inbox",
21
+ icon: <HugeiconsIcon icon={InboxIcon} size={22} />,
22
+ },
23
+ {
24
+ id: "calendar",
25
+ label: "Calendar",
26
+ icon: (
27
+ <HugeiconsIcon icon={Calendar03Icon} size={22} />
28
+ ),
29
+ },
30
+ {
31
+ id: "library",
32
+ label: "Library",
33
+ icon: <HugeiconsIcon icon={LibraryIcon} size={22} />,
34
+ },
35
+ {
36
+ id: "profile",
37
+ label: "Profile",
38
+ icon: <HugeiconsIcon icon={UserIcon} size={22} />,
39
+ },
40
+ ]
41
+
42
+ export function TabBarFiveTabs() {
43
+ const [active, setActive] = useState("inbox")
44
+
45
+ return (
46
+ <div className="relative h-32 w-full max-w-sm overflow-hidden rounded-5xl bg-fill/40">
47
+ <TabBar
48
+ label="Main"
49
+ tabs={tabs}
50
+ active={active}
51
+ className="absolute inset-x-3 bottom-3"
52
+ renderLink={(tab, props) => (
53
+ <a
54
+ key={tab.id}
55
+ href={`#${tab.id}`}
56
+ {...props}
57
+ onClick={(event) => {
58
+ event.preventDefault()
59
+ setActive(tab.id)
60
+ }}
61
+ />
62
+ )}
63
+ />
64
+ </div>
65
+ )
66
+ }