-
Notifications
You must be signed in to change notification settings - Fork 80
feat: expo template #402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: expo template #402
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
apps/docs/docs/getting-started/templates/_mobileContent.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| import { MDXSection } from '@site/src/components/page/MDXSection'; | ||
| import { MDXArticle } from '@site/src/components/page/MDXArticle'; | ||
| import { TemplateCard } from '@site/src/components/page/TemplateCard'; | ||
| import { HStack } from '@coinbase/cds-web/layout'; | ||
| import ThemedImage from '@theme/ThemedImage'; | ||
|
|
||
| <MDXSection> | ||
| <MDXArticle> | ||
|
|
||
| ## Get started | ||
|
|
||
| The easiest way to get started with CDS on mobile is with a template. The Expo template includes the required CDS packages, dependencies, and pre-configured settings with a working example application to help you start building. | ||
|
|
||
| <HStack gap={2} style={{ marginTop: '1.5rem', flexWrap: 'wrap', alignItems: 'stretch' }}> | ||
| <TemplateCard | ||
| name="Expo" | ||
| description="Built for cross-platform mobile applications with React Native" | ||
| href="https://github.com/coinbase/cds/tree/master/templates/expo-app" | ||
| icon={ | ||
| <ThemedImage | ||
| sources={{ | ||
| light: '/img/logos/frameworks/expo_light.png', | ||
| dark: '/img/logos/frameworks/expo_dark.png', | ||
| }} | ||
| alt="Expo" | ||
| style={{ paddingTop: 'var(--space-0_75)', paddingBottom: 'var(--space-0_75)' }} | ||
| height="100%" | ||
| /> | ||
| } | ||
| /> | ||
| </HStack> | ||
|
|
||
| </MDXArticle> | ||
| </MDXSection> | ||
|
|
||
| <MDXSection> | ||
| <MDXArticle> | ||
|
|
||
| ## Installation | ||
|
|
||
| To create a new project from the template, use `gitpick` to bootstrap your application: | ||
|
|
||
| ### Expo | ||
|
|
||
| ```bash | ||
| npx -y gitpick coinbase/cds/tree/master/templates/expo-app cds-expo | ||
| cd cds-expo | ||
| ``` | ||
|
|
||
| </MDXArticle> | ||
| </MDXSection> | ||
|
|
||
| <MDXSection> | ||
| <MDXArticle> | ||
|
|
||
| ## Setup | ||
|
|
||
| After creating your project, install dependencies and start developing: | ||
|
|
||
| ```bash | ||
| # We suggest using nvm to manage Node.js versions | ||
| nvm install | ||
| nvm use | ||
|
|
||
| # Enable corepack for package manager setup | ||
| corepack enable | ||
|
|
||
| # Install dependencies | ||
| yarn | ||
|
|
||
| # Start development server | ||
| yarn start | ||
| ``` | ||
|
|
||
| </MDXArticle> | ||
| </MDXSection> | ||
|
|
||
| <MDXSection> | ||
| <MDXArticle> | ||
|
|
||
| ## What's included | ||
|
|
||
| All templates come pre-configured with: | ||
|
|
||
| - Latest CDS packages (`@coinbase/cds-mobile`, `@coinbase/cds-icons`, etc.) | ||
| - TypeScript configuration | ||
| - Example components demonstrating common UI patterns | ||
| - Theme setup with CDS default theme | ||
| - Navigation with React Navigation | ||
|
|
||
| </MDXArticle> | ||
| </MDXSection> | ||
|
|
||
| <MDXSection> | ||
| <MDXArticle> | ||
|
|
||
| ## Next steps | ||
|
|
||
| After setting up your template, learn how to customize and extend CDS: | ||
|
|
||
| - [Theming](/getting-started/theming) - Customize colors, spacing, and typography | ||
| - [Installation](/getting-started/installation) - Manual installation and setup options | ||
|
|
||
| </MDXArticle> | ||
| </MDXSection> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "description": "Get started quickly with a pre-built Expo template configured with CDS components and best practices." | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # dependencies | ||
| node_modules/ | ||
|
|
||
| # Expo | ||
| .expo/ | ||
| dist/ | ||
| web-build/ | ||
|
|
||
| # Native | ||
| *.orig.* | ||
| *.jks | ||
| *.p8 | ||
| *.p12 | ||
| *.key | ||
| *.mobileprovision | ||
|
|
||
| # Metro | ||
| .metro-health-check* | ||
|
|
||
| # debug | ||
| npm-debug.* | ||
| yarn-debug.* | ||
| yarn-error.* | ||
|
|
||
| # macOS | ||
| .DS_Store | ||
| *.pem | ||
|
|
||
| # local env files | ||
| .env*.local | ||
|
|
||
| # typescript | ||
| *.tsbuildinfo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 22 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| nodeLinker: node-modules | ||
|
|
||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| import React, { memo, useState, useCallback } from 'react'; | ||
| import { ScrollView } from 'react-native'; | ||
| import { GestureHandlerRootView } from 'react-native-gesture-handler'; | ||
| import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context'; | ||
| import { useFonts } from 'expo-font'; | ||
| import { Inter_400Regular, Inter_600SemiBold } from '@expo-google-fonts/inter'; | ||
|
|
||
hcopp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import type { ColorScheme } from '@coinbase/cds-common'; | ||
| import type { TabValue } from '@coinbase/cds-common/tabs/useTabs'; | ||
|
|
||
| import { useTheme } from '@coinbase/cds-mobile'; | ||
| import { defaultTheme } from '@coinbase/cds-mobile/themes/defaultTheme'; | ||
| import { VStack, HStack, Box } from '@coinbase/cds-mobile/layout'; | ||
| import { TabbedChips } from '@coinbase/cds-mobile/alpha/tabbed-chips/TabbedChips'; | ||
| import { PortalProvider } from '@coinbase/cds-mobile/overlays/PortalProvider'; | ||
| import { StatusBar, ThemeProvider } from '@coinbase/cds-mobile/system'; | ||
|
|
||
| import { Navbar } from './components/Navbar'; | ||
| import { AssetList } from './components/AssetList'; | ||
| import { CardList } from './components/CardList'; | ||
| import { AssetCarousel } from './components/AssetCarousel'; | ||
| import { AssetChart } from './components/AssetChart'; | ||
| import { TabBarButton } from './components/TabBarButton'; | ||
|
|
||
| const chipTabs = [ | ||
| { id: 'all', label: 'All' }, | ||
| { id: 'crypto', label: 'Crypto' }, | ||
| { id: 'nfts', label: 'NFTs' }, | ||
| { id: 'defi', label: 'DeFi' }, | ||
| { id: 'earn', label: 'Earn' }, | ||
| ]; | ||
|
|
||
| const CdsSafeAreaProvider = memo(({ children }: React.PropsWithChildren) => { | ||
| const theme = useTheme(); | ||
| return ( | ||
| <SafeAreaProvider style={{ backgroundColor: theme.color.bg }}>{children}</SafeAreaProvider> | ||
| ); | ||
| }); | ||
|
|
||
| export default function App() { | ||
| const [activeColorScheme, setActiveColorScheme] = useState<ColorScheme>('light'); | ||
| const [fontsLoaded] = useFonts({ | ||
| CoinbaseIcons: require('@coinbase/cds-icons/fonts/native/CoinbaseIcons.ttf'), | ||
| Inter_400Regular, | ||
| Inter_600SemiBold, | ||
| }); | ||
|
|
||
| const toggleColorScheme = useCallback( | ||
| () => setActiveColorScheme((s) => (s === 'light' ? 'dark' : 'light')), | ||
| [], | ||
| ); | ||
|
|
||
| if (!fontsLoaded) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <GestureHandlerRootView style={{ flex: 1 }}> | ||
| <ThemeProvider activeColorScheme={activeColorScheme} theme={defaultTheme}> | ||
| <CdsSafeAreaProvider> | ||
| <PortalProvider> | ||
| <StatusBar /> | ||
| <AppContent toggleColorScheme={toggleColorScheme} /> | ||
| </PortalProvider> | ||
| </CdsSafeAreaProvider> | ||
| </ThemeProvider> | ||
| </GestureHandlerRootView> | ||
| ); | ||
| } | ||
|
|
||
| function AppContent({ toggleColorScheme }: { toggleColorScheme: () => void }) { | ||
| const [activeChip, setActiveChip] = useState<TabValue | null>(chipTabs[0]); | ||
| const [activeNavTab, setActiveNavTab] = useState('home'); | ||
| const insets = useSafeAreaInsets(); | ||
|
|
||
| return ( | ||
| <VStack style={{ flex: 1 }} background="bg"> | ||
| <Navbar toggleColorScheme={toggleColorScheme} /> | ||
|
|
||
| <Box paddingX={2} paddingY={1}> | ||
| <TabbedChips | ||
| accessibilityLabel="Filter categories" | ||
| activeTab={activeChip} | ||
| onChange={setActiveChip} | ||
| tabs={chipTabs} | ||
| /> | ||
| </Box> | ||
|
|
||
| <ScrollView style={{ flex: 1 }} contentContainerStyle={{ paddingBottom: 24 }}> | ||
| <Box padding={2}> | ||
| <AssetChart /> | ||
| </Box> | ||
|
|
||
| <Box paddingY={1}> | ||
| <AssetCarousel /> | ||
| </Box> | ||
|
|
||
| <Box padding={2}> | ||
| <AssetList /> | ||
| </Box> | ||
|
|
||
| <Box paddingY={1}> | ||
| <CardList /> | ||
| </Box> | ||
| </ScrollView> | ||
|
|
||
| <Box borderedTop background="bg" style={{ paddingBottom: insets.bottom }}> | ||
| <HStack> | ||
| <TabBarButton | ||
| icon="home" | ||
| label="Home" | ||
| active={activeNavTab === 'home'} | ||
| onPress={() => setActiveNavTab('home')} | ||
| /> | ||
| <TabBarButton | ||
| icon="sendReceive" | ||
| label="Trade" | ||
| active={activeNavTab === 'trade'} | ||
| onPress={() => setActiveNavTab('trade')} | ||
| /> | ||
| <TabBarButton | ||
| icon="compass" | ||
| label="Explore" | ||
| active={activeNavTab === 'explore'} | ||
| onPress={() => setActiveNavTab('explore')} | ||
| /> | ||
| <TabBarButton | ||
| icon="account" | ||
| label="Account" | ||
| active={activeNavTab === 'account'} | ||
| onPress={() => setActiveNavTab('account')} | ||
| /> | ||
| </HStack> | ||
| </Box> | ||
| </VStack> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Coinbase Design System - Expo Template | ||
|
|
||
| A React Native mobile application template integrated with the Coinbase Design System (CDS). | ||
|
|
||
| ## Installation | ||
|
|
||
| Use `gitpick` to create a new project from this template: | ||
|
|
||
| ```sh | ||
| npx -y gitpick coinbase/cds/tree/master/templates/expo-app cds-expo | ||
| cd cds-expo | ||
| ``` | ||
|
|
||
| ## Setup | ||
|
|
||
| We suggest [nvm](https://github.com/nvm-sh/nvm/tree/master) to manage Node.js versions. If you have it installed, you can use these commands to set the correct Node.js version. Using corepack ensures you have your package manager setup. | ||
|
|
||
| ```sh | ||
| nvm install | ||
| nvm use | ||
| corepack enable | ||
| yarn | ||
| ``` | ||
|
|
||
hcopp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ## Development | ||
|
|
||
| - `yarn start` - Start the Expo development server | ||
| - `yarn ios` - Run on iOS simulator | ||
| - `yarn android` - Run on Android emulator | ||
| - `yarn web` - Run in web browser | ||
|
|
||
| ## Dev Builds | ||
|
|
||
| Some CDS components require native modules that are not available in Expo Go. If you use any of the following components, you will need to create a [development build](https://docs.expo.dev/develop/development-builds/introduction/): | ||
|
|
||
| - `DatePicker` | ||
| - `openWebBrowser` | ||
| - `AndroidNavigationBar` | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Figured this was worth placing this in, let me know if y'all disagree or if we should be a little more generic (I think these are the three but not 100% confident). |
||
|
|
||
| To create a development build: | ||
|
|
||
| ```sh | ||
| npx expo prebuild | ||
| npx expo run:ios # or npx expo run:android | ||
| ``` | ||
|
|
||
| ## Documentation | ||
|
|
||
| Visit [cds.coinbase.com](https://cds.coinbase.com) for the latest CDS documentation and component examples. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No way to test this until we release