@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,1576 @@
|
|
|
1
|
+
# Carousel
|
|
2
|
+
|
|
3
|
+
A flexible carousel component for displaying sequences of content with navigation and pagination options.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
import { Carousel } from '@coinbase/cds-web/carousel/Carousel'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Required | Default | Description |
|
|
14
|
+
| --- | --- | --- | --- | --- |
|
|
15
|
+
| `NavigationComponent` | `CarouselNavigationComponent` | No | `DefaultCarouselNavigation` | Custom component to render navigation arrows. |
|
|
16
|
+
| `PaginationComponent` | `CarouselPaginationComponent` | No | `DefaultCarouselPagination` | Custom component to render pagination indicators. |
|
|
17
|
+
| `alignContent` | `ResponsiveProp<center \| normal \| start \| end \| flex-start \| flex-end \| stretch \| baseline \| first baseline \| last baseline \| space-between \| space-around \| space-evenly>` | No | `-` | - |
|
|
18
|
+
| `alignItems` | `ResponsiveProp<center \| normal \| start \| end \| flex-start \| flex-end \| self-start \| self-end \| stretch \| baseline \| first baseline \| last baseline>` | No | `-` | - |
|
|
19
|
+
| `alignSelf` | `ResponsiveProp<center \| normal \| auto \| start \| end \| flex-start \| flex-end \| self-start \| self-end \| stretch \| baseline \| first baseline \| last baseline>` | No | `-` | - |
|
|
20
|
+
| `as` | `div` | No | `-` | - |
|
|
21
|
+
| `aspectRatio` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset \| auto` | No | `-` | - |
|
|
22
|
+
| `background` | `currentColor \| fg \| fgMuted \| fgInverse \| fgPrimary \| fgWarning \| fgPositive \| fgNegative \| bg \| bgAlternate \| bgInverse \| bgOverlay \| bgElevation1 \| bgElevation2 \| bgPrimary \| bgPrimaryWash \| bgSecondary \| bgTertiary \| bgSecondaryWash \| bgNegative \| bgNegativeWash \| bgPositive \| bgPositiveWash \| bgWarning \| bgWarningWash \| bgLine \| bgLineHeavy \| bgLineInverse \| bgLinePrimary \| bgLinePrimarySubtle \| accentSubtleRed \| accentBoldRed \| accentSubtleGreen \| accentBoldGreen \| accentSubtleBlue \| accentBoldBlue \| accentSubtlePurple \| accentBoldPurple \| accentSubtleYellow \| accentBoldYellow \| accentSubtleGray \| accentBoldGray \| transparent` | No | `-` | - |
|
|
23
|
+
| `borderBottomLeftRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `-` | - |
|
|
24
|
+
| `borderBottomRightRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `-` | - |
|
|
25
|
+
| `borderBottomWidth` | `0 \| 100 \| 200 \| 300 \| 400 \| 500` | No | `-` | - |
|
|
26
|
+
| `borderColor` | `currentColor \| fg \| fgMuted \| fgInverse \| fgPrimary \| fgWarning \| fgPositive \| fgNegative \| bg \| bgAlternate \| bgInverse \| bgOverlay \| bgElevation1 \| bgElevation2 \| bgPrimary \| bgPrimaryWash \| bgSecondary \| bgTertiary \| bgSecondaryWash \| bgNegative \| bgNegativeWash \| bgPositive \| bgPositiveWash \| bgWarning \| bgWarningWash \| bgLine \| bgLineHeavy \| bgLineInverse \| bgLinePrimary \| bgLinePrimarySubtle \| accentSubtleRed \| accentBoldRed \| accentSubtleGreen \| accentBoldGreen \| accentSubtleBlue \| accentBoldBlue \| accentSubtlePurple \| accentBoldPurple \| accentSubtleYellow \| accentBoldYellow \| accentSubtleGray \| accentBoldGray \| transparent` | No | `-` | - |
|
|
27
|
+
| `borderEndWidth` | `0 \| 100 \| 200 \| 300 \| 400 \| 500` | No | `-` | - |
|
|
28
|
+
| `borderRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `-` | - |
|
|
29
|
+
| `borderStartWidth` | `0 \| 100 \| 200 \| 300 \| 400 \| 500` | No | `-` | - |
|
|
30
|
+
| `borderTopLeftRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `-` | - |
|
|
31
|
+
| `borderTopRightRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `-` | - |
|
|
32
|
+
| `borderTopWidth` | `0 \| 100 \| 200 \| 300 \| 400 \| 500` | No | `-` | - |
|
|
33
|
+
| `borderWidth` | `0 \| 100 \| 200 \| 300 \| 400 \| 500` | No | `-` | - |
|
|
34
|
+
| `bordered` | `boolean` | No | `-` | Add a border around all sides of the box. |
|
|
35
|
+
| `borderedBottom` | `boolean` | No | `-` | Add a border to the bottom side of the box. |
|
|
36
|
+
| `borderedEnd` | `boolean` | No | `-` | Add a border to the trailing side of the box. |
|
|
37
|
+
| `borderedHorizontal` | `boolean` | No | `-` | Add a border to the leading and trailing sides of the box. |
|
|
38
|
+
| `borderedStart` | `boolean` | No | `-` | Add a border to the leading side of the box. |
|
|
39
|
+
| `borderedTop` | `boolean` | No | `-` | Add a border to the top side of the box. |
|
|
40
|
+
| `borderedVertical` | `boolean` | No | `-` | Add a border to the top and bottom sides of the box. |
|
|
41
|
+
| `bottom` | `ResponsiveProp<Bottom<string \| number>>` | No | `-` | - |
|
|
42
|
+
| `classNames` | `{ root?: string; title?: string \| undefined; navigation?: string \| undefined; pagination?: string \| undefined; carousel?: string \| undefined; carouselContainer?: string \| undefined; } \| undefined` | No | `-` | Custom class names for the component. |
|
|
43
|
+
| `color` | `currentColor \| fg \| fgMuted \| fgInverse \| fgPrimary \| fgWarning \| fgPositive \| fgNegative \| bg \| bgAlternate \| bgInverse \| bgOverlay \| bgElevation1 \| bgElevation2 \| bgPrimary \| bgPrimaryWash \| bgSecondary \| bgTertiary \| bgSecondaryWash \| bgNegative \| bgNegativeWash \| bgPositive \| bgPositiveWash \| bgWarning \| bgWarningWash \| bgLine \| bgLineHeavy \| bgLineInverse \| bgLinePrimary \| bgLinePrimarySubtle \| accentSubtleRed \| accentBoldRed \| accentSubtleGreen \| accentBoldGreen \| accentSubtleBlue \| accentBoldBlue \| accentSubtlePurple \| accentBoldPurple \| accentSubtleYellow \| accentBoldYellow \| accentSubtleGray \| accentBoldGray \| transparent` | No | `-` | - |
|
|
44
|
+
| `columnGap` | `0 \| 5 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1 \| 1.5 \| 2 \| 3 \| 4 \| 6 \| 7 \| 8 \| 9` | No | `-` | - |
|
|
45
|
+
| `dangerouslySetBackground` | `string` | No | `-` | - |
|
|
46
|
+
| `display` | `ResponsiveProp<grid \| revert \| none \| block \| inline \| inline-block \| flex \| inline-flex \| inline-grid \| contents \| flow-root \| list-item>` | No | `-` | - |
|
|
47
|
+
| `drag` | `none \| free \| snap` | No | `'snap'` | Defines the drag interaction behavior for the carousel. none disables dragging completely. free enables free-form dragging with natural deceleration when released. snap enables dragging with automatic snapping to targets when released, defined by snapMode. |
|
|
48
|
+
| `elevation` | `0 \| 1 \| 2` | No | `-` | - |
|
|
49
|
+
| `flexBasis` | `ResponsiveProp<FlexBasis<string \| number>>` | No | `-` | - |
|
|
50
|
+
| `flexDirection` | `ResponsiveProp<column \| row \| row-reverse \| column-reverse>` | No | `-` | - |
|
|
51
|
+
| `flexGrow` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset` | No | `-` | - |
|
|
52
|
+
| `flexShrink` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset` | No | `-` | - |
|
|
53
|
+
| `flexWrap` | `ResponsiveProp<nowrap \| wrap \| wrap-reverse>` | No | `-` | - |
|
|
54
|
+
| `font` | `ResponsiveProp<FontFamily \| inherit>` | No | `-` | - |
|
|
55
|
+
| `fontFamily` | `ResponsiveProp<FontFamily \| inherit>` | No | `-` | - |
|
|
56
|
+
| `fontSize` | `ResponsiveProp<FontSize \| inherit>` | No | `-` | - |
|
|
57
|
+
| `fontWeight` | `ResponsiveProp<FontWeight \| inherit>` | No | `-` | - |
|
|
58
|
+
| `gap` | `0 \| 5 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1 \| 1.5 \| 2 \| 3 \| 4 \| 6 \| 7 \| 8 \| 9` | No | `-` | - |
|
|
59
|
+
| `grid` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset \| none` | No | `-` | - |
|
|
60
|
+
| `gridArea` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset \| auto` | No | `-` | - |
|
|
61
|
+
| `gridAutoColumns` | `ResponsiveProp<GridAutoColumns<string \| number>>` | No | `-` | - |
|
|
62
|
+
| `gridAutoFlow` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset \| row \| column \| dense` | No | `-` | - |
|
|
63
|
+
| `gridAutoRows` | `ResponsiveProp<GridAutoRows<string \| number>>` | No | `-` | - |
|
|
64
|
+
| `gridColumn` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset \| auto` | No | `-` | - |
|
|
65
|
+
| `gridColumnEnd` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset \| auto` | No | `-` | - |
|
|
66
|
+
| `gridColumnStart` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset \| auto` | No | `-` | - |
|
|
67
|
+
| `gridRow` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset \| auto` | No | `-` | - |
|
|
68
|
+
| `gridRowEnd` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset \| auto` | No | `-` | - |
|
|
69
|
+
| `gridRowStart` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset \| auto` | No | `-` | - |
|
|
70
|
+
| `gridTemplate` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset \| none` | No | `-` | - |
|
|
71
|
+
| `gridTemplateAreas` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset \| none` | No | `-` | - |
|
|
72
|
+
| `gridTemplateColumns` | `ResponsiveProp<GridTemplateColumns<string \| number>>` | No | `-` | - |
|
|
73
|
+
| `gridTemplateRows` | `ResponsiveProp<GridTemplateRows<string \| number>>` | No | `-` | - |
|
|
74
|
+
| `height` | `ResponsiveProp<Height<string \| number>>` | No | `-` | - |
|
|
75
|
+
| `hideNavigation` | `boolean` | No | `-` | Hides the navigation arrows (previous/next buttons). |
|
|
76
|
+
| `hidePagination` | `boolean` | No | `-` | Hides the pagination indicators (dots/bars showing current page). |
|
|
77
|
+
| `justifyContent` | `ResponsiveProp<left \| right \| center \| normal \| start \| end \| flex-start \| flex-end \| stretch \| space-between \| space-around \| space-evenly>` | No | `-` | - |
|
|
78
|
+
| `key` | `Key \| null` | No | `-` | - |
|
|
79
|
+
| `left` | `ResponsiveProp<Left<string \| number>>` | No | `-` | - |
|
|
80
|
+
| `lineHeight` | `ResponsiveProp<LineHeight \| inherit>` | No | `-` | - |
|
|
81
|
+
| `margin` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
|
|
82
|
+
| `marginBottom` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
|
|
83
|
+
| `marginEnd` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
|
|
84
|
+
| `marginStart` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
|
|
85
|
+
| `marginTop` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
|
|
86
|
+
| `marginX` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
|
|
87
|
+
| `marginY` | `ResponsiveProp<0 \| -5 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1 \| -1.5 \| -2 \| -3 \| -4 \| -6 \| -7 \| -8 \| -9>` | No | `-` | - |
|
|
88
|
+
| `maxHeight` | `ResponsiveProp<MaxHeight<string \| number>>` | No | `-` | - |
|
|
89
|
+
| `maxWidth` | `ResponsiveProp<MaxWidth<string \| number>>` | No | `-` | - |
|
|
90
|
+
| `minHeight` | `ResponsiveProp<MinHeight<string \| number>>` | No | `-` | - |
|
|
91
|
+
| `minWidth` | `ResponsiveProp<MinWidth<string \| number>>` | No | `-` | - |
|
|
92
|
+
| `nextPageAccessibilityLabel` | `string` | No | `-` | Accessibility label for the next page button. |
|
|
93
|
+
| `onChange` | `FormEventHandler<HTMLDivElement>` | No | `-` | - |
|
|
94
|
+
| `onChangePage` | `((activePageIndex: number) => void)` | No | `-` | Callback fired when the carousel page changes. |
|
|
95
|
+
| `opacity` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset` | No | `-` | - |
|
|
96
|
+
| `overflow` | `ResponsiveProp<hidden \| auto \| visible \| clip \| scroll>` | No | `-` | - |
|
|
97
|
+
| `padding` | `0 \| 5 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1 \| 1.5 \| 2 \| 3 \| 4 \| 6 \| 7 \| 8 \| 9` | No | `-` | - |
|
|
98
|
+
| `paddingBottom` | `0 \| 5 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1 \| 1.5 \| 2 \| 3 \| 4 \| 6 \| 7 \| 8 \| 9` | No | `-` | - |
|
|
99
|
+
| `paddingEnd` | `0 \| 5 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1 \| 1.5 \| 2 \| 3 \| 4 \| 6 \| 7 \| 8 \| 9` | No | `-` | - |
|
|
100
|
+
| `paddingStart` | `0 \| 5 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1 \| 1.5 \| 2 \| 3 \| 4 \| 6 \| 7 \| 8 \| 9` | No | `-` | - |
|
|
101
|
+
| `paddingTop` | `0 \| 5 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1 \| 1.5 \| 2 \| 3 \| 4 \| 6 \| 7 \| 8 \| 9` | No | `-` | - |
|
|
102
|
+
| `paddingX` | `0 \| 5 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1 \| 1.5 \| 2 \| 3 \| 4 \| 6 \| 7 \| 8 \| 9` | No | `-` | - |
|
|
103
|
+
| `paddingY` | `0 \| 5 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1 \| 1.5 \| 2 \| 3 \| 4 \| 6 \| 7 \| 8 \| 9` | No | `-` | - |
|
|
104
|
+
| `paginationAccessibilityLabel` | `string \| ((pageIndex: number) => string)` | No | `-` | Accessibility label for the go to page button. |
|
|
105
|
+
| `pin` | `top \| bottom \| left \| right \| all` | No | `-` | Direction in which to absolutely pin the box. |
|
|
106
|
+
| `position` | `ResponsiveProp<fixed \| static \| relative \| absolute \| sticky>` | No | `-` | - |
|
|
107
|
+
| `previousPageAccessibilityLabel` | `string` | No | `-` | Accessibility label for the previous page button. |
|
|
108
|
+
| `ref` | `((instance: CarouselImperativeHandle \| null) => void) \| RefObject<CarouselImperativeHandle> \| null` | No | `-` | - |
|
|
109
|
+
| `right` | `ResponsiveProp<Right<string \| number>>` | No | `-` | - |
|
|
110
|
+
| `rowGap` | `0 \| 5 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1 \| 1.5 \| 2 \| 3 \| 4 \| 6 \| 7 \| 8 \| 9` | No | `-` | - |
|
|
111
|
+
| `snapMode` | `page \| item` | No | `'page'` | Specifies the pagination and navigation strategy for the carousel. item treats each item as a separate page for navigation, pagination, and snapping. page groups items into pages based on visible area for navigation, pagination, and snapping. This affects page calculation, navigation button behavior, and snap targets when dragging. |
|
|
112
|
+
| `style` | `CSSProperties` | No | `-` | Custom styles for the root element. |
|
|
113
|
+
| `styles` | `{ root?: CSSProperties; title?: CSSProperties \| undefined; navigation?: CSSProperties \| undefined; pagination?: CSSProperties \| undefined; carousel?: CSSProperties \| undefined; carouselContainer?: CSSProperties \| undefined; } \| undefined` | No | `-` | Custom styles for the component. |
|
|
114
|
+
| `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 |
|
|
115
|
+
| `textAlign` | `ResponsiveProp<center \| start \| end \| justify>` | No | `-` | - |
|
|
116
|
+
| `textDecoration` | `ResponsiveProp<none \| underline \| overline \| line-through \| underline overline \| underline double>` | No | `-` | - |
|
|
117
|
+
| `textTransform` | `ResponsiveProp<capitalize \| lowercase \| none \| uppercase>` | No | `-` | - |
|
|
118
|
+
| `title` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Title to display above the carousel. When a string is provided, it will be rendered with default title styling. When a React element is provided, it completely replaces the default title component and styling. |
|
|
119
|
+
| `top` | `ResponsiveProp<Top<string \| number>>` | No | `-` | - |
|
|
120
|
+
| `transform` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset \| none` | No | `-` | - |
|
|
121
|
+
| `userSelect` | `ResponsiveProp<text \| none \| auto \| all>` | No | `-` | - |
|
|
122
|
+
| `visibility` | `ResponsiveProp<hidden \| visible>` | No | `-` | - |
|
|
123
|
+
| `width` | `ResponsiveProp<Width<string \| number>>` | No | `-` | - |
|
|
124
|
+
| `zIndex` | `-moz-initial \| inherit \| initial \| revert \| revert-layer \| unset \| auto` | No | `-` | - |
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
## Examples
|
|
128
|
+
|
|
129
|
+
### Basic Example
|
|
130
|
+
|
|
131
|
+
Carousels are a great way to showcase a list of items in a compact and engaging way.
|
|
132
|
+
By default, Carousels have navigation and pagination enabled.
|
|
133
|
+
You can also add a title to the Carousel by setting `title` prop.
|
|
134
|
+
|
|
135
|
+
You simply wrap each child in a `CarouselItem` component, and can optionally set the `width` prop to control the width of the item.
|
|
136
|
+
|
|
137
|
+
You can also set the `styles` prop to control the styles of the carousel, such as the gap between items.
|
|
138
|
+
|
|
139
|
+
:::tip Images
|
|
140
|
+
|
|
141
|
+
Images inside of the carousel have `pointer-events` disabled by default.
|
|
142
|
+
|
|
143
|
+
:::
|
|
144
|
+
|
|
145
|
+
```jsx live
|
|
146
|
+
function MyCarousel() {
|
|
147
|
+
function SquareAssetCard({ imageUrl, name }) {
|
|
148
|
+
return (
|
|
149
|
+
<ContainedAssetCard
|
|
150
|
+
description={
|
|
151
|
+
<TextLabel2 as="p" color="fgPositive" numberOfLines={2}>
|
|
152
|
+
↗6.37%
|
|
153
|
+
</TextLabel2>
|
|
154
|
+
}
|
|
155
|
+
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
156
|
+
subtitle={name}
|
|
157
|
+
title="$0.87"
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
return (
|
|
162
|
+
<Box style={{ marginInline: 'calc(-1 * var(--space-3))' }}>
|
|
163
|
+
<Carousel
|
|
164
|
+
hidePagination
|
|
165
|
+
title="Explore Assets"
|
|
166
|
+
styles={{
|
|
167
|
+
root: { paddingInline: 'var(--space-3)' },
|
|
168
|
+
carousel: { gap: 'var(--space-1)' },
|
|
169
|
+
}}
|
|
170
|
+
>
|
|
171
|
+
{Object.values(assets).map((asset, index) => (
|
|
172
|
+
<CarouselItem key={asset.symbol} id={asset.symbol} accessibilityLabel={asset.name}>
|
|
173
|
+
<SquareAssetCard imageUrl={asset.imageUrl} name={asset.symbol} />
|
|
174
|
+
</CarouselItem>
|
|
175
|
+
))}
|
|
176
|
+
</Carousel>
|
|
177
|
+
</Box>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Item Sizing
|
|
183
|
+
|
|
184
|
+
Items by default take their natural width while in the carousel, such as from our example above.
|
|
185
|
+
However, you can set the `width` prop of `CarouselItem` to control the width of the item.
|
|
186
|
+
|
|
187
|
+
#### Dynamic Sizing
|
|
188
|
+
|
|
189
|
+
Items can be given a width proportional to the carousel width.
|
|
190
|
+
|
|
191
|
+
:::tip Tip
|
|
192
|
+
|
|
193
|
+
If you have a gap between items, you should account for that in the width.
|
|
194
|
+
For example, if you have a gap of 8px, and you want to show 2 items per page,
|
|
195
|
+
you should give each item a width of `calc(50% - 4px)`.
|
|
196
|
+
|
|
197
|
+
:::
|
|
198
|
+
|
|
199
|
+
```jsx live
|
|
200
|
+
function DynamicSizingCarousel() {
|
|
201
|
+
const itemsPerPage = [
|
|
202
|
+
{ id: 'one', label: 'One' },
|
|
203
|
+
{ id: 'two', label: 'Two' },
|
|
204
|
+
{ id: 'three', label: 'Three' },
|
|
205
|
+
];
|
|
206
|
+
const [selectedItemsPerPage, setSelectedItemsPerPage] = useState(itemsPerPage[0]);
|
|
207
|
+
const itemWidths = {
|
|
208
|
+
one: '100%',
|
|
209
|
+
two: 'calc((100% - var(--space-1)) / 2)',
|
|
210
|
+
three: 'calc((100% - (2 * var(--space-1))) / 3)',
|
|
211
|
+
};
|
|
212
|
+
function NoopFn() {
|
|
213
|
+
console.log('pressed');
|
|
214
|
+
}
|
|
215
|
+
function ActionButton({ isVisible, children }) {
|
|
216
|
+
return (
|
|
217
|
+
<Button
|
|
218
|
+
compact
|
|
219
|
+
flush="start"
|
|
220
|
+
numberOfLines={1}
|
|
221
|
+
onClick={NoopFn}
|
|
222
|
+
tabIndex={isVisible ? undefined : -1}
|
|
223
|
+
variant="secondary"
|
|
224
|
+
>
|
|
225
|
+
{children}
|
|
226
|
+
</Button>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
return (
|
|
230
|
+
<VStack gap={2}>
|
|
231
|
+
<HStack justifyContent="flex-end" gap={2} alignItems="center">
|
|
232
|
+
<TextHeadline as="h3">Items per page</TextHeadline>
|
|
233
|
+
<SegmentedTabs
|
|
234
|
+
activeTab={selectedItemsPerPage}
|
|
235
|
+
onChange={setSelectedItemsPerPage}
|
|
236
|
+
tabs={itemsPerPage}
|
|
237
|
+
/>
|
|
238
|
+
</HStack>
|
|
239
|
+
<Box style={{ marginInline: 'calc(-1 * var(--space-3))' }}>
|
|
240
|
+
<Carousel
|
|
241
|
+
hidePagination
|
|
242
|
+
title="Learn more"
|
|
243
|
+
styles={{
|
|
244
|
+
root: { paddingInline: 'var(--space-3)' },
|
|
245
|
+
carousel: { gap: 'var(--space-1)' },
|
|
246
|
+
}}
|
|
247
|
+
key={selectedItemsPerPage.id}
|
|
248
|
+
>
|
|
249
|
+
<CarouselItem
|
|
250
|
+
id="recurring-buy"
|
|
251
|
+
width={itemWidths[selectedItemsPerPage.id]}
|
|
252
|
+
accessibilityLabelledBy="recurring-buy-label"
|
|
253
|
+
>
|
|
254
|
+
{({ isVisible }) => (
|
|
255
|
+
<UpsellCard
|
|
256
|
+
action={<ActionButton isVisible={isVisible}>Get started</ActionButton>}
|
|
257
|
+
description="Want to add funds to your card every week or month?"
|
|
258
|
+
media={
|
|
259
|
+
<Box bottom={6} position="relative" right={24}>
|
|
260
|
+
<Pictogram dimension="64x64" name="recurringPurchases" />
|
|
261
|
+
</Box>
|
|
262
|
+
}
|
|
263
|
+
minWidth="0"
|
|
264
|
+
title={
|
|
265
|
+
<TextHeadline as="h3" id="recurring-buy-label">
|
|
266
|
+
Recurring Buy
|
|
267
|
+
</TextHeadline>
|
|
268
|
+
}
|
|
269
|
+
width="100%"
|
|
270
|
+
/>
|
|
271
|
+
)}
|
|
272
|
+
</CarouselItem>
|
|
273
|
+
<CarouselItem
|
|
274
|
+
id="eths-apr"
|
|
275
|
+
width={itemWidths[selectedItemsPerPage.id]}
|
|
276
|
+
accessibilityLabelledBy="eths-apr-label"
|
|
277
|
+
>
|
|
278
|
+
{({ isVisible }) => (
|
|
279
|
+
<UpsellCard
|
|
280
|
+
action={<ActionButton isVisible={isVisible}>Start earning</ActionButton>}
|
|
281
|
+
dangerouslySetBackground="rgb(var(--purple70))"
|
|
282
|
+
description={
|
|
283
|
+
<TextLabel2 as="p" numberOfLines={3} color="fgInverse">
|
|
284
|
+
Earn staking rewards on ETH by holding it on Coinbase
|
|
285
|
+
</TextLabel2>
|
|
286
|
+
}
|
|
287
|
+
media={
|
|
288
|
+
<Box left={16} position="relative" top={12}>
|
|
289
|
+
<RemoteImage height={174} source="/img/feature.png" />
|
|
290
|
+
</Box>
|
|
291
|
+
}
|
|
292
|
+
minWidth="0"
|
|
293
|
+
title={
|
|
294
|
+
<TextHeadline id="eths-apr-label" color="fgInverse" as="h3">
|
|
295
|
+
Up to 3.29% APR on ETHs
|
|
296
|
+
</TextHeadline>
|
|
297
|
+
}
|
|
298
|
+
width="100%"
|
|
299
|
+
/>
|
|
300
|
+
)}
|
|
301
|
+
</CarouselItem>
|
|
302
|
+
<CarouselItem
|
|
303
|
+
id="join-the-community"
|
|
304
|
+
width={itemWidths[selectedItemsPerPage.id]}
|
|
305
|
+
accessibilityLabelledBy="join-the-community-label"
|
|
306
|
+
>
|
|
307
|
+
{({ isVisible }) => (
|
|
308
|
+
<UpsellCard
|
|
309
|
+
action={<ActionButton isVisible={isVisible}>Start chatting</ActionButton>}
|
|
310
|
+
dangerouslySetBackground="rgb(var(--teal70))"
|
|
311
|
+
description={
|
|
312
|
+
<TextLabel2 as="p" numberOfLines={3} color="fgInverse">
|
|
313
|
+
Chat with other devs in our Discord community
|
|
314
|
+
</TextLabel2>
|
|
315
|
+
}
|
|
316
|
+
media={
|
|
317
|
+
<Box left={16} position="relative" top={4}>
|
|
318
|
+
<RemoteImage height={174} source="/img/community.png" />
|
|
319
|
+
</Box>
|
|
320
|
+
}
|
|
321
|
+
minWidth="0"
|
|
322
|
+
title={
|
|
323
|
+
<TextHeadline id="join-the-community-label" color="fgInverse" as="h3">
|
|
324
|
+
Join the community
|
|
325
|
+
</TextHeadline>
|
|
326
|
+
}
|
|
327
|
+
width="100%"
|
|
328
|
+
/>
|
|
329
|
+
)}
|
|
330
|
+
</CarouselItem>
|
|
331
|
+
<CarouselItem
|
|
332
|
+
id="coinbase-one-offer"
|
|
333
|
+
width={itemWidths[selectedItemsPerPage.id]}
|
|
334
|
+
accessibilityLabelledBy="coinbase-one-offer-label"
|
|
335
|
+
>
|
|
336
|
+
{({ isVisible }) => (
|
|
337
|
+
<UpsellCard
|
|
338
|
+
action={<ActionButton isVisible={isVisible}>Get 60 days free</ActionButton>}
|
|
339
|
+
dangerouslySetBackground="rgb(var(--blue80))"
|
|
340
|
+
description={
|
|
341
|
+
<TextLabel2 as="p" numberOfLines={3} color="fgInverse">
|
|
342
|
+
Use code NOV60 when you sign up for Coinbase One
|
|
343
|
+
</TextLabel2>
|
|
344
|
+
}
|
|
345
|
+
media={
|
|
346
|
+
<Box left={16} position="relative" top={0}>
|
|
347
|
+
<RemoteImage height={174} source="/img/marketing.png" />
|
|
348
|
+
</Box>
|
|
349
|
+
}
|
|
350
|
+
minWidth="0"
|
|
351
|
+
title={
|
|
352
|
+
<TextHeadline id="coinbase-one-offer-label" color="fgInverse" as="h3">
|
|
353
|
+
Coinbase One offer
|
|
354
|
+
</TextHeadline>
|
|
355
|
+
}
|
|
356
|
+
width="100%"
|
|
357
|
+
/>
|
|
358
|
+
)}
|
|
359
|
+
</CarouselItem>
|
|
360
|
+
<CarouselItem
|
|
361
|
+
id="coinbase-card"
|
|
362
|
+
width={itemWidths[selectedItemsPerPage.id]}
|
|
363
|
+
accessibilityLabelledBy="coinbase-card-label"
|
|
364
|
+
>
|
|
365
|
+
{({ isVisible }) => (
|
|
366
|
+
<UpsellCard
|
|
367
|
+
action={<ActionButton isVisible={isVisible}>Get started</ActionButton>}
|
|
368
|
+
dangerouslySetBackground="rgb(var(--gray100))"
|
|
369
|
+
description={
|
|
370
|
+
<TextLabel2 as="p" numberOfLines={3} color="fgInverse">
|
|
371
|
+
Spend USDC to get rewards with our Visa® debit card
|
|
372
|
+
</TextLabel2>
|
|
373
|
+
}
|
|
374
|
+
media={
|
|
375
|
+
<Box left={16} position="relative" top={0}>
|
|
376
|
+
<RemoteImage height={174} source="/img/object.png" />
|
|
377
|
+
</Box>
|
|
378
|
+
}
|
|
379
|
+
minWidth="0"
|
|
380
|
+
title={
|
|
381
|
+
<TextHeadline id="coinbase-card-label" color="fgInverse" as="h3">
|
|
382
|
+
Coinbase Card
|
|
383
|
+
</TextHeadline>
|
|
384
|
+
}
|
|
385
|
+
width="100%"
|
|
386
|
+
/>
|
|
387
|
+
)}
|
|
388
|
+
</CarouselItem>
|
|
389
|
+
</Carousel>
|
|
390
|
+
</Box>
|
|
391
|
+
</VStack>
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
#### Responsive Sizing
|
|
397
|
+
|
|
398
|
+
You can also use responsive props to change the number of items visible based on the carousel width.
|
|
399
|
+
The carousel below will show per page 1 item on mobile, 2 items on tablet, and 3 items on desktop.
|
|
400
|
+
|
|
401
|
+
```jsx live
|
|
402
|
+
function ResponsiveSizingCarousel() {
|
|
403
|
+
const itemWidth = {
|
|
404
|
+
phone: '100%',
|
|
405
|
+
tablet: 'calc((100% - var(--space-1)) / 2)',
|
|
406
|
+
desktop: 'calc((100% - (2 * var(--space-1))) / 3)',
|
|
407
|
+
};
|
|
408
|
+
function NoopFn() {
|
|
409
|
+
console.log('pressed');
|
|
410
|
+
}
|
|
411
|
+
function ActionButton({ isVisible, children }) {
|
|
412
|
+
return (
|
|
413
|
+
<Pressable
|
|
414
|
+
background="transparent"
|
|
415
|
+
onClick={NoopFn}
|
|
416
|
+
paddingY={1}
|
|
417
|
+
tabIndex={isVisible ? undefined : -1}
|
|
418
|
+
borderRadius={500}
|
|
419
|
+
>
|
|
420
|
+
<Text color="fgPrimary" font="headline" numberOfLines={1}>
|
|
421
|
+
{children}
|
|
422
|
+
</Text>
|
|
423
|
+
</Pressable>
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
return (
|
|
427
|
+
<Box style={{ marginInline: 'calc(-1 * var(--space-3))' }}>
|
|
428
|
+
<Carousel
|
|
429
|
+
hidePagination
|
|
430
|
+
title="Learn more"
|
|
431
|
+
styles={{ root: { paddingInline: 'var(--space-3)' }, carousel: { gap: 'var(--space-1)' } }}
|
|
432
|
+
drag="free"
|
|
433
|
+
>
|
|
434
|
+
<CarouselItem id="earn-more-crypto" width={itemWidth}>
|
|
435
|
+
{({ isVisible }) => (
|
|
436
|
+
<NudgeCard
|
|
437
|
+
title="Earn more crypto"
|
|
438
|
+
description="You've got unstaked crypto."
|
|
439
|
+
pictogram="key"
|
|
440
|
+
action={<ActionButton isVisible={isVisible}>Start earning</ActionButton>}
|
|
441
|
+
width="100%"
|
|
442
|
+
minWidth="0"
|
|
443
|
+
/>
|
|
444
|
+
)}
|
|
445
|
+
</CarouselItem>
|
|
446
|
+
<CarouselItem id="secure-your-account" width={itemWidth}>
|
|
447
|
+
{({ isVisible }) => (
|
|
448
|
+
<NudgeCard
|
|
449
|
+
title="Secure your account"
|
|
450
|
+
description="Add two-factor authentication."
|
|
451
|
+
pictogram="shield"
|
|
452
|
+
action={<ActionButton isVisible={isVisible}>Enable 2FA</ActionButton>}
|
|
453
|
+
width="100%"
|
|
454
|
+
minWidth="0"
|
|
455
|
+
/>
|
|
456
|
+
)}
|
|
457
|
+
</CarouselItem>
|
|
458
|
+
<CarouselItem id="complete-your-profile" width={itemWidth}>
|
|
459
|
+
{({ isVisible }) => (
|
|
460
|
+
<NudgeCard
|
|
461
|
+
title="Complete your profile"
|
|
462
|
+
description="Add more details."
|
|
463
|
+
pictogram="accountsNavigation"
|
|
464
|
+
action={<ActionButton isVisible={isVisible}>Update</ActionButton>}
|
|
465
|
+
width="100%"
|
|
466
|
+
minWidth="0"
|
|
467
|
+
/>
|
|
468
|
+
)}
|
|
469
|
+
</CarouselItem>
|
|
470
|
+
</Carousel>
|
|
471
|
+
</Box>
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
#### Varied Sizing
|
|
477
|
+
|
|
478
|
+
Not all carousel items need to be the same size. You can provide CarouselItems of varying widths as well.
|
|
479
|
+
|
|
480
|
+
```jsx live
|
|
481
|
+
function VariedSizingCarousel() {
|
|
482
|
+
function SquareAssetCard({ imageUrl, name }) {
|
|
483
|
+
return (
|
|
484
|
+
<ContainedAssetCard
|
|
485
|
+
description={
|
|
486
|
+
<TextLabel2 as="p" color="fgPositive" numberOfLines={2}>
|
|
487
|
+
↗6.37%
|
|
488
|
+
</TextLabel2>
|
|
489
|
+
}
|
|
490
|
+
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
491
|
+
subtitle={name}
|
|
492
|
+
title="$0.87"
|
|
493
|
+
/>
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
function NoopFn() {
|
|
497
|
+
console.log('pressed');
|
|
498
|
+
}
|
|
499
|
+
function ActionButton({ isVisible, children }) {
|
|
500
|
+
return (
|
|
501
|
+
<Pressable
|
|
502
|
+
background="transparent"
|
|
503
|
+
onClick={NoopFn}
|
|
504
|
+
paddingY={1}
|
|
505
|
+
tabIndex={isVisible ? undefined : -1}
|
|
506
|
+
borderRadius={500}
|
|
507
|
+
>
|
|
508
|
+
<Text color="fgPrimary" font="headline" numberOfLines={1}>
|
|
509
|
+
{children}
|
|
510
|
+
</Text>
|
|
511
|
+
</Pressable>
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
const itemWidth = {
|
|
515
|
+
phone: '100%',
|
|
516
|
+
tablet: 'calc((100% - var(--space-1)) / 2)',
|
|
517
|
+
desktop: 'calc((100% - var(--space-1)) / 2)',
|
|
518
|
+
};
|
|
519
|
+
return (
|
|
520
|
+
<Box style={{ marginInline: 'calc(-1 * var(--space-3))' }}>
|
|
521
|
+
<Carousel
|
|
522
|
+
hidePagination
|
|
523
|
+
title="Varied Sizing"
|
|
524
|
+
styles={{ root: { paddingInline: 'var(--space-3)' }, carousel: { gap: 'var(--space-1)' } }}
|
|
525
|
+
>
|
|
526
|
+
<CarouselItem id="earn-more-crypto" width={itemWidth}>
|
|
527
|
+
{({ isVisible }) => (
|
|
528
|
+
<NudgeCard
|
|
529
|
+
title="Earn more crypto"
|
|
530
|
+
description="You've got unstaked crypto. Stake it now to earn more."
|
|
531
|
+
pictogram="key"
|
|
532
|
+
action={<ActionButton isVisible={isVisible}>Start earning</ActionButton>}
|
|
533
|
+
width="100%"
|
|
534
|
+
minWidth="0"
|
|
535
|
+
/>
|
|
536
|
+
)}
|
|
537
|
+
</CarouselItem>
|
|
538
|
+
<CarouselItem id="btc">
|
|
539
|
+
<SquareAssetCard imageUrl={assets.btc.imageUrl} name="BTC" />
|
|
540
|
+
</CarouselItem>
|
|
541
|
+
<CarouselItem id="secure-your-account" width={itemWidth}>
|
|
542
|
+
{({ isVisible }) => (
|
|
543
|
+
<NudgeCard
|
|
544
|
+
title="Secure your account"
|
|
545
|
+
description="Add two-factor authentication for enhanced security."
|
|
546
|
+
pictogram="shield"
|
|
547
|
+
action={<ActionButton isVisible={isVisible}>Enable 2FA</ActionButton>}
|
|
548
|
+
width="100%"
|
|
549
|
+
minWidth="0"
|
|
550
|
+
/>
|
|
551
|
+
)}
|
|
552
|
+
</CarouselItem>
|
|
553
|
+
<CarouselItem id="eth">
|
|
554
|
+
<SquareAssetCard imageUrl={assets.eth.imageUrl} name="ETH" />
|
|
555
|
+
</CarouselItem>
|
|
556
|
+
<CarouselItem id="complete-your-profile" width={itemWidth}>
|
|
557
|
+
{({ isVisible }) => (
|
|
558
|
+
<NudgeCard
|
|
559
|
+
title="Complete your profile"
|
|
560
|
+
description="Add more details to personalize your experience."
|
|
561
|
+
pictogram="accountsNavigation"
|
|
562
|
+
action={<ActionButton isVisible={isVisible}>Update profile</ActionButton>}
|
|
563
|
+
width="100%"
|
|
564
|
+
minWidth="0"
|
|
565
|
+
/>
|
|
566
|
+
)}
|
|
567
|
+
</CarouselItem>
|
|
568
|
+
<CarouselItem id="ltc">
|
|
569
|
+
<SquareAssetCard imageUrl={assets.ltc.imageUrl} name="LTC" />
|
|
570
|
+
</CarouselItem>
|
|
571
|
+
</Carousel>
|
|
572
|
+
</Box>
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
### Drag
|
|
578
|
+
|
|
579
|
+
You can set the `drag` prop to `snap` (default), `free`, or `none`.
|
|
580
|
+
When set to `snap`, upon release the carousel will snap to either the nearest item or page (depending on `snapMode`).
|
|
581
|
+
|
|
582
|
+
```jsx live
|
|
583
|
+
function DragCarousel() {
|
|
584
|
+
const dragOptions = [
|
|
585
|
+
{ id: 'snap', label: 'Snap' },
|
|
586
|
+
{ id: 'free', label: 'Free' },
|
|
587
|
+
{ id: 'none', label: 'None' },
|
|
588
|
+
];
|
|
589
|
+
const [drag, setDrag] = useState(dragOptions[0]);
|
|
590
|
+
function SquareAssetCard({ imageUrl, name }) {
|
|
591
|
+
return (
|
|
592
|
+
<ContainedAssetCard
|
|
593
|
+
description={
|
|
594
|
+
<TextLabel2 as="p" color="fgPositive" numberOfLines={2}>
|
|
595
|
+
↗6.37%
|
|
596
|
+
</TextLabel2>
|
|
597
|
+
}
|
|
598
|
+
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
599
|
+
subtitle={name}
|
|
600
|
+
title="$0.87"
|
|
601
|
+
/>
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
return (
|
|
605
|
+
<VStack gap={2}>
|
|
606
|
+
<HStack justifyContent="flex-end" gap={2} alignItems="center">
|
|
607
|
+
<TextHeadline as="h3">Drag</TextHeadline>
|
|
608
|
+
<SegmentedTabs activeTab={drag} onChange={setDrag} tabs={dragOptions} />
|
|
609
|
+
</HStack>
|
|
610
|
+
<Box style={{ marginInline: 'calc(-1 * var(--space-3))' }}>
|
|
611
|
+
<Carousel
|
|
612
|
+
title="Explore Assets"
|
|
613
|
+
hidePagination
|
|
614
|
+
drag={drag.id}
|
|
615
|
+
styles={{
|
|
616
|
+
root: { paddingInline: 'var(--space-3)' },
|
|
617
|
+
carousel: { gap: 'var(--space-1)' },
|
|
618
|
+
}}
|
|
619
|
+
snapMode="item"
|
|
620
|
+
key={drag.id}
|
|
621
|
+
>
|
|
622
|
+
{Object.values(assets).map((asset, index) => (
|
|
623
|
+
<CarouselItem key={asset.symbol} id={asset.symbol}>
|
|
624
|
+
<SquareAssetCard imageUrl={asset.imageUrl} name={asset.symbol} />
|
|
625
|
+
</CarouselItem>
|
|
626
|
+
))}
|
|
627
|
+
</Carousel>
|
|
628
|
+
</Box>
|
|
629
|
+
</VStack>
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
### Snap Mode
|
|
635
|
+
|
|
636
|
+
You can set the `snapMode` to `page` (default) or `item`.
|
|
637
|
+
When set to `page`, the carousel will automatically group items into pages.
|
|
638
|
+
When set to `item`, the carousel will snap to the nearest item.
|
|
639
|
+
|
|
640
|
+
```jsx live
|
|
641
|
+
function SnapModeCarousel() {
|
|
642
|
+
const snapModeOptions = [
|
|
643
|
+
{ id: 'page', label: 'Page' },
|
|
644
|
+
{ id: 'item', label: 'Item' },
|
|
645
|
+
];
|
|
646
|
+
const [snapMode, setSnapMode] = useState(snapModeOptions[0]);
|
|
647
|
+
function SquareAssetCard({ imageUrl, name }) {
|
|
648
|
+
return (
|
|
649
|
+
<ContainedAssetCard
|
|
650
|
+
description={
|
|
651
|
+
<TextLabel2 as="p" color="fgPositive" numberOfLines={2}>
|
|
652
|
+
↗6.37%
|
|
653
|
+
</TextLabel2>
|
|
654
|
+
}
|
|
655
|
+
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
656
|
+
subtitle={name}
|
|
657
|
+
title="$0.87"
|
|
658
|
+
/>
|
|
659
|
+
);
|
|
660
|
+
}
|
|
661
|
+
return (
|
|
662
|
+
<VStack gap={2}>
|
|
663
|
+
<HStack justifyContent="flex-end" gap={2} alignItems="center">
|
|
664
|
+
<TextHeadline as="h3">Snap mode</TextHeadline>
|
|
665
|
+
<SegmentedTabs activeTab={snapMode} onChange={setSnapMode} tabs={snapModeOptions} />
|
|
666
|
+
</HStack>
|
|
667
|
+
<Box style={{ marginInline: 'calc(-1 * var(--space-3))' }}>
|
|
668
|
+
<Carousel
|
|
669
|
+
title="Explore Assets"
|
|
670
|
+
styles={{
|
|
671
|
+
root: { paddingInline: 'var(--space-3)' },
|
|
672
|
+
carousel: { gap: 'var(--space-1)' },
|
|
673
|
+
}}
|
|
674
|
+
snapMode={snapMode.id}
|
|
675
|
+
key={snapMode.id}
|
|
676
|
+
>
|
|
677
|
+
{Object.values(assets).map((asset, index) => (
|
|
678
|
+
<CarouselItem key={asset.symbol} id={asset.symbol}>
|
|
679
|
+
<SquareAssetCard imageUrl={asset.imageUrl} name={asset.symbol} />
|
|
680
|
+
</CarouselItem>
|
|
681
|
+
))}
|
|
682
|
+
</Carousel>
|
|
683
|
+
</Box>
|
|
684
|
+
</VStack>
|
|
685
|
+
);
|
|
686
|
+
}
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
### Overflow
|
|
690
|
+
|
|
691
|
+
By default, the carousel's inner overflow is visible.
|
|
692
|
+
This means that you can apply padding to the inner carousel element
|
|
693
|
+
(such as `styles={{ carousel: { paddingInline: 'var(--space-3)' } }}`) and it will not be clipped.
|
|
694
|
+
You can pair this with modifying the spacing of the inner carousel to match
|
|
695
|
+
the padding of your page (along with a wrapping div to negate any default spacing).
|
|
696
|
+
This creates a seamless experience.
|
|
697
|
+
|
|
698
|
+
:::tip Tip
|
|
699
|
+
|
|
700
|
+
If you want to have the next item be shown at the edge of the screen, make sure your carousel padding is larger than your gap.
|
|
701
|
+
|
|
702
|
+
:::
|
|
703
|
+
|
|
704
|
+
```jsx live
|
|
705
|
+
function OverflowCarousel() {
|
|
706
|
+
function SquareAssetCard({ isVisible, imageUrl, name }) {
|
|
707
|
+
return (
|
|
708
|
+
<ContainedAssetCard
|
|
709
|
+
description={
|
|
710
|
+
<TextLabel2 as="p" color="fgPositive" numberOfLines={2}>
|
|
711
|
+
↗6.37%
|
|
712
|
+
</TextLabel2>
|
|
713
|
+
}
|
|
714
|
+
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
715
|
+
onClick={isVisible ? () => console.log('clicked') : undefined}
|
|
716
|
+
subtitle={name}
|
|
717
|
+
title="$0.87"
|
|
718
|
+
/>
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
return (
|
|
722
|
+
<Box style={{ marginInline: 'calc(-1 * var(--space-3))' }}>
|
|
723
|
+
<Carousel
|
|
724
|
+
title="Explore Assets"
|
|
725
|
+
snapMode="item"
|
|
726
|
+
styles={{
|
|
727
|
+
root: { paddingInline: 'var(--space-3)' },
|
|
728
|
+
carousel: { gap: 'var(--space-1)' },
|
|
729
|
+
}}
|
|
730
|
+
>
|
|
731
|
+
{Object.values(assets).map((asset, index) => (
|
|
732
|
+
<CarouselItem key={asset.symbol} id={asset.symbol}>
|
|
733
|
+
{({ isVisible }) => (
|
|
734
|
+
<SquareAssetCard
|
|
735
|
+
isVisible={isVisible}
|
|
736
|
+
imageUrl={asset.imageUrl}
|
|
737
|
+
name={asset.symbol}
|
|
738
|
+
/>
|
|
739
|
+
)}
|
|
740
|
+
</CarouselItem>
|
|
741
|
+
))}
|
|
742
|
+
</Carousel>
|
|
743
|
+
</Box>
|
|
744
|
+
);
|
|
745
|
+
}
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
### Accessibility
|
|
749
|
+
|
|
750
|
+
The carousel is accessible by default.
|
|
751
|
+
|
|
752
|
+
You need to use `accessibilityLabel` or `accessibilityLabelledBy` props to provide a label for the carousel items.
|
|
753
|
+
|
|
754
|
+
If you have elements that are focusable, you can use `isVisible` render prop to disable focus when the item is not visible.
|
|
755
|
+
|
|
756
|
+
```jsx
|
|
757
|
+
<Carousel>
|
|
758
|
+
<CarouselItem id="btc" accessibilityLabel="Bitcoin">
|
|
759
|
+
<SquareAssetCard imageUrl={assets.btc.imageUrl} name={assets.btc.symbol} />
|
|
760
|
+
</CarouselItem>
|
|
761
|
+
<CarouselItem id="recurring-buy" width="100%" accessibilityLabelledBy="recurring-buy-label">
|
|
762
|
+
{({ isVisible }) => (
|
|
763
|
+
<UpsellCard
|
|
764
|
+
action={
|
|
765
|
+
<Button
|
|
766
|
+
compact
|
|
767
|
+
flush="start"
|
|
768
|
+
numberOfLines={1}
|
|
769
|
+
onClick={NoopFn}
|
|
770
|
+
tabIndex={isVisible ? undefined : -1}
|
|
771
|
+
variant="secondary"
|
|
772
|
+
>
|
|
773
|
+
Get started
|
|
774
|
+
</Button>
|
|
775
|
+
}
|
|
776
|
+
description="Want to add funds to your card every week or month?"
|
|
777
|
+
media={
|
|
778
|
+
<Box bottom={6} position="relative" right={24}>
|
|
779
|
+
<Pictogram dimension="64x64" name="recurringPurchases" />
|
|
780
|
+
</Box>
|
|
781
|
+
}
|
|
782
|
+
minWidth="0"
|
|
783
|
+
title={
|
|
784
|
+
<TextHeadline as="h3" id="recurring-buy-label">
|
|
785
|
+
Recurring Buy
|
|
786
|
+
</TextHeadline>
|
|
787
|
+
}
|
|
788
|
+
width="100%"
|
|
789
|
+
/>
|
|
790
|
+
)}
|
|
791
|
+
</CarouselItem>
|
|
792
|
+
</Carousel>
|
|
793
|
+
```
|
|
794
|
+
|
|
795
|
+
### Customization
|
|
796
|
+
|
|
797
|
+
#### Custom Components
|
|
798
|
+
|
|
799
|
+
You can customize the navigation and pagination components of the carousel using the `NavigationComponent` and `PaginationComponent` props. You can also modify the title by providing a ReactNode for the `title` prop.
|
|
800
|
+
|
|
801
|
+
```jsx live
|
|
802
|
+
function CustomComponentsCarousel() {
|
|
803
|
+
function SeeAllComponent({ style }) {
|
|
804
|
+
return (
|
|
805
|
+
<TextHeadline style={style}>
|
|
806
|
+
<Link openInNewWindow href="https://coinbase.com/">
|
|
807
|
+
See all
|
|
808
|
+
</Link>
|
|
809
|
+
</TextHeadline>
|
|
810
|
+
);
|
|
811
|
+
}
|
|
812
|
+
function PaginationComponent({ totalPages, activePageIndex, onClickPage, style }) {
|
|
813
|
+
const canGoPrevious = activePageIndex > 0;
|
|
814
|
+
const canGoNext = activePageIndex < totalPages - 1;
|
|
815
|
+
const dotStyles = {
|
|
816
|
+
width: 'var(--space-2)',
|
|
817
|
+
height: 'var(--space-2)',
|
|
818
|
+
borderRadius: 'var(--borderRadius-1000)',
|
|
819
|
+
} as const;
|
|
820
|
+
function onPrevious() {
|
|
821
|
+
onClickPage(activePageIndex - 1);
|
|
822
|
+
}
|
|
823
|
+
function onNext() {
|
|
824
|
+
onClickPage(activePageIndex + 1);
|
|
825
|
+
}
|
|
826
|
+
return (
|
|
827
|
+
<HStack justifyContent="space-between" paddingY={0.5} style={style}>
|
|
828
|
+
<HStack gap={1}>
|
|
829
|
+
<IconButton
|
|
830
|
+
accessibilityLabel="Previous"
|
|
831
|
+
disabled={!canGoPrevious}
|
|
832
|
+
name="caretLeft"
|
|
833
|
+
onClick={onPrevious}
|
|
834
|
+
variant="foregroundMuted"
|
|
835
|
+
/>
|
|
836
|
+
<IconButton
|
|
837
|
+
accessibilityLabel="Next"
|
|
838
|
+
disabled={!canGoNext}
|
|
839
|
+
name="caretRight"
|
|
840
|
+
onClick={onNext}
|
|
841
|
+
variant="foregroundMuted"
|
|
842
|
+
/>
|
|
843
|
+
</HStack>
|
|
844
|
+
<HStack alignItems="center" gap={1}>
|
|
845
|
+
{Array.from({ length: totalPages }, (_, index) => (
|
|
846
|
+
<Pressable
|
|
847
|
+
key={index}
|
|
848
|
+
accessibilityLabel={`Go to page ${index + 1}`}
|
|
849
|
+
background={index === activePageIndex ? 'bgPrimary' : 'bgSecondary'}
|
|
850
|
+
borderColor={index === activePageIndex ? 'fgPrimary' : 'bgLine'}
|
|
851
|
+
data-testid={`carousel-page-${index}`}
|
|
852
|
+
onClick={() => onClickPage(index)}
|
|
853
|
+
style={dotStyles}
|
|
854
|
+
/>
|
|
855
|
+
))}
|
|
856
|
+
</HStack>
|
|
857
|
+
</HStack>
|
|
858
|
+
);
|
|
859
|
+
}
|
|
860
|
+
function NoopFn() {
|
|
861
|
+
console.log('pressed');
|
|
862
|
+
}
|
|
863
|
+
function ActionButton({ isVisible, children }) {
|
|
864
|
+
return (
|
|
865
|
+
<Button
|
|
866
|
+
compact
|
|
867
|
+
flush="start"
|
|
868
|
+
numberOfLines={1}
|
|
869
|
+
onClick={NoopFn}
|
|
870
|
+
tabIndex={isVisible ? undefined : -1}
|
|
871
|
+
variant="secondary"
|
|
872
|
+
>
|
|
873
|
+
{children}
|
|
874
|
+
</Button>
|
|
875
|
+
);
|
|
876
|
+
}
|
|
877
|
+
const itemWidth = {
|
|
878
|
+
phone: '100%',
|
|
879
|
+
tablet: 'round(down, calc((100% - var(--space-1)) / 2), 1px)',
|
|
880
|
+
desktop: 'round(down, calc((100% - var(--space-1)) / 2), 1px)',
|
|
881
|
+
};
|
|
882
|
+
return (
|
|
883
|
+
<Box style={{ marginInline: 'calc(-1 * var(--space-3))' }}>
|
|
884
|
+
<Carousel
|
|
885
|
+
NavigationComponent={SeeAllComponent}
|
|
886
|
+
PaginationComponent={PaginationComponent}
|
|
887
|
+
styles={{
|
|
888
|
+
root: { paddingInline: 'var(--space-3)' },
|
|
889
|
+
carousel: { gap: 'var(--space-1)' },
|
|
890
|
+
}}
|
|
891
|
+
title={
|
|
892
|
+
<TextHeadline as="h3">
|
|
893
|
+
Learn more
|
|
894
|
+
</TextHeadline>
|
|
895
|
+
}
|
|
896
|
+
>
|
|
897
|
+
<CarouselItem id="recurring-buy" width={itemWidth}>
|
|
898
|
+
{({ isVisible }) => (
|
|
899
|
+
<UpsellCard
|
|
900
|
+
action={<ActionButton isVisible={isVisible}>Get started</ActionButton>}
|
|
901
|
+
description="Want to add funds to your card every week or month?"
|
|
902
|
+
media={
|
|
903
|
+
<Box bottom={6} position="relative" right={24}>
|
|
904
|
+
<Pictogram dimension="64x64" name="recurringPurchases" />
|
|
905
|
+
</Box>
|
|
906
|
+
}
|
|
907
|
+
minWidth="0"
|
|
908
|
+
title="Recurring Buy"
|
|
909
|
+
width="100%"
|
|
910
|
+
/>
|
|
911
|
+
)}
|
|
912
|
+
</CarouselItem>
|
|
913
|
+
<CarouselItem id="eths-apr" width={itemWidth}>
|
|
914
|
+
{({ isVisible }) => (
|
|
915
|
+
<UpsellCard
|
|
916
|
+
action={<ActionButton isVisible={isVisible}>Start earning</ActionButton>}
|
|
917
|
+
dangerouslySetBackground="rgb(var(--purple70))"
|
|
918
|
+
description={
|
|
919
|
+
<TextLabel2 as="p" numberOfLines={3} color="fgInverse">
|
|
920
|
+
Earn staking rewards on ETH by holding it on Coinbase
|
|
921
|
+
</TextLabel2>
|
|
922
|
+
}
|
|
923
|
+
media={
|
|
924
|
+
<Box left={16} position="relative" top={12}>
|
|
925
|
+
<RemoteImage height={174} source="/img/feature.png" />
|
|
926
|
+
</Box>
|
|
927
|
+
}
|
|
928
|
+
minWidth="0"
|
|
929
|
+
title={
|
|
930
|
+
<TextHeadline color="fgInverse" as="h3">
|
|
931
|
+
Up to 3.29% APR on ETHs
|
|
932
|
+
</TextHeadline>
|
|
933
|
+
}
|
|
934
|
+
width="100%"
|
|
935
|
+
/>
|
|
936
|
+
)}
|
|
937
|
+
</CarouselItem>
|
|
938
|
+
<CarouselItem id="join-the-community" width={itemWidth}>
|
|
939
|
+
{({ isVisible }) => (
|
|
940
|
+
<UpsellCard
|
|
941
|
+
action={<ActionButton isVisible={isVisible}>Start chatting</ActionButton>}
|
|
942
|
+
dangerouslySetBackground="rgb(var(--teal70))"
|
|
943
|
+
description={
|
|
944
|
+
<TextLabel2 as="p" numberOfLines={3} color="fgInverse">
|
|
945
|
+
Chat with other devs in our Discord community
|
|
946
|
+
</TextLabel2>
|
|
947
|
+
}
|
|
948
|
+
media={
|
|
949
|
+
<Box left={16} position="relative" top={4}>
|
|
950
|
+
<RemoteImage height={174} source="/img/community.png" />
|
|
951
|
+
</Box>
|
|
952
|
+
}
|
|
953
|
+
minWidth="0"
|
|
954
|
+
title={
|
|
955
|
+
<TextHeadline color="fgInverse" as="h3">
|
|
956
|
+
Join the community
|
|
957
|
+
</TextHeadline>
|
|
958
|
+
}
|
|
959
|
+
width="100%"
|
|
960
|
+
/>
|
|
961
|
+
)}
|
|
962
|
+
</CarouselItem>
|
|
963
|
+
<CarouselItem id="coinbase-one-offer" width={itemWidth}>
|
|
964
|
+
{({ isVisible }) => (
|
|
965
|
+
<UpsellCard
|
|
966
|
+
action={<ActionButton isVisible={isVisible}>Get 60 days free</ActionButton>}
|
|
967
|
+
dangerouslySetBackground="rgb(var(--blue80))"
|
|
968
|
+
description={
|
|
969
|
+
<TextLabel2 as="p" numberOfLines={3} color="fgInverse">
|
|
970
|
+
Use code NOV60 when you sign up for Coinbase One
|
|
971
|
+
</TextLabel2>
|
|
972
|
+
}
|
|
973
|
+
media={
|
|
974
|
+
<Box left={16} position="relative" top={0}>
|
|
975
|
+
<RemoteImage height={174} source="/img/marketing.png" />
|
|
976
|
+
</Box>
|
|
977
|
+
}
|
|
978
|
+
minWidth="0"
|
|
979
|
+
title={
|
|
980
|
+
<TextHeadline color="fgInverse" as="h3">
|
|
981
|
+
Coinbase One offer
|
|
982
|
+
</TextHeadline>
|
|
983
|
+
}
|
|
984
|
+
width="100%"
|
|
985
|
+
/>
|
|
986
|
+
)}
|
|
987
|
+
</CarouselItem>
|
|
988
|
+
<CarouselItem id="coinbase-card" width={itemWidth}>
|
|
989
|
+
{({ isVisible }) => (
|
|
990
|
+
<UpsellCard
|
|
991
|
+
action={<ActionButton isVisible={isVisible}>Get started</ActionButton>}
|
|
992
|
+
dangerouslySetBackground="rgb(var(--gray100))"
|
|
993
|
+
description={
|
|
994
|
+
<TextLabel2 as="p" numberOfLines={3} color="fgInverse">
|
|
995
|
+
Spend USDC to get rewards with our Visa® debit card
|
|
996
|
+
</TextLabel2>
|
|
997
|
+
}
|
|
998
|
+
media={
|
|
999
|
+
<Box left={16} position="relative" top={0}>
|
|
1000
|
+
<RemoteImage height={174} source="/img/object.png" />
|
|
1001
|
+
</Box>
|
|
1002
|
+
}
|
|
1003
|
+
minWidth="0"
|
|
1004
|
+
title={
|
|
1005
|
+
<TextHeadline color="fgInverse" as="h3">
|
|
1006
|
+
Coinbase Card
|
|
1007
|
+
</TextHeadline>
|
|
1008
|
+
}
|
|
1009
|
+
width="100%"
|
|
1010
|
+
/>
|
|
1011
|
+
)}
|
|
1012
|
+
</CarouselItem>
|
|
1013
|
+
</Carousel>
|
|
1014
|
+
</Box>
|
|
1015
|
+
);
|
|
1016
|
+
}
|
|
1017
|
+
```
|
|
1018
|
+
|
|
1019
|
+
#### Custom Styles
|
|
1020
|
+
|
|
1021
|
+
You can use the `classNames` and `styles` props to customize different parts of the carousel.
|
|
1022
|
+
|
|
1023
|
+
```jsx live
|
|
1024
|
+
function CustomStylesCarousel() {
|
|
1025
|
+
return (
|
|
1026
|
+
<Box style={{ marginInline: 'calc(-1 * var(--space-3))' }}>
|
|
1027
|
+
<Carousel
|
|
1028
|
+
styles={{
|
|
1029
|
+
root: { position: 'relative', paddingInline: 'var(--space-6)' },
|
|
1030
|
+
carousel: { gap: 'var(--space-6)' },
|
|
1031
|
+
}}
|
|
1032
|
+
NavigationComponent={({
|
|
1033
|
+
className,
|
|
1034
|
+
style,
|
|
1035
|
+
disableGoNext,
|
|
1036
|
+
disableGoPrevious,
|
|
1037
|
+
nextPageAccessibilityLabel,
|
|
1038
|
+
onGoNext,
|
|
1039
|
+
onGoPrevious,
|
|
1040
|
+
previousPageAccessibilityLabel,
|
|
1041
|
+
}) => {
|
|
1042
|
+
return (
|
|
1043
|
+
<DefaultCarouselNavigation
|
|
1044
|
+
className={className}
|
|
1045
|
+
disableGoNext={disableGoNext}
|
|
1046
|
+
disableGoPrevious={disableGoPrevious}
|
|
1047
|
+
nextPageAccessibilityLabel={nextPageAccessibilityLabel}
|
|
1048
|
+
onGoNext={onGoNext}
|
|
1049
|
+
onGoPrevious={onGoPrevious}
|
|
1050
|
+
previousPageAccessibilityLabel={previousPageAccessibilityLabel}
|
|
1051
|
+
style={style}
|
|
1052
|
+
styles={{
|
|
1053
|
+
previousButton: {
|
|
1054
|
+
position: 'absolute',
|
|
1055
|
+
top: 'var(--space-8)',
|
|
1056
|
+
zIndex: 1,
|
|
1057
|
+
left: 'var(--space-0_5)',
|
|
1058
|
+
},
|
|
1059
|
+
nextButton: {
|
|
1060
|
+
position: 'absolute',
|
|
1061
|
+
top: 'var(--space-8)',
|
|
1062
|
+
zIndex: 1,
|
|
1063
|
+
right: 'var(--space-0_5)',
|
|
1064
|
+
},
|
|
1065
|
+
}}
|
|
1066
|
+
/>
|
|
1067
|
+
);
|
|
1068
|
+
}}
|
|
1069
|
+
>
|
|
1070
|
+
<CarouselItem id="earn-more-crypto" width="100%">
|
|
1071
|
+
<NudgeCard
|
|
1072
|
+
title="Earn more crypto"
|
|
1073
|
+
description="You've got unstaked crypto. Stake it now to earn more."
|
|
1074
|
+
pictogram="key"
|
|
1075
|
+
action="Start earning"
|
|
1076
|
+
onActionPress={() => console.log('Action pressed')}
|
|
1077
|
+
width="100%"
|
|
1078
|
+
minWidth="0"
|
|
1079
|
+
/>
|
|
1080
|
+
</CarouselItem>
|
|
1081
|
+
<CarouselItem id="secure-your-account" width="100%">
|
|
1082
|
+
<NudgeCard
|
|
1083
|
+
title="Secure your account"
|
|
1084
|
+
description="Add two-factor authentication for enhanced security."
|
|
1085
|
+
pictogram="shield"
|
|
1086
|
+
action="Enable 2FA"
|
|
1087
|
+
onActionPress={() => console.log('Enable 2FA pressed')}
|
|
1088
|
+
width="100%"
|
|
1089
|
+
minWidth="0"
|
|
1090
|
+
/>
|
|
1091
|
+
</CarouselItem>
|
|
1092
|
+
<CarouselItem id="complete-your-profile" width="100%">
|
|
1093
|
+
<NudgeCard
|
|
1094
|
+
title="Complete your profile"
|
|
1095
|
+
description="Add more details to personalize your experience."
|
|
1096
|
+
pictogram="accountsNavigation"
|
|
1097
|
+
action="Update profile"
|
|
1098
|
+
onActionPress={() => console.log('Update profile pressed')}
|
|
1099
|
+
width="100%"
|
|
1100
|
+
minWidth="0"
|
|
1101
|
+
/>
|
|
1102
|
+
</CarouselItem>
|
|
1103
|
+
</Carousel>
|
|
1104
|
+
</Box>
|
|
1105
|
+
);
|
|
1106
|
+
}
|
|
1107
|
+
```
|
|
1108
|
+
|
|
1109
|
+
#### Dynamic Content
|
|
1110
|
+
|
|
1111
|
+
You can dynamically add and remove items from the carousel.
|
|
1112
|
+
|
|
1113
|
+
```jsx live
|
|
1114
|
+
function DynamicContentCarousel() {
|
|
1115
|
+
const [items, setItems] = useState(Object.values(assets).slice(0, 3));
|
|
1116
|
+
|
|
1117
|
+
function SquareAssetCard({ imageUrl, name }) {
|
|
1118
|
+
return (
|
|
1119
|
+
<ContainedAssetCard
|
|
1120
|
+
description={
|
|
1121
|
+
<TextLabel2 as="p" color="fgPositive" numberOfLines={2}>
|
|
1122
|
+
↗6.37%
|
|
1123
|
+
</TextLabel2>
|
|
1124
|
+
}
|
|
1125
|
+
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
1126
|
+
subtitle={name}
|
|
1127
|
+
title="$0.87"
|
|
1128
|
+
/>
|
|
1129
|
+
);
|
|
1130
|
+
}
|
|
1131
|
+
function addAsset() {
|
|
1132
|
+
const randomAsset =
|
|
1133
|
+
Object.values(assets)[Math.floor(Math.random() * Object.values(assets).length)];
|
|
1134
|
+
setItems([...items, { ...randomAsset, symbol: `${randomAsset.symbol}-${items.length}` }]);
|
|
1135
|
+
}
|
|
1136
|
+
return (
|
|
1137
|
+
<VStack gap={2}>
|
|
1138
|
+
<HStack justifyContent="flex-end" gap={2} alignItems="center">
|
|
1139
|
+
<Button compact onClick={addAsset}>
|
|
1140
|
+
Add Asset
|
|
1141
|
+
</Button>
|
|
1142
|
+
<Button compact onClick={() => setItems(items.slice(0, -1))} disabled={items.length === 0}>
|
|
1143
|
+
Remove Last
|
|
1144
|
+
</Button>
|
|
1145
|
+
</HStack>
|
|
1146
|
+
<Box style={{ marginInline: 'calc(-1 * var(--space-3))' }}>
|
|
1147
|
+
<Carousel
|
|
1148
|
+
title="Explore Assets"
|
|
1149
|
+
styles={{
|
|
1150
|
+
root: { paddingInline: 'var(--space-3)' },
|
|
1151
|
+
carousel: { gap: 'var(--space-1)', height: '156px' },
|
|
1152
|
+
}}
|
|
1153
|
+
>
|
|
1154
|
+
{items.map((asset, index) => (
|
|
1155
|
+
<CarouselItem key={asset.symbol} id={asset.symbol}>
|
|
1156
|
+
<SquareAssetCard imageUrl={asset.imageUrl} name={asset.symbol} />
|
|
1157
|
+
</CarouselItem>
|
|
1158
|
+
))}
|
|
1159
|
+
</Carousel>
|
|
1160
|
+
</Box>
|
|
1161
|
+
</VStack>
|
|
1162
|
+
);
|
|
1163
|
+
}
|
|
1164
|
+
```
|
|
1165
|
+
|
|
1166
|
+
You can also animate items as they enter or leave the viewport.
|
|
1167
|
+
|
|
1168
|
+
```jsx live
|
|
1169
|
+
function AnimatedCarousel() {
|
|
1170
|
+
function SquareAssetCard({ imageUrl, name }) {
|
|
1171
|
+
const ref = useRef(null);
|
|
1172
|
+
// useInView is a framer motion hook that detects when an element is in the viewport
|
|
1173
|
+
const isInView = useInView(ref, {
|
|
1174
|
+
amount: 0.5,
|
|
1175
|
+
once: false,
|
|
1176
|
+
});
|
|
1177
|
+
|
|
1178
|
+
return (
|
|
1179
|
+
<motion.div
|
|
1180
|
+
ref={ref}
|
|
1181
|
+
initial={{ scale: 1 }}
|
|
1182
|
+
animate={{
|
|
1183
|
+
scale: isInView ? 1 : 0.8,
|
|
1184
|
+
}}
|
|
1185
|
+
>
|
|
1186
|
+
<ContainedAssetCard
|
|
1187
|
+
description={
|
|
1188
|
+
<TextLabel2 as="p" color="fgPositive" numberOfLines={2}>
|
|
1189
|
+
↗6.37%
|
|
1190
|
+
</TextLabel2>
|
|
1191
|
+
}
|
|
1192
|
+
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
1193
|
+
subtitle={name}
|
|
1194
|
+
title="$0.87"
|
|
1195
|
+
/>
|
|
1196
|
+
</motion.div>
|
|
1197
|
+
);
|
|
1198
|
+
}
|
|
1199
|
+
return (
|
|
1200
|
+
<Box style={{ marginInline: 'calc(-1 * var(--space-3))' }}>
|
|
1201
|
+
<Carousel
|
|
1202
|
+
title="Explore Assets"
|
|
1203
|
+
styles={{
|
|
1204
|
+
root: { paddingInline: 'var(--space-3)' },
|
|
1205
|
+
carousel: { gap: 'var(--space-1)' },
|
|
1206
|
+
}}
|
|
1207
|
+
snapMode="item"
|
|
1208
|
+
hidePagination
|
|
1209
|
+
>
|
|
1210
|
+
{Object.values(assets).map((asset, index) => (
|
|
1211
|
+
<CarouselItem key={asset.symbol} id={asset.symbol}>
|
|
1212
|
+
<SquareAssetCard imageUrl={asset.imageUrl} name={asset.symbol} />
|
|
1213
|
+
</CarouselItem>
|
|
1214
|
+
))}
|
|
1215
|
+
</Carousel>
|
|
1216
|
+
</Box>
|
|
1217
|
+
);
|
|
1218
|
+
}
|
|
1219
|
+
```
|
|
1220
|
+
|
|
1221
|
+
You can even change the size or content of items. In the example below, click an asset to highlight it.
|
|
1222
|
+
|
|
1223
|
+
```jsx live
|
|
1224
|
+
function AnimatedSelectionCarousel() {
|
|
1225
|
+
const dimensions = { width: 140, height: 60 };
|
|
1226
|
+
const path = useSparklinePath({ ...dimensions, data: prices });
|
|
1227
|
+
|
|
1228
|
+
const SquareAssetCard = memo(({ isVisible, imageUrl, name, color }) => {
|
|
1229
|
+
const squareSize = 156;
|
|
1230
|
+
const largeSize = 327;
|
|
1231
|
+
const [isHighlighted, setIsHighlighted] = useState(false);
|
|
1232
|
+
const [size, setSize] = useState('s');
|
|
1233
|
+
|
|
1234
|
+
const handleClick = useCallback(() => {
|
|
1235
|
+
setIsHighlighted((highlighted) => !highlighted);
|
|
1236
|
+
}, [setIsHighlighted]);
|
|
1237
|
+
|
|
1238
|
+
const onAnimationStart = useCallback(() => {
|
|
1239
|
+
if (isHighlighted) {
|
|
1240
|
+
setSize('l');
|
|
1241
|
+
}
|
|
1242
|
+
}, [isHighlighted, setSize]);
|
|
1243
|
+
const onAnimationComplete = useCallback(() => {
|
|
1244
|
+
if (!isHighlighted) {
|
|
1245
|
+
setSize('s');
|
|
1246
|
+
}
|
|
1247
|
+
}, [isHighlighted, setSize]);
|
|
1248
|
+
|
|
1249
|
+
return (
|
|
1250
|
+
<Pressable onClick={handleClick} tabIndex={isVisible ? undefined : -1} borderRadius={500}>
|
|
1251
|
+
<motion.div
|
|
1252
|
+
initial={{ width: squareSize }}
|
|
1253
|
+
animate={{
|
|
1254
|
+
width: isHighlighted ? largeSize : squareSize,
|
|
1255
|
+
}}
|
|
1256
|
+
onAnimationStart={onAnimationStart}
|
|
1257
|
+
onAnimationComplete={onAnimationComplete}
|
|
1258
|
+
style={{
|
|
1259
|
+
overflow: 'hidden',
|
|
1260
|
+
borderRadius: 'var(--borderRadius-500)',
|
|
1261
|
+
}}
|
|
1262
|
+
>
|
|
1263
|
+
<ContainedAssetCard
|
|
1264
|
+
description={
|
|
1265
|
+
<TextLabel2 as="p" color="fgPositive" numberOfLines={2}>
|
|
1266
|
+
↗6.37%
|
|
1267
|
+
</TextLabel2>
|
|
1268
|
+
}
|
|
1269
|
+
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
1270
|
+
subtitle={name}
|
|
1271
|
+
title="$0.87"
|
|
1272
|
+
style={{ maxWidth: largeSize, width: '100%' }}
|
|
1273
|
+
size={size}
|
|
1274
|
+
>
|
|
1275
|
+
<VStack padding={1} justifyContent="center" height={squareSize}>
|
|
1276
|
+
<Sparkline {...dimensions} path={path} color={color} />
|
|
1277
|
+
</VStack>
|
|
1278
|
+
</ContainedAssetCard>
|
|
1279
|
+
</motion.div>
|
|
1280
|
+
</Pressable>
|
|
1281
|
+
);
|
|
1282
|
+
});
|
|
1283
|
+
return (
|
|
1284
|
+
<Box style={{ marginInline: 'calc(-1 * var(--space-3))' }}>
|
|
1285
|
+
<Carousel
|
|
1286
|
+
title="Explore Assets"
|
|
1287
|
+
styles={{
|
|
1288
|
+
root: { paddingInline: 'var(--space-3)' },
|
|
1289
|
+
carousel: { gap: 'var(--space-1)' },
|
|
1290
|
+
}}
|
|
1291
|
+
>
|
|
1292
|
+
{Object.values(assets).map((asset, index) => (
|
|
1293
|
+
<CarouselItem key={asset.symbol} id={asset.symbol}>
|
|
1294
|
+
{({ isVisible }) => (
|
|
1295
|
+
<SquareAssetCard
|
|
1296
|
+
isVisible={isVisible}
|
|
1297
|
+
imageUrl={asset.imageUrl}
|
|
1298
|
+
name={asset.symbol}
|
|
1299
|
+
color={asset.color}
|
|
1300
|
+
/>
|
|
1301
|
+
)}
|
|
1302
|
+
</CarouselItem>
|
|
1303
|
+
))}
|
|
1304
|
+
</Carousel>
|
|
1305
|
+
</Box>
|
|
1306
|
+
);
|
|
1307
|
+
}
|
|
1308
|
+
```
|
|
1309
|
+
|
|
1310
|
+
#### Hide Navigation and Pagination
|
|
1311
|
+
|
|
1312
|
+
You can hide the navigation and pagination components of the carousel if desired (using `hideNavigation` and `hidePagination` props).
|
|
1313
|
+
|
|
1314
|
+
Note that this can prevent proper accessibility for the carousel. If hiding pagination, it's recommended instead to
|
|
1315
|
+
pass in `DefaultCarouselNavigation` with `hideUnlessFocused` prop. Alternatively, you can ensure that the carousel is
|
|
1316
|
+
navigable by keyboard through other means.
|
|
1317
|
+
|
|
1318
|
+
```jsx live
|
|
1319
|
+
function HideNavigationAndPaginationCarousel() {
|
|
1320
|
+
function SquareAssetCard({ imageUrl, name }) {
|
|
1321
|
+
return (
|
|
1322
|
+
<ContainedAssetCard
|
|
1323
|
+
description={
|
|
1324
|
+
<TextLabel2 as="p" color="fgPositive" numberOfLines={2}>
|
|
1325
|
+
↗6.37%
|
|
1326
|
+
</TextLabel2>
|
|
1327
|
+
}
|
|
1328
|
+
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
1329
|
+
subtitle={name}
|
|
1330
|
+
title="$0.87"
|
|
1331
|
+
/>
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
return (
|
|
1335
|
+
<Box style={{ marginInline: 'calc(-1 * var(--space-3))' }}>
|
|
1336
|
+
<Carousel
|
|
1337
|
+
title="Explore Assets"
|
|
1338
|
+
hidePagination
|
|
1339
|
+
NavigationComponent={(props) => <DefaultCarouselNavigation {...props} hideUnlessFocused />}
|
|
1340
|
+
drag="free"
|
|
1341
|
+
snapMode="item"
|
|
1342
|
+
styles={{
|
|
1343
|
+
root: { paddingInline: 'var(--space-3)' },
|
|
1344
|
+
carousel: { gap: 'var(--space-1)' },
|
|
1345
|
+
}}
|
|
1346
|
+
>
|
|
1347
|
+
{Object.values(assets).map((asset, index) => (
|
|
1348
|
+
<CarouselItem key={asset.symbol} id={asset.symbol}>
|
|
1349
|
+
<SquareAssetCard imageUrl={asset.imageUrl} name={asset.symbol} />
|
|
1350
|
+
</CarouselItem>
|
|
1351
|
+
))}
|
|
1352
|
+
</Carousel>
|
|
1353
|
+
</Box>
|
|
1354
|
+
);
|
|
1355
|
+
}
|
|
1356
|
+
```
|
|
1357
|
+
|
|
1358
|
+
#### Animated Pagination
|
|
1359
|
+
|
|
1360
|
+
You can create smooth pagination animations by customizing the pagination dots. This example shows how to create expanding dots that smoothly transition between active and inactive states.
|
|
1361
|
+
|
|
1362
|
+
```jsx live
|
|
1363
|
+
function AnimatedPaginationCarousel() {
|
|
1364
|
+
const AnimatedPagination = memo((props) => {
|
|
1365
|
+
const { totalPages, activePageIndex, onClickPage, style } = props;
|
|
1366
|
+
|
|
1367
|
+
const dotStyles = {
|
|
1368
|
+
height: 'var(--space-1)',
|
|
1369
|
+
borderRadius: 'var(--borderRadius-1000)',
|
|
1370
|
+
transition: 'all 0.3s ease',
|
|
1371
|
+
cursor: 'pointer',
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1374
|
+
return (
|
|
1375
|
+
<HStack alignItems="center" gap={0.5} justifyContent="center" style={style}>
|
|
1376
|
+
{Array.from({ length: totalPages }, (_, index) => {
|
|
1377
|
+
const isActive = index === activePageIndex;
|
|
1378
|
+
return (
|
|
1379
|
+
<Pressable
|
|
1380
|
+
key={index}
|
|
1381
|
+
accessibilityLabel={`Go to page ${index + 1}`}
|
|
1382
|
+
background={isActive ? 'bgPrimary' : 'bgLine'}
|
|
1383
|
+
borderWidth={0}
|
|
1384
|
+
data-testid={`carousel-page-${index}`}
|
|
1385
|
+
onClick={() => onClickPage?.(index)}
|
|
1386
|
+
style={{
|
|
1387
|
+
...dotStyles,
|
|
1388
|
+
width: isActive ? 'var(--space-3)' : 'var(--space-1)',
|
|
1389
|
+
}}
|
|
1390
|
+
/>
|
|
1391
|
+
);
|
|
1392
|
+
})}
|
|
1393
|
+
</HStack>
|
|
1394
|
+
);
|
|
1395
|
+
});
|
|
1396
|
+
|
|
1397
|
+
function SquareAssetCard({ imageUrl, name }) {
|
|
1398
|
+
return (
|
|
1399
|
+
<ContainedAssetCard
|
|
1400
|
+
description={
|
|
1401
|
+
<TextLabel2 as="p" color="fgPositive" numberOfLines={2}>
|
|
1402
|
+
↗6.37%
|
|
1403
|
+
</TextLabel2>
|
|
1404
|
+
}
|
|
1405
|
+
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
1406
|
+
subtitle={name}
|
|
1407
|
+
title="$0.87"
|
|
1408
|
+
/>
|
|
1409
|
+
);
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
return (
|
|
1413
|
+
<Box style={{ marginInline: 'calc(-1 * var(--space-3))' }}>
|
|
1414
|
+
<Carousel
|
|
1415
|
+
PaginationComponent={AnimatedPagination}
|
|
1416
|
+
drag="snap"
|
|
1417
|
+
snapMode="page"
|
|
1418
|
+
styles={{
|
|
1419
|
+
root: { paddingInline: 'var(--space-3)' },
|
|
1420
|
+
carousel: { gap: 'var(--space-1)' },
|
|
1421
|
+
}}
|
|
1422
|
+
title="Explore Assets"
|
|
1423
|
+
>
|
|
1424
|
+
{Object.values(assets).map((asset, index) => (
|
|
1425
|
+
<CarouselItem key={asset.symbol} id={asset.symbol} accessibilityLabel={asset.name}>
|
|
1426
|
+
<SquareAssetCard imageUrl={asset.imageUrl} name={asset.symbol} />
|
|
1427
|
+
</CarouselItem>
|
|
1428
|
+
))}
|
|
1429
|
+
</Carousel>
|
|
1430
|
+
</Box>
|
|
1431
|
+
);
|
|
1432
|
+
}
|
|
1433
|
+
```
|
|
1434
|
+
|
|
1435
|
+
### Imperative API
|
|
1436
|
+
|
|
1437
|
+
You can control the carousel programmatically using a ref. The carousel exposes methods to navigate to specific pages and access the current page index.
|
|
1438
|
+
|
|
1439
|
+
```jsx live
|
|
1440
|
+
function ImperativeApiCarousel() {
|
|
1441
|
+
const carouselRef = useRef(null);
|
|
1442
|
+
const [currentPageInfo, setCurrentPageInfo] = useState('Page 1');
|
|
1443
|
+
|
|
1444
|
+
function handleGoToPage(pageIndex: number) {
|
|
1445
|
+
if (carouselRef.current) {
|
|
1446
|
+
const clampedPageIndex = Math.max(0, Math.min(carouselRef.current.totalPages - 1, pageIndex));
|
|
1447
|
+
carouselRef.current.goToPage(clampedPageIndex);
|
|
1448
|
+
setCurrentPageInfo(`Page ${clampedPageIndex + 1}`);
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
function handleGoToFirstPage() {
|
|
1453
|
+
handleGoToPage(0);
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
function handleGoToLastPage() {
|
|
1457
|
+
if (carouselRef.current) {
|
|
1458
|
+
handleGoToPage(carouselRef.current.totalPages - 1);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
function handleGoToPrevPage() {
|
|
1463
|
+
if (carouselRef.current) {
|
|
1464
|
+
handleGoToPage(carouselRef.current.activePageIndex - 1);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
function handleGoToNextPage() {
|
|
1469
|
+
if (carouselRef.current) {
|
|
1470
|
+
handleGoToPage(carouselRef.current.activePageIndex + 1);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
function SquareAssetCard({ imageUrl, name }) {
|
|
1475
|
+
return (
|
|
1476
|
+
<ContainedAssetCard
|
|
1477
|
+
description={
|
|
1478
|
+
<TextLabel2 as="p" color="fgPositive" numberOfLines={2}>
|
|
1479
|
+
↗6.37%
|
|
1480
|
+
</TextLabel2>
|
|
1481
|
+
}
|
|
1482
|
+
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
1483
|
+
subtitle={name}
|
|
1484
|
+
title="$0.87"
|
|
1485
|
+
/>
|
|
1486
|
+
);
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
return (
|
|
1490
|
+
<VStack gap={2}>
|
|
1491
|
+
<HStack gap={2} style={{ flexWrap: 'wrap' }} justifyContent="space-between">
|
|
1492
|
+
<HStack gap={1}>
|
|
1493
|
+
<IconButton
|
|
1494
|
+
onClick={handleGoToFirstPage}
|
|
1495
|
+
variant="secondary"
|
|
1496
|
+
name="doubleChevronRight"
|
|
1497
|
+
style={{ transform: 'rotate(180deg)' }}
|
|
1498
|
+
accessibilityLabel="Go to first page"
|
|
1499
|
+
/>
|
|
1500
|
+
<IconButton
|
|
1501
|
+
onClick={handleGoToPrevPage}
|
|
1502
|
+
variant="secondary"
|
|
1503
|
+
name="arrowLeft"
|
|
1504
|
+
active
|
|
1505
|
+
accessibilityLabel="Go to previous page"
|
|
1506
|
+
/>
|
|
1507
|
+
</HStack>
|
|
1508
|
+
<Box
|
|
1509
|
+
alignItems="center"
|
|
1510
|
+
background="bgSecondary"
|
|
1511
|
+
borderRadius={500}
|
|
1512
|
+
flexGrow={1}
|
|
1513
|
+
justifyContent="center"
|
|
1514
|
+
paddingX={2}
|
|
1515
|
+
paddingY={1}
|
|
1516
|
+
>
|
|
1517
|
+
<Text color="fgMuted" font="label1">
|
|
1518
|
+
{currentPageInfo}
|
|
1519
|
+
</Text>
|
|
1520
|
+
</Box>
|
|
1521
|
+
<HStack gap={1}>
|
|
1522
|
+
<IconButton
|
|
1523
|
+
onClick={handleGoToNextPage}
|
|
1524
|
+
variant="secondary"
|
|
1525
|
+
name="arrowRight"
|
|
1526
|
+
active
|
|
1527
|
+
accessibilityLabel="Go to next page"
|
|
1528
|
+
/>
|
|
1529
|
+
<IconButton
|
|
1530
|
+
onClick={handleGoToLastPage}
|
|
1531
|
+
variant="secondary"
|
|
1532
|
+
name="doubleChevronRight"
|
|
1533
|
+
accessibilityLabel="Go to last page"
|
|
1534
|
+
/>
|
|
1535
|
+
</HStack>
|
|
1536
|
+
</HStack>
|
|
1537
|
+
<Box style={{ marginInline: 'calc(-1 * var(--space-3))' }}>
|
|
1538
|
+
<Carousel
|
|
1539
|
+
ref={carouselRef}
|
|
1540
|
+
hidePagination
|
|
1541
|
+
hideNavigation
|
|
1542
|
+
drag="none"
|
|
1543
|
+
snapMode="item"
|
|
1544
|
+
styles={{
|
|
1545
|
+
root: { paddingInline: 'var(--space-3)' },
|
|
1546
|
+
carousel: { gap: 'var(--space-1)' },
|
|
1547
|
+
}}
|
|
1548
|
+
title="Explore Assets"
|
|
1549
|
+
>
|
|
1550
|
+
{Object.values(assets).map((asset, index) => (
|
|
1551
|
+
<CarouselItem key={asset.symbol} id={asset.symbol} accessibilityLabel={asset.name}>
|
|
1552
|
+
<SquareAssetCard imageUrl={asset.imageUrl} name={asset.symbol} />
|
|
1553
|
+
</CarouselItem>
|
|
1554
|
+
))}
|
|
1555
|
+
</Carousel>
|
|
1556
|
+
</Box>
|
|
1557
|
+
</VStack>
|
|
1558
|
+
);
|
|
1559
|
+
}
|
|
1560
|
+
```
|
|
1561
|
+
|
|
1562
|
+
### Callbacks
|
|
1563
|
+
|
|
1564
|
+
You can use the `onChangePage`, `onDragStart`, and `onDragEnd` callbacks to listen for user interaction in the carousel.
|
|
1565
|
+
|
|
1566
|
+
```tsx
|
|
1567
|
+
<Carousel
|
|
1568
|
+
onChangePage={(pageIndex: number) => console.log('Page changed', activePageIndex)}
|
|
1569
|
+
onDragStart={() => console.log('Drag started')}
|
|
1570
|
+
onDragEnd={() => console.log('Drag ended')}
|
|
1571
|
+
>
|
|
1572
|
+
...
|
|
1573
|
+
</Carousel>
|
|
1574
|
+
```
|
|
1575
|
+
|
|
1576
|
+
|