@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.
- package/LICENSE +21 -0
- package/README.md +83 -2
- package/package.json +96 -5
- package/src/appearance/index.ts +2 -0
- package/src/appearance/platform.tsx +123 -0
- package/src/appearance/theme.tsx +535 -0
- package/src/components/ambient/ambient.docs.tsx +68 -0
- package/src/components/ambient/ambient.tsx +43 -0
- package/src/components/ambient/examples/ambient-images.tsx +30 -0
- package/src/components/ambient/examples/ambient-now-playing.tsx +55 -0
- package/src/components/ambient/examples/ambient-showcase.tsx +33 -0
- package/src/components/ambient/examples/ambient-usage.tsx +19 -0
- package/src/components/ambient/index.ts +1 -0
- package/src/components/button/button-styles.ts +60 -0
- package/src/components/button/button.docs.tsx +116 -0
- package/src/components/button/button.tsx +91 -0
- package/src/components/button/examples/button-disabled.tsx +19 -0
- package/src/components/button/examples/button-icon.tsx +39 -0
- package/src/components/button/examples/button-link.tsx +12 -0
- package/src/components/button/examples/button-pending.tsx +27 -0
- package/src/components/button/examples/button-showcase.tsx +115 -0
- package/src/components/button/examples/button-sizes.tsx +12 -0
- package/src/components/button/examples/button-usage.tsx +12 -0
- package/src/components/button/examples/button-variants.tsx +15 -0
- package/src/components/button/examples/button-with-icon.tsx +32 -0
- package/src/components/button/examples/icon-button-player.tsx +38 -0
- package/src/components/button/examples/icon-button-showcase.tsx +83 -0
- package/src/components/button/examples/icon-button-usage.tsx +11 -0
- package/src/components/button/examples/icon-button-variants.tsx +39 -0
- package/src/components/button/icon-button.docs.tsx +68 -0
- package/src/components/button/icon-button.tsx +73 -0
- package/src/components/button/pending-spinner.tsx +14 -0
- package/src/components/button/use-pending-indicator.ts +27 -0
- package/src/components/chip/chip.docs.tsx +37 -0
- package/src/components/chip/chip.tsx +35 -0
- package/src/components/chip/examples/chip-in-rows.tsx +19 -0
- package/src/components/chip/examples/chip-showcase.tsx +51 -0
- package/src/components/chip/examples/chip-tones.tsx +13 -0
- package/src/components/chip/examples/chip-usage.tsx +5 -0
- package/src/components/compact-date-picker/calendar-month.ts +131 -0
- package/src/components/compact-date-picker/compact-date-picker.docs.tsx +81 -0
- package/src/components/compact-date-picker/compact-date-picker.tsx +438 -0
- package/src/components/compact-date-picker/examples/compact-date-picker-showcase.tsx +35 -0
- package/src/components/compact-date-picker/examples/compact-date-picker-usage.tsx +22 -0
- package/src/components/compact-time-picker/compact-time-picker.docs.tsx +80 -0
- package/src/components/compact-time-picker/compact-time-picker.tsx +432 -0
- package/src/components/compact-time-picker/examples/compact-time-picker-showcase.tsx +31 -0
- package/src/components/compact-time-picker/examples/compact-time-picker-usage.tsx +21 -0
- package/src/components/compact-time-picker/time-value.ts +67 -0
- package/src/components/content-view/content-view.docs.tsx +61 -0
- package/src/components/content-view/content-view.tsx +197 -0
- package/src/components/content-view/examples/content-view-header-action.tsx +33 -0
- package/src/components/content-view/examples/content-view-showcase.tsx +65 -0
- package/src/components/content-view/examples/content-view-stats.tsx +35 -0
- package/src/components/content-view/examples/content-view-usage.tsx +14 -0
- package/src/components/content-view/index.ts +1 -0
- package/src/components/context-menu/conceal-menu-source.ts +33 -0
- package/src/components/context-menu/context-menu-host.tsx +445 -0
- package/src/components/context-menu/context-menu-store.ts +165 -0
- package/src/components/context-menu/context-menu.docs.tsx +92 -0
- package/src/components/context-menu/examples/context-menu-checked.tsx +37 -0
- package/src/components/context-menu/examples/context-menu-list.tsx +85 -0
- package/src/components/context-menu/examples/context-menu-showcase.tsx +56 -0
- package/src/components/context-menu/examples/context-menu-toolbar.tsx +63 -0
- package/src/components/context-menu/examples/context-menu-usage.tsx +24 -0
- package/src/components/context-menu/menu-position.ts +55 -0
- package/src/components/context-menu/menu-reveal.ts +75 -0
- package/src/components/context-menu/use-context-menu.ts +90 -0
- package/src/components/conversation/conversation.docs.tsx +88 -0
- package/src/components/conversation/conversation.tsx +279 -0
- package/src/components/conversation/examples/conversation-composer.tsx +36 -0
- package/src/components/conversation/examples/conversation-days.tsx +48 -0
- package/src/components/conversation/examples/conversation-showcase.tsx +71 -0
- package/src/components/conversation/examples/conversation-usage.tsx +28 -0
- package/src/components/conversation/index.ts +1 -0
- package/src/components/date-picker/date-picker.docs.tsx +88 -0
- package/src/components/date-picker/date-picker.tsx +103 -0
- package/src/components/date-picker/date-value.ts +37 -0
- package/src/components/date-picker/examples/date-picker-locales.tsx +41 -0
- package/src/components/date-picker/examples/date-picker-past-only.tsx +29 -0
- package/src/components/date-picker/examples/date-picker-showcase.tsx +49 -0
- package/src/components/date-picker/examples/date-picker-usage.tsx +22 -0
- package/src/components/dialog/dialog-host.tsx +156 -0
- package/src/components/dialog/dialog-store.ts +56 -0
- package/src/components/dialog/dialog.docs.tsx +114 -0
- package/src/components/dialog/dialog.tsx +200 -0
- package/src/components/dialog/examples/dialog-confirm.tsx +24 -0
- package/src/components/dialog/examples/dialog-form.tsx +46 -0
- package/src/components/dialog/examples/dialog-inline.tsx +48 -0
- package/src/components/dialog/examples/dialog-showcase.tsx +53 -0
- package/src/components/dialog/examples/dialog-usage.tsx +31 -0
- package/src/components/dialog/index.ts +1 -0
- package/src/components/labeled-content/examples/labeled-content-descriptions.tsx +37 -0
- package/src/components/labeled-content/examples/labeled-content-showcase.tsx +54 -0
- package/src/components/labeled-content/examples/labeled-content-usage.tsx +22 -0
- package/src/components/labeled-content/examples/labeled-content-values.tsx +26 -0
- package/src/components/labeled-content/examples/labeled-content-wide.tsx +46 -0
- package/src/components/labeled-content/labeled-content.docs.tsx +69 -0
- package/src/components/labeled-content/labeled-content.tsx +66 -0
- package/src/components/locale-switcher/examples/locale-switcher-native-names.tsx +30 -0
- package/src/components/locale-switcher/examples/locale-switcher-showcase.tsx +46 -0
- package/src/components/locale-switcher/examples/locale-switcher-translated-page.tsx +35 -0
- package/src/components/locale-switcher/examples/locale-switcher-usage.tsx +20 -0
- package/src/components/locale-switcher/index.ts +1 -0
- package/src/components/locale-switcher/locale-switcher.docs.tsx +91 -0
- package/src/components/locale-switcher/locale-switcher.tsx +252 -0
- package/src/components/picker/examples/picker-details.tsx +44 -0
- package/src/components/picker/examples/picker-searchable.tsx +48 -0
- package/src/components/picker/examples/picker-showcase.tsx +66 -0
- package/src/components/picker/examples/picker-usage.tsx +20 -0
- package/src/components/picker/picker.docs.tsx +68 -0
- package/src/components/picker/picker.tsx +493 -0
- package/src/components/popover/examples/popover-help.tsx +57 -0
- package/src/components/popover/examples/popover-menu.tsx +51 -0
- package/src/components/popover/examples/popover-showcase.tsx +61 -0
- package/src/components/popover/examples/popover-usage.tsx +31 -0
- package/src/components/popover/popover.docs.tsx +84 -0
- package/src/components/popover/popover.tsx +138 -0
- package/src/components/profile-image/examples/profile-image-fallbacks.tsx +29 -0
- package/src/components/profile-image/examples/profile-image-group.tsx +34 -0
- package/src/components/profile-image/examples/profile-image-showcase.tsx +30 -0
- package/src/components/profile-image/examples/profile-image-usage.tsx +14 -0
- package/src/components/profile-image/profile-image.docs.tsx +81 -0
- package/src/components/profile-image/profile-image.tsx +80 -0
- package/src/components/search-field/examples/search-field-filter.tsx +53 -0
- package/src/components/search-field/examples/search-field-showcase.tsx +56 -0
- package/src/components/search-field/examples/search-field-toolbar.tsx +27 -0
- package/src/components/search-field/examples/search-field-usage.tsx +18 -0
- package/src/components/search-field/search-field.docs.tsx +58 -0
- package/src/components/search-field/search-field.tsx +29 -0
- package/src/components/search-list/examples/search-list-dropdown.tsx +53 -0
- package/src/components/search-list/examples/search-list-groups.tsx +64 -0
- package/src/components/search-list/examples/search-list-showcase.tsx +67 -0
- package/src/components/search-list/examples/search-list-usage.tsx +27 -0
- package/src/components/search-list/search-list.docs.tsx +87 -0
- package/src/components/search-list/search-list.tsx +265 -0
- package/src/components/section/examples/section-actions.tsx +35 -0
- package/src/components/section/examples/section-groups.tsx +41 -0
- package/src/components/section/examples/section-showcase.tsx +63 -0
- package/src/components/section/examples/section-usage.tsx +19 -0
- package/src/components/section/section.docs.tsx +51 -0
- package/src/components/section/section.tsx +41 -0
- package/src/components/secure-field/examples/secure-field-new-password.tsx +56 -0
- package/src/components/secure-field/examples/secure-field-reveal.tsx +20 -0
- package/src/components/secure-field/examples/secure-field-showcase.tsx +62 -0
- package/src/components/secure-field/examples/secure-field-usage.tsx +19 -0
- package/src/components/secure-field/secure-field.docs.tsx +72 -0
- package/src/components/secure-field/secure-field.tsx +10 -0
- package/src/components/segmented-control/examples/segmented-control-overflow.tsx +28 -0
- package/src/components/segmented-control/examples/segmented-control-showcase.tsx +59 -0
- package/src/components/segmented-control/examples/segmented-control-usage.tsx +20 -0
- package/src/components/segmented-control/examples/segmented-control-views.tsx +32 -0
- package/src/components/segmented-control/segmented-control.docs.tsx +61 -0
- package/src/components/segmented-control/segmented-control.tsx +122 -0
- package/src/components/sheet/examples/sheet-choices.tsx +58 -0
- package/src/components/sheet/examples/sheet-share.tsx +51 -0
- package/src/components/sheet/examples/sheet-showcase.tsx +74 -0
- package/src/components/sheet/examples/sheet-usage.tsx +32 -0
- package/src/components/sheet/modal-environment.ts +113 -0
- package/src/components/sheet/sheet-portal.tsx +89 -0
- package/src/components/sheet/sheet.docs.tsx +75 -0
- package/src/components/sheet/sheet.tsx +112 -0
- package/src/components/sheet/use-sheet-focus.ts +130 -0
- package/src/components/sidebar/examples/sidebar-groups.tsx +133 -0
- package/src/components/sidebar/examples/sidebar-showcase.tsx +123 -0
- package/src/components/sidebar/examples/sidebar-unread.tsx +66 -0
- package/src/components/sidebar/examples/sidebar-usage.tsx +52 -0
- package/src/components/sidebar/sidebar.docs.tsx +135 -0
- package/src/components/sidebar/sidebar.tsx +69 -0
- package/src/components/stat-tile/examples/stat-tile-filters.tsx +32 -0
- package/src/components/stat-tile/examples/stat-tile-grid.tsx +21 -0
- package/src/components/stat-tile/examples/stat-tile-showcase.tsx +52 -0
- package/src/components/stat-tile/examples/stat-tile-usage.tsx +13 -0
- package/src/components/stat-tile/index.ts +1 -0
- package/src/components/stat-tile/stat-tile.docs.tsx +60 -0
- package/src/components/stat-tile/stat-tile.tsx +68 -0
- package/src/components/status-indicator/examples/status-indicator-live.tsx +34 -0
- package/src/components/status-indicator/examples/status-indicator-showcase.tsx +39 -0
- package/src/components/status-indicator/examples/status-indicator-states.tsx +17 -0
- package/src/components/status-indicator/examples/status-indicator-usage.tsx +9 -0
- package/src/components/status-indicator/status-indicator.docs.tsx +43 -0
- package/src/components/status-indicator/status-indicator.tsx +35 -0
- package/src/components/swatch-picker/examples/swatch-picker-accents.tsx +42 -0
- package/src/components/swatch-picker/examples/swatch-picker-labels.tsx +45 -0
- package/src/components/swatch-picker/examples/swatch-picker-showcase.tsx +70 -0
- package/src/components/swatch-picker/examples/swatch-picker-usage.tsx +39 -0
- package/src/components/swatch-picker/swatch-picker.docs.tsx +60 -0
- package/src/components/swatch-picker/swatch-picker.tsx +96 -0
- package/src/components/tab-bar/examples/tab-bar-five-tabs.tsx +66 -0
- package/src/components/tab-bar/examples/tab-bar-minimize.tsx +71 -0
- package/src/components/tab-bar/examples/tab-bar-showcase.tsx +82 -0
- package/src/components/tab-bar/examples/tab-bar-usage.tsx +54 -0
- package/src/components/tab-bar/tab-bar.docs.tsx +136 -0
- package/src/components/tab-bar/tab-bar.tsx +148 -0
- package/src/components/tab-view/examples/tab-view-keyboard.tsx +39 -0
- package/src/components/tab-view/examples/tab-view-settings.tsx +56 -0
- package/src/components/tab-view/examples/tab-view-showcase.tsx +53 -0
- package/src/components/tab-view/examples/tab-view-usage.tsx +23 -0
- package/src/components/tab-view/tab-view.docs.tsx +77 -0
- package/src/components/tab-view/tab-view.tsx +130 -0
- package/src/components/table/examples/table-empty.tsx +53 -0
- package/src/components/table/examples/table-invoices.tsx +102 -0
- package/src/components/table/examples/table-selection.tsx +150 -0
- package/src/components/table/examples/table-showcase.tsx +115 -0
- package/src/components/table/examples/table-usage.tsx +67 -0
- package/src/components/table/examples/table-wide.tsx +75 -0
- package/src/components/table/table.docs.tsx +131 -0
- package/src/components/table/table.tsx +149 -0
- package/src/components/text-editor/examples/text-editor-comment.tsx +48 -0
- package/src/components/text-editor/examples/text-editor-count.tsx +38 -0
- package/src/components/text-editor/examples/text-editor-showcase.tsx +58 -0
- package/src/components/text-editor/examples/text-editor-usage.tsx +25 -0
- package/src/components/text-editor/text-editor.docs.tsx +61 -0
- package/src/components/text-editor/text-editor.tsx +19 -0
- package/src/components/text-field/examples/text-field-icons.tsx +72 -0
- package/src/components/text-field/examples/text-field-showcase.tsx +50 -0
- package/src/components/text-field/examples/text-field-usage.tsx +18 -0
- package/src/components/text-field/examples/text-field-validation.tsx +27 -0
- package/src/components/text-field/text-field.docs.tsx +118 -0
- package/src/components/text-field/text-field.tsx +135 -0
- package/src/components/toast/examples/toast-action.tsx +32 -0
- package/src/components/toast/examples/toast-promise.tsx +45 -0
- package/src/components/toast/examples/toast-showcase.tsx +49 -0
- package/src/components/toast/examples/toast-usage.tsx +13 -0
- package/src/components/toast/toast-store.ts +166 -0
- package/src/components/toast/toast.docs.tsx +79 -0
- package/src/components/toast/toaster.tsx +374 -0
- package/src/components/toggle/examples/toggle-checkboxes.tsx +43 -0
- package/src/components/toggle/examples/toggle-settings.tsx +31 -0
- package/src/components/toggle/examples/toggle-showcase.tsx +59 -0
- package/src/components/toggle/examples/toggle-usage.tsx +13 -0
- package/src/components/toggle/toggle.docs.tsx +69 -0
- package/src/components/toggle/toggle.tsx +85 -0
- package/src/components/tooltip/examples/tooltip-icon-buttons.tsx +27 -0
- package/src/components/tooltip/examples/tooltip-shortcuts.tsx +38 -0
- package/src/components/tooltip/examples/tooltip-showcase.tsx +44 -0
- package/src/components/tooltip/examples/tooltip-usage.tsx +13 -0
- package/src/components/tooltip/tooltip-host.tsx +156 -0
- package/src/components/tooltip/tooltip.docs.tsx +56 -0
- package/src/components/view-controller/examples/view-controller-action.tsx +27 -0
- package/src/components/view-controller/examples/view-controller-settings.tsx +31 -0
- package/src/components/view-controller/examples/view-controller-showcase.tsx +45 -0
- package/src/components/view-controller/examples/view-controller-usage.tsx +19 -0
- package/src/components/view-controller/index.ts +1 -0
- package/src/components/view-controller/view-controller.docs.tsx +71 -0
- package/src/components/view-controller/view-controller.tsx +81 -0
- package/src/docs/index.ts +3 -0
- package/src/docs/registry.ts +113 -0
- package/src/docs/snippet.ts +17 -0
- package/src/docs/types.ts +180 -0
- package/src/hooks/scroll/minimize-decision.ts +13 -0
- package/src/hooks/use-anchored-placement.ts +43 -0
- package/src/hooks/use-dismiss.ts +58 -0
- package/src/hooks/use-media-query.ts +106 -0
- package/src/hooks/use-minimize-on-scroll.ts +92 -0
- package/src/hooks/use-visual-viewport.ts +76 -0
- package/src/hooks/viewport/types.ts +19 -0
- package/src/hooks/viewport/viewport-metrics.ts +25 -0
- package/src/icons/icons.tsx +298 -0
- package/src/index.ts +78 -0
- package/src/lib/anchored-placement.ts +92 -0
- package/src/lib/class-names.ts +21 -0
- package/src/lib/date.ts +96 -0
- package/src/lib/floating-layers.ts +28 -0
- package/src/lib/haptics.ts +25 -0
- package/src/lib/language.ts +21 -0
- package/src/lib/screen-edges.ts +45 -0
- package/src/lib/shapes.ts +70 -0
- package/src/motion/transitions.ts +30 -0
- package/src/styles/base.css +1 -0
- package/src/styles/styles.css +3 -0
- package/src/styles/theme.css +1 -0
- package/src/styles/typeset.css +1 -0
- package/src/styles/utilities.css +1 -0
- package/src/tokens.ts +1 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { InformationCircleIcon } from "@hugeicons/core-free-icons"
|
|
2
|
+
import { HugeiconsIcon } from "@hugeicons/react"
|
|
3
|
+
import { IconButton } from "@passui/react/icon-button"
|
|
4
|
+
import { Popover } from "@passui/react/popover"
|
|
5
|
+
import { TextField } from "@passui/react/text-field"
|
|
6
|
+
import { useDismiss } from "@passui/react/use-dismiss"
|
|
7
|
+
import { useRef, useState } from "react"
|
|
8
|
+
|
|
9
|
+
export function PopoverHelp() {
|
|
10
|
+
const [open, setOpen] = useState(false)
|
|
11
|
+
const [uri, setUri] = useState(
|
|
12
|
+
"https://app.example.com/callback"
|
|
13
|
+
)
|
|
14
|
+
const anchor = useRef<HTMLDivElement>(null)
|
|
15
|
+
useDismiss(anchor, open, () => setOpen(false))
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className="flex h-72 w-full max-w-sm flex-col gap-2">
|
|
19
|
+
<TextField
|
|
20
|
+
label="Redirect URI"
|
|
21
|
+
value={uri}
|
|
22
|
+
onChange={(event) =>
|
|
23
|
+
setUri(event.target.value)
|
|
24
|
+
}
|
|
25
|
+
action={
|
|
26
|
+
<div ref={anchor} className="relative">
|
|
27
|
+
<IconButton
|
|
28
|
+
label="What's a redirect URI?"
|
|
29
|
+
size="icon-xs"
|
|
30
|
+
variant="ghost"
|
|
31
|
+
aria-expanded={open}
|
|
32
|
+
onClick={() => setOpen(!open)}
|
|
33
|
+
>
|
|
34
|
+
<HugeiconsIcon
|
|
35
|
+
icon={InformationCircleIcon}
|
|
36
|
+
size={18}
|
|
37
|
+
/>
|
|
38
|
+
</IconButton>
|
|
39
|
+
<Popover
|
|
40
|
+
open={open}
|
|
41
|
+
origin="top-right"
|
|
42
|
+
role="dialog"
|
|
43
|
+
aria-label="Redirect URI"
|
|
44
|
+
className="top-full right-0 mt-2 w-64 p-4"
|
|
45
|
+
>
|
|
46
|
+
<p className="text-footnote text-label">
|
|
47
|
+
Where Pass sends people back
|
|
48
|
+
after they sign in. It must
|
|
49
|
+
match your app exactly.
|
|
50
|
+
</p>
|
|
51
|
+
</Popover>
|
|
52
|
+
</div>
|
|
53
|
+
}
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Button } from "@passui/react/button"
|
|
2
|
+
import { Popover } from "@passui/react/popover"
|
|
3
|
+
import { useDismiss } from "@passui/react/use-dismiss"
|
|
4
|
+
import { toast } from "@passui/react"
|
|
5
|
+
import { useRef, useState } from "react"
|
|
6
|
+
|
|
7
|
+
const actions = [
|
|
8
|
+
"Duplicate",
|
|
9
|
+
"Move to folder",
|
|
10
|
+
"Export as PDF",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
export function PopoverMenu() {
|
|
14
|
+
const [open, setOpen] = useState(false)
|
|
15
|
+
const anchor = useRef<HTMLDivElement>(null)
|
|
16
|
+
useDismiss(anchor, open, () => setOpen(false))
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div ref={anchor} className="relative">
|
|
20
|
+
<Button
|
|
21
|
+
variant="secondary"
|
|
22
|
+
aria-haspopup="menu"
|
|
23
|
+
aria-expanded={open}
|
|
24
|
+
onClick={() => setOpen(!open)}
|
|
25
|
+
>
|
|
26
|
+
More
|
|
27
|
+
</Button>
|
|
28
|
+
<Popover
|
|
29
|
+
open={open}
|
|
30
|
+
origin="top-right"
|
|
31
|
+
role="menu"
|
|
32
|
+
className="top-full right-0 mt-2 flex w-56 flex-col p-1.5"
|
|
33
|
+
>
|
|
34
|
+
{actions.map((action) => (
|
|
35
|
+
<button
|
|
36
|
+
key={action}
|
|
37
|
+
type="button"
|
|
38
|
+
role="menuitem"
|
|
39
|
+
className="rounded-3xl px-3 py-2 text-start text-subheadline text-label hover:bg-fill"
|
|
40
|
+
onClick={() => {
|
|
41
|
+
setOpen(false)
|
|
42
|
+
toast(action)
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
{action}
|
|
46
|
+
</button>
|
|
47
|
+
))}
|
|
48
|
+
</Popover>
|
|
49
|
+
</div>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Button } from "@passui/react/button"
|
|
2
|
+
import { Popover } from "@passui/react/popover"
|
|
3
|
+
import {
|
|
4
|
+
ProfileImage,
|
|
5
|
+
ProfileImageContent,
|
|
6
|
+
ProfileImageFallback,
|
|
7
|
+
} from "@passui/react/profile-image"
|
|
8
|
+
import { useDismiss } from "@passui/react/use-dismiss"
|
|
9
|
+
import { useRef, useState } from "react"
|
|
10
|
+
|
|
11
|
+
export function PopoverShowcase() {
|
|
12
|
+
const [open, setOpen] = useState(true)
|
|
13
|
+
const anchor = useRef<HTMLDivElement>(null)
|
|
14
|
+
useDismiss(anchor, open, () => setOpen(false))
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div className="flex h-80 w-full max-w-sm justify-end">
|
|
18
|
+
<div ref={anchor} className="relative">
|
|
19
|
+
<button
|
|
20
|
+
type="button"
|
|
21
|
+
aria-label="Account"
|
|
22
|
+
aria-expanded={open}
|
|
23
|
+
onClick={() => setOpen(!open)}
|
|
24
|
+
className="rounded-full"
|
|
25
|
+
>
|
|
26
|
+
<ProfileImage className="size-11">
|
|
27
|
+
<ProfileImageContent src="/avatars/aiko.svg" />
|
|
28
|
+
<ProfileImageFallback>
|
|
29
|
+
AK
|
|
30
|
+
</ProfileImageFallback>
|
|
31
|
+
</ProfileImage>
|
|
32
|
+
</button>
|
|
33
|
+
<Popover
|
|
34
|
+
open={open}
|
|
35
|
+
origin="top-right"
|
|
36
|
+
role="dialog"
|
|
37
|
+
aria-label="Account"
|
|
38
|
+
className="top-full right-0 mt-2 flex w-64 flex-col items-center gap-3 p-5 text-center"
|
|
39
|
+
>
|
|
40
|
+
<ProfileImage className="size-16 text-title3">
|
|
41
|
+
<ProfileImageContent src="/avatars/aiko.svg" />
|
|
42
|
+
<ProfileImageFallback>
|
|
43
|
+
AK
|
|
44
|
+
</ProfileImageFallback>
|
|
45
|
+
</ProfileImage>
|
|
46
|
+
<div className="flex flex-col">
|
|
47
|
+
<span className="text-headline font-semibold text-label">
|
|
48
|
+
Aiko Kamado
|
|
49
|
+
</span>
|
|
50
|
+
<span className="text-footnote text-label-secondary">
|
|
51
|
+
aiko@example.com
|
|
52
|
+
</span>
|
|
53
|
+
</div>
|
|
54
|
+
<Button variant="secondary" size="sm">
|
|
55
|
+
Manage your account
|
|
56
|
+
</Button>
|
|
57
|
+
</Popover>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Button } from "@passui/react/button"
|
|
2
|
+
import { Popover } from "@passui/react/popover"
|
|
3
|
+
import { useDismiss } from "@passui/react/use-dismiss"
|
|
4
|
+
import { useRef, useState } from "react"
|
|
5
|
+
|
|
6
|
+
export function PopoverUsage() {
|
|
7
|
+
const [open, setOpen] = useState(false)
|
|
8
|
+
const anchor = useRef<HTMLDivElement>(null)
|
|
9
|
+
useDismiss(anchor, open, () => setOpen(false))
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<div ref={anchor} className="relative">
|
|
13
|
+
<Button
|
|
14
|
+
variant="secondary"
|
|
15
|
+
aria-expanded={open}
|
|
16
|
+
onClick={() => setOpen(!open)}
|
|
17
|
+
>
|
|
18
|
+
What's this?
|
|
19
|
+
</Button>
|
|
20
|
+
<Popover
|
|
21
|
+
open={open}
|
|
22
|
+
className="top-full left-0 mt-2 w-64 p-4"
|
|
23
|
+
>
|
|
24
|
+
<p className="text-callout text-label">
|
|
25
|
+
A passkey signs you in with your face,
|
|
26
|
+
fingerprint or screen lock.
|
|
27
|
+
</p>
|
|
28
|
+
</Popover>
|
|
29
|
+
</div>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { PopoverHelp } from "./examples/popover-help"
|
|
2
|
+
import { useRef, useState } from "react"
|
|
3
|
+
import { Button } from "../button/button"
|
|
4
|
+
import { defineDocs } from "../../docs/types"
|
|
5
|
+
import { useDismiss } from "../../hooks/use-dismiss"
|
|
6
|
+
import { PopoverMenu } from "./examples/popover-menu"
|
|
7
|
+
import { PopoverShowcase } from "./examples/popover-showcase"
|
|
8
|
+
import { PopoverUsage } from "./examples/popover-usage"
|
|
9
|
+
import { Popover, type PopoverProps } from "./popover"
|
|
10
|
+
|
|
11
|
+
type DemoProps = Pick<PopoverProps, "origin">
|
|
12
|
+
|
|
13
|
+
function PopoverDemo({ origin }: DemoProps) {
|
|
14
|
+
const [open, setOpen] = useState(false)
|
|
15
|
+
const anchor = useRef<HTMLDivElement>(null)
|
|
16
|
+
useDismiss(anchor, open, () => setOpen(false))
|
|
17
|
+
return (
|
|
18
|
+
<div ref={anchor} className="relative">
|
|
19
|
+
<Button
|
|
20
|
+
variant="secondary"
|
|
21
|
+
aria-expanded={open}
|
|
22
|
+
onClick={() => setOpen(!open)}
|
|
23
|
+
>
|
|
24
|
+
Open popover
|
|
25
|
+
</Button>
|
|
26
|
+
<Popover
|
|
27
|
+
open={open}
|
|
28
|
+
origin={origin}
|
|
29
|
+
className={
|
|
30
|
+
origin === "top-right"
|
|
31
|
+
? "top-full right-0 mt-2 w-60 p-4"
|
|
32
|
+
: "top-full left-0 mt-2 w-60 p-4"
|
|
33
|
+
}
|
|
34
|
+
>
|
|
35
|
+
<p className="text-callout text-label">
|
|
36
|
+
Grows from its {origin ?? "top-left"}{" "}
|
|
37
|
+
corner. Escape or a click outside closes
|
|
38
|
+
it.
|
|
39
|
+
</p>
|
|
40
|
+
</Popover>
|
|
41
|
+
</div>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const popoverDocs = defineDocs<PopoverProps>()({
|
|
46
|
+
slug: "popover",
|
|
47
|
+
name: "Popover",
|
|
48
|
+
importPath: "@passui/react/popover",
|
|
49
|
+
controls: {
|
|
50
|
+
origin: {
|
|
51
|
+
kind: "select",
|
|
52
|
+
options: { "top-left": true, "top-right": true },
|
|
53
|
+
default: "top-left",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
render: (values) => <PopoverDemo {...values} />,
|
|
57
|
+
childrenSnippet: ({ origin }) => ({
|
|
58
|
+
imports: [
|
|
59
|
+
'import { useRef, useState } from "react"',
|
|
60
|
+
'import { useDismiss } from "@passui/react/use-dismiss"',
|
|
61
|
+
],
|
|
62
|
+
setup: [
|
|
63
|
+
"const [open, setOpen] = useState(false)",
|
|
64
|
+
"const anchor = useRef<HTMLDivElement>(null)",
|
|
65
|
+
"useDismiss(anchor, open, () => setOpen(false))",
|
|
66
|
+
],
|
|
67
|
+
expressionProps: { open: "open" },
|
|
68
|
+
extraProps: {
|
|
69
|
+
className:
|
|
70
|
+
origin === "top-right"
|
|
71
|
+
? "top-full right-0 mt-2 w-60 p-4"
|
|
72
|
+
: "top-full left-0 mt-2 w-60 p-4",
|
|
73
|
+
},
|
|
74
|
+
children:
|
|
75
|
+
"\n {/* inside a relative parent with ref={anchor} */}\n",
|
|
76
|
+
}),
|
|
77
|
+
usage: PopoverUsage,
|
|
78
|
+
showcase: PopoverShowcase,
|
|
79
|
+
examples: [
|
|
80
|
+
{ id: "menu", component: PopoverMenu },
|
|
81
|
+
{ id: "help", component: PopoverHelp },
|
|
82
|
+
],
|
|
83
|
+
previewHeight: 320,
|
|
84
|
+
})
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AnimatePresence,
|
|
3
|
+
type HTMLMotionProps,
|
|
4
|
+
motion,
|
|
5
|
+
useReducedMotion,
|
|
6
|
+
} from "motion/react"
|
|
7
|
+
import { useLayoutEffect, useRef, useState } from "react"
|
|
8
|
+
import { cn } from "../../lib/class-names"
|
|
9
|
+
import { screenEdges } from "../../lib/screen-edges"
|
|
10
|
+
import { popoverMotion } from "../../motion/transitions"
|
|
11
|
+
|
|
12
|
+
export type PopoverOrigin = "top-left" | "top-right"
|
|
13
|
+
|
|
14
|
+
export interface PopoverProps extends HTMLMotionProps<"div"> {
|
|
15
|
+
open: boolean
|
|
16
|
+
/** Which corner the popover grows from. */
|
|
17
|
+
origin?: PopoverOrigin
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface PopoverFit {
|
|
21
|
+
shift: number
|
|
22
|
+
maxWidth?: number
|
|
23
|
+
maxHeight?: number
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A glass surface that springs open from its anchor. Position it with
|
|
28
|
+
* `className` (it is absolutely positioned within a relative parent); it
|
|
29
|
+
* moves itself back inside the screen if that would cross an edge, and
|
|
30
|
+
* keeps checking while the viewport resizes or anything scrolls.
|
|
31
|
+
*/
|
|
32
|
+
export function Popover({ open, ...props }: PopoverProps) {
|
|
33
|
+
return (
|
|
34
|
+
<AnimatePresence>
|
|
35
|
+
{open && <OpenPopover {...props} />}
|
|
36
|
+
</AnimatePresence>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function OpenPopover({
|
|
41
|
+
origin = "top-left",
|
|
42
|
+
className,
|
|
43
|
+
style,
|
|
44
|
+
children,
|
|
45
|
+
...props
|
|
46
|
+
}: Omit<PopoverProps, "open">) {
|
|
47
|
+
const ref = useRef<HTMLDivElement>(null)
|
|
48
|
+
const reducedMotion = useReducedMotion()
|
|
49
|
+
const [fit, setFit] = useState<PopoverFit>({ shift: 0 })
|
|
50
|
+
|
|
51
|
+
useLayoutEffect(() => {
|
|
52
|
+
const refit = () => {
|
|
53
|
+
const element = ref.current
|
|
54
|
+
if (!element) return
|
|
55
|
+
// Where it sits once open: measured without the opening scale, before paint.
|
|
56
|
+
const transform = element.style.transform
|
|
57
|
+
element.style.transform = "none"
|
|
58
|
+
const rect = element.getBoundingClientRect()
|
|
59
|
+
element.style.transform = transform
|
|
60
|
+
const edges = screenEdges()
|
|
61
|
+
const right = window.innerWidth - edges.right
|
|
62
|
+
let shift = 0
|
|
63
|
+
if (rect.right > right) shift = right - rect.right
|
|
64
|
+
if (rect.left + shift < edges.left)
|
|
65
|
+
shift = edges.left - rect.left
|
|
66
|
+
const room =
|
|
67
|
+
window.innerHeight - edges.bottom - rect.top
|
|
68
|
+
setFit({
|
|
69
|
+
shift,
|
|
70
|
+
maxWidth:
|
|
71
|
+
window.innerWidth -
|
|
72
|
+
edges.left -
|
|
73
|
+
edges.right,
|
|
74
|
+
maxHeight:
|
|
75
|
+
rect.height > room
|
|
76
|
+
? Math.max(room, 0)
|
|
77
|
+
: undefined,
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
refit()
|
|
81
|
+
const viewport = window.visualViewport
|
|
82
|
+
viewport?.addEventListener("resize", refit)
|
|
83
|
+
viewport?.addEventListener("scroll", refit)
|
|
84
|
+
window.addEventListener("resize", refit)
|
|
85
|
+
window.addEventListener("scroll", refit, true)
|
|
86
|
+
return () => {
|
|
87
|
+
viewport?.removeEventListener("resize", refit)
|
|
88
|
+
viewport?.removeEventListener("scroll", refit)
|
|
89
|
+
window.removeEventListener("resize", refit)
|
|
90
|
+
window.removeEventListener("scroll", refit, true)
|
|
91
|
+
}
|
|
92
|
+
}, [])
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<motion.div
|
|
96
|
+
ref={ref}
|
|
97
|
+
{...popoverMotion}
|
|
98
|
+
initial={
|
|
99
|
+
reducedMotion
|
|
100
|
+
? { opacity: 0 }
|
|
101
|
+
: popoverMotion.initial
|
|
102
|
+
}
|
|
103
|
+
animate={
|
|
104
|
+
reducedMotion
|
|
105
|
+
? { opacity: 1 }
|
|
106
|
+
: popoverMotion.animate
|
|
107
|
+
}
|
|
108
|
+
exit={
|
|
109
|
+
reducedMotion
|
|
110
|
+
? { opacity: 0 }
|
|
111
|
+
: popoverMotion.exit
|
|
112
|
+
}
|
|
113
|
+
transition={
|
|
114
|
+
reducedMotion
|
|
115
|
+
? { duration: 0 }
|
|
116
|
+
: popoverMotion.transition
|
|
117
|
+
}
|
|
118
|
+
style={{
|
|
119
|
+
transformOrigin:
|
|
120
|
+
origin === "top-left"
|
|
121
|
+
? "0% 0%"
|
|
122
|
+
: "100% 0%",
|
|
123
|
+
x: fit.shift,
|
|
124
|
+
maxWidth: fit.maxWidth,
|
|
125
|
+
maxHeight: fit.maxHeight,
|
|
126
|
+
overflowY: fit.maxHeight ? "auto" : undefined,
|
|
127
|
+
...style,
|
|
128
|
+
}}
|
|
129
|
+
className={cn(
|
|
130
|
+
"glass-menu absolute z-40 rounded-5xl",
|
|
131
|
+
className
|
|
132
|
+
)}
|
|
133
|
+
{...props}
|
|
134
|
+
>
|
|
135
|
+
{children}
|
|
136
|
+
</motion.div>
|
|
137
|
+
)
|
|
138
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProfileImage,
|
|
3
|
+
ProfileImageContent,
|
|
4
|
+
ProfileImageFallback,
|
|
5
|
+
} from "@passui/react/profile-image"
|
|
6
|
+
|
|
7
|
+
export function ProfileImageFallbacks() {
|
|
8
|
+
return (
|
|
9
|
+
<div className="flex items-center gap-4">
|
|
10
|
+
<ProfileImage className="size-11">
|
|
11
|
+
<ProfileImageContent src="/avatars/kenji.svg" />
|
|
12
|
+
<ProfileImageFallback>
|
|
13
|
+
KM
|
|
14
|
+
</ProfileImageFallback>
|
|
15
|
+
</ProfileImage>
|
|
16
|
+
<ProfileImage className="size-11">
|
|
17
|
+
<ProfileImageContent src="/avatars/missing.png" />
|
|
18
|
+
<ProfileImageFallback>
|
|
19
|
+
MP
|
|
20
|
+
</ProfileImageFallback>
|
|
21
|
+
</ProfileImage>
|
|
22
|
+
<ProfileImage className="size-11">
|
|
23
|
+
<ProfileImageFallback>
|
|
24
|
+
JS
|
|
25
|
+
</ProfileImageFallback>
|
|
26
|
+
</ProfileImage>
|
|
27
|
+
</div>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProfileImage,
|
|
3
|
+
ProfileImageContent,
|
|
4
|
+
ProfileImageFallback,
|
|
5
|
+
} from "@passui/react/profile-image"
|
|
6
|
+
|
|
7
|
+
const people = [
|
|
8
|
+
{ initials: "AK", src: "/avatars/aiko.svg" },
|
|
9
|
+
{ initials: "KM", src: "/avatars/kenji.svg" },
|
|
10
|
+
{ initials: "MP", src: "/avatars/mira.svg" },
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
export function ProfileImageGroup() {
|
|
14
|
+
return (
|
|
15
|
+
<div className="flex items-center">
|
|
16
|
+
{people.map((person) => (
|
|
17
|
+
<ProfileImage
|
|
18
|
+
key={person.initials}
|
|
19
|
+
className="-ms-2 size-9 ring-2 ring-background first:ms-0"
|
|
20
|
+
>
|
|
21
|
+
<ProfileImageContent src={person.src} />
|
|
22
|
+
<ProfileImageFallback>
|
|
23
|
+
{person.initials}
|
|
24
|
+
</ProfileImageFallback>
|
|
25
|
+
</ProfileImage>
|
|
26
|
+
))}
|
|
27
|
+
<ProfileImage className="-ms-2 size-9 ring-2 ring-background">
|
|
28
|
+
<ProfileImageFallback>
|
|
29
|
+
+4
|
|
30
|
+
</ProfileImageFallback>
|
|
31
|
+
</ProfileImage>
|
|
32
|
+
</div>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Button } from "@passui/react/button"
|
|
2
|
+
import {
|
|
3
|
+
ProfileImage,
|
|
4
|
+
ProfileImageContent,
|
|
5
|
+
ProfileImageFallback,
|
|
6
|
+
} from "@passui/react/profile-image"
|
|
7
|
+
|
|
8
|
+
export function ProfileImageShowcase() {
|
|
9
|
+
return (
|
|
10
|
+
<div className="flex w-full max-w-xs flex-col items-center gap-4 rounded-4xl bg-elevated p-6 text-center shadow-sm ring-1 ring-separator/60">
|
|
11
|
+
<ProfileImage className="size-20 text-title3">
|
|
12
|
+
<ProfileImageContent src="/avatars/aiko.svg" />
|
|
13
|
+
<ProfileImageFallback>
|
|
14
|
+
AK
|
|
15
|
+
</ProfileImageFallback>
|
|
16
|
+
</ProfileImage>
|
|
17
|
+
<div className="flex flex-col gap-0.5">
|
|
18
|
+
<h2 className="text-headline font-semibold text-label">
|
|
19
|
+
Aiko Kamado
|
|
20
|
+
</h2>
|
|
21
|
+
<p className="text-footnote text-label-secondary">
|
|
22
|
+
aiko@example.com
|
|
23
|
+
</p>
|
|
24
|
+
</div>
|
|
25
|
+
<Button variant="secondary" size="sm">
|
|
26
|
+
Change photo
|
|
27
|
+
</Button>
|
|
28
|
+
</div>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProfileImage,
|
|
3
|
+
ProfileImageContent,
|
|
4
|
+
ProfileImageFallback,
|
|
5
|
+
} from "@passui/react/profile-image"
|
|
6
|
+
|
|
7
|
+
export function ProfileImageUsage() {
|
|
8
|
+
return (
|
|
9
|
+
<ProfileImage className="size-11">
|
|
10
|
+
<ProfileImageContent src="/avatars/aiko.svg" />
|
|
11
|
+
<ProfileImageFallback>AK</ProfileImageFallback>
|
|
12
|
+
</ProfileImage>
|
|
13
|
+
)
|
|
14
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsxText } from "../../docs/snippet"
|
|
2
|
+
import { defineDocs } from "../../docs/types"
|
|
3
|
+
import { ProfileImageFallbacks } from "./examples/profile-image-fallbacks"
|
|
4
|
+
import { ProfileImageGroup } from "./examples/profile-image-group"
|
|
5
|
+
import { ProfileImageShowcase } from "./examples/profile-image-showcase"
|
|
6
|
+
import { ProfileImageUsage } from "./examples/profile-image-usage"
|
|
7
|
+
import {
|
|
8
|
+
ProfileImage,
|
|
9
|
+
ProfileImageContent,
|
|
10
|
+
ProfileImageFallback,
|
|
11
|
+
} from "./profile-image"
|
|
12
|
+
|
|
13
|
+
// Size is a class name on ProfileImage, and the photo and initials are
|
|
14
|
+
// its children; the snippet writes all three itself.
|
|
15
|
+
type DemoProps = {
|
|
16
|
+
size: "small" | "medium" | "large"
|
|
17
|
+
photo: boolean
|
|
18
|
+
initials: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const sizes = {
|
|
22
|
+
small: "size-7",
|
|
23
|
+
medium: "size-11",
|
|
24
|
+
large: "size-20 text-title3",
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const profileImageDocs = defineDocs<DemoProps>()({
|
|
28
|
+
slug: "profile-image",
|
|
29
|
+
name: "ProfileImage",
|
|
30
|
+
importPath: "@passui/react/profile-image",
|
|
31
|
+
controls: {
|
|
32
|
+
size: {
|
|
33
|
+
kind: "select",
|
|
34
|
+
options: {
|
|
35
|
+
small: true,
|
|
36
|
+
medium: true,
|
|
37
|
+
large: true,
|
|
38
|
+
},
|
|
39
|
+
default: "medium",
|
|
40
|
+
},
|
|
41
|
+
photo: { kind: "boolean", default: true },
|
|
42
|
+
initials: { kind: "text", default: "AK" },
|
|
43
|
+
},
|
|
44
|
+
render: ({ size, photo, initials }) => (
|
|
45
|
+
<ProfileImage className={sizes[size]}>
|
|
46
|
+
<ProfileImageContent
|
|
47
|
+
src={photo ? "/avatars/aiko.svg" : undefined}
|
|
48
|
+
/>
|
|
49
|
+
<ProfileImageFallback>
|
|
50
|
+
{initials}
|
|
51
|
+
</ProfileImageFallback>
|
|
52
|
+
</ProfileImage>
|
|
53
|
+
),
|
|
54
|
+
childrenSnippet: ({ size, photo, initials }) => ({
|
|
55
|
+
imports: [
|
|
56
|
+
'import { ProfileImageContent, ProfileImageFallback } from "@passui/react/profile-image"',
|
|
57
|
+
],
|
|
58
|
+
omit: ["size", "photo", "initials"],
|
|
59
|
+
extraProps: { className: sizes[size] },
|
|
60
|
+
children: [
|
|
61
|
+
"",
|
|
62
|
+
...(photo
|
|
63
|
+
? [
|
|
64
|
+
' <ProfileImageContent src="/avatars/aiko.svg" />',
|
|
65
|
+
]
|
|
66
|
+
: []),
|
|
67
|
+
` <ProfileImageFallback>${jsxText(initials)}</ProfileImageFallback>`,
|
|
68
|
+
"",
|
|
69
|
+
].join("\n"),
|
|
70
|
+
}),
|
|
71
|
+
usage: ProfileImageUsage,
|
|
72
|
+
showcase: ProfileImageShowcase,
|
|
73
|
+
examples: [
|
|
74
|
+
{
|
|
75
|
+
id: "fallbacks",
|
|
76
|
+
component: ProfileImageFallbacks,
|
|
77
|
+
playground: { photo: false },
|
|
78
|
+
},
|
|
79
|
+
{ id: "group", component: ProfileImageGroup },
|
|
80
|
+
],
|
|
81
|
+
})
|