@coinbase/cds-mcp-server 8.17.2 → 8.17.3
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/CHANGELOG.md +4 -0
- package/mcp-docs/mobile/components/Accordion.txt +189 -0
- package/mcp-docs/mobile/components/AccordionItem.txt +30 -0
- package/mcp-docs/mobile/components/Alert.txt +156 -0
- package/mcp-docs/mobile/components/AreaChart.txt +266 -0
- package/mcp-docs/mobile/components/Avatar.txt +196 -0
- package/mcp-docs/mobile/components/AvatarButton.txt +226 -0
- package/mcp-docs/mobile/components/Banner.txt +222 -0
- package/mcp-docs/mobile/components/BarChart.txt +816 -0
- package/mcp-docs/mobile/components/Box.txt +174 -0
- package/mcp-docs/mobile/components/BrowserBar.txt +147 -0
- package/mcp-docs/mobile/components/Button.txt +199 -0
- package/mcp-docs/mobile/components/ButtonGroup.txt +80 -0
- package/mcp-docs/mobile/components/Carousel.txt +1084 -0
- package/mcp-docs/mobile/components/CartesianChart.txt +826 -0
- package/mcp-docs/mobile/components/CellMedia.txt +71 -0
- package/mcp-docs/mobile/components/Checkbox.txt +246 -0
- package/mcp-docs/mobile/components/CheckboxCell.txt +202 -0
- package/mcp-docs/mobile/components/CheckboxGroup.txt +285 -0
- package/mcp-docs/mobile/components/Chip.txt +195 -0
- package/mcp-docs/mobile/components/Coachmark.txt +158 -0
- package/mcp-docs/mobile/components/Collapsible.txt +105 -0
- package/mcp-docs/mobile/components/ContainedAssetCard.txt +135 -0
- package/mcp-docs/mobile/components/ContentCard.txt +366 -0
- package/mcp-docs/mobile/components/ContentCardBody.txt +136 -0
- package/mcp-docs/mobile/components/ContentCardFooter.txt +128 -0
- package/mcp-docs/mobile/components/ContentCardHeader.txt +146 -0
- package/mcp-docs/mobile/components/ContentCell.txt +227 -0
- package/mcp-docs/mobile/components/ControlGroup.txt +444 -0
- package/mcp-docs/mobile/components/DatePicker.txt +497 -0
- package/mcp-docs/mobile/components/Divider.txt +139 -0
- package/mcp-docs/mobile/components/DotCount.txt +146 -0
- package/mcp-docs/mobile/components/DotStatusColor.txt +59 -0
- package/mcp-docs/mobile/components/DotSymbol.txt +135 -0
- package/mcp-docs/mobile/components/Fallback.txt +158 -0
- package/mcp-docs/mobile/components/FloatingAssetCard.txt +156 -0
- package/mcp-docs/mobile/components/HStack.txt +235 -0
- package/mcp-docs/mobile/components/HeroSquare.txt +48 -0
- package/mcp-docs/mobile/components/Icon.txt +52 -0
- package/mcp-docs/mobile/components/IconButton.txt +269 -0
- package/mcp-docs/mobile/components/InputChip.txt +188 -0
- package/mcp-docs/mobile/components/Interactable.txt +187 -0
- package/mcp-docs/mobile/components/LineChart.txt +1325 -0
- package/mcp-docs/mobile/components/Link.txt +292 -0
- package/mcp-docs/mobile/components/ListCell.txt +391 -0
- package/mcp-docs/mobile/components/LogoMark.txt +85 -0
- package/mcp-docs/mobile/components/LogoWordMark.txt +94 -0
- package/mcp-docs/mobile/components/Lottie.txt +139 -0
- package/mcp-docs/mobile/components/LottieStatusAnimation.txt +47 -0
- package/mcp-docs/mobile/components/Modal.txt +84 -0
- package/mcp-docs/mobile/components/ModalBody.txt +34 -0
- package/mcp-docs/mobile/components/ModalFooter.txt +25 -0
- package/mcp-docs/mobile/components/ModalHeader.txt +28 -0
- package/mcp-docs/mobile/components/MultiContentModule.txt +380 -0
- package/mcp-docs/mobile/components/NavigationTitle.txt +132 -0
- package/mcp-docs/mobile/components/NavigationTitleSelect.txt +142 -0
- package/mcp-docs/mobile/components/NudgeCard.txt +90 -0
- package/mcp-docs/mobile/components/Numpad.txt +341 -0
- package/mcp-docs/mobile/components/Overlay.txt +152 -0
- package/mcp-docs/mobile/components/PageFooter.txt +161 -0
- package/mcp-docs/mobile/components/PageHeader.txt +186 -0
- package/mcp-docs/mobile/components/PeriodSelector.txt +408 -0
- package/mcp-docs/mobile/components/Pictogram.txt +48 -0
- package/mcp-docs/mobile/components/Point.txt +205 -0
- package/mcp-docs/mobile/components/PortalProvider.txt +79 -0
- package/mcp-docs/mobile/components/Pressable.txt +211 -0
- package/mcp-docs/mobile/components/ProgressBar.txt +130 -0
- package/mcp-docs/mobile/components/ProgressBarWithFixedLabels.txt +161 -0
- package/mcp-docs/mobile/components/ProgressBarWithFloatLabel.txt +138 -0
- package/mcp-docs/mobile/components/ProgressCircle.txt +237 -0
- package/mcp-docs/mobile/components/Radio.txt +242 -0
- package/mcp-docs/mobile/components/RadioCell.txt +202 -0
- package/mcp-docs/mobile/components/RadioGroup.txt +282 -0
- package/mcp-docs/mobile/components/ReferenceLine.txt +153 -0
- package/mcp-docs/mobile/components/RemoteImage.txt +106 -0
- package/mcp-docs/mobile/components/RemoteImageGroup.txt +61 -0
- package/mcp-docs/mobile/components/RollingNumber.txt +789 -0
- package/mcp-docs/mobile/components/Scrubber.txt +204 -0
- package/mcp-docs/mobile/components/SearchInput.txt +192 -0
- package/mcp-docs/mobile/components/SectionHeader.txt +205 -0
- package/mcp-docs/mobile/components/SegmentedTabs.txt +316 -0
- package/mcp-docs/mobile/components/Select.txt +212 -0
- package/mcp-docs/mobile/components/SelectChip.txt +324 -0
- package/mcp-docs/mobile/components/SelectOption.txt +85 -0
- package/mcp-docs/mobile/components/SlideButton.txt +331 -0
- package/mcp-docs/mobile/components/Spacer.txt +84 -0
- package/mcp-docs/mobile/components/Sparkline.txt +123 -0
- package/mcp-docs/mobile/components/SparklineGradient.txt +107 -0
- package/mcp-docs/mobile/components/SparklineInteractive.txt +157 -0
- package/mcp-docs/mobile/components/SparklineInteractiveHeader.txt +73 -0
- package/mcp-docs/mobile/components/Spinner.txt +49 -0
- package/mcp-docs/mobile/components/SpotIcon.txt +48 -0
- package/mcp-docs/mobile/components/SpotRectangle.txt +48 -0
- package/mcp-docs/mobile/components/SpotSquare.txt +48 -0
- package/mcp-docs/mobile/components/Stepper.txt +528 -0
- package/mcp-docs/mobile/components/SubBrandLogoMark.txt +126 -0
- package/mcp-docs/mobile/components/SubBrandLogoWordMark.txt +126 -0
- package/mcp-docs/mobile/components/Switch.txt +98 -0
- package/mcp-docs/mobile/components/TabIndicator.txt +49 -0
- package/mcp-docs/mobile/components/TabLabel.txt +154 -0
- package/mcp-docs/mobile/components/TabNavigation.txt +147 -0
- package/mcp-docs/mobile/components/TabbedChips.txt +143 -0
- package/mcp-docs/mobile/components/Tabs.txt +191 -0
- package/mcp-docs/mobile/components/Tag.txt +301 -0
- package/mcp-docs/mobile/components/Text.txt +212 -0
- package/mcp-docs/mobile/components/TextInput.txt +718 -0
- package/mcp-docs/mobile/components/ThemeProvider.txt +133 -0
- package/mcp-docs/mobile/components/Toast.txt +197 -0
- package/mcp-docs/mobile/components/Tooltip.txt +60 -0
- package/mcp-docs/mobile/components/TopNavBar.txt +162 -0
- package/mcp-docs/mobile/components/Tour.txt +159 -0
- package/mcp-docs/mobile/components/Tray.txt +253 -0
- package/mcp-docs/mobile/components/UpsellCard.txt +322 -0
- package/mcp-docs/mobile/components/VStack.txt +223 -0
- package/mcp-docs/mobile/components/XAxis.txt +622 -0
- package/mcp-docs/mobile/components/YAxis.txt +568 -0
- package/mcp-docs/mobile/getting-started/introduction.txt +99 -0
- package/mcp-docs/mobile/getting-started/mcp-server.txt +94 -0
- package/mcp-docs/mobile/getting-started/playground.txt +25 -0
- package/mcp-docs/mobile/hooks/useDimensions.txt +47 -0
- package/mcp-docs/mobile/hooks/useOverlayContentContext.txt +215 -0
- package/mcp-docs/mobile/hooks/useTheme.txt +110 -0
- package/mcp-docs/mobile/routes.txt +132 -0
- package/mcp-docs/web/components/Accordion.txt +190 -0
- package/mcp-docs/web/components/AccordionItem.txt +32 -0
- package/mcp-docs/web/components/Alert.txt +165 -0
- package/mcp-docs/web/components/AreaChart.txt +511 -0
- package/mcp-docs/web/components/Avatar.txt +212 -0
- package/mcp-docs/web/components/AvatarButton.txt +241 -0
- package/mcp-docs/web/components/Banner.txt +227 -0
- package/mcp-docs/web/components/BarChart.txt +1268 -0
- package/mcp-docs/web/components/Box.txt +176 -0
- package/mcp-docs/web/components/Button.txt +213 -0
- package/mcp-docs/web/components/ButtonGroup.txt +80 -0
- package/mcp-docs/web/components/Calendar.txt +182 -0
- package/mcp-docs/web/components/Carousel.txt +1576 -0
- package/mcp-docs/web/components/CartesianChart.txt +1045 -0
- package/mcp-docs/web/components/CellMedia.txt +57 -0
- package/mcp-docs/web/components/Checkbox.txt +189 -0
- package/mcp-docs/web/components/CheckboxCell.txt +203 -0
- package/mcp-docs/web/components/CheckboxGroup.txt +220 -0
- package/mcp-docs/web/components/Chip.txt +197 -0
- package/mcp-docs/web/components/Coachmark.txt +189 -0
- package/mcp-docs/web/components/Collapsible.txt +120 -0
- package/mcp-docs/web/components/ContainedAssetCard.txt +233 -0
- package/mcp-docs/web/components/ContentCard.txt +368 -0
- package/mcp-docs/web/components/ContentCardBody.txt +138 -0
- package/mcp-docs/web/components/ContentCardFooter.txt +130 -0
- package/mcp-docs/web/components/ContentCardHeader.txt +148 -0
- package/mcp-docs/web/components/ContentCell.txt +220 -0
- package/mcp-docs/web/components/ControlGroup.txt +437 -0
- package/mcp-docs/web/components/DatePicker.txt +506 -0
- package/mcp-docs/web/components/Divider.txt +144 -0
- package/mcp-docs/web/components/DotCount.txt +150 -0
- package/mcp-docs/web/components/DotStatusColor.txt +59 -0
- package/mcp-docs/web/components/DotSymbol.txt +138 -0
- package/mcp-docs/web/components/Dropdown.txt +120 -0
- package/mcp-docs/web/components/Fallback.txt +164 -0
- package/mcp-docs/web/components/FloatingAssetCard.txt +251 -0
- package/mcp-docs/web/components/FullscreenAlert.txt +70 -0
- package/mcp-docs/web/components/FullscreenModal.txt +146 -0
- package/mcp-docs/web/components/FullscreenModalLayout.txt +188 -0
- package/mcp-docs/web/components/Grid.txt +237 -0
- package/mcp-docs/web/components/GridColumn.txt +210 -0
- package/mcp-docs/web/components/HStack.txt +237 -0
- package/mcp-docs/web/components/HeroSquare.txt +49 -0
- package/mcp-docs/web/components/Icon.txt +146 -0
- package/mcp-docs/web/components/IconButton.txt +391 -0
- package/mcp-docs/web/components/InputChip.txt +188 -0
- package/mcp-docs/web/components/Interactable.txt +194 -0
- package/mcp-docs/web/components/LineChart.txt +1577 -0
- package/mcp-docs/web/components/Link.txt +244 -0
- package/mcp-docs/web/components/ListCell.txt +397 -0
- package/mcp-docs/web/components/LogoMark.txt +85 -0
- package/mcp-docs/web/components/LogoWordMark.txt +94 -0
- package/mcp-docs/web/components/Lottie.txt +158 -0
- package/mcp-docs/web/components/LottieStatusAnimation.txt +58 -0
- package/mcp-docs/web/components/MediaQueryProvider.txt +109 -0
- package/mcp-docs/web/components/Modal.txt +193 -0
- package/mcp-docs/web/components/ModalBody.txt +118 -0
- package/mcp-docs/web/components/ModalFooter.txt +120 -0
- package/mcp-docs/web/components/ModalHeader.txt +124 -0
- package/mcp-docs/web/components/MultiContentModule.txt +382 -0
- package/mcp-docs/web/components/NavigationBar.txt +103 -0
- package/mcp-docs/web/components/NavigationTitle.txt +26 -0
- package/mcp-docs/web/components/NavigationTitleSelect.txt +46 -0
- package/mcp-docs/web/components/NudgeCard.txt +182 -0
- package/mcp-docs/web/components/Overlay.txt +172 -0
- package/mcp-docs/web/components/PageFooter.txt +185 -0
- package/mcp-docs/web/components/PageHeader.txt +244 -0
- package/mcp-docs/web/components/Pagination.txt +500 -0
- package/mcp-docs/web/components/PeriodSelector.txt +704 -0
- package/mcp-docs/web/components/Pictogram.txt +49 -0
- package/mcp-docs/web/components/Point.txt +461 -0
- package/mcp-docs/web/components/PortalProvider.txt +77 -0
- package/mcp-docs/web/components/Pressable.txt +194 -0
- package/mcp-docs/web/components/ProgressBar.txt +164 -0
- package/mcp-docs/web/components/ProgressBarWithFixedLabels.txt +213 -0
- package/mcp-docs/web/components/ProgressBarWithFloatLabel.txt +182 -0
- package/mcp-docs/web/components/ProgressCircle.txt +444 -0
- package/mcp-docs/web/components/Radio.txt +220 -0
- package/mcp-docs/web/components/RadioCell.txt +216 -0
- package/mcp-docs/web/components/RadioGroup.txt +289 -0
- package/mcp-docs/web/components/ReferenceLine.txt +452 -0
- package/mcp-docs/web/components/RemoteImage.txt +166 -0
- package/mcp-docs/web/components/RemoteImageGroup.txt +87 -0
- package/mcp-docs/web/components/RollingNumber.txt +1022 -0
- package/mcp-docs/web/components/Scrubber.txt +232 -0
- package/mcp-docs/web/components/SearchInput.txt +118 -0
- package/mcp-docs/web/components/SectionHeader.txt +218 -0
- package/mcp-docs/web/components/SegmentedTabs.txt +325 -0
- package/mcp-docs/web/components/Select.txt +225 -0
- package/mcp-docs/web/components/SelectChip.txt +315 -0
- package/mcp-docs/web/components/SelectOption.txt +166 -0
- package/mcp-docs/web/components/Sidebar.txt +350 -0
- package/mcp-docs/web/components/SidebarItem.txt +132 -0
- package/mcp-docs/web/components/SidebarMoreMenu.txt +31 -0
- package/mcp-docs/web/components/Spacer.txt +174 -0
- package/mcp-docs/web/components/Sparkline.txt +123 -0
- package/mcp-docs/web/components/SparklineGradient.txt +107 -0
- package/mcp-docs/web/components/SparklineInteractive.txt +154 -0
- package/mcp-docs/web/components/SparklineInteractiveHeader.txt +77 -0
- package/mcp-docs/web/components/Spinner.txt +129 -0
- package/mcp-docs/web/components/SpotIcon.txt +49 -0
- package/mcp-docs/web/components/SpotRectangle.txt +49 -0
- package/mcp-docs/web/components/SpotSquare.txt +49 -0
- package/mcp-docs/web/components/Stepper.txt +683 -0
- package/mcp-docs/web/components/SubBrandLogoMark.txt +126 -0
- package/mcp-docs/web/components/SubBrandLogoWordMark.txt +126 -0
- package/mcp-docs/web/components/Switch.txt +86 -0
- package/mcp-docs/web/components/TabIndicator.txt +49 -0
- package/mcp-docs/web/components/TabLabel.txt +159 -0
- package/mcp-docs/web/components/TabNavigation.txt +160 -0
- package/mcp-docs/web/components/TabbedChips.txt +156 -0
- package/mcp-docs/web/components/Table.txt +368 -0
- package/mcp-docs/web/components/TableBody.txt +84 -0
- package/mcp-docs/web/components/TableCaption.txt +103 -0
- package/mcp-docs/web/components/TableCell.txt +166 -0
- package/mcp-docs/web/components/TableCellFallback.txt +98 -0
- package/mcp-docs/web/components/TableFooter.txt +84 -0
- package/mcp-docs/web/components/TableHeader.txt +101 -0
- package/mcp-docs/web/components/TableRow.txt +141 -0
- package/mcp-docs/web/components/Tabs.txt +213 -0
- package/mcp-docs/web/components/Tag.txt +305 -0
- package/mcp-docs/web/components/Text.txt +233 -0
- package/mcp-docs/web/components/TextInput.txt +653 -0
- package/mcp-docs/web/components/ThemeProvider.txt +200 -0
- package/mcp-docs/web/components/TileButton.txt +159 -0
- package/mcp-docs/web/components/Toast.txt +204 -0
- package/mcp-docs/web/components/Tooltip.txt +90 -0
- package/mcp-docs/web/components/Tour.txt +180 -0
- package/mcp-docs/web/components/Tray.txt +289 -0
- package/mcp-docs/web/components/UpsellCard.txt +320 -0
- package/mcp-docs/web/components/VStack.txt +225 -0
- package/mcp-docs/web/components/XAxis.txt +620 -0
- package/mcp-docs/web/components/YAxis.txt +549 -0
- package/mcp-docs/web/getting-started/introduction.txt +99 -0
- package/mcp-docs/web/getting-started/mcp-server.txt +94 -0
- package/mcp-docs/web/getting-started/playground.txt +25 -0
- package/mcp-docs/web/hooks/useBreakpoints.txt +33 -0
- package/mcp-docs/web/hooks/useDimensions.txt +55 -0
- package/mcp-docs/web/hooks/useHasMounted.txt +55 -0
- package/mcp-docs/web/hooks/useIsoEffect.txt +42 -0
- package/mcp-docs/web/hooks/useMediaQuery.txt +94 -0
- package/mcp-docs/web/hooks/useOverlayContentContext.txt +217 -0
- package/mcp-docs/web/hooks/useScrollBlocker.txt +63 -0
- package/mcp-docs/web/hooks/useTheme.txt +105 -0
- package/mcp-docs/web/routes.txt +155 -0
- package/package.json +1 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Tooltip
|
|
2
|
+
|
|
3
|
+
A component that displays additional information on hover.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
import { Tooltip } from '@coinbase/cds-web/overlays/Tooltip'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Required | Default | Description |
|
|
14
|
+
| --- | --- | --- | --- | --- |
|
|
15
|
+
| `content` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | Yes | `-` | The content to render within the tooltip. |
|
|
16
|
+
| `autoFocusDelay` | `number` | No | `undefined` | The amount of time in milliseconds to wait before auto-focusing the first focusable element. |
|
|
17
|
+
| `disableAutoFocus` | `boolean` | No | `false` | If true, the focus trap will not automatically shift focus to itself when it opens, and replace it to the last focused element when it closes. |
|
|
18
|
+
| `disableFocusTrap` | `boolean` | No | `-` | Disables the focus trap to allow normal keyboard navigation. |
|
|
19
|
+
| `disablePortal` | `boolean` | No | `false` | - |
|
|
20
|
+
| `disableTypeFocus` | `boolean` | No | `-` | Use for editable Search Input components to ensure focus is correctly applied |
|
|
21
|
+
| `elevation` | `0 \| 1 \| 2` | No | `-` | Determines a components shadow styles. Parent should have overflow set to visible to ensure styles are not clipped. |
|
|
22
|
+
| `focusTabIndexElements` | `boolean` | No | `false` | If true, the focus trap will include all elements with tabIndex values in the list of focusable elements. |
|
|
23
|
+
| `gap` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `1` | This value corresponds to how big the gap between the subject and the tooltip is. We do not encourage usage of this prop. But it is enabled for special cases as an escape hatch. |
|
|
24
|
+
| `invertColorScheme` | `boolean` | No | `true` | Invert the themes activeColorScheme for this component |
|
|
25
|
+
| `placement` | `top \| bottom \| left \| right` | No | `top` | Position of tooltip in relation to the subject. |
|
|
26
|
+
| `respectNegativeTabIndex` | `boolean` | No | `false` | If true, the focus trap will respect negative tabIndex values, removing them from the list of focusable elements. |
|
|
27
|
+
| `testID` | `string` | No | `-` | Used to locate this element in unit and end-to-end tests. Under the hood, testID translates to data-testid on Web. On Mobile, testID stays the same - testID |
|
|
28
|
+
| `tooltipId` | `string` | No | `-` | A unique ID used to ensure tooltips are accessible |
|
|
29
|
+
| `visible` | `boolean` | No | `true` | Control whether the tooltip is shown or hidden. |
|
|
30
|
+
| `zIndex` | `number` | No | `4` | Typically only used when disablePortal is set to true to adjust zIndex of tooltip. When using portal this value should remain as default. |
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Examples
|
|
34
|
+
|
|
35
|
+
### Placement
|
|
36
|
+
|
|
37
|
+
```jsx live
|
|
38
|
+
function TooltipPlacement() {
|
|
39
|
+
const content = 'This is the tooltip Content';
|
|
40
|
+
return (
|
|
41
|
+
<HStack spacingHorizontal={2} gap={2} justifyContent="space-around">
|
|
42
|
+
<Tooltip content={content}>
|
|
43
|
+
<Button>Default</Button>
|
|
44
|
+
</Tooltip>
|
|
45
|
+
<Tooltip content={content} placement="top">
|
|
46
|
+
<Button>Top</Button>
|
|
47
|
+
</Tooltip>
|
|
48
|
+
<Tooltip content={content} placement="left">
|
|
49
|
+
<Button>Left</Button>
|
|
50
|
+
</Tooltip>
|
|
51
|
+
<Tooltip content={content} placement="right">
|
|
52
|
+
<Button>Right</Button>
|
|
53
|
+
</Tooltip>
|
|
54
|
+
<Tooltip content={content} placement="bottom">
|
|
55
|
+
<Button>Bottom</Button>
|
|
56
|
+
</Tooltip>
|
|
57
|
+
</HStack>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Positioning
|
|
63
|
+
|
|
64
|
+
Sometimes you may want to use a tooltip with an absolute positioned element.
|
|
65
|
+
|
|
66
|
+
To ensure the tooltip is properly aligned, you should instead set the position prop on the tooltip.
|
|
67
|
+
|
|
68
|
+
```jsx live
|
|
69
|
+
function TooltipPosition() {
|
|
70
|
+
const content = 'This is the tooltip Content';
|
|
71
|
+
return (
|
|
72
|
+
<VStack gap={2}>
|
|
73
|
+
<Box position="relative">
|
|
74
|
+
Set your default display currency.
|
|
75
|
+
<Tooltip content="I am not centered horizontally">
|
|
76
|
+
<Icon active color="fg" name="info" paddingStart={1} position="absolute" />
|
|
77
|
+
</Tooltip>
|
|
78
|
+
</Box>
|
|
79
|
+
<Box position="relative">
|
|
80
|
+
Set your default display currency.
|
|
81
|
+
<Tooltip content="I am centered horizontally" position="absolute">
|
|
82
|
+
<Icon active color="fg" name="info" paddingStart={1} />
|
|
83
|
+
</Tooltip>
|
|
84
|
+
</Box>
|
|
85
|
+
</VStack>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Tour
|
|
2
|
+
|
|
3
|
+
Creates guided tours of a user interface.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
import { Tour, TourStep } from '@coinbase/cds-web/tour'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Required | Default | Description |
|
|
14
|
+
| --- | --- | --- | --- | --- |
|
|
15
|
+
| `activeTourStep` | `TourStepValue<T> \| null` | Yes | `-` | - |
|
|
16
|
+
| `onChange` | `(tourStep: TourStepValue<T> \| null) => void` | Yes | `-` | - |
|
|
17
|
+
| `steps` | `TourStepValue<T>[]` | Yes | `-` | - |
|
|
18
|
+
| `TourMaskComponent` | `TourMaskComponent` | No | `DefaultTourMask` | The Component to render as a tour overlay and mask. |
|
|
19
|
+
| `TourStepArrowComponent` | `TourStepArrowComponent` | No | `DefaultTourStepArrow` | The default Component to render for each TourStep arrow element. |
|
|
20
|
+
| `disableAutoScroll` | `boolean` | No | `-` | Disable automatically scrolling to active elements. |
|
|
21
|
+
| `disablePortal` | `boolean` | No | `-` | - |
|
|
22
|
+
| `hideOverlay` | `boolean` | No | `false` | Hide overlay when tour is active |
|
|
23
|
+
| `scrollOptions` | `TourScrollOptions` | No | `{ behavior: 'smooth', marginX: 100, marginY: 100, }` | Controls the scrolling behavior and margins when calling element.scrollTo() to scroll to an active TourStep target. |
|
|
24
|
+
| `testID` | `string` | No | `-` | Used to locate this element in unit and end-to-end tests. Under the hood, testID translates to data-testid on Web. On Mobile, testID stays the same - testID |
|
|
25
|
+
| `tourMaskBorderRadius` | `string \| number` | No | `-` | Corner radius for the TourMasks content mask. Uses SVG rect elements rx and ry attributes https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/rx. |
|
|
26
|
+
| `tourMaskPadding` | `string \| number` | No | `-` | Padding to add around the edges of the TourMasks content mask. |
|
|
27
|
+
| `tourStepAutoPlacement` | `{ padding?: Padding; rootBoundary?: RootBoundary \| undefined; elementContext?: ElementContext \| undefined; altBoundary?: boolean \| undefined; crossAxis?: boolean \| undefined; alignment?: Alignment \| null \| undefined; autoAlignment?: boolean \| undefined; allowedPlacements?: Placement[] \| undefined; boundary?: Boundary \| undefined; } \| undefined` | No | `24` | Configures @floating-ui autoPlacement options for Tour Step component. See https://floating-ui.com/docs/autoplacement. |
|
|
28
|
+
| `tourStepOffset` | `number \| Partial<{ mainAxis: number; crossAxis: number; alignmentAxis: number \| null; }> \| Derivable<OffsetValue>` | No | `24` | Configures @floating-ui offset options for Tour Step component. See https://floating-ui.com/docs/offset. |
|
|
29
|
+
| `tourStepShift` | `{ padding?: Padding; rootBoundary?: RootBoundary \| undefined; elementContext?: ElementContext \| undefined; altBoundary?: boolean \| undefined; crossAxis?: boolean \| undefined; mainAxis?: boolean \| undefined; limiter?: { fn: (state: MiddlewareState) => Coords; options?: any; } \| undefined; boundary?: Boundary \| undefined; } \| undefined` | No | `-` | Configures @floating-ui shift options for Tour Step component. See https://floating-ui.com/docs/shift. |
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## Examples
|
|
33
|
+
|
|
34
|
+
### Basic usage
|
|
35
|
+
|
|
36
|
+
```jsx live
|
|
37
|
+
function Example() {
|
|
38
|
+
const [activeTourStep, setActiveTourStep] = useState(null);
|
|
39
|
+
|
|
40
|
+
const StepOne = () => {
|
|
41
|
+
const [checked, setChecked] = useState(false);
|
|
42
|
+
|
|
43
|
+
const { goNextTourStep, stopTour } = useTourContext();
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Coachmark
|
|
47
|
+
action={
|
|
48
|
+
<Button compact onClick={goNextTourStep}>
|
|
49
|
+
Next
|
|
50
|
+
</Button>
|
|
51
|
+
}
|
|
52
|
+
checkbox={
|
|
53
|
+
<Checkbox checked={checked} onChange={setChecked}>
|
|
54
|
+
Don't show again
|
|
55
|
+
</Checkbox>
|
|
56
|
+
}
|
|
57
|
+
content="Add up to 3 lines of body copy. Deliver your message with clarity and impact"
|
|
58
|
+
onClose={stopTour}
|
|
59
|
+
title="My first step"
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const StepTwo = () => {
|
|
65
|
+
const { goNextTourStep, goPreviousTourStep, stopTour } = useTourContext();
|
|
66
|
+
return (
|
|
67
|
+
<Coachmark
|
|
68
|
+
action={
|
|
69
|
+
<HStack gap={1}>
|
|
70
|
+
<Button compact onClick={goPreviousTourStep} variant="secondary">
|
|
71
|
+
Back
|
|
72
|
+
</Button>
|
|
73
|
+
<Button compact onClick={goNextTourStep}>
|
|
74
|
+
Next
|
|
75
|
+
</Button>
|
|
76
|
+
</HStack>
|
|
77
|
+
}
|
|
78
|
+
content={
|
|
79
|
+
<VStack gap={2}>
|
|
80
|
+
<TextCaption as="p" color="fgMuted">
|
|
81
|
+
50%
|
|
82
|
+
</TextCaption>
|
|
83
|
+
<ProgressBar progress={0.5} />
|
|
84
|
+
<TextBody as="p">
|
|
85
|
+
Add up to 3 lines of body copy. Deliver your message with clarity and impact
|
|
86
|
+
</TextBody>
|
|
87
|
+
</VStack>
|
|
88
|
+
}
|
|
89
|
+
media={<RemoteImage height={150} source={ethBackground} width="100%" />}
|
|
90
|
+
onClose={stopTour}
|
|
91
|
+
title="My second step"
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const StepThree = () => {
|
|
97
|
+
const { stopTour, goNextTourStep, goPreviousTourStep } = useTourContext();
|
|
98
|
+
return (
|
|
99
|
+
<Coachmark
|
|
100
|
+
action={
|
|
101
|
+
<HStack gap={1}>
|
|
102
|
+
<Button compact onClick={goPreviousTourStep} variant="secondary">
|
|
103
|
+
Back
|
|
104
|
+
</Button>
|
|
105
|
+
<Button compact onClick={stopTour}>
|
|
106
|
+
Done
|
|
107
|
+
</Button>
|
|
108
|
+
</HStack>
|
|
109
|
+
}
|
|
110
|
+
content="Add up to 3 lines of body copy. Deliver your message with clarity and impact"
|
|
111
|
+
title="My third step"
|
|
112
|
+
width={350}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const tourSteps = [
|
|
118
|
+
{
|
|
119
|
+
id: 'step1',
|
|
120
|
+
onBeforeActive: () => console.log('step1 before'),
|
|
121
|
+
Component: StepOne,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: 'step2',
|
|
125
|
+
onBeforeActive: () => console.log('step2 before'),
|
|
126
|
+
Component: StepTwo,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: 'step3',
|
|
130
|
+
onBeforeActive: () => console.log('step3 before'),
|
|
131
|
+
Component: StepThree,
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
const TourExample = ({ spacerWidthIncrement = 0, spacerHeightIncrement = 500 }) => {
|
|
136
|
+
const { startTour } = useTourContext();
|
|
137
|
+
|
|
138
|
+
const handleClick = useCallback(() => startTour(), [startTour]);
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<VStack flexGrow={1} gap={2} justifyContent="space-between">
|
|
142
|
+
<Button compact onClick={handleClick}>
|
|
143
|
+
Start tour
|
|
144
|
+
</Button>
|
|
145
|
+
<TourStep id="step1">
|
|
146
|
+
<Box background="bgAlternate" padding={4}>
|
|
147
|
+
<TextBody as="p">This is step 1</TextBody>
|
|
148
|
+
</Box>
|
|
149
|
+
</TourStep>
|
|
150
|
+
<Box height={spacerHeightIncrement} />
|
|
151
|
+
<HStack justifyContent="flex-end">
|
|
152
|
+
<Box flexShrink={0} width={spacerWidthIncrement} />
|
|
153
|
+
<TourStep id="step2">
|
|
154
|
+
<Box background="bgAlternate" padding={4} width={150}>
|
|
155
|
+
<TextBody as="p">This is step 2</TextBody>
|
|
156
|
+
</Box>
|
|
157
|
+
</TourStep>
|
|
158
|
+
</HStack>
|
|
159
|
+
<Box height={spacerHeightIncrement} />
|
|
160
|
+
<HStack>
|
|
161
|
+
<Box flexShrink={0} width={spacerWidthIncrement * 2} />
|
|
162
|
+
<TourStep id="step3">
|
|
163
|
+
<VStack background="bgAlternate" padding={4} width={150}>
|
|
164
|
+
<TextBody as="p">This is step 3</TextBody>
|
|
165
|
+
</VStack>
|
|
166
|
+
</TourStep>
|
|
167
|
+
</HStack>
|
|
168
|
+
</VStack>
|
|
169
|
+
);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<Tour activeTourStep={activeTourStep} onChange={setActiveTourStep} steps={tourSteps}>
|
|
174
|
+
<TourExample />
|
|
175
|
+
</Tour>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# Tray
|
|
2
|
+
|
|
3
|
+
An elevated container pinned to the bottom of the screen.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
import { Tray } from '@coinbase/cds-web/overlays/tray/Tray'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Required | Default | Description |
|
|
14
|
+
| --- | --- | --- | --- | --- |
|
|
15
|
+
| `onCloseComplete` | `() => void` | Yes | `-` | Action that will happen when tray is dismissed |
|
|
16
|
+
| `closeAccessibilityHint` | `string` | No | `-` | Sets an accessible hint or description for the close button. On web, maps to aria-describedby and lists the id(s) of the element(s) that describe the element on which the attribute is set. On mobile, a string that helps users understand what will happen when they perform an action on the accessibility element when that result is not clear from the accessibility label. |
|
|
17
|
+
| `closeAccessibilityLabel` | `string` | No | `-` | Sets an accessible label for the close button. On web, maps to aria-label and defines a string value that labels an interactive element. On mobile, VoiceOver will read this string when a user selects the associated element. |
|
|
18
|
+
| `focusTabIndexElements` | `boolean` | No | `false` | Allow any element with tabIndex attribute to be focusable in FocusTrap, rather than only focusing specific interactive element types like button. This can be useful when having long content in a Modal. |
|
|
19
|
+
| `footer` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Optional footer content that will be fixed to the bottom of the tray |
|
|
20
|
+
| `id` | `string` | No | `-` | HTML ID for the tray |
|
|
21
|
+
| `key` | `Key \| null` | No | `-` | - |
|
|
22
|
+
| `onBlur` | `(() => void)` | No | `-` | Callback fired when the overlay is pressed, or swipe to close |
|
|
23
|
+
| `onClose` | `(() => void)` | No | `-` | Action that will happen when tray is dismissed |
|
|
24
|
+
| `onVisibilityChange` | `((context: hidden \| visible) => void)` | No | `-` | Optional callback that, if provided, will be triggered when the Tray is toggled open/ closed If used for analytics, context (visible \| hidden) can be bundled with the event info to track whether the multiselect was toggled into or out of view |
|
|
25
|
+
| `preventDismiss` | `boolean` | No | `-` | Prevents a user from dismissing the tray by pressing the overlay or swiping |
|
|
26
|
+
| `ref` | `((instance: TrayRefProps \| null) => void) \| RefObject<TrayRefProps> \| null` | No | `-` | - |
|
|
27
|
+
| `restoreFocusOnUnmount` | `boolean` | No | `true` | If true, the focus trap will restore focus to the previously focused element when it unmounts. WARNING: If you disable this, you need to ensure that focus is restored properly so it doesnt end up on the body |
|
|
28
|
+
| `role` | `dialog \| alertdialog` | No | `-` | WAI-ARIA Roles |
|
|
29
|
+
| `title` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Text or ReactNode for optional Tray title |
|
|
30
|
+
| `verticalDrawerPercentageOfView` | `string` | No | `-` | Allow user of component to define maximum percentage of screen that can be taken up by the Drawer |
|
|
31
|
+
| `zIndex` | `number` | No | `-` | z-index for the tray overlay |
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## Examples
|
|
35
|
+
|
|
36
|
+
:::tip Accessibility tip
|
|
37
|
+
|
|
38
|
+
**Labels**
|
|
39
|
+
|
|
40
|
+
Trays require an accessibility label, which we set to `title` by default. However, if you don't want to provide a `title` or there's other text that gives the user better context to the tray, then you can pass an element id to `accessibilityLabelledBy`. Alternatively, you may directly provide a contextual label to `accessibilityLabel`.
|
|
41
|
+
|
|
42
|
+
:::
|
|
43
|
+
|
|
44
|
+
### Basic usage with Callback
|
|
45
|
+
|
|
46
|
+
The recommended way to use a `Tray` is by passing a callback as children, which receives a `handleClose` function:
|
|
47
|
+
|
|
48
|
+
```tsx live
|
|
49
|
+
function BasicTray() {
|
|
50
|
+
const [visible, setVisible] = useState(false);
|
|
51
|
+
const handleOpen = () => setVisible(true);
|
|
52
|
+
const handleClose = () => setVisible(false);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<VStack gap={2}>
|
|
56
|
+
<Button onClick={handleOpen}>Open Tray</Button>
|
|
57
|
+
{visible && (
|
|
58
|
+
<Tray title="Example Title" onCloseComplete={handleClose}>
|
|
59
|
+
{({ handleClose }) => (
|
|
60
|
+
<VStack gap={2}>
|
|
61
|
+
<Text>This is the content of the tray.</Text>
|
|
62
|
+
<Button onClick={handleClose}>Close</Button>
|
|
63
|
+
</VStack>
|
|
64
|
+
)}
|
|
65
|
+
</Tray>
|
|
66
|
+
)}
|
|
67
|
+
</VStack>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Using Ref to Control the Tray
|
|
73
|
+
|
|
74
|
+
:::tip Accessibility tip
|
|
75
|
+
|
|
76
|
+
**Trigger Focus**
|
|
77
|
+
|
|
78
|
+
A `ref` to the trigger that opens the tray, along with an `onClosedComplete` method to reset focus on the trigger when the tray closes, needs to be wired up for accessibility (see code example below).
|
|
79
|
+
|
|
80
|
+
:::
|
|
81
|
+
|
|
82
|
+
You can also control the Tray using a ref, which provides a `close()` method:
|
|
83
|
+
|
|
84
|
+
```tsx live
|
|
85
|
+
function TrayWithRef() {
|
|
86
|
+
const [visible, setVisible] = useState(false);
|
|
87
|
+
const trayRef = useRef<DrawerRefBaseProps>(null);
|
|
88
|
+
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
89
|
+
|
|
90
|
+
const handleOpen = () => setVisible(true);
|
|
91
|
+
const handleClose = () => {
|
|
92
|
+
setVisible(false);
|
|
93
|
+
triggerRef.current?.focus();
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<VStack gap={2}>
|
|
98
|
+
<Button ref={triggerRef} onClick={handleOpen}>
|
|
99
|
+
Open Tray
|
|
100
|
+
</Button>
|
|
101
|
+
{visible && (
|
|
102
|
+
<Tray ref={trayRef} title="Ref Controlled Tray" onCloseComplete={handleClose}>
|
|
103
|
+
<VStack gap={2}>
|
|
104
|
+
<Text>Control this tray using the ref.</Text>
|
|
105
|
+
<Button onClick={() => trayRef.current?.close()}>Close</Button>
|
|
106
|
+
</VStack>
|
|
107
|
+
</Tray>
|
|
108
|
+
)}
|
|
109
|
+
</VStack>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Scrollable Content
|
|
115
|
+
|
|
116
|
+
Trays with long content will automatically be scrollable.
|
|
117
|
+
|
|
118
|
+
```tsx live
|
|
119
|
+
function ScrollableTray() {
|
|
120
|
+
const [visible, setVisible] = useState(false);
|
|
121
|
+
const handleOpen = () => setVisible(true);
|
|
122
|
+
const handleClose = () => setVisible(false);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<VStack gap={2}>
|
|
126
|
+
<Button onClick={handleOpen}>Open Scrollable Tray</Button>
|
|
127
|
+
{visible && (
|
|
128
|
+
<Tray title="Scrollable Content" onCloseComplete={handleClose}>
|
|
129
|
+
{({ handleClose }) => (
|
|
130
|
+
<VStack gap={2}>
|
|
131
|
+
<VStack gap={2}>
|
|
132
|
+
<Text>
|
|
133
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor
|
|
134
|
+
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
|
|
135
|
+
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
136
|
+
</Text>
|
|
137
|
+
<Text>
|
|
138
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
|
139
|
+
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|
140
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
|
141
|
+
</Text>
|
|
142
|
+
<Text>
|
|
143
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor
|
|
144
|
+
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
|
|
145
|
+
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
146
|
+
</Text>
|
|
147
|
+
<Text>
|
|
148
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
|
149
|
+
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|
150
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
|
151
|
+
</Text>
|
|
152
|
+
<Text>
|
|
153
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor
|
|
154
|
+
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
|
|
155
|
+
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
156
|
+
</Text>
|
|
157
|
+
<Text>
|
|
158
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
|
159
|
+
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|
160
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
|
161
|
+
</Text>
|
|
162
|
+
<Text>
|
|
163
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor
|
|
164
|
+
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
|
|
165
|
+
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
166
|
+
</Text>
|
|
167
|
+
<Text>
|
|
168
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
|
169
|
+
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|
170
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
|
171
|
+
</Text>
|
|
172
|
+
<Text>
|
|
173
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor
|
|
174
|
+
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
|
|
175
|
+
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
176
|
+
</Text>
|
|
177
|
+
<Text>
|
|
178
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
|
179
|
+
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|
180
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
|
181
|
+
</Text>
|
|
182
|
+
<Text>
|
|
183
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor
|
|
184
|
+
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
|
|
185
|
+
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
186
|
+
</Text>
|
|
187
|
+
<Text>
|
|
188
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
|
189
|
+
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|
190
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
|
191
|
+
</Text>
|
|
192
|
+
</VStack>
|
|
193
|
+
<HStack justifyContent="flex-end">
|
|
194
|
+
<Button onClick={handleClose}>Close</Button>
|
|
195
|
+
</HStack>
|
|
196
|
+
</VStack>
|
|
197
|
+
)}
|
|
198
|
+
</Tray>
|
|
199
|
+
)}
|
|
200
|
+
</VStack>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Non-Dismissible Tray
|
|
206
|
+
|
|
207
|
+
Trays can be configured to prevent the user from dismissing the tray by clicking close, clicking outside, or pressing ESC.
|
|
208
|
+
|
|
209
|
+
```tsx live
|
|
210
|
+
function NonDismissibleTray() {
|
|
211
|
+
const [visible, setVisible] = useState(false);
|
|
212
|
+
const handleOpen = () => setVisible(true);
|
|
213
|
+
const handleClose = () => setVisible(false);
|
|
214
|
+
|
|
215
|
+
return (
|
|
216
|
+
<VStack gap={2}>
|
|
217
|
+
<Button onClick={handleOpen}>Open Non-Dismissible Tray</Button>
|
|
218
|
+
{visible && (
|
|
219
|
+
<Tray title="Non-Dismissible Tray" preventDismiss onCloseComplete={handleClose}>
|
|
220
|
+
{({ handleClose }) => (
|
|
221
|
+
<VStack gap={2}>
|
|
222
|
+
<Text>
|
|
223
|
+
This tray cannot be dismissed, user must click an explicit action button to close
|
|
224
|
+
it.
|
|
225
|
+
</Text>
|
|
226
|
+
<Button onClick={handleClose}>Close</Button>
|
|
227
|
+
</VStack>
|
|
228
|
+
)}
|
|
229
|
+
</Tray>
|
|
230
|
+
)}
|
|
231
|
+
</VStack>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Multiple Overlay Flow
|
|
237
|
+
|
|
238
|
+
When transitioning between overlays, ensure proper dismounting using `onCloseComplete`:
|
|
239
|
+
|
|
240
|
+
```tsx live
|
|
241
|
+
function TrayToModalFlow() {
|
|
242
|
+
const [isTrayVisible, setIsTrayVisible] = useState(false);
|
|
243
|
+
const [isModalVisible, setIsModalVisible] = useState(false);
|
|
244
|
+
|
|
245
|
+
const openTray = () => setIsTrayVisible(true);
|
|
246
|
+
const closeTray = () => setIsTrayVisible(false);
|
|
247
|
+
const openModal = () => setIsModalVisible(true);
|
|
248
|
+
const closeModal = () => setIsModalVisible(false);
|
|
249
|
+
|
|
250
|
+
const handleTrayClose = useCallback(() => {
|
|
251
|
+
closeTray();
|
|
252
|
+
openModal();
|
|
253
|
+
}, []);
|
|
254
|
+
|
|
255
|
+
return (
|
|
256
|
+
<VStack gap={2}>
|
|
257
|
+
<Button onClick={openTray}>Start Flow</Button>
|
|
258
|
+
{isTrayVisible && (
|
|
259
|
+
<Tray title="First Step" onCloseComplete={handleTrayClose}>
|
|
260
|
+
{({ handleClose }) => (
|
|
261
|
+
<VStack gap={2}>
|
|
262
|
+
<Text>Click below to continue to the modal</Text>
|
|
263
|
+
<Button onClick={handleClose}>Continue to Modal</Button>
|
|
264
|
+
</VStack>
|
|
265
|
+
)}
|
|
266
|
+
</Tray>
|
|
267
|
+
)}
|
|
268
|
+
<Modal visible={isModalVisible} onRequestClose={closeModal}>
|
|
269
|
+
<ModalHeader title="Second Step" />
|
|
270
|
+
<ModalBody>
|
|
271
|
+
<VStack gap={2}>
|
|
272
|
+
<Text>This is the second step in the flow.</Text>
|
|
273
|
+
<Button onClick={closeModal}>Finish</Button>
|
|
274
|
+
</VStack>
|
|
275
|
+
</ModalBody>
|
|
276
|
+
</Modal>
|
|
277
|
+
</VStack>
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Note: The Tray component is an elevated container that is pinned to the bottom of the screen and provides a standardized way to present bottom sheets in your web application. Key points:
|
|
283
|
+
|
|
284
|
+
- Use `onCloseComplete` for cleanup when the tray is dismissed
|
|
285
|
+
- Children can be either a React node or a render function that receives a `handleClose` function
|
|
286
|
+
- The `ref` provides `open()` and `close()` methods for controlling the tray
|
|
287
|
+
- When transitioning between overlays, ensure proper dismounting using lifecycle methods
|
|
288
|
+
|
|
289
|
+
|