@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,57 @@
|
|
|
1
|
+
# installation
|
|
2
|
+
|
|
3
|
+
This guide will help you get started with installing CDS in your React Native project. Follow the instructions below to set up CDS and start building with our cross-platform components.
|
|
4
|
+
|
|
5
|
+
### Installation
|
|
6
|
+
|
|
7
|
+
To install the CDS library for React Native applications, run the following command:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @coinbase/cds-mobile
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Alternatively, if you are using Yarn:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add @coinbase/cds-mobile
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
:::tip
|
|
20
|
+
For React Native projects, ensure you have set up your environment for React Native development. Refer to the [React Native Environment Setup Guide](https://reactnative.dev/docs/environment-setup) if needed.
|
|
21
|
+
:::
|
|
22
|
+
|
|
23
|
+
### Getting started
|
|
24
|
+
#### 1. Render a ThemeProvider
|
|
25
|
+
|
|
26
|
+
Render a ThemeProvider at the root of your application, and pass the `theme` and `activeColorScheme`.
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { ThemeProvider } from '@coinbase/cds-mobile';
|
|
30
|
+
import { defaultTheme } from '@coinbase/cds-mobile/themes/defaultTheme';
|
|
31
|
+
import App from './App';
|
|
32
|
+
|
|
33
|
+
const Index = () => (
|
|
34
|
+
<ThemeProvider theme={defaultTheme} activeColorScheme="light">
|
|
35
|
+
<App />
|
|
36
|
+
</ThemeProvider>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
export default Index;
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### 2. Verify the installation
|
|
43
|
+
|
|
44
|
+
Try importing and rendering a simple CDS component.
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import { Button } from '@coinbase/cds-mobile/buttons';
|
|
48
|
+
|
|
49
|
+
const Test = () => <Button>Click Me</Button>;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Next steps
|
|
53
|
+
|
|
54
|
+
Learn how to customize CDS's appearance.
|
|
55
|
+
|
|
56
|
+
[See the theming docs here →](/getting-started/theming)
|
|
57
|
+
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: introduction
|
|
3
|
+
title: Introduction
|
|
4
|
+
hide_title: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import { VStack } from '@coinbase/cds-web/layout';
|
|
8
|
+
import { MDXSection } from '@site/src/components/page/MDXSection';
|
|
9
|
+
import { MDXArticle } from '@site/src/components/page/MDXArticle';
|
|
10
|
+
import { ContentHeader } from '@site/src/components/page/ContentHeader';
|
|
11
|
+
import { GettingStartedBanner } from '@site/src/components/page/ComponentBanner/GettingStartedBanner';
|
|
12
|
+
|
|
13
|
+
<VStack gap={5}>
|
|
14
|
+
<ContentHeader
|
|
15
|
+
title="Introduction"
|
|
16
|
+
description="Coinbase Design System is a cross-platform component library for React and React Native. CDS has high adoption in every product at Coinbase, accelerating development and ensuring a consistent user experience across all platforms."
|
|
17
|
+
banner={<GettingStartedBanner />}
|
|
18
|
+
/>
|
|
19
|
+
|
|
20
|
+
<MDXSection>
|
|
21
|
+
<MDXArticle>
|
|
22
|
+
## Key features
|
|
23
|
+
|
|
24
|
+
- **Cross-platform** - CDS provides components for both React DOM and React Native. We go to great lengths to ensure that the source code is as identical as possible across React and React Native without compromising on platform-specific features.
|
|
25
|
+
|
|
26
|
+
- **Powerful theming** - The ThemeProvider can be used to define a custom theme for your application supporting light and dark mode.
|
|
27
|
+
|
|
28
|
+
- **Rich styling capabilities** - Components are designed to integrate with third-party libraries like styled-components, and to be customizable via theming, props, StyleProps, classnames, and inline styles.
|
|
29
|
+
|
|
30
|
+
- **Subcomponent composition** - Components are built using smaller subcomponents that can be fully customized or replaced via props.
|
|
31
|
+
|
|
32
|
+
- **Accessibility** - Components are accessible out of the box, and can be customized to different accessibility standards.
|
|
33
|
+
|
|
34
|
+
</MDXArticle>
|
|
35
|
+
</MDXSection>
|
|
36
|
+
|
|
37
|
+
<MDXSection>
|
|
38
|
+
<MDXArticle>
|
|
39
|
+
## Web-only features
|
|
40
|
+
|
|
41
|
+
- **Atomic static CSS** - CSS is compiled to atomic static classnames at library build time.
|
|
42
|
+
|
|
43
|
+
- **Responsive styles** - Components support responsive styles out of the box. Use the responsive syntax to adjust layouts and styles based on device breakpoints without writing custom media queries.
|
|
44
|
+
|
|
45
|
+
- **CSS layers** - All CSS is added to the `cds` layer. This allows you to easily override CDS styles with your own styles.
|
|
46
|
+
|
|
47
|
+
- **Polymorphic components** - Components can be rendered as different HTML elements or as other components.
|
|
48
|
+
|
|
49
|
+
</MDXArticle>
|
|
50
|
+
</MDXSection>
|
|
51
|
+
|
|
52
|
+
<MDXSection>
|
|
53
|
+
<MDXArticle>
|
|
54
|
+
## Developer experience
|
|
55
|
+
|
|
56
|
+
CDS is designed to make your development workflow as smooth as possible.
|
|
57
|
+
|
|
58
|
+
- **TypeScript first** - Full type safety with excellent IDE autocomplete for props, theme values, and style props. Most mistakes are caught at compile time.
|
|
59
|
+
|
|
60
|
+
- **Flexible styling** - Use the StyleProps API for rapid development with theme-aware values, or drop down to className and style props for full control. Mix and match approaches as needed.
|
|
61
|
+
|
|
62
|
+
- **Component composition** - Build complex UIs by composing simple primitives. Most components expose subcomponents that can be customized or replaced entirely.
|
|
63
|
+
|
|
64
|
+
- **Performance optimized** - All web components use atomic CSS with zero runtime overhead. CSS is generated at build time and styles are applied via static classnames.
|
|
65
|
+
|
|
66
|
+
- **Extensive documentation** - Every component includes Storybook stories, interactive examples, detailed prop tables, and usage guidelines.
|
|
67
|
+
|
|
68
|
+
```jsx
|
|
69
|
+
import { ThemeProvider } from '@coinbase/cds-web';
|
|
70
|
+
import { defaultTheme } from '@coinbase/cds-web/themes/defaultTheme';
|
|
71
|
+
import { Box } from '@coinbase/cds-web/layout';
|
|
72
|
+
import { Text } from '@coinbase/cds-web/typography';
|
|
73
|
+
import { Button } from '@coinbase/cds-web/buttons';
|
|
74
|
+
|
|
75
|
+
const App = () => (
|
|
76
|
+
<ThemeProvider theme={defaultTheme} activeColorScheme="light">
|
|
77
|
+
<Box padding={4} background="bgPrimary" borderRadius={200}>
|
|
78
|
+
<Text font="title1" color="fg">
|
|
79
|
+
Welcome to CDS
|
|
80
|
+
</Text>
|
|
81
|
+
<Button variant="positive" marginTop={2}>
|
|
82
|
+
Get started
|
|
83
|
+
</Button>
|
|
84
|
+
</Box>
|
|
85
|
+
</ThemeProvider>
|
|
86
|
+
);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
</MDXArticle>
|
|
90
|
+
</MDXSection>
|
|
91
|
+
|
|
92
|
+
<MDXSection>
|
|
93
|
+
<MDXArticle>
|
|
94
|
+
## Next steps
|
|
95
|
+
|
|
96
|
+
Learn how to install and use CDS.
|
|
97
|
+
|
|
98
|
+
[See the installation docs here →](/getting-started/installation)
|
|
99
|
+
|
|
100
|
+
</MDXArticle>
|
|
101
|
+
</MDXSection>
|
|
102
|
+
</VStack>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: playground
|
|
3
|
+
title: Playground
|
|
4
|
+
hide_title: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import { VStack } from '@coinbase/cds-web/layout';
|
|
8
|
+
import { MDXSection } from '@site/src/components/page/MDXSection';
|
|
9
|
+
import { MDXArticle } from '@site/src/components/page/MDXArticle';
|
|
10
|
+
import { ContentHeader } from '@site/src/components/page/ContentHeader';
|
|
11
|
+
import { PlaygroundBanner } from '@site/src/components/page/ComponentBanner/PlaygroundBanner';
|
|
12
|
+
import { ShareablePlayground } from '@site/src/components/page/ShareablePlayground';
|
|
13
|
+
|
|
14
|
+
<VStack gap={5}>
|
|
15
|
+
<ContentHeader
|
|
16
|
+
title="Playground"
|
|
17
|
+
description="Live code playground for testing and sharing CDS components and code examples. All CDS components and hooks and all React exports are available to use in the playground without importing them. You must call render() to render your code."
|
|
18
|
+
banner={<PlaygroundBanner />}
|
|
19
|
+
/>
|
|
20
|
+
|
|
21
|
+
<MDXSection>
|
|
22
|
+
<MDXArticle>
|
|
23
|
+
|
|
24
|
+
<ShareablePlayground />
|
|
25
|
+
|
|
26
|
+
</MDXArticle>
|
|
27
|
+
</MDXSection>
|
|
28
|
+
</VStack>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# styling
|
|
2
|
+
|
|
3
|
+
CDS includes powerful and flexible APIs for styling components. Easily access values from the theme, or go rogue with full customization.
|
|
4
|
+
|
|
5
|
+
### `StyleProps` API
|
|
6
|
+
|
|
7
|
+
Most components support the StyleProps API. StyleProps automatically have access to the values in the theme, and some StyleProps are limited to only the theme values.
|
|
8
|
+
|
|
9
|
+
[See the full list of StyleProps here →](/components/layout/Box/?platform=mobile&tab=props)
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
// ✅ The `bgNegative` token will automatically update with the theme!
|
|
13
|
+
<Box background="bgNegative" width={100} />
|
|
14
|
+
|
|
15
|
+
// ❌ Error: Type '"#0000ff"' is not assignable to type 'Color | undefined'.
|
|
16
|
+
<Box background="#0000ff" width={100} />
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
:::tip
|
|
20
|
+
The docs page of every component has a props table listing all the available props!
|
|
21
|
+
:::
|
|
22
|
+
|
|
23
|
+
:::note
|
|
24
|
+
The StyleProps API uses the ThemeProvider Context under the hood to enable dynamic theming.
|
|
25
|
+
:::
|
|
26
|
+
|
|
27
|
+
### `style` and `styles` props
|
|
28
|
+
|
|
29
|
+
Most components support the native `style` prop for inline styles.
|
|
30
|
+
|
|
31
|
+
```jsx
|
|
32
|
+
<Box style={{ backgroundColor: '#0000ff' }} />
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Some complex components support passing inline styles to subcomponents with the `styles` prop.
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
<ProgressCircle
|
|
39
|
+
styles={{
|
|
40
|
+
circle: {
|
|
41
|
+
stroke: 'transparent',
|
|
42
|
+
},
|
|
43
|
+
progress: {
|
|
44
|
+
strokeLinecap: 'square',
|
|
45
|
+
},
|
|
46
|
+
}}
|
|
47
|
+
color="fgPositive"
|
|
48
|
+
progress={0.75}
|
|
49
|
+
size={100}
|
|
50
|
+
/>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Styles are combined using React Native's style arrays, and are added in order of specificity.
|
|
54
|
+
|
|
55
|
+
```jsx
|
|
56
|
+
<PageHeader style={{ backgroundColor: 'red' }} styles={{ root: { backgroundColor: 'blue' } }} />
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
In the example above, `backgroundColor` will be blue.
|
|
60
|
+
|
|
61
|
+
:::tip
|
|
62
|
+
We will continue to add the `styles` prop to more components over time. Please feel free to request specific components that you think would benefit from this API.
|
|
63
|
+
:::
|
|
64
|
+
|
|
65
|
+
### Component specific props
|
|
66
|
+
|
|
67
|
+
Many components have their own specific props that can affect styling.
|
|
68
|
+
|
|
69
|
+
```jsx
|
|
70
|
+
<Button compact variant="primary">
|
|
71
|
+
Click me
|
|
72
|
+
</Button>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Combining techniques
|
|
76
|
+
|
|
77
|
+
Mix and match these styling techniques for complete customization!
|
|
78
|
+
|
|
79
|
+
```jsx
|
|
80
|
+
<Button variant="primary" borderColor="accentBoldPurple" style={{ fontFamily: 'Times' }}>
|
|
81
|
+
Click me
|
|
82
|
+
</Button>
|
|
83
|
+
```
|
|
84
|
+
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
# theming
|
|
2
|
+
|
|
3
|
+
The theme contains design tokens like colors, fonts, spacing, and more. The ThemeProvider provides access to these values via CSS Variables for web, and React Context for both web and React Native.
|
|
4
|
+
|
|
5
|
+
import { defaultTheme } from '@coinbase/cds-mobile/themes/defaultTheme';
|
|
6
|
+
import { JSONCodeBlock } from '@site/src/components/page/JSONCodeBlock';
|
|
7
|
+
|
|
8
|
+
### ThemeProvider component
|
|
9
|
+
|
|
10
|
+
The ThemeProvider provides the theme context to all child components.
|
|
11
|
+
|
|
12
|
+
You must pass the `theme` prop to configure the theme, and the `activeColorScheme` prop to set light or dark mode.
|
|
13
|
+
|
|
14
|
+
[See the ThemeProvider docs here →](/components/other/ThemeProvider)
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { ThemeProvider } from '@coinbase/cds-mobile/system/ThemeProvider';
|
|
18
|
+
import { defaultTheme } from '@coinbase/cds-mobile/themes/defaultTheme';
|
|
19
|
+
|
|
20
|
+
const App = () => (
|
|
21
|
+
<ThemeProvider theme={defaultTheme} activeColorScheme="light">
|
|
22
|
+
{/* Your app components */}
|
|
23
|
+
</ThemeProvider>
|
|
24
|
+
);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
:::tip
|
|
28
|
+
Changing the `activeColorScheme` automatically updates the values returned from the `useTheme` hook.
|
|
29
|
+
:::
|
|
30
|
+
|
|
31
|
+
#### `useTheme` hook
|
|
32
|
+
|
|
33
|
+
The `useTheme` hook provides access to the current `theme` and `activeColorScheme`.
|
|
34
|
+
|
|
35
|
+
The `color` and `spectrum` objects automatically change based on the `activeColorScheme`.
|
|
36
|
+
|
|
37
|
+
[See the `useTheme` docs here →](/hooks/useTheme)
|
|
38
|
+
|
|
39
|
+
```jsx
|
|
40
|
+
const theme = useTheme();
|
|
41
|
+
theme.activeColorScheme; // "light" or "dark"
|
|
42
|
+
theme.spectrum; // Resolves to lightSpectrum or darkSpectrum, depends on activeColorScheme
|
|
43
|
+
theme.color; // Resolves to lightColor or darkColor, depends on activeColorScheme
|
|
44
|
+
theme.color.bgPrimary; // "rgb(0,82,255)" or "rgb(87,139,250)", depends on activeColorScheme
|
|
45
|
+
theme.space[2]; // 16
|
|
46
|
+
theme.borderRadius[200]; // 8
|
|
47
|
+
theme.fontSize.display3; // 40
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
#### Nested themes
|
|
51
|
+
|
|
52
|
+
ThemeProviders can be nested to create theme overrides for specific sections.
|
|
53
|
+
|
|
54
|
+
```jsx
|
|
55
|
+
<ThemeProvider theme={defaultTheme} activeColorScheme="light">
|
|
56
|
+
{/* Default theme in light color scheme */}
|
|
57
|
+
|
|
58
|
+
<ThemeProvider theme={customTheme} activeColorScheme="dark">
|
|
59
|
+
{/* Custom theme in dark color scheme */}
|
|
60
|
+
</ThemeProvider>
|
|
61
|
+
</ThemeProvider>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
When nesting, you may want to override specific color values from the current theme. Overrides must be conditionally applied because we don't enforce that a theme has both light and dark colors defined.
|
|
65
|
+
|
|
66
|
+
```jsx
|
|
67
|
+
// Override parts of the parent theme
|
|
68
|
+
const theme = useTheme();
|
|
69
|
+
const customTheme = {
|
|
70
|
+
...theme,
|
|
71
|
+
...(theme.lightColor &&
|
|
72
|
+
theme.lightSpectrum && {
|
|
73
|
+
lightColor: {
|
|
74
|
+
...theme.lightColor,
|
|
75
|
+
bg: `rgb(${theme.lightSpectrum.orange50})`,
|
|
76
|
+
bgPrimary: `rgb(${theme.lightSpectrum.red20})`,
|
|
77
|
+
bgSecondary: `rgb(${theme.lightSpectrum.blue50})`,
|
|
78
|
+
},
|
|
79
|
+
}),
|
|
80
|
+
...(theme.darkColor &&
|
|
81
|
+
theme.darkSpectrum && {
|
|
82
|
+
darkColor: {
|
|
83
|
+
...theme.darkColor,
|
|
84
|
+
bg: `rgb(${theme.darkSpectrum.orange50})`,
|
|
85
|
+
bgPrimary: `rgb(${theme.darkSpectrum.red20})`,
|
|
86
|
+
bgSecondary: `rgb(${theme.darkSpectrum.blue50})`,
|
|
87
|
+
},
|
|
88
|
+
}),
|
|
89
|
+
} as const satisfies Theme;
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### Theme inheritence
|
|
93
|
+
|
|
94
|
+
Nested ThemeProviders do not automatically inherit the theme from their parent provider. You can manually inherit the theme with the `useTheme` hook.
|
|
95
|
+
|
|
96
|
+
```jsx
|
|
97
|
+
const Example = () => {
|
|
98
|
+
// Pass the parent theme down to another ThemeProvider
|
|
99
|
+
const theme = useTheme();
|
|
100
|
+
return (
|
|
101
|
+
<ThemeProvider theme={theme} activeColorScheme={theme.activeColorScheme}>
|
|
102
|
+
{children}
|
|
103
|
+
</ThemeProvider>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### InvertedThemeProvider component
|
|
109
|
+
|
|
110
|
+
The InvertedThemeProvider automatically inherits from its parent theme and flips the `activeColorScheme` to the opposite value.
|
|
111
|
+
|
|
112
|
+
```jsx
|
|
113
|
+
<ThemeProvider theme={defaultTheme} activeColorScheme="light">
|
|
114
|
+
{/* Default theme in light color scheme */}
|
|
115
|
+
|
|
116
|
+
<InvertedThemeProvider>
|
|
117
|
+
{/* Default theme in inverse (dark) color scheme */}
|
|
118
|
+
</InvertedThemeProvider>
|
|
119
|
+
</ThemeProvider>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### `ThemeConfig` vs `Theme` type
|
|
123
|
+
|
|
124
|
+
Use the `ThemeConfig` type when creating a theme, or when passing the `theme` prop to the ThemeProvider.
|
|
125
|
+
|
|
126
|
+
Use the `Theme` type for the return value of the `useTheme` hook. The `Theme` type includes all the properties of `ThemeConfig` - plus the `activeColorScheme`, `color`, and `spectrum` properties.
|
|
127
|
+
|
|
128
|
+
[See the `ThemeConfig` type definition here →](https://github.com/coinbase/cds/blob/master/packages/mobile/src/core/theme.ts#L11)
|
|
129
|
+
|
|
130
|
+
[See the `Theme` type definition here →](https://github.com/coinbase/cds/blob/master/packages/mobile/src/core/theme.ts#L50)
|
|
131
|
+
|
|
132
|
+
:::tip
|
|
133
|
+
Although the `Theme` type includes extra properties, you can still pass the `useTheme` return value directly to the ThemeProvider `theme` prop as shown in the [theme inheritence section.](#theme-inheritence)
|
|
134
|
+
:::
|
|
135
|
+
|
|
136
|
+
### `spectrum` vs `color` values
|
|
137
|
+
|
|
138
|
+
The `spectrum` variables are partial `"r,g,b"` strings while `color` variables are complete CSS color values.
|
|
139
|
+
|
|
140
|
+
Both `color` and `spectrum` behave inversely in light and dark mode.
|
|
141
|
+
|
|
142
|
+
For example with the `defaultTheme` config, `spectrum.gray0` is white in light mode and black in dark mode. We use `spectrum` variables to define `color` variables, so this same behavior extends to `color`.
|
|
143
|
+
|
|
144
|
+
The `color` variables have semantic names which describe their application in the UI. You should prefer to use `color` variables instead of `spectrum` variables when styling UI.
|
|
145
|
+
|
|
146
|
+
```jsx
|
|
147
|
+
const theme = useTheme();
|
|
148
|
+
theme.lightSpectrum.gray0; // "255,255,255"
|
|
149
|
+
theme.darkSpectrum.gray0; // "10,11,13"
|
|
150
|
+
theme.spectrum.gray100; // "255,255,255" or "10,11,13", depends on activeColorScheme
|
|
151
|
+
theme.lightColor.bg; // "rgb(255,255,255)"
|
|
152
|
+
theme.darkColor.bg; // "rgb(10,11,13)"
|
|
153
|
+
theme.color.bg; // "rgb(255,255,255)" or "rgb(10,11,13)", depends on activeColorScheme
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
:::tip
|
|
157
|
+
Prefer to use semantic `color` variables for UI styles. Direct usage of `spectrum` values should be a rare exception.
|
|
158
|
+
:::
|
|
159
|
+
|
|
160
|
+
### Creating a theme
|
|
161
|
+
#### Defining colors
|
|
162
|
+
|
|
163
|
+
We recommend defining `lightSpectrum` and `darkSpectrum` as separate objects. This makes it easier to reference them when defining the `lightColor` and `darkColor` values.
|
|
164
|
+
|
|
165
|
+
The `lightColor` and `darkColor` values must be raw color strings (hex, rgba, hsl, etc), they cannot contain CSS Variables or CSS functions.
|
|
166
|
+
|
|
167
|
+
#### The `space` scale
|
|
168
|
+
|
|
169
|
+
CDS expects that the theme `space` values will be multiples of some base number.
|
|
170
|
+
|
|
171
|
+
For example, the `defaultTheme` uses `8px` as the base number:
|
|
172
|
+
|
|
173
|
+
```jsx
|
|
174
|
+
theme.space[0]; // 0
|
|
175
|
+
theme.space[0.25]; // 2
|
|
176
|
+
theme.space[0.5]; // 4
|
|
177
|
+
theme.space[1]; // 8
|
|
178
|
+
theme.space[1.5]; // 12
|
|
179
|
+
theme.space[2]; // 16
|
|
180
|
+
theme.space[3]; // 24
|
|
181
|
+
// etc.
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
While it is possible to customize the `space` values in any way, deviating from this expectation may produce broken styles.
|
|
185
|
+
|
|
186
|
+
#### Example new theme
|
|
187
|
+
|
|
188
|
+
In this example we'll start with the `defaultTheme` and customize a couple values.
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
import type { ThemeConfig } from '@coinbase/cds-mobile/core/theme';
|
|
192
|
+
import { ThemeProvider } from '@coinbase/cds-mobile/system/ThemeProvider';
|
|
193
|
+
import { defaultTheme } from '@coinbase/cds-mobile/themes/defaultTheme';
|
|
194
|
+
|
|
195
|
+
// Define lightSpectrum and darkSpectrum as separate objects
|
|
196
|
+
const lightSpectrum = {
|
|
197
|
+
...defaultTheme.lightSpectrum,
|
|
198
|
+
blue60: '8,90,255',
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const darkSpectrum = {
|
|
202
|
+
...defaultTheme.darkSpectrum,
|
|
203
|
+
blue60: '65,125,245',
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
// Use lightSpectrum and darkSpectrum to define the lightColor and darkColor values
|
|
207
|
+
const myTheme = {
|
|
208
|
+
...defaultTheme,
|
|
209
|
+
id: 'my-custom-theme',
|
|
210
|
+
lightSpectrum,
|
|
211
|
+
darkSpectrum,
|
|
212
|
+
lightColor: {
|
|
213
|
+
...defaultTheme.lightColor,
|
|
214
|
+
bgPrimary: `rgb(${lightSpectrum.red60})`,
|
|
215
|
+
},
|
|
216
|
+
darkColor: {
|
|
217
|
+
...defaultTheme.darkColor,
|
|
218
|
+
bgPrimary: `rgb(${darkSpectrum.red60})`,
|
|
219
|
+
},
|
|
220
|
+
} as const satisfies ThemeConfig;
|
|
221
|
+
|
|
222
|
+
const App = () => (
|
|
223
|
+
<ThemeProvider theme={myTheme} activeColorScheme="light">
|
|
224
|
+
{/* Your app components */}
|
|
225
|
+
</ThemeProvider>
|
|
226
|
+
);
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
:::tip
|
|
230
|
+
Use the `ThemeConfig` type with TypeScript's `satisfies` keyword to enforce type safety for your theme.
|
|
231
|
+
:::
|
|
232
|
+
|
|
233
|
+
### `defaultTheme` config
|
|
234
|
+
|
|
235
|
+
The `defaultTheme` is a good example of a complete `ThemeConfig`. You can use it as an example when developing your own themes.
|
|
236
|
+
|
|
237
|
+
[See the `defaultTheme` source code here →](https://github.com/coinbase/cds/blob/master/packages/mobile/src/themes/defaultTheme.ts)
|
|
238
|
+
|
|
239
|
+
<JSONCodeBlock json={defaultTheme} />
|
|
240
|
+
|
|
241
|
+
### `ThemeVars` namespace
|
|
242
|
+
|
|
243
|
+
The `ThemeVars` namespace contains type definitions for all themeable variable names in CDS. It includes any custom theme variables added in `ThemeVarsExtended`.
|
|
244
|
+
|
|
245
|
+
```tsx
|
|
246
|
+
import type { ThemeVars } from '@coinbase/cds-common/core/theme';
|
|
247
|
+
|
|
248
|
+
// All theme variables are accessible through ThemeVars
|
|
249
|
+
ThemeVars.Color; // 'fg' | 'bg' | 'bgPrimary' | 'bgSecondary' | ...
|
|
250
|
+
ThemeVars.SpectrumColor; // 'blue60' | 'red40' | 'gray100' | ...
|
|
251
|
+
ThemeVars.SpectrumHue; // 'blue' | 'green' | 'orange' | 'gray' | ...
|
|
252
|
+
ThemeVars.SpectrumHueStep; // 0 | 5 | 10 | 20 | ...
|
|
253
|
+
ThemeVars.Space; // 0 | 0.25 | 0.5 | 1 | 2 | ...
|
|
254
|
+
ThemeVars.BorderWidth; // 0 | 100 | 200 | ...
|
|
255
|
+
ThemeVars.BorderRadius; // 0 | 100 | 200 | ...
|
|
256
|
+
ThemeVars.Font; // 'display1' | 'title1' | 'body' | ...
|
|
257
|
+
ThemeVars.FontFamily; // 'display1' | 'title1' | 'body' | ...
|
|
258
|
+
ThemeVars.FontSize; // 'display1' | 'title1' | 'body' | ...
|
|
259
|
+
ThemeVars.FontWeight; // 'display1' | 'title1' | 'body' | ...
|
|
260
|
+
ThemeVars.LineHeight; // 'display1' | 'title1' | 'body' | ...
|
|
261
|
+
ThemeVars.TextTransform; // 'display1' | 'title1' | 'body' | ...
|
|
262
|
+
ThemeVars.IconSize; // 'xs' | 's' | 'm' | 'l'
|
|
263
|
+
ThemeVars.AvatarSize; // 's' | 'm' | 'l' | 'xl' | ...
|
|
264
|
+
ThemeVars.ControlSize; // 'checkboxSize' | 'radioSize' | ...
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Extending the theme
|
|
268
|
+
|
|
269
|
+
You can extend the theme by adding custom theme variables. In this example we'll show how to add a custom color variable, but you can extend other types of `ThemeVars` as well.
|
|
270
|
+
|
|
271
|
+
Start by overriding interfaces in the `ThemeVarsExtended` namespace to add new theme variables. Only the key names are used, the `void` type is just a necessary placeholder.
|
|
272
|
+
|
|
273
|
+
```jsx
|
|
274
|
+
declare module '@coinbase/cds-common/core/theme' {
|
|
275
|
+
export namespace ThemeVarsExtended {
|
|
276
|
+
export interface Color {
|
|
277
|
+
myCustomColor: void;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
This adds `myCustomColor` to `ThemeVars.Color` - which enforces that this variable must be defined in your theme to satisfy the `ThemeConfig` type, and allows this variable name to be passed to the `StyleProps` API anywhere that theme colors are accepted.
|
|
284
|
+
|
|
285
|
+
Now that `myCustomColor` is defined in your theme the `useTheme` hook will include it in the return value.
|
|
286
|
+
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# useDimensions
|
|
2
|
+
|
|
3
|
+
Measures the screen dimensions and status bar height.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { useDimensions } from '@coinbase/cds-mobile/hooks/useDimensions'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## API
|
|
12
|
+
|
|
13
|
+
### Parameters
|
|
14
|
+
|
|
15
|
+
None. The hook takes no parameters.
|
|
16
|
+
|
|
17
|
+
### Returns
|
|
18
|
+
|
|
19
|
+
Returns an object with the following properties:
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
type Return = {
|
|
23
|
+
screenHeight: number;
|
|
24
|
+
screenWidth: number;
|
|
25
|
+
statusBarHeight: number;
|
|
26
|
+
};
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- `screenHeight`: The total height of the device screen in points (DIP).
|
|
30
|
+
- `screenWidth`: The total width of the device screen in points (DIP).
|
|
31
|
+
- `statusBarHeight`: The height of the device's status bar in points (DIP).
|
|
32
|
+
|
|
33
|
+
:::tip
|
|
34
|
+
All dimensions are in points (DIP - Density Independent Pixels), not physical pixels. Values automatically update on device orientation changes. The status bar height varies by device type, orientation, and presence of notches or dynamic islands.
|
|
35
|
+
:::
|
|
36
|
+
|
|
37
|
+
## Examples
|
|
38
|
+
|
|
39
|
+
### Basic usage
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
function Example() {
|
|
43
|
+
const { screenWidth, screenHeight, statusBarHeight } = useDimensions();
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Box backgroundColor="bgAlternate" padding={3} borderRadius={300} width="100%">
|
|
47
|
+
<VStack gap={2}>
|
|
48
|
+
<TextHeadline>
|
|
49
|
+
Screen dimensions: {screenWidth}x{screenHeight}
|
|
50
|
+
</TextHeadline>
|
|
51
|
+
<TextHeadline>Status bar height: {statusBarHeight}px</TextHeadline>
|
|
52
|
+
</VStack>
|
|
53
|
+
</Box>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### With Safe Area Layout
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
function Example() {
|
|
62
|
+
const { screenHeight, statusBarHeight } = useDimensions();
|
|
63
|
+
const contentHeight = screenHeight - statusBarHeight;
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Box backgroundColor="bgAlternate" height={contentHeight} paddingTop={statusBarHeight}>
|
|
67
|
+
<TextHeadline>Content below status bar</TextHeadline>
|
|
68
|
+
</Box>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|