@coinbase/cds-mcp-server 8.17.2 → 8.17.4
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 +8 -0
- package/mcp-docs/mobile/components/Accordion.txt +188 -0
- package/mcp-docs/mobile/components/AccordionItem.txt +29 -0
- package/mcp-docs/mobile/components/Alert.txt +155 -0
- package/mcp-docs/mobile/components/AreaChart.txt +265 -0
- package/mcp-docs/mobile/components/Avatar.txt +195 -0
- package/mcp-docs/mobile/components/AvatarButton.txt +225 -0
- package/mcp-docs/mobile/components/Banner.txt +221 -0
- package/mcp-docs/mobile/components/BarChart.txt +815 -0
- package/mcp-docs/mobile/components/Box.txt +173 -0
- package/mcp-docs/mobile/components/BrowserBar.txt +146 -0
- package/mcp-docs/mobile/components/Button.txt +198 -0
- package/mcp-docs/mobile/components/ButtonGroup.txt +79 -0
- package/mcp-docs/mobile/components/Carousel.txt +1083 -0
- package/mcp-docs/mobile/components/CartesianChart.txt +825 -0
- package/mcp-docs/mobile/components/CellMedia.txt +70 -0
- package/mcp-docs/mobile/components/Checkbox.txt +245 -0
- package/mcp-docs/mobile/components/CheckboxCell.txt +201 -0
- package/mcp-docs/mobile/components/CheckboxGroup.txt +284 -0
- package/mcp-docs/mobile/components/Chip.txt +194 -0
- package/mcp-docs/mobile/components/Coachmark.txt +157 -0
- package/mcp-docs/mobile/components/Collapsible.txt +104 -0
- package/mcp-docs/mobile/components/ContainedAssetCard.txt +134 -0
- package/mcp-docs/mobile/components/ContentCard.txt +365 -0
- package/mcp-docs/mobile/components/ContentCardBody.txt +135 -0
- package/mcp-docs/mobile/components/ContentCardFooter.txt +127 -0
- package/mcp-docs/mobile/components/ContentCardHeader.txt +145 -0
- package/mcp-docs/mobile/components/ContentCell.txt +226 -0
- package/mcp-docs/mobile/components/ControlGroup.txt +443 -0
- package/mcp-docs/mobile/components/DatePicker.txt +496 -0
- package/mcp-docs/mobile/components/Divider.txt +138 -0
- package/mcp-docs/mobile/components/DotCount.txt +145 -0
- package/mcp-docs/mobile/components/DotStatusColor.txt +58 -0
- package/mcp-docs/mobile/components/DotSymbol.txt +134 -0
- package/mcp-docs/mobile/components/Fallback.txt +157 -0
- package/mcp-docs/mobile/components/FloatingAssetCard.txt +155 -0
- package/mcp-docs/mobile/components/HStack.txt +234 -0
- package/mcp-docs/mobile/components/HeroSquare.txt +47 -0
- package/mcp-docs/mobile/components/Icon.txt +51 -0
- package/mcp-docs/mobile/components/IconButton.txt +268 -0
- package/mcp-docs/mobile/components/InputChip.txt +187 -0
- package/mcp-docs/mobile/components/Interactable.txt +186 -0
- package/mcp-docs/mobile/components/LineChart.txt +1324 -0
- package/mcp-docs/mobile/components/Link.txt +291 -0
- package/mcp-docs/mobile/components/ListCell.txt +412 -0
- package/mcp-docs/mobile/components/LogoMark.txt +84 -0
- package/mcp-docs/mobile/components/LogoWordMark.txt +93 -0
- package/mcp-docs/mobile/components/Lottie.txt +138 -0
- package/mcp-docs/mobile/components/LottieStatusAnimation.txt +46 -0
- package/mcp-docs/mobile/components/Modal.txt +83 -0
- package/mcp-docs/mobile/components/ModalBody.txt +33 -0
- package/mcp-docs/mobile/components/ModalFooter.txt +24 -0
- package/mcp-docs/mobile/components/ModalHeader.txt +27 -0
- package/mcp-docs/mobile/components/MultiContentModule.txt +379 -0
- package/mcp-docs/mobile/components/NavigationTitle.txt +131 -0
- package/mcp-docs/mobile/components/NavigationTitleSelect.txt +141 -0
- package/mcp-docs/mobile/components/NudgeCard.txt +89 -0
- package/mcp-docs/mobile/components/Numpad.txt +340 -0
- package/mcp-docs/mobile/components/Overlay.txt +151 -0
- package/mcp-docs/mobile/components/PageFooter.txt +160 -0
- package/mcp-docs/mobile/components/PageHeader.txt +185 -0
- package/mcp-docs/mobile/components/PeriodSelector.txt +407 -0
- package/mcp-docs/mobile/components/Pictogram.txt +47 -0
- package/mcp-docs/mobile/components/Point.txt +204 -0
- package/mcp-docs/mobile/components/PortalProvider.txt +78 -0
- package/mcp-docs/mobile/components/Pressable.txt +210 -0
- package/mcp-docs/mobile/components/ProgressBar.txt +129 -0
- package/mcp-docs/mobile/components/ProgressBarWithFixedLabels.txt +160 -0
- package/mcp-docs/mobile/components/ProgressBarWithFloatLabel.txt +137 -0
- package/mcp-docs/mobile/components/ProgressCircle.txt +236 -0
- package/mcp-docs/mobile/components/Radio.txt +241 -0
- package/mcp-docs/mobile/components/RadioCell.txt +201 -0
- package/mcp-docs/mobile/components/RadioGroup.txt +281 -0
- package/mcp-docs/mobile/components/ReferenceLine.txt +152 -0
- package/mcp-docs/mobile/components/RemoteImage.txt +105 -0
- package/mcp-docs/mobile/components/RemoteImageGroup.txt +60 -0
- package/mcp-docs/mobile/components/RollingNumber.txt +788 -0
- package/mcp-docs/mobile/components/Scrubber.txt +203 -0
- package/mcp-docs/mobile/components/SearchInput.txt +191 -0
- package/mcp-docs/mobile/components/SectionHeader.txt +204 -0
- package/mcp-docs/mobile/components/SegmentedTabs.txt +315 -0
- package/mcp-docs/mobile/components/Select.txt +211 -0
- package/mcp-docs/mobile/components/SelectChip.txt +323 -0
- package/mcp-docs/mobile/components/SelectOption.txt +84 -0
- package/mcp-docs/mobile/components/SlideButton.txt +330 -0
- package/mcp-docs/mobile/components/Spacer.txt +83 -0
- package/mcp-docs/mobile/components/Sparkline.txt +122 -0
- package/mcp-docs/mobile/components/SparklineGradient.txt +106 -0
- package/mcp-docs/mobile/components/SparklineInteractive.txt +156 -0
- package/mcp-docs/mobile/components/SparklineInteractiveHeader.txt +72 -0
- package/mcp-docs/mobile/components/Spinner.txt +48 -0
- package/mcp-docs/mobile/components/SpotIcon.txt +47 -0
- package/mcp-docs/mobile/components/SpotRectangle.txt +47 -0
- package/mcp-docs/mobile/components/SpotSquare.txt +47 -0
- package/mcp-docs/mobile/components/Stepper.txt +527 -0
- package/mcp-docs/mobile/components/SubBrandLogoMark.txt +125 -0
- package/mcp-docs/mobile/components/SubBrandLogoWordMark.txt +125 -0
- package/mcp-docs/mobile/components/Switch.txt +97 -0
- package/mcp-docs/mobile/components/TabIndicator.txt +48 -0
- package/mcp-docs/mobile/components/TabLabel.txt +153 -0
- package/mcp-docs/mobile/components/TabNavigation.txt +146 -0
- package/mcp-docs/mobile/components/TabbedChips.txt +142 -0
- package/mcp-docs/mobile/components/Tabs.txt +190 -0
- package/mcp-docs/mobile/components/Tag.txt +300 -0
- package/mcp-docs/mobile/components/Text.txt +211 -0
- package/mcp-docs/mobile/components/TextInput.txt +717 -0
- package/mcp-docs/mobile/components/ThemeProvider.txt +132 -0
- package/mcp-docs/mobile/components/Toast.txt +196 -0
- package/mcp-docs/mobile/components/Tooltip.txt +59 -0
- package/mcp-docs/mobile/components/TopNavBar.txt +161 -0
- package/mcp-docs/mobile/components/Tour.txt +158 -0
- package/mcp-docs/mobile/components/Tray.txt +252 -0
- package/mcp-docs/mobile/components/UpsellCard.txt +321 -0
- package/mcp-docs/mobile/components/VStack.txt +222 -0
- package/mcp-docs/mobile/components/XAxis.txt +621 -0
- package/mcp-docs/mobile/components/YAxis.txt +567 -0
- package/mcp-docs/mobile/getting-started/ai-overview.txt +108 -0
- package/mcp-docs/mobile/getting-started/installation.txt +57 -0
- package/mcp-docs/mobile/getting-started/introduction.txt +102 -0
- package/mcp-docs/mobile/getting-started/playground.txt +28 -0
- package/mcp-docs/mobile/getting-started/styling.txt +84 -0
- package/mcp-docs/mobile/getting-started/theming.txt +286 -0
- package/mcp-docs/mobile/hooks/useDimensions.txt +72 -0
- package/mcp-docs/mobile/hooks/useEventHandler.txt +120 -0
- package/mcp-docs/mobile/hooks/useMergeRefs.txt +116 -0
- package/mcp-docs/mobile/hooks/useOverlayContentContext.txt +280 -0
- package/mcp-docs/mobile/hooks/usePreviousValue.txt +74 -0
- package/mcp-docs/mobile/hooks/useRefMap.txt +178 -0
- package/mcp-docs/mobile/hooks/useTheme.txt +321 -0
- package/mcp-docs/mobile/routes.txt +139 -0
- package/mcp-docs/web/components/Accordion.txt +189 -0
- package/mcp-docs/web/components/AccordionItem.txt +31 -0
- package/mcp-docs/web/components/Alert.txt +164 -0
- package/mcp-docs/web/components/AreaChart.txt +510 -0
- package/mcp-docs/web/components/Avatar.txt +211 -0
- package/mcp-docs/web/components/AvatarButton.txt +240 -0
- package/mcp-docs/web/components/Banner.txt +226 -0
- package/mcp-docs/web/components/BarChart.txt +1267 -0
- package/mcp-docs/web/components/Box.txt +175 -0
- package/mcp-docs/web/components/Button.txt +212 -0
- package/mcp-docs/web/components/ButtonGroup.txt +79 -0
- package/mcp-docs/web/components/Calendar.txt +181 -0
- package/mcp-docs/web/components/Carousel.txt +1575 -0
- package/mcp-docs/web/components/CartesianChart.txt +1044 -0
- package/mcp-docs/web/components/CellMedia.txt +56 -0
- package/mcp-docs/web/components/Checkbox.txt +188 -0
- package/mcp-docs/web/components/CheckboxCell.txt +202 -0
- package/mcp-docs/web/components/CheckboxGroup.txt +219 -0
- package/mcp-docs/web/components/Chip.txt +196 -0
- package/mcp-docs/web/components/Coachmark.txt +188 -0
- package/mcp-docs/web/components/Collapsible.txt +119 -0
- package/mcp-docs/web/components/ContainedAssetCard.txt +232 -0
- package/mcp-docs/web/components/ContentCard.txt +367 -0
- package/mcp-docs/web/components/ContentCardBody.txt +137 -0
- package/mcp-docs/web/components/ContentCardFooter.txt +129 -0
- package/mcp-docs/web/components/ContentCardHeader.txt +147 -0
- package/mcp-docs/web/components/ContentCell.txt +219 -0
- package/mcp-docs/web/components/ControlGroup.txt +436 -0
- package/mcp-docs/web/components/DatePicker.txt +505 -0
- package/mcp-docs/web/components/Divider.txt +143 -0
- package/mcp-docs/web/components/DotCount.txt +149 -0
- package/mcp-docs/web/components/DotStatusColor.txt +58 -0
- package/mcp-docs/web/components/DotSymbol.txt +137 -0
- package/mcp-docs/web/components/Dropdown.txt +119 -0
- package/mcp-docs/web/components/Fallback.txt +163 -0
- package/mcp-docs/web/components/FloatingAssetCard.txt +250 -0
- package/mcp-docs/web/components/FullscreenAlert.txt +69 -0
- package/mcp-docs/web/components/FullscreenModal.txt +145 -0
- package/mcp-docs/web/components/FullscreenModalLayout.txt +187 -0
- package/mcp-docs/web/components/Grid.txt +236 -0
- package/mcp-docs/web/components/GridColumn.txt +209 -0
- package/mcp-docs/web/components/HStack.txt +236 -0
- package/mcp-docs/web/components/HeroSquare.txt +48 -0
- package/mcp-docs/web/components/Icon.txt +145 -0
- package/mcp-docs/web/components/IconButton.txt +390 -0
- package/mcp-docs/web/components/InputChip.txt +187 -0
- package/mcp-docs/web/components/Interactable.txt +193 -0
- package/mcp-docs/web/components/LineChart.txt +1576 -0
- package/mcp-docs/web/components/Link.txt +243 -0
- package/mcp-docs/web/components/ListCell.txt +418 -0
- package/mcp-docs/web/components/LogoMark.txt +84 -0
- package/mcp-docs/web/components/LogoWordMark.txt +93 -0
- package/mcp-docs/web/components/Lottie.txt +157 -0
- package/mcp-docs/web/components/LottieStatusAnimation.txt +57 -0
- package/mcp-docs/web/components/MediaQueryProvider.txt +108 -0
- package/mcp-docs/web/components/Modal.txt +196 -0
- package/mcp-docs/web/components/ModalBody.txt +117 -0
- package/mcp-docs/web/components/ModalFooter.txt +119 -0
- package/mcp-docs/web/components/ModalHeader.txt +123 -0
- package/mcp-docs/web/components/MultiContentModule.txt +381 -0
- package/mcp-docs/web/components/NavigationBar.txt +102 -0
- package/mcp-docs/web/components/NavigationTitle.txt +25 -0
- package/mcp-docs/web/components/NavigationTitleSelect.txt +45 -0
- package/mcp-docs/web/components/NudgeCard.txt +181 -0
- package/mcp-docs/web/components/Overlay.txt +171 -0
- package/mcp-docs/web/components/PageFooter.txt +184 -0
- package/mcp-docs/web/components/PageHeader.txt +243 -0
- package/mcp-docs/web/components/Pagination.txt +499 -0
- package/mcp-docs/web/components/PeriodSelector.txt +703 -0
- package/mcp-docs/web/components/Pictogram.txt +48 -0
- package/mcp-docs/web/components/Point.txt +460 -0
- package/mcp-docs/web/components/PortalProvider.txt +76 -0
- package/mcp-docs/web/components/Pressable.txt +193 -0
- package/mcp-docs/web/components/ProgressBar.txt +163 -0
- package/mcp-docs/web/components/ProgressBarWithFixedLabels.txt +212 -0
- package/mcp-docs/web/components/ProgressBarWithFloatLabel.txt +181 -0
- package/mcp-docs/web/components/ProgressCircle.txt +443 -0
- package/mcp-docs/web/components/Radio.txt +219 -0
- package/mcp-docs/web/components/RadioCell.txt +215 -0
- package/mcp-docs/web/components/RadioGroup.txt +288 -0
- package/mcp-docs/web/components/ReferenceLine.txt +451 -0
- package/mcp-docs/web/components/RemoteImage.txt +165 -0
- package/mcp-docs/web/components/RemoteImageGroup.txt +86 -0
- package/mcp-docs/web/components/RollingNumber.txt +1021 -0
- package/mcp-docs/web/components/Scrubber.txt +231 -0
- package/mcp-docs/web/components/SearchInput.txt +117 -0
- package/mcp-docs/web/components/SectionHeader.txt +217 -0
- package/mcp-docs/web/components/SegmentedTabs.txt +324 -0
- package/mcp-docs/web/components/Select.txt +224 -0
- package/mcp-docs/web/components/SelectChip.txt +314 -0
- package/mcp-docs/web/components/SelectOption.txt +165 -0
- package/mcp-docs/web/components/Sidebar.txt +349 -0
- package/mcp-docs/web/components/SidebarItem.txt +131 -0
- package/mcp-docs/web/components/SidebarMoreMenu.txt +30 -0
- package/mcp-docs/web/components/Spacer.txt +173 -0
- package/mcp-docs/web/components/Sparkline.txt +122 -0
- package/mcp-docs/web/components/SparklineGradient.txt +106 -0
- package/mcp-docs/web/components/SparklineInteractive.txt +153 -0
- package/mcp-docs/web/components/SparklineInteractiveHeader.txt +76 -0
- package/mcp-docs/web/components/Spinner.txt +128 -0
- package/mcp-docs/web/components/SpotIcon.txt +48 -0
- package/mcp-docs/web/components/SpotRectangle.txt +48 -0
- package/mcp-docs/web/components/SpotSquare.txt +48 -0
- package/mcp-docs/web/components/Stepper.txt +682 -0
- package/mcp-docs/web/components/SubBrandLogoMark.txt +125 -0
- package/mcp-docs/web/components/SubBrandLogoWordMark.txt +125 -0
- package/mcp-docs/web/components/Switch.txt +85 -0
- package/mcp-docs/web/components/TabIndicator.txt +48 -0
- package/mcp-docs/web/components/TabLabel.txt +158 -0
- package/mcp-docs/web/components/TabNavigation.txt +159 -0
- package/mcp-docs/web/components/TabbedChips.txt +155 -0
- package/mcp-docs/web/components/Table.txt +367 -0
- package/mcp-docs/web/components/TableBody.txt +83 -0
- package/mcp-docs/web/components/TableCaption.txt +102 -0
- package/mcp-docs/web/components/TableCell.txt +165 -0
- package/mcp-docs/web/components/TableCellFallback.txt +97 -0
- package/mcp-docs/web/components/TableFooter.txt +83 -0
- package/mcp-docs/web/components/TableHeader.txt +100 -0
- package/mcp-docs/web/components/TableRow.txt +140 -0
- package/mcp-docs/web/components/Tabs.txt +212 -0
- package/mcp-docs/web/components/Tag.txt +304 -0
- package/mcp-docs/web/components/Text.txt +232 -0
- package/mcp-docs/web/components/TextInput.txt +652 -0
- package/mcp-docs/web/components/ThemeProvider.txt +199 -0
- package/mcp-docs/web/components/TileButton.txt +158 -0
- package/mcp-docs/web/components/Toast.txt +203 -0
- package/mcp-docs/web/components/Tooltip.txt +89 -0
- package/mcp-docs/web/components/Tour.txt +179 -0
- package/mcp-docs/web/components/Tray.txt +288 -0
- package/mcp-docs/web/components/UpsellCard.txt +319 -0
- package/mcp-docs/web/components/VStack.txt +224 -0
- package/mcp-docs/web/components/XAxis.txt +619 -0
- package/mcp-docs/web/components/YAxis.txt +548 -0
- package/mcp-docs/web/getting-started/ai-overview.txt +108 -0
- package/mcp-docs/web/getting-started/installation.txt +103 -0
- package/mcp-docs/web/getting-started/introduction.txt +102 -0
- package/mcp-docs/web/getting-started/playground.txt +28 -0
- package/mcp-docs/web/getting-started/styling.txt +161 -0
- package/mcp-docs/web/getting-started/templates.txt +121 -0
- package/mcp-docs/web/getting-started/theming.txt +426 -0
- package/mcp-docs/web/hooks/useBreakpoints.txt +61 -0
- package/mcp-docs/web/hooks/useDimensions.txt +114 -0
- package/mcp-docs/web/hooks/useEventHandler.txt +120 -0
- package/mcp-docs/web/hooks/useHasMounted.txt +75 -0
- package/mcp-docs/web/hooks/useIsoEffect.txt +58 -0
- package/mcp-docs/web/hooks/useMediaQuery.txt +114 -0
- package/mcp-docs/web/hooks/useMergeRefs.txt +116 -0
- package/mcp-docs/web/hooks/useOverlayContentContext.txt +279 -0
- package/mcp-docs/web/hooks/usePreviousValue.txt +74 -0
- package/mcp-docs/web/hooks/useRefMap.txt +178 -0
- package/mcp-docs/web/hooks/useScrollBlocker.txt +82 -0
- package/mcp-docs/web/hooks/useTheme.txt +364 -0
- package/mcp-docs/web/routes.txt +163 -0
- package/package.json +1 -1
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
# useOverlayContentContext
|
|
2
|
+
|
|
3
|
+
A React context and hook for detecting if components are rendered inside overlay containers like modals, drawers, tours, and trays.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { OverlayContentContext, useOverlayContentContext } from '@coinbase/cds-common/overlays/OverlayContentContext'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## API
|
|
12
|
+
|
|
13
|
+
### Parameters
|
|
14
|
+
|
|
15
|
+
The `useOverlayContentContext` hook accepts no parameters.
|
|
16
|
+
|
|
17
|
+
### Returns
|
|
18
|
+
|
|
19
|
+
Returns an `OverlayContentContextValue` object with overlay state information:
|
|
20
|
+
|
|
21
|
+
- `isOverlay?: boolean` - True if inside any overlay component (automatically derived from other values if not explicitly set)
|
|
22
|
+
- `isModal?: boolean` - True if inside a Modal component
|
|
23
|
+
- `isDrawer?: boolean` - True if inside a Drawer or Tray component
|
|
24
|
+
- `isTour?: boolean` - True if inside a Tour component
|
|
25
|
+
|
|
26
|
+
All properties are optional and will be `undefined` when outside of overlay contexts.
|
|
27
|
+
|
|
28
|
+
:::tip
|
|
29
|
+
This hook is safe to use anywhere in your component tree - it does not throw an error when used outside a provider. When `isOverlay` is not explicitly provided, it will be automatically derived as `true` if any of the other overlay type flags are `true`.
|
|
30
|
+
:::
|
|
31
|
+
|
|
32
|
+
### OverlayContentContext
|
|
33
|
+
|
|
34
|
+
The React context that provides overlay state information. Can be used directly with `React.useContext` or through the `useOverlayContentContext` hook.
|
|
35
|
+
|
|
36
|
+
#### Context Value Type
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
type OverlayContentContextValue = {
|
|
40
|
+
isOverlay?: boolean;
|
|
41
|
+
isModal?: boolean;
|
|
42
|
+
isDrawer?: boolean;
|
|
43
|
+
isTour?: boolean;
|
|
44
|
+
};
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Provider Usage
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
import { OverlayContentContext } from '@coinbase/cds-common/overlays/OverlayContentContext';
|
|
51
|
+
|
|
52
|
+
function MyOverlayComponent() {
|
|
53
|
+
const contextValue = {
|
|
54
|
+
isModal: true,
|
|
55
|
+
isDrawer: false,
|
|
56
|
+
isTour: false,
|
|
57
|
+
// isOverlay will be automatically derived as true
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<OverlayContentContext.Provider value={contextValue}>
|
|
62
|
+
{/* Your overlay content */}
|
|
63
|
+
</OverlayContentContext.Provider>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Automatic Derivation
|
|
69
|
+
|
|
70
|
+
If `isOverlay` is not explicitly provided in the context value, it will be automatically derived as `true` when any of `isModal`, `isDrawer`, or `isTour` is `true`. This ensures consistent behavior across the system.
|
|
71
|
+
|
|
72
|
+
**Important**: When adding new overlay types to the `OverlayContentContextValue` type, remember to update the derivation logic in the `useOverlayContentContext` hook.
|
|
73
|
+
|
|
74
|
+
## Examples
|
|
75
|
+
|
|
76
|
+
The `useOverlayContentContext` hook provides information about whether a component is rendered inside various types of overlay containers. This is useful for conditional rendering and styling based on the overlay context.
|
|
77
|
+
|
|
78
|
+
### Basic usage
|
|
79
|
+
|
|
80
|
+
```tsx live
|
|
81
|
+
function ExampleComponent() {
|
|
82
|
+
const { isOverlay, isModal, isDrawer, isTour } = useOverlayContentContext();
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<VStack gap={2}>
|
|
86
|
+
<TextHeadline>Overlay Context Information</TextHeadline>
|
|
87
|
+
<Text>Is inside any overlay: {isOverlay ? 'Yes' : 'No'}</Text>
|
|
88
|
+
<Text>Is inside modal: {isModal ? 'Yes' : 'No'}</Text>
|
|
89
|
+
<Text>Is inside drawer/tray: {isDrawer ? 'Yes' : 'No'}</Text>
|
|
90
|
+
<Text>Is inside tour: {isTour ? 'Yes' : 'No'}</Text>
|
|
91
|
+
</VStack>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Real Modal Example
|
|
97
|
+
|
|
98
|
+
Click the button below to open a modal and see how the hook behaves inside vs outside:
|
|
99
|
+
|
|
100
|
+
```tsx live
|
|
101
|
+
function ModalExample() {
|
|
102
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
103
|
+
|
|
104
|
+
const ExampleComponent = () => {
|
|
105
|
+
const { isOverlay, isModal, isDrawer, isTour } = useOverlayContentContext();
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<VStack gap={2}>
|
|
109
|
+
<TextHeadline>Overlay Context Information</TextHeadline>
|
|
110
|
+
<Text>Is inside any overlay: {isOverlay ? 'Yes' : 'No'}</Text>
|
|
111
|
+
<Text>Is inside modal: {isModal ? 'Yes' : 'No'}</Text>
|
|
112
|
+
<Text>Is inside drawer/tray: {isDrawer ? 'Yes' : 'No'}</Text>
|
|
113
|
+
<Text>Is inside tour: {isTour ? 'Yes' : 'No'}</Text>
|
|
114
|
+
</VStack>
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<VStack gap={3}>
|
|
120
|
+
<VStack gap={2} padding={3} background="bgSecondary" borderRadius={400}>
|
|
121
|
+
<TextHeadline>Outside Modal</TextHeadline>
|
|
122
|
+
<ExampleComponent />
|
|
123
|
+
</VStack>
|
|
124
|
+
|
|
125
|
+
<Button onClick={() => setIsModalOpen(true)}>Open Modal</Button>
|
|
126
|
+
|
|
127
|
+
<Modal visible={isModalOpen} onRequestClose={() => setIsModalOpen(false)}>
|
|
128
|
+
<ModalHeader closeAccessibilityLabel="Close" title="Modal with Context Hook" />
|
|
129
|
+
<ModalBody>
|
|
130
|
+
<VStack gap={3}>
|
|
131
|
+
<Text>
|
|
132
|
+
This content is rendered inside a modal. Notice how the context values change:
|
|
133
|
+
</Text>
|
|
134
|
+
<VStack gap={2} padding={3} background="bgAlternate" borderRadius={400}>
|
|
135
|
+
<ExampleComponent />
|
|
136
|
+
</VStack>
|
|
137
|
+
<Text color="fgMuted" font="caption">
|
|
138
|
+
The hook automatically detects it's inside a modal context!
|
|
139
|
+
</Text>
|
|
140
|
+
</VStack>
|
|
141
|
+
</ModalBody>
|
|
142
|
+
</Modal>
|
|
143
|
+
</VStack>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Using the Context Provider
|
|
149
|
+
|
|
150
|
+
You can also use the `OverlayContentContext` directly to provide context values:
|
|
151
|
+
|
|
152
|
+
```tsx live
|
|
153
|
+
function ContextProviderExample() {
|
|
154
|
+
const ExampleComponent = () => {
|
|
155
|
+
const { isOverlay, isModal, isDrawer, isTour } = useOverlayContentContext();
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
<VStack gap={2}>
|
|
159
|
+
<TextHeadline>Overlay Context Information</TextHeadline>
|
|
160
|
+
<Text>Is inside any overlay: {isOverlay ? 'Yes' : 'No'}</Text>
|
|
161
|
+
<Text>Is inside modal: {isModal ? 'Yes' : 'No'}</Text>
|
|
162
|
+
<Text>Is inside drawer/tray: {isDrawer ? 'Yes' : 'No'}</Text>
|
|
163
|
+
<Text>Is inside tour: {isTour ? 'Yes' : 'No'}</Text>
|
|
164
|
+
</VStack>
|
|
165
|
+
);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const contextValue = {
|
|
169
|
+
isModal: true,
|
|
170
|
+
isDrawer: false,
|
|
171
|
+
isTour: false,
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<OverlayContentContext.Provider value={contextValue}>
|
|
176
|
+
<VStack gap={2} padding={3} background="bgSecondary" borderRadius={400}>
|
|
177
|
+
<TextHeadline>Inside Context Provider</TextHeadline>
|
|
178
|
+
<ExampleComponent />
|
|
179
|
+
</VStack>
|
|
180
|
+
</OverlayContentContext.Provider>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Conditional Rendering
|
|
186
|
+
|
|
187
|
+
Use the hook to conditionally render content based on overlay context:
|
|
188
|
+
|
|
189
|
+
```tsx live
|
|
190
|
+
function ConditionalRenderingExample() {
|
|
191
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
192
|
+
|
|
193
|
+
const ConditionalContent = () => {
|
|
194
|
+
const { isOverlay, isModal } = useOverlayContentContext();
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
<VStack gap={2}>
|
|
198
|
+
<TextHeadline>Conditional Content</TextHeadline>
|
|
199
|
+
{isOverlay ? (
|
|
200
|
+
<VStack gap={1}>
|
|
201
|
+
<Text color="fgPositive">✓ This content shows when inside an overlay</Text>
|
|
202
|
+
{isModal && <Text color="fgPrimary">🎯 Specifically inside a modal!</Text>}
|
|
203
|
+
</VStack>
|
|
204
|
+
) : (
|
|
205
|
+
<Text color="fgMuted">This content shows when not in an overlay</Text>
|
|
206
|
+
)}
|
|
207
|
+
</VStack>
|
|
208
|
+
);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<VStack gap={3}>
|
|
213
|
+
<VStack gap={2} padding={3} background="bgSecondary" borderRadius={400}>
|
|
214
|
+
<TextHeadline>Outside Modal</TextHeadline>
|
|
215
|
+
<ConditionalContent />
|
|
216
|
+
</VStack>
|
|
217
|
+
|
|
218
|
+
<Button onClick={() => setIsModalOpen(true)}>Open Modal</Button>
|
|
219
|
+
|
|
220
|
+
<Modal visible={isModalOpen} onRequestClose={() => setIsModalOpen(false)}>
|
|
221
|
+
<ModalHeader closeAccessibilityLabel="Close" title="Conditional Content Demo" />
|
|
222
|
+
<ModalBody>
|
|
223
|
+
<ConditionalContent />
|
|
224
|
+
</ModalBody>
|
|
225
|
+
</Modal>
|
|
226
|
+
</VStack>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Styling Based on Context
|
|
232
|
+
|
|
233
|
+
```tsx live
|
|
234
|
+
function StylingExample() {
|
|
235
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
236
|
+
|
|
237
|
+
const StyledContent = () => {
|
|
238
|
+
const { isModal, isDrawer } = useOverlayContentContext();
|
|
239
|
+
|
|
240
|
+
const getBackgroundColor = () => {
|
|
241
|
+
if (isModal) return 'bgPrimaryWash';
|
|
242
|
+
if (isDrawer) return 'bgSecondaryWash';
|
|
243
|
+
return 'bgAlternate';
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const getStatusText = () => {
|
|
247
|
+
if (isModal) return 'Modal styling applied! 🎉';
|
|
248
|
+
if (isDrawer) return 'Drawer styling applied!';
|
|
249
|
+
return 'Default styling';
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
return (
|
|
253
|
+
<VStack padding={3} background={getBackgroundColor()} borderRadius={400} gap={2}>
|
|
254
|
+
<TextHeadline>Dynamic Styling</TextHeadline>
|
|
255
|
+
<Text>{getStatusText()}</Text>
|
|
256
|
+
<Text color="fgMuted" font="caption">
|
|
257
|
+
Background color: {getBackgroundColor()}
|
|
258
|
+
</Text>
|
|
259
|
+
</VStack>
|
|
260
|
+
);
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
return (
|
|
264
|
+
<VStack gap={3}>
|
|
265
|
+
<StyledContent />
|
|
266
|
+
|
|
267
|
+
<Button onClick={() => setIsModalOpen(true)}>Open Modal</Button>
|
|
268
|
+
|
|
269
|
+
<Modal visible={isModalOpen} onRequestClose={() => setIsModalOpen(false)}>
|
|
270
|
+
<ModalHeader closeAccessibilityLabel="Close" title="Dynamic Styling Demo" />
|
|
271
|
+
<ModalBody>
|
|
272
|
+
<StyledContent />
|
|
273
|
+
</ModalBody>
|
|
274
|
+
</Modal>
|
|
275
|
+
</VStack>
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# usePreviousValue
|
|
2
|
+
|
|
3
|
+
Returns the previous value of a given variable, useful for comparing current and previous states in effects or for tracking changes over time.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { usePreviousValue } from '@coinbase/cds-common/hooks/usePreviousValue'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## API
|
|
12
|
+
|
|
13
|
+
### Parameters
|
|
14
|
+
|
|
15
|
+
The `usePreviousValue` hook accepts a single parameter:
|
|
16
|
+
|
|
17
|
+
- `value: T` - The value to track. Can be of any type.
|
|
18
|
+
|
|
19
|
+
### Returns
|
|
20
|
+
|
|
21
|
+
Returns the previous value of type `T | undefined`:
|
|
22
|
+
|
|
23
|
+
- Returns `undefined` on the first render
|
|
24
|
+
- Returns the previous value of the tracked value on subsequent renders
|
|
25
|
+
|
|
26
|
+
:::tip
|
|
27
|
+
This hook is useful for comparing the current value with its previous state, such as in animations, transitions, or when you need to react to value changes. The hook uses a ref to store the previous value, ensuring it persists between renders.
|
|
28
|
+
:::
|
|
29
|
+
|
|
30
|
+
## Examples
|
|
31
|
+
|
|
32
|
+
### Basic usage
|
|
33
|
+
|
|
34
|
+
```tsx live
|
|
35
|
+
function Example() {
|
|
36
|
+
const [count, setCount] = useState(0);
|
|
37
|
+
const previousCount = usePreviousValue(count);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<VStack gap={3} alignItems="start">
|
|
41
|
+
<VStack gap={1}>
|
|
42
|
+
<TextHeadline>Current count: {count}</TextHeadline>
|
|
43
|
+
<TextHeadline>Previous count: {previousCount ?? 'None'}</TextHeadline>
|
|
44
|
+
</VStack>
|
|
45
|
+
<Button onClick={() => setCount(count + 1)}>Increment</Button>
|
|
46
|
+
</VStack>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### With Complex Values
|
|
52
|
+
|
|
53
|
+
```tsx live
|
|
54
|
+
function Example() {
|
|
55
|
+
const [user, setUser] = useState({ name: 'John', age: 25 });
|
|
56
|
+
const previousUser = usePreviousValue(user);
|
|
57
|
+
|
|
58
|
+
const updateAge = () => {
|
|
59
|
+
setUser((prev) => ({ ...prev, age: prev.age + 1 }));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<VStack gap={3} alignItems="start">
|
|
64
|
+
<VStack gap={1}>
|
|
65
|
+
<TextHeadline>Name: {user.name}</TextHeadline>
|
|
66
|
+
<TextHeadline>Age: {user.age}</TextHeadline>
|
|
67
|
+
<TextHeadline>Previous age: {previousUser?.age ?? 'None'}</TextHeadline>
|
|
68
|
+
</VStack>
|
|
69
|
+
<Button onClick={updateAge}>Add Year</Button>
|
|
70
|
+
</VStack>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# useRefMap
|
|
2
|
+
|
|
3
|
+
Manages a collection of refs using a key-value map structure, allowing dynamic registration and retrieval of refs by their unique identifiers. Commonly used in components that need to track multiple DOM elements, such as tabs, tours, or complex navigation systems.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { useRefMap } from '@coinbase/cds-common/hooks/useRefMap'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## API
|
|
12
|
+
|
|
13
|
+
### Parameters
|
|
14
|
+
|
|
15
|
+
The `useRefMap` hook accepts an optional configuration object:
|
|
16
|
+
|
|
17
|
+
- `options?: RefMapOptions<RefValue>` - Configuration options for the ref map
|
|
18
|
+
- `initialRefMap?: Record<string, RefValue>` - Optional initial map of refs
|
|
19
|
+
|
|
20
|
+
The generic type `RefValue` represents the type of values stored in the ref map (typically `HTMLElement` or a specific element type).
|
|
21
|
+
|
|
22
|
+
### Returns
|
|
23
|
+
|
|
24
|
+
Returns a `RefMapApi<RefValue>` object with the following properties:
|
|
25
|
+
|
|
26
|
+
- `refs: Record<string, RefValue>` - The current map of all registered refs
|
|
27
|
+
- `getRef: (id: string) => RefValue | null` - Function to retrieve a ref by its ID
|
|
28
|
+
- `registerRef: (id: string, ref: RefValue) => void` - Function to register a new ref with an ID
|
|
29
|
+
|
|
30
|
+
:::tip
|
|
31
|
+
This hook is particularly useful when working with components that need to manage multiple refs, such as in tour guides where elements need to be highlighted, or in tab systems where tab panels need to be referenced. The hook maintains a stable reference to the ref map and its utility functions across renders.
|
|
32
|
+
:::
|
|
33
|
+
|
|
34
|
+
## Examples
|
|
35
|
+
|
|
36
|
+
### Basic usage
|
|
37
|
+
|
|
38
|
+
```tsx live
|
|
39
|
+
function Example() {
|
|
40
|
+
const { registerRef, getRef } = useRefMap<HTMLDivElement>();
|
|
41
|
+
const toast = useToast();
|
|
42
|
+
|
|
43
|
+
const handleClick = () => {
|
|
44
|
+
// Get the element by its ID and log its dimensions
|
|
45
|
+
const element = getRef('box1');
|
|
46
|
+
if (element) {
|
|
47
|
+
toast.show(`Box dimensions: ${element.offsetWidth}x${element.offsetHeight}`);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<VStack gap={2}>
|
|
53
|
+
<Box
|
|
54
|
+
ref={(el) => el && registerRef('box1', el)}
|
|
55
|
+
padding={3}
|
|
56
|
+
background="bgAlternate"
|
|
57
|
+
borderRadius={300}
|
|
58
|
+
>
|
|
59
|
+
<TextBody>This box is registered with ID 'box1'</TextBody>
|
|
60
|
+
</Box>
|
|
61
|
+
<Button onClick={handleClick}>Get Box Dimensions</Button>
|
|
62
|
+
</VStack>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### With Multiple Elements
|
|
68
|
+
|
|
69
|
+
```tsx live
|
|
70
|
+
function Example() {
|
|
71
|
+
const { registerRef, getRef } = useRefMap<HTMLDivElement>();
|
|
72
|
+
const [activeId, setActiveId] = useState<string | null>(null);
|
|
73
|
+
|
|
74
|
+
const highlightElement = (id: string) => {
|
|
75
|
+
// Reset previous highlight
|
|
76
|
+
if (activeId) {
|
|
77
|
+
const prevElement = getRef(activeId);
|
|
78
|
+
if (prevElement) {
|
|
79
|
+
prevElement.style.outline = 'none';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Highlight new element
|
|
84
|
+
const element = getRef(id);
|
|
85
|
+
if (element) {
|
|
86
|
+
element.style.outline = '2px solid var(--color-fgPrimary)';
|
|
87
|
+
setActiveId(id);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<VStack gap={3}>
|
|
93
|
+
<HStack gap={2}>
|
|
94
|
+
<Button onClick={() => highlightElement('box1')}>Highlight Box 1</Button>
|
|
95
|
+
<Button onClick={() => highlightElement('box2')}>Highlight Box 2</Button>
|
|
96
|
+
<Button onClick={() => highlightElement('box3')}>Highlight Box 3</Button>
|
|
97
|
+
</HStack>
|
|
98
|
+
|
|
99
|
+
<VStack gap={2}>
|
|
100
|
+
<Box
|
|
101
|
+
ref={(el) => el && registerRef('box1', el)}
|
|
102
|
+
padding={3}
|
|
103
|
+
background="bgAlternate"
|
|
104
|
+
borderRadius={300}
|
|
105
|
+
>
|
|
106
|
+
<TextBody>Box 1</TextBody>
|
|
107
|
+
</Box>
|
|
108
|
+
|
|
109
|
+
<Box
|
|
110
|
+
ref={(el) => el && registerRef('box2', el)}
|
|
111
|
+
padding={3}
|
|
112
|
+
background="bgAlternate"
|
|
113
|
+
borderRadius={300}
|
|
114
|
+
>
|
|
115
|
+
<TextBody>Box 2</TextBody>
|
|
116
|
+
</Box>
|
|
117
|
+
|
|
118
|
+
<Box
|
|
119
|
+
ref={(el) => el && registerRef('box3', el)}
|
|
120
|
+
padding={3}
|
|
121
|
+
background="bgAlternate"
|
|
122
|
+
borderRadius={300}
|
|
123
|
+
>
|
|
124
|
+
<TextBody>Box 3</TextBody>
|
|
125
|
+
</Box>
|
|
126
|
+
</VStack>
|
|
127
|
+
</VStack>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### With Initial Refs
|
|
133
|
+
|
|
134
|
+
```tsx live
|
|
135
|
+
function Example() {
|
|
136
|
+
// Create initial refs map
|
|
137
|
+
const box1Ref = useRef<HTMLDivElement>(null);
|
|
138
|
+
const box2Ref = useRef<HTMLDivElement>(null);
|
|
139
|
+
|
|
140
|
+
const initialRefs = {
|
|
141
|
+
box1: box1Ref.current,
|
|
142
|
+
box2: box2Ref.current,
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const { refs, registerRef } = useRefMap<HTMLDivElement>({
|
|
146
|
+
initialRefMap: initialRefs,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const logRefs = () => {
|
|
150
|
+
console.log('Current refs:', refs);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<VStack gap={2}>
|
|
155
|
+
<Box
|
|
156
|
+
ref={(el) => el && registerRef('box1', el)}
|
|
157
|
+
padding={3}
|
|
158
|
+
background="bgAlternate"
|
|
159
|
+
borderRadius={300}
|
|
160
|
+
>
|
|
161
|
+
<TextBody>Box 1</TextBody>
|
|
162
|
+
</Box>
|
|
163
|
+
|
|
164
|
+
<Box
|
|
165
|
+
ref={(el) => el && registerRef('box2', el)}
|
|
166
|
+
padding={3}
|
|
167
|
+
background="bgAlternate"
|
|
168
|
+
borderRadius={300}
|
|
169
|
+
>
|
|
170
|
+
<TextBody>Box 2</TextBody>
|
|
171
|
+
</Box>
|
|
172
|
+
|
|
173
|
+
<Button onClick={logRefs}>Log Refs</Button>
|
|
174
|
+
</VStack>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# useScrollBlocker
|
|
2
|
+
|
|
3
|
+
Block and unblock page scrolling.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { useScrollBlocker } from '@coinbase/cds-web/hooks/useScrollBlocker'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## API
|
|
12
|
+
|
|
13
|
+
### Parameters
|
|
14
|
+
|
|
15
|
+
The `useScrollBlocker` hook does not accept any parameters.
|
|
16
|
+
|
|
17
|
+
### Returns
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
type Return = (shouldBlock: boolean) => void;
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Returns a function that takes a boolean parameter to control scroll blocking:
|
|
24
|
+
|
|
25
|
+
- `shouldBlock`: When `true`, blocks page scrolling. When `false`, re-enables scrolling.
|
|
26
|
+
|
|
27
|
+
:::tip
|
|
28
|
+
This hook is useful for temporarily disabling page scrolling, such as when displaying modals or overlays. It automatically handles scroll bar width compensation to prevent layout shifts.
|
|
29
|
+
:::
|
|
30
|
+
|
|
31
|
+
## Examples
|
|
32
|
+
|
|
33
|
+
### Basic usage
|
|
34
|
+
|
|
35
|
+
```tsx live
|
|
36
|
+
function Example() {
|
|
37
|
+
const blockScroll = useScrollBlocker();
|
|
38
|
+
const [isBlocked, setIsBlocked] = useState(false);
|
|
39
|
+
|
|
40
|
+
const toggleScroll = () => {
|
|
41
|
+
setIsBlocked(!isBlocked);
|
|
42
|
+
blockScroll(!isBlocked);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<VStack gap={3} alignItems="start">
|
|
47
|
+
<TextHeadline>Scroll is currently {isBlocked ? 'blocked' : 'enabled'}</TextHeadline>
|
|
48
|
+
<Button onClick={toggleScroll}>{isBlocked ? 'Enable Scroll' : 'Block Scroll'}</Button>
|
|
49
|
+
</VStack>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### With Overlay
|
|
55
|
+
|
|
56
|
+
```tsx live
|
|
57
|
+
function Example() {
|
|
58
|
+
const blockScroll = useScrollBlocker();
|
|
59
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
60
|
+
|
|
61
|
+
const openModal = () => {
|
|
62
|
+
setIsOpen(true);
|
|
63
|
+
blockScroll(true);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const closeModal = () => {
|
|
67
|
+
setIsOpen(false);
|
|
68
|
+
blockScroll(false);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<VStack gap={3} alignItems="start">
|
|
73
|
+
<Button onClick={openModal}>Open Overlay</Button>
|
|
74
|
+
<Modal visible={isOpen} onRequestClose={closeModal}>
|
|
75
|
+
<ModalHeader title="Modal Title" />
|
|
76
|
+
<ModalBody>Modal Content</ModalBody>
|
|
77
|
+
</Modal>
|
|
78
|
+
</VStack>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|