@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,330 @@
|
|
|
1
|
+
# SlideButton
|
|
2
|
+
|
|
3
|
+
A button that slides to confirm an action.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { SlideButton } from '@coinbase/cds-mobile/buttons/SlideButton'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Examples
|
|
12
|
+
|
|
13
|
+
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
14
|
+
import ThemedImage from '@theme/ThemedImage';
|
|
15
|
+
|
|
16
|
+
### SlideButton
|
|
17
|
+
|
|
18
|
+
Use the `onChange` prop to listen and make changes to the `checked` state.
|
|
19
|
+
|
|
20
|
+
<ThemedImage
|
|
21
|
+
sources={{
|
|
22
|
+
light: useBaseUrl('/img/docs/slideButton/default.gif'),
|
|
23
|
+
dark: useBaseUrl('/img/docs/slideButton/default_dark.gif'),
|
|
24
|
+
}}
|
|
25
|
+
style={{
|
|
26
|
+
borderRadius: 'var(--borderRadius-400)',
|
|
27
|
+
border: '1.5px solid var(--color-bgLine)',
|
|
28
|
+
}}
|
|
29
|
+
alt="Slide button"
|
|
30
|
+
/>
|
|
31
|
+
|
|
32
|
+
```jsx
|
|
33
|
+
function Example() {
|
|
34
|
+
const [checked, setChecked] = useState(false);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<SlideButton
|
|
38
|
+
checked={checked}
|
|
39
|
+
onChange={setChecked}
|
|
40
|
+
onSlideComplete={() => console.log('Completed')}
|
|
41
|
+
uncheckedLabel="Swipe to confirm"
|
|
42
|
+
checkedLabel="Confirming..."
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Negative SlideButton
|
|
49
|
+
|
|
50
|
+
You can use the `variant` prop to change the color of the button.
|
|
51
|
+
|
|
52
|
+
<ThemedImage
|
|
53
|
+
sources={{
|
|
54
|
+
light: useBaseUrl('/img/docs/slideButton/negative_variant.jpg'),
|
|
55
|
+
dark: useBaseUrl('/img/docs/slideButton/negative_variant_dark.jpg'),
|
|
56
|
+
}}
|
|
57
|
+
style={{
|
|
58
|
+
borderRadius: 'var(--borderRadius-400)',
|
|
59
|
+
border: '1.5px solid var(--color-bgLine)',
|
|
60
|
+
}}
|
|
61
|
+
alt="Negative variant slide button"
|
|
62
|
+
/>
|
|
63
|
+
|
|
64
|
+
```jsx
|
|
65
|
+
function Example() {
|
|
66
|
+
const [checked, setChecked] = useState(false);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<SlideButton
|
|
70
|
+
checked={checked}
|
|
71
|
+
onChange={setChecked}
|
|
72
|
+
onSlideComplete={() => console.log('Completed')}
|
|
73
|
+
uncheckedLabel="Swipe to confirm"
|
|
74
|
+
checkedLabel="Confirming..."
|
|
75
|
+
variant="negative"
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Auto Complete on Threshold
|
|
82
|
+
|
|
83
|
+
You can set the button to automatically complete when the slide reaches the threshold:
|
|
84
|
+
|
|
85
|
+
```jsx
|
|
86
|
+
function Example() {
|
|
87
|
+
const [checked, setChecked] = useState(false);
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<SlideButton
|
|
91
|
+
checked={checked}
|
|
92
|
+
onChange={setChecked}
|
|
93
|
+
onSlideComplete={() => console.log('Completed')}
|
|
94
|
+
uncheckedLabel="Swipe to confirm"
|
|
95
|
+
checkedLabel="Confirming..."
|
|
96
|
+
autoCompleteSlideOnThresholdMet
|
|
97
|
+
/>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Custom Nodes on SlideButton
|
|
103
|
+
|
|
104
|
+
You can also use SlideButton with custom nodes.
|
|
105
|
+
|
|
106
|
+
<ThemedImage
|
|
107
|
+
sources={{
|
|
108
|
+
light: useBaseUrl('/img/docs/slideButton/custom_nodes.jpg'),
|
|
109
|
+
dark: useBaseUrl('/img/docs/slideButton/custom_nodes_dark.jpg'),
|
|
110
|
+
}}
|
|
111
|
+
style={{
|
|
112
|
+
borderRadius: 'var(--borderRadius-400)',
|
|
113
|
+
border: '1.5px solid var(--color-bgLine)',
|
|
114
|
+
}}
|
|
115
|
+
alt="Custom nodes on slide button"
|
|
116
|
+
/>
|
|
117
|
+
|
|
118
|
+
```jsx
|
|
119
|
+
function Example() {
|
|
120
|
+
const [checked, setChecked] = useState(false);
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<SlideButton
|
|
124
|
+
checked={checked}
|
|
125
|
+
onChange={setChecked}
|
|
126
|
+
onSlideComplete={() => console.log('Completed')}
|
|
127
|
+
uncheckedLabel="Swipe to enable notifications"
|
|
128
|
+
checkedLabel="Enabling..."
|
|
129
|
+
startUncheckedNode={<Icon color="fgInverse" name="bellCheck" size="m" />}
|
|
130
|
+
endCheckedNode={<Icon color="fgInverse" name="bellInactive" size="m" />}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Custom Background and Handle Components
|
|
137
|
+
|
|
138
|
+
You can customize the background and handle components of the SlideButton.
|
|
139
|
+
|
|
140
|
+
<ThemedImage
|
|
141
|
+
sources={{
|
|
142
|
+
light: useBaseUrl('/img/docs/slideButton/custom_components.jpg'),
|
|
143
|
+
dark: useBaseUrl('/img/docs/slideButton/custom_components_dark.jpg'),
|
|
144
|
+
}}
|
|
145
|
+
style={{
|
|
146
|
+
borderRadius: 'var(--borderRadius-400)',
|
|
147
|
+
border: '1.5px solid var(--color-bgLine)',
|
|
148
|
+
}}
|
|
149
|
+
alt="Custom background and handle components"
|
|
150
|
+
/>
|
|
151
|
+
|
|
152
|
+
```jsx
|
|
153
|
+
function Example() {
|
|
154
|
+
const [checked, setChecked] = useState(false);
|
|
155
|
+
|
|
156
|
+
const CustomHandle = ({ checked, ...props }: SlideButtonHandleProps) => (
|
|
157
|
+
<Pressable
|
|
158
|
+
{...props}
|
|
159
|
+
accessibilityLabel="Demo button"
|
|
160
|
+
accessibilityRole="button"
|
|
161
|
+
background={checked ? 'bgPositive' : 'bgNegative'}
|
|
162
|
+
borderRadius={300}
|
|
163
|
+
width="100%"
|
|
164
|
+
>
|
|
165
|
+
<HStack alignItems="center" height="100%" justifyContent="center" width="100%">
|
|
166
|
+
<HStack height="100%" pin="right" alignItems="center" padding={2}>
|
|
167
|
+
<TextLabel1>➡️</TextLabel1>
|
|
168
|
+
</HStack>
|
|
169
|
+
</HStack>
|
|
170
|
+
</Pressable>
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const CustomBackground = ({ checked, ...props }: SlideButtonBackgroundProps) => (
|
|
174
|
+
<HStack
|
|
175
|
+
{...props}
|
|
176
|
+
bordered
|
|
177
|
+
alignItems="center"
|
|
178
|
+
background="bgSecondary"
|
|
179
|
+
borderColor={checked ? 'fgPositive' : 'fgNegative'}
|
|
180
|
+
borderRadius={300}
|
|
181
|
+
height="100%"
|
|
182
|
+
justifyContent="center"
|
|
183
|
+
width="100%"
|
|
184
|
+
>
|
|
185
|
+
<TextHeadline>Slide me</TextHeadline>
|
|
186
|
+
</HStack>
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<SlideButton
|
|
191
|
+
uncheckedLabel="Swipe to confirm"
|
|
192
|
+
checkedLabel="Confirming..."
|
|
193
|
+
checked={checked}
|
|
194
|
+
onChange={setChecked}
|
|
195
|
+
SlideButtonBackgroundComponent={CustomBackground}
|
|
196
|
+
SlideButtonHandleComponent={CustomHandle}
|
|
197
|
+
height={50}
|
|
198
|
+
/>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Props
|
|
204
|
+
|
|
205
|
+
| Prop | Type | Required | Default | Description |
|
|
206
|
+
| --- | --- | --- | --- | --- |
|
|
207
|
+
| `checked` | `boolean` | Yes | `-` | Control whether the button is in a checked state. |
|
|
208
|
+
| `SlideButtonBackgroundComponent` | `SlideButtonBackgroundComponent` | No | `DefaultSlideButtonBackground` | Custom component to render as the container behind the sliding handle. |
|
|
209
|
+
| `SlideButtonHandleComponent` | `SlideButtonHandleComponent` | No | `DefaultSlideButtonHandle` | Custom component to render as the sliding handle. |
|
|
210
|
+
| `alignContent` | `flex-start \| flex-end \| center \| stretch \| space-between \| space-around \| space-evenly` | No | `-` | - |
|
|
211
|
+
| `alignItems` | `flex-start \| flex-end \| center \| stretch \| baseline` | No | `-` | - |
|
|
212
|
+
| `alignSelf` | `auto \| FlexAlignType` | No | `-` | - |
|
|
213
|
+
| `aspectRatio` | `string \| number` | No | `-` | - |
|
|
214
|
+
| `autoCompleteSlideOnThresholdMet` | `boolean` | No | `-` | If true, the slide button will automatically complete the slide when the threshold is met. If false, the user must release to complete the action. |
|
|
215
|
+
| `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 | `-` | Background color of the overlay (element being interacted with). |
|
|
216
|
+
| `blendStyles` | `{ background?: string; pressedBackground?: string \| undefined; disabledBackground?: string \| undefined; borderColor?: string \| undefined; pressedBorderColor?: string \| undefined; disabledBorderColor?: string \| undefined; } \| undefined` | No | `-` | Custom color overrides for different interaction states. Base colors (background, borderColor) are used directly, while interaction state colors (pressed, disabled) are used as alternative base colors for blending calculations with blend strength and color scheme considerations. |
|
|
217
|
+
| `block` | `boolean` | No | `-` | Set element to block and expand to 100% width. |
|
|
218
|
+
| `borderBottomLeftRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `-` | - |
|
|
219
|
+
| `borderBottomRightRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `-` | - |
|
|
220
|
+
| `borderBottomWidth` | `0 \| 100 \| 200 \| 300 \| 400 \| 500` | No | `-` | - |
|
|
221
|
+
| `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 | `-` | - |
|
|
222
|
+
| `borderEndWidth` | `0 \| 100 \| 200 \| 300 \| 400 \| 500` | No | `-` | - |
|
|
223
|
+
| `borderRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `-` | - |
|
|
224
|
+
| `borderStartWidth` | `0 \| 100 \| 200 \| 300 \| 400 \| 500` | No | `-` | - |
|
|
225
|
+
| `borderTopLeftRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `-` | - |
|
|
226
|
+
| `borderTopRightRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `-` | - |
|
|
227
|
+
| `borderTopWidth` | `0 \| 100 \| 200 \| 300 \| 400 \| 500` | No | `-` | - |
|
|
228
|
+
| `borderWidth` | `0 \| 100 \| 200 \| 300 \| 400 \| 500` | No | `-` | - |
|
|
229
|
+
| `bordered` | `boolean` | No | `-` | Add a border around all sides of the box. |
|
|
230
|
+
| `borderedBottom` | `boolean` | No | `-` | Add a border to the bottom side of the box. |
|
|
231
|
+
| `borderedEnd` | `boolean` | No | `-` | Add a border to the trailing side of the box. |
|
|
232
|
+
| `borderedHorizontal` | `boolean` | No | `-` | Add a border to the leading and trailing sides of the box. |
|
|
233
|
+
| `borderedStart` | `boolean` | No | `-` | Add a border to the leading side of the box. |
|
|
234
|
+
| `borderedTop` | `boolean` | No | `-` | Add a border to the top side of the box. |
|
|
235
|
+
| `borderedVertical` | `boolean` | No | `-` | Add a border to the top and bottom sides of the box. |
|
|
236
|
+
| `bottom` | `string \| number` | No | `-` | - |
|
|
237
|
+
| `checkThreshold` | `number` | No | `0.7` | Threshold (as a percentage from 0 to 1) at which a slide gesture will complete. A value of 0.7 means the user must slide 70% of the way across to trigger completion. |
|
|
238
|
+
| `checkedLabel` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Label or content shown when button is in checked state. |
|
|
239
|
+
| `children` | `((string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal) & (string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal \| ((state: PressableStateCallbackType) => ReactNode))) \| null` | No | `-` | Either children or a render prop that receives a boolean reflecting whether the component is currently pressed. |
|
|
240
|
+
| `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 | `-` | - |
|
|
241
|
+
| `columnGap` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | - |
|
|
242
|
+
| `contentStyle` | `null \| false \| ViewStyle \| RegisteredStyle<ViewStyle> \| RecursiveArray<Falsy \| ViewStyle \| RegisteredStyle<ViewStyle>>` | No | `-` | Apply animated styles to the inner container. |
|
|
243
|
+
| `dangerouslySetBackground` | `string` | No | `-` | - |
|
|
244
|
+
| `debounceTime` | `number` | No | `500` | The amount of time to wait (in milliseconds) before invoking the debounced function. This prop is used in conjunction with the disableDebounce prop. The debounce function is configured to be invoked as soon as its called, but subsequent calls within the debounceTime period will be ignored. |
|
|
245
|
+
| `disableDebounce` | `boolean` | No | `-` | React Native is historically trash at debouncing touch events. This can cause a lot of unwanted behavior such as double navigations where we push a screen onto the stack 2 times. Debouncing the event 500 miliseconds, but taking the leading event prevents this effect and the accidental double-tap. |
|
|
246
|
+
| `disabled` | `boolean` | No | `-` | Is the element currently disabled. Whether the press behavior is disabled. Disables user interaction with the slide button. When true, prevents gesture events from firing. |
|
|
247
|
+
| `display` | `flex \| none` | No | `-` | - |
|
|
248
|
+
| `elevation` | `0 \| 1 \| 2` | No | `-` | Determines box shadow styles. Parent should have overflow set to visible to ensure styles are not clipped. Is the element elevated. |
|
|
249
|
+
| `endCheckedNode` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Custom end node to render for the checked state of the handle, to replace the default loading indicator. |
|
|
250
|
+
| `feedback` | `none \| light \| normal \| heavy` | No | `none` | Haptic feedback to trigger when being pressed. |
|
|
251
|
+
| `flexBasis` | `string \| number` | No | `-` | - |
|
|
252
|
+
| `flexDirection` | `row \| column \| row-reverse \| column-reverse` | No | `-` | - |
|
|
253
|
+
| `flexGrow` | `number` | No | `-` | - |
|
|
254
|
+
| `flexShrink` | `number` | No | `-` | - |
|
|
255
|
+
| `flexWrap` | `wrap \| nowrap \| wrap-reverse` | No | `-` | - |
|
|
256
|
+
| `font` | `inherit \| FontFamily` | No | `-` | - |
|
|
257
|
+
| `fontFamily` | `inherit \| FontFamily` | No | `-` | - |
|
|
258
|
+
| `fontSize` | `inherit \| FontSize` | No | `-` | - |
|
|
259
|
+
| `fontWeight` | `inherit \| FontWeight` | No | `-` | - |
|
|
260
|
+
| `gap` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | - |
|
|
261
|
+
| `height` | `number` | No | `-` | Height of the entire button component (background and handle). If you pass a custom SlideButtonBackgroundComponent or SlideButtonHandleComponent, this property will be applied to both. |
|
|
262
|
+
| `justifyContent` | `flex-start \| flex-end \| center \| space-between \| space-around \| space-evenly` | No | `-` | - |
|
|
263
|
+
| `key` | `Key \| null` | No | `-` | - |
|
|
264
|
+
| `left` | `string \| number` | No | `-` | - |
|
|
265
|
+
| `lineHeight` | `inherit \| LineHeight` | No | `-` | - |
|
|
266
|
+
| `margin` | `0 \| -1 \| -2 \| -3 \| -4 \| -5 \| -6 \| -7 \| -8 \| -9 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1.5` | No | `-` | - |
|
|
267
|
+
| `marginBottom` | `0 \| -1 \| -2 \| -3 \| -4 \| -5 \| -6 \| -7 \| -8 \| -9 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1.5` | No | `-` | - |
|
|
268
|
+
| `marginEnd` | `0 \| -1 \| -2 \| -3 \| -4 \| -5 \| -6 \| -7 \| -8 \| -9 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1.5` | No | `-` | - |
|
|
269
|
+
| `marginStart` | `0 \| -1 \| -2 \| -3 \| -4 \| -5 \| -6 \| -7 \| -8 \| -9 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1.5` | No | `-` | - |
|
|
270
|
+
| `marginTop` | `0 \| -1 \| -2 \| -3 \| -4 \| -5 \| -6 \| -7 \| -8 \| -9 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1.5` | No | `-` | - |
|
|
271
|
+
| `marginX` | `0 \| -1 \| -2 \| -3 \| -4 \| -5 \| -6 \| -7 \| -8 \| -9 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1.5` | No | `-` | - |
|
|
272
|
+
| `marginY` | `0 \| -1 \| -2 \| -3 \| -4 \| -5 \| -6 \| -7 \| -8 \| -9 \| -10 \| -0.25 \| -0.5 \| -0.75 \| -1.5` | No | `-` | - |
|
|
273
|
+
| `maxHeight` | `string \| number` | No | `-` | - |
|
|
274
|
+
| `maxWidth` | `string \| number` | No | `-` | - |
|
|
275
|
+
| `minHeight` | `string \| number` | No | `-` | - |
|
|
276
|
+
| `minWidth` | `string \| number` | No | `-` | - |
|
|
277
|
+
| `noScaleOnPress` | `boolean` | No | `-` | Dont scale element on press. |
|
|
278
|
+
| `onChange` | `((checked: boolean) => void)` | No | `-` | Callback function fired when slide button state changes. Will always be called after onSlideComplete and before onSlideEnd. |
|
|
279
|
+
| `onPointerCancel` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
280
|
+
| `onPointerCancelCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
281
|
+
| `onPointerDown` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
282
|
+
| `onPointerDownCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
283
|
+
| `onPointerEnter` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
284
|
+
| `onPointerEnterCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
285
|
+
| `onPointerLeave` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
286
|
+
| `onPointerLeaveCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
287
|
+
| `onPointerMove` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
288
|
+
| `onPointerMoveCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
289
|
+
| `onPointerUp` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
290
|
+
| `onPointerUpCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
291
|
+
| `onPress` | `((event: GestureResponderEvent) => void) \| null` | No | `-` | Called when a single tap gesture is detected. |
|
|
292
|
+
| `onPressIn` | `(((event: GestureResponderEvent) => void) & ((event: GestureResponderEvent) => void))` | No | `-` | Callback fired before onPress when button is pressed. Called when a touch is engaged before onPress. |
|
|
293
|
+
| `onPressOut` | `(((event: GestureResponderEvent) => void) & ((event: GestureResponderEvent) => void))` | No | `-` | Callback fired before onPress when button is released. Called when a touch is released before onPress. |
|
|
294
|
+
| `onSlideCancel` | `(() => void)` | No | `-` | Callback function fired when the slide gesture is cancelled. This occurs when a user slides less than the threshold required to complete the action. Will always be called before onSlideEnd. |
|
|
295
|
+
| `onSlideComplete` | `(() => void)` | No | `-` | Callback function fired when the slide gesture ends successfully. This is called when the user has slid past the threshold to complete the action. Will always be called before onSlideEnd and after onChange. |
|
|
296
|
+
| `onSlideEnd` | `(() => void)` | No | `-` | Callback function fired when the slide gesture ends. Will always be called last in the slide sequence. |
|
|
297
|
+
| `onSlideStart` | `(() => void)` | No | `-` | Callback function fired when the slide gesture begins. |
|
|
298
|
+
| `opacity` | `number \| AnimatedNode` | No | `-` | - |
|
|
299
|
+
| `overflow` | `visible \| hidden \| scroll` | No | `-` | - |
|
|
300
|
+
| `padding` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | - |
|
|
301
|
+
| `paddingBottom` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | - |
|
|
302
|
+
| `paddingEnd` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | - |
|
|
303
|
+
| `paddingStart` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | - |
|
|
304
|
+
| `paddingTop` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | - |
|
|
305
|
+
| `paddingX` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | - |
|
|
306
|
+
| `paddingY` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | - |
|
|
307
|
+
| `pin` | `top \| bottom \| left \| right \| all` | No | `-` | Direction in which to absolutely pin the box. |
|
|
308
|
+
| `position` | `absolute \| relative \| static \| fixed \| sticky` | No | `-` | - |
|
|
309
|
+
| `ref` | `((instance: View \| null) => void) \| RefObject<View> \| null` | No | `-` | - |
|
|
310
|
+
| `right` | `string \| number` | No | `-` | - |
|
|
311
|
+
| `rowGap` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | - |
|
|
312
|
+
| `startUncheckedNode` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Custom start node to render for the unchecked state of the handle, to replace the default arrow icon. |
|
|
313
|
+
| `styles` | `{ container?: StyleProp<ViewStyle>; background?: StyleProp<ViewStyle>; handle?: StyleProp<ViewStyle>; }` | No | `-` | Custom styles for the slide button. |
|
|
314
|
+
| `testID` | `string` | No | `-` | Used to locate this element in unit and end-to-end tests. Used to locate this view in end-to-end tests. |
|
|
315
|
+
| `textAlign` | `left \| right \| auto \| center \| justify` | No | `-` | - |
|
|
316
|
+
| `textDecorationLine` | `none \| underline \| line-through \| underline line-through` | No | `-` | - |
|
|
317
|
+
| `textDecorationStyle` | `solid \| dotted \| dashed \| double` | No | `-` | - |
|
|
318
|
+
| `textTransform` | `none \| capitalize \| uppercase \| lowercase` | No | `-` | - |
|
|
319
|
+
| `top` | `string \| number` | No | `-` | - |
|
|
320
|
+
| `transform` | `string \| (({ scaleX: AnimatableNumericValue; } & { scaleY?: undefined; translateX?: undefined; translateY?: undefined; perspective?: undefined; rotate?: undefined; rotateX?: undefined; rotateY?: undefined; rotateZ?: undefined; scale?: undefined; skewX?: undefined; skewY?: undefined; matrix?: undefined; }) \| ({ scaleY: AnimatableNumericValue; } & { scaleX?: undefined; translateX?: undefined; translateY?: undefined; perspective?: undefined; rotate?: undefined; rotateX?: undefined; rotateY?: undefined; rotateZ?: undefined; scale?: undefined; skewX?: undefined; skewY?: undefined; matrix?: undefined; }) \| ({ translateX: AnimatableNumericValue \| ${number}%; } & { scaleX?: undefined; scaleY?: undefined; translateY?: undefined; perspective?: undefined; rotate?: undefined; rotateX?: undefined; rotateY?: undefined; rotateZ?: undefined; scale?: undefined; skewX?: undefined; skewY?: undefined; matrix?: undefined; }) \| ({ translateY: AnimatableNumericValue \| ${number}%; } & { scaleX?: undefined; scaleY?: undefined; translateX?: undefined; perspective?: undefined; rotate?: undefined; rotateX?: undefined; rotateY?: undefined; rotateZ?: undefined; scale?: undefined; skewX?: undefined; skewY?: undefined; matrix?: undefined; }) \| ({ perspective: AnimatableNumericValue; } & { scaleX?: undefined; scaleY?: undefined; translateX?: undefined; translateY?: undefined; rotate?: undefined; rotateX?: undefined; rotateY?: undefined; rotateZ?: undefined; scale?: undefined; skewX?: undefined; skewY?: undefined; matrix?: undefined; }) \| ({ rotate: AnimatableStringValue; } & { scaleX?: undefined; scaleY?: undefined; translateX?: undefined; translateY?: undefined; perspective?: undefined; rotateX?: undefined; rotateY?: undefined; rotateZ?: undefined; scale?: undefined; skewX?: undefined; skewY?: undefined; matrix?: undefined; }) \| ({ rotateX: AnimatableStringValue; } & { scaleX?: undefined; scaleY?: undefined; translateX?: undefined; translateY?: undefined; perspective?: undefined; rotate?: undefined; rotateY?: undefined; rotateZ?: undefined; scale?: undefined; skewX?: undefined; skewY?: undefined; matrix?: undefined; }) \| ({ rotateY: AnimatableStringValue; } & { scaleX?: undefined; scaleY?: undefined; translateX?: undefined; translateY?: undefined; perspective?: undefined; rotate?: undefined; rotateX?: undefined; rotateZ?: undefined; scale?: undefined; skewX?: undefined; skewY?: undefined; matrix?: undefined; }) \| ({ rotateZ: AnimatableStringValue; } & { scaleX?: undefined; scaleY?: undefined; translateX?: undefined; translateY?: undefined; perspective?: undefined; rotate?: undefined; rotateX?: undefined; rotateY?: undefined; scale?: undefined; skewX?: undefined; skewY?: undefined; matrix?: undefined; }) \| ({ scale: AnimatableNumericValue; } & { scaleX?: undefined; scaleY?: undefined; translateX?: undefined; translateY?: undefined; perspective?: undefined; rotate?: undefined; rotateX?: undefined; rotateY?: undefined; rotateZ?: undefined; skewX?: undefined; skewY?: undefined; matrix?: undefined; }) \| ({ skewX: AnimatableStringValue; } & { scaleX?: undefined; scaleY?: undefined; translateX?: undefined; translateY?: undefined; perspective?: undefined; rotate?: undefined; rotateX?: undefined; rotateY?: undefined; rotateZ?: undefined; scale?: undefined; skewY?: undefined; matrix?: undefined; }) \| ({ skewY: AnimatableStringValue; } & { scaleX?: undefined; scaleY?: undefined; translateX?: undefined; translateY?: undefined; perspective?: undefined; rotate?: undefined; rotateX?: undefined; rotateY?: undefined; rotateZ?: undefined; scale?: undefined; skewX?: undefined; matrix?: undefined; }) \| ({ matrix: AnimatableNumericValue[]; } & { scaleX?: undefined; scaleY?: undefined; translateX?: undefined; translateY?: undefined; perspective?: undefined; rotate?: undefined; rotateX?: undefined; rotateY?: undefined; rotateZ?: undefined; scale?: undefined; skewX?: undefined; skewY?: undefined; }))[]` | No | `-` | - |
|
|
321
|
+
| `transparentWhileInactive` | `boolean` | No | `-` | Mark the background and border as transparent until the element is interacted with (hovered, pressed, etc). Must be used in conjunction with the pressed prop |
|
|
322
|
+
| `transparentWhilePressed` | `boolean` | No | `-` | Mark the background and border as transparent even while element is interacted with (elevation underlay issue). Must be used in conjunction with the pressed prop |
|
|
323
|
+
| `uncheckedLabel` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Label or content shown when button is in unchecked state. |
|
|
324
|
+
| `userSelect` | `none \| auto \| contain \| text \| all` | No | `-` | - |
|
|
325
|
+
| `variant` | `primary \| positive \| negative` | No | `'primary'` | Toggle design and visual variants of the slide button. |
|
|
326
|
+
| `width` | `string \| number` | No | `-` | - |
|
|
327
|
+
| `wrapperStyles` | `{ base?: StyleProp<ViewStyle>; pressed?: StyleProp<ViewStyle>; disabled?: StyleProp<ViewStyle>; }` | No | `-` | Apply styles to the outer container. |
|
|
328
|
+
| `zIndex` | `number` | No | `-` | - |
|
|
329
|
+
|
|
330
|
+
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Spacer
|
|
2
|
+
|
|
3
|
+
Creates space between elements.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Spacer } from '@coinbase/cds-mobile/layout/Spacer'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Examples
|
|
12
|
+
|
|
13
|
+
### Vertical Spacer
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
<VStack>
|
|
17
|
+
<Box padding={2} background="bgAlternate" borderRadius="300">
|
|
18
|
+
Box 1
|
|
19
|
+
</Box>
|
|
20
|
+
<Spacer vertical={2} />
|
|
21
|
+
<Box padding={2} background="bgAlternate" borderRadius="300">
|
|
22
|
+
Box 2
|
|
23
|
+
</Box>
|
|
24
|
+
<Spacer vertical={4} />
|
|
25
|
+
<Box padding={2} background="bgAlternate" borderRadius="300">
|
|
26
|
+
Box 3
|
|
27
|
+
</Box>
|
|
28
|
+
<Spacer vertical={6} />
|
|
29
|
+
<Box padding={2} background="bgAlternate" borderRadius="300">
|
|
30
|
+
Box 4
|
|
31
|
+
</Box>
|
|
32
|
+
</VStack>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Horizontal Spacer
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
<HStack>
|
|
39
|
+
<Box padding={2} background="bgAlternate" borderRadius="300">
|
|
40
|
+
Box 1
|
|
41
|
+
</Box>
|
|
42
|
+
<Spacer horizontal={2} />
|
|
43
|
+
<Box padding={2} background="bgAlternate" borderRadius="300">
|
|
44
|
+
Box 2
|
|
45
|
+
</Box>
|
|
46
|
+
<Spacer horizontal={4} />
|
|
47
|
+
<Box padding={2} background="bgAlternate" borderRadius="300">
|
|
48
|
+
Box 3
|
|
49
|
+
</Box>
|
|
50
|
+
<Spacer horizontal={6} />
|
|
51
|
+
<Box padding={2} background="bgAlternate" borderRadius="300">
|
|
52
|
+
Box 4
|
|
53
|
+
</Box>
|
|
54
|
+
</HStack>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Props
|
|
58
|
+
|
|
59
|
+
| Prop | Type | Required | Default | Description |
|
|
60
|
+
| --- | --- | --- | --- | --- |
|
|
61
|
+
| `animated` | `boolean` | No | `-` | - |
|
|
62
|
+
| `horizontal` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | Padding in the horizontal direction |
|
|
63
|
+
| `maxHorizontal` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | Max padding in the horizontal direction |
|
|
64
|
+
| `maxVertical` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | Max padding in the vertical direction |
|
|
65
|
+
| `minHorizontal` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | Min padding in the horizontal direction |
|
|
66
|
+
| `minVertical` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | Min padding in the vertical direction |
|
|
67
|
+
| `onPointerCancel` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
68
|
+
| `onPointerCancelCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
69
|
+
| `onPointerDown` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
70
|
+
| `onPointerDownCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
71
|
+
| `onPointerEnter` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
72
|
+
| `onPointerEnterCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
73
|
+
| `onPointerLeave` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
74
|
+
| `onPointerLeaveCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
75
|
+
| `onPointerMove` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
76
|
+
| `onPointerMoveCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
77
|
+
| `onPointerUp` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
78
|
+
| `onPointerUpCapture` | `((event: PointerEvent) => void)` | No | `-` | - |
|
|
79
|
+
| `style` | `false \| RegisteredStyle<ViewStyle> \| Value \| AnimatedInterpolation<string \| number> \| WithAnimatedObject<ViewStyle> \| WithAnimatedArray<Falsy \| ViewStyle \| RegisteredStyle<ViewStyle> \| RecursiveArray<Falsy \| ViewStyle \| RegisteredStyle<ViewStyle>> \| readonly (Falsy \| ViewStyle \| RegisteredStyle<ViewStyle>)[]> \| null` | No | `-` | - |
|
|
80
|
+
| `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 Used to locate this view in end-to-end tests. |
|
|
81
|
+
| `vertical` | `0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10 \| 0.25 \| 0.5 \| 0.75 \| 1.5` | No | `-` | Padding in the vertical direction |
|
|
82
|
+
|
|
83
|
+
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Sparkline
|
|
2
|
+
|
|
3
|
+
A small line chart component for displaying data trends.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Sparkline } from '@coinbase/cds-mobile-visualization'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Examples
|
|
12
|
+
|
|
13
|
+
### Basic Example
|
|
14
|
+
|
|
15
|
+
The global warning banner is used to communicate important alerts or warnings to users across the entire platform, ensuring universal visibility and building trust.
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
function Example() {
|
|
19
|
+
const dimensions = { width: 64, height: 20 };
|
|
20
|
+
const path = useSparklinePath({ ...dimensions, data: prices });
|
|
21
|
+
return (
|
|
22
|
+
<ListCell
|
|
23
|
+
media={<CellMedia type="image" source={assets.btc.imageUrl} title="BTC" />}
|
|
24
|
+
intermediary={<Sparkline {...dimensions} path={path} color={assets.btc.color} />}
|
|
25
|
+
title={assets.btc.name}
|
|
26
|
+
description={assets.btc.symbol}
|
|
27
|
+
detail={prices[0]}
|
|
28
|
+
subdetail="+4.55%"
|
|
29
|
+
variant="positive"
|
|
30
|
+
onClick={() => console.log('clicked')}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Dynamic path colors
|
|
37
|
+
|
|
38
|
+
```jsx
|
|
39
|
+
function Example() {
|
|
40
|
+
const dimensions = { width: 400, height: 200 };
|
|
41
|
+
const path = useSparklinePath({ ...dimensions, data: prices });
|
|
42
|
+
return (
|
|
43
|
+
<VStack gap={2}>
|
|
44
|
+
{assetColors.map((color) => (
|
|
45
|
+
<Sparkline key={color} {...dimensions} path={path} color={color} />
|
|
46
|
+
))}
|
|
47
|
+
</VStack>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Dynamic background colors
|
|
53
|
+
|
|
54
|
+
```jsx
|
|
55
|
+
function Example() {
|
|
56
|
+
const dimensions = { width: 400, height: 200 };
|
|
57
|
+
const path = useSparklinePath({ ...dimensions, data: prices });
|
|
58
|
+
return (
|
|
59
|
+
<VStack gap={2}>
|
|
60
|
+
{assetColors.map((background) => (
|
|
61
|
+
<VStack key={background} dangerouslySetBackground={background}>
|
|
62
|
+
<Sparkline {...dimensions} path={path} background={background} color="auto" />
|
|
63
|
+
</VStack>
|
|
64
|
+
))}
|
|
65
|
+
</VStack>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### y axis scaling
|
|
71
|
+
|
|
72
|
+
```jsx
|
|
73
|
+
function Example() {
|
|
74
|
+
const yAxisScalingFactor = 0.2;
|
|
75
|
+
const dimensions = { width: 400, height: 200 };
|
|
76
|
+
const path = useSparklinePath({ ...dimensions, data: prices, yAxisScalingFactor });
|
|
77
|
+
return (
|
|
78
|
+
<VStack gap={2}>
|
|
79
|
+
<TextLabel1 as="p">Scale {yAxisScalingFactor}</TextLabel1>
|
|
80
|
+
<Sparkline {...dimensions} path={path} color="auto" yAxisScalingFactor={yAxisScalingFactor} />
|
|
81
|
+
</VStack>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Sparkline fill
|
|
87
|
+
|
|
88
|
+
```jsx
|
|
89
|
+
function Example() {
|
|
90
|
+
const dimensions = { width: 400, height: 200 };
|
|
91
|
+
const path = useSparklinePath({ ...dimensions, data: prices });
|
|
92
|
+
const area = useSparklineArea({ ...dimensions, data: prices });
|
|
93
|
+
return (
|
|
94
|
+
<VStack gap={2}>
|
|
95
|
+
{assetColors.map((color) => (
|
|
96
|
+
<Sparkline key={color} {...dimensions} path={path} color={color}>
|
|
97
|
+
<SparklineArea area={area} />
|
|
98
|
+
</Sparkline>
|
|
99
|
+
))}
|
|
100
|
+
</VStack>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Props
|
|
106
|
+
|
|
107
|
+
| Prop | Type | Required | Default | Description |
|
|
108
|
+
| --- | --- | --- | --- | --- |
|
|
109
|
+
| `color` | `string` | Yes | `-` | The color of the Sparkline graphs line. Accepts any raw color value (hex, rgba, hsl, etc) or auto. Using auto dynamically selects black or white for optimal accessibility. Does not work with CDS theme color names like fgPrimary or CSS variables. |
|
|
110
|
+
| `height` | `number` | Yes | `-` | Height of the Sparkline |
|
|
111
|
+
| `width` | `number` | Yes | `-` | Width of the Sparkline |
|
|
112
|
+
| `background` | `string` | No | `-` | - |
|
|
113
|
+
| `children` | `null \| false \| ReactElement<SparklineAreaBaseProps, string \| JSXElementConstructor<any>> \| OptionalElement<SparklineAreaBaseProps>[]` | No | `-` | an optional SparklineArea that can be used to fill in the Sparkline |
|
|
114
|
+
| `fillType` | `dotted \| gradient \| gradientDotted` | No | `'dotted'` | Type of fill to use for the area |
|
|
115
|
+
| `key` | `Key \| null` | No | `-` | - |
|
|
116
|
+
| `path` | `string` | No | `-` | Svg path as string. CDS offers a useSparklinePath which is useful to generate this string. This is accessible via import { useSparklinePath } from @coinbase/cds-common/visualizations/useSparklinePath;. Alternatively, you can use product tailored tooling to generate the SVG path. This component only requires a valid path string is provided. |
|
|
117
|
+
| `ref` | `((instance: Path \| null) => void) \| RefObject<Path \| null> \| null` | No | `-` | - |
|
|
118
|
+
| `strokeType` | `solid \| gradient` | No | `'solid'` | Type of stroke to use for the line - gradient: Gradient colored stroke line - solid: Solid colored stroke line |
|
|
119
|
+
| `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 |
|
|
120
|
+
| `yAxisScalingFactor` | `number` | No | `-` | Scales the sparkline to show more or less variance. Use a number less than 1 for less variance and a number greater than 1 for more variance. If you use a number greater than 1 it may clip the boundaries of the sparkline. |
|
|
121
|
+
|
|
122
|
+
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# SparklineGradient
|
|
2
|
+
|
|
3
|
+
A small line chart component with gradient fill below the line.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { SparklineGradient } from '@coinbase/cds-mobile-visualization'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Examples
|
|
12
|
+
|
|
13
|
+
Expands upon the [Sparkline](/components/graphs/Sparkline) component to provide a gradient stroke. However, for dark mode we disable the gradient effect. These are typically used at a larger size for portfolio charts or on detail Asset pages.
|
|
14
|
+
|
|
15
|
+
### Dynamic path colors
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
function Example() {
|
|
19
|
+
const dimensions = { width: 400, height: 200 };
|
|
20
|
+
const path = useSparklinePath({ ...dimensions, data: prices });
|
|
21
|
+
return (
|
|
22
|
+
<VStack gap={2}>
|
|
23
|
+
{assetColors.map((color) => (
|
|
24
|
+
<SparklineGradient key={color} {...dimensions} path={path} color={color} />
|
|
25
|
+
))}
|
|
26
|
+
</VStack>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Dynamic background colors
|
|
32
|
+
|
|
33
|
+
```jsx
|
|
34
|
+
function Example() {
|
|
35
|
+
const dimensions = { width: 400, height: 200 };
|
|
36
|
+
const path = useSparklinePath({ ...dimensions, data: prices });
|
|
37
|
+
return (
|
|
38
|
+
<VStack gap={2}>
|
|
39
|
+
{assetColors.map((background) => (
|
|
40
|
+
<VStack key={background} dangerouslySetBackground={background}>
|
|
41
|
+
<SparklineGradient {...dimensions} path={path} background={background} color="auto" />
|
|
42
|
+
</VStack>
|
|
43
|
+
))}
|
|
44
|
+
</VStack>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### y axis scaling
|
|
50
|
+
|
|
51
|
+
```jsx
|
|
52
|
+
function Example() {
|
|
53
|
+
const yAxisScalingFactor = 0.2;
|
|
54
|
+
const dimensions = { width: 400, height: 200 };
|
|
55
|
+
const path = useSparklinePath({ ...dimensions, data: prices, yAxisScalingFactor });
|
|
56
|
+
return (
|
|
57
|
+
<VStack gap={2}>
|
|
58
|
+
<TextLabel1 as="p">Scale {yAxisScalingFactor}</TextLabel1>
|
|
59
|
+
<SparklineGradient
|
|
60
|
+
{...dimensions}
|
|
61
|
+
path={path}
|
|
62
|
+
color="auto"
|
|
63
|
+
yAxisScalingFactor={yAxisScalingFactor}
|
|
64
|
+
/>
|
|
65
|
+
</VStack>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Sparkline fill
|
|
71
|
+
|
|
72
|
+
```jsx
|
|
73
|
+
function Example() {
|
|
74
|
+
const dimensions = { width: 400, height: 200 };
|
|
75
|
+
const path = useSparklinePath({ ...dimensions, data: prices });
|
|
76
|
+
const area = useSparklineArea({ ...dimensions, data: prices });
|
|
77
|
+
return (
|
|
78
|
+
<VStack gap={2}>
|
|
79
|
+
{assetColors.map((color) => (
|
|
80
|
+
<SparklineGradient key={color} {...dimensions} path={path} color={color}>
|
|
81
|
+
<SparklineArea area={area} />
|
|
82
|
+
</SparklineGradient>
|
|
83
|
+
))}
|
|
84
|
+
</VStack>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Props
|
|
90
|
+
|
|
91
|
+
| Prop | Type | Required | Default | Description |
|
|
92
|
+
| --- | --- | --- | --- | --- |
|
|
93
|
+
| `color` | `string` | Yes | `-` | The color of the Sparkline graphs line. Accepts any raw color value (hex, rgba, hsl, etc) or auto. Using auto dynamically selects black or white for optimal accessibility. Does not work with CDS theme color names like fgPrimary or CSS variables. |
|
|
94
|
+
| `height` | `number` | Yes | `-` | Height of the Sparkline |
|
|
95
|
+
| `width` | `number` | Yes | `-` | Width of the Sparkline |
|
|
96
|
+
| `background` | `string` | No | `-` | - |
|
|
97
|
+
| `children` | `null \| false \| ReactElement<SparklineAreaBaseProps, string \| JSXElementConstructor<any>> \| OptionalElement<SparklineAreaBaseProps>[]` | No | `-` | an optional SparklineArea that can be used to fill in the Sparkline |
|
|
98
|
+
| `fillType` | `dotted \| gradient \| gradientDotted` | No | `'dotted'` | Type of fill to use for the area |
|
|
99
|
+
| `key` | `Key \| null` | No | `-` | - |
|
|
100
|
+
| `path` | `string` | No | `-` | Svg path as string. CDS offers a useSparklinePath which is useful to generate this string. This is accessible via import { useSparklinePath } from @coinbase/cds-common/visualizations/useSparklinePath;. Alternatively, you can use product tailored tooling to generate the SVG path. This component only requires a valid path string is provided. |
|
|
101
|
+
| `ref` | `((instance: Path \| null) => void) \| RefObject<Path \| null> \| null` | No | `-` | - |
|
|
102
|
+
| `strokeType` | `solid \| gradient` | No | `'solid'` | Type of stroke to use for the line - gradient: Gradient colored stroke line - solid: Solid colored stroke line |
|
|
103
|
+
| `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 |
|
|
104
|
+
| `yAxisScalingFactor` | `number` | No | `-` | Scales the sparkline to show more or less variance. Use a number less than 1 for less variance and a number greater than 1 for more variance. If you use a number greater than 1 it may clip the boundaries of the sparkline. |
|
|
105
|
+
|
|
106
|
+
|