@@ -8,18 +8,21 @@ import {
88 withTiming ,
99} from 'react-native-reanimated' ;
1010import type { ThemeVars } from '@coinbase/cds-common/core/theme' ;
11- import { assets } from '@coinbase/cds-common/internal/data/assets' ;
11+ import { assets , ethBackground } from '@coinbase/cds-common/internal/data/assets' ;
1212import { candles as btcCandles } from '@coinbase/cds-common/internal/data/candles' ;
1313import { prices } from '@coinbase/cds-common/internal/data/prices' ;
1414import { sparklineInteractiveData } from '@coinbase/cds-common/internal/visualizations/SparklineInteractiveData' ;
1515import { useTabsContext } from '@coinbase/cds-common/tabs/TabsContext' ;
1616import type { TabValue } from '@coinbase/cds-common/tabs/useTabs' ;
17+ import { NoopFn } from '@coinbase/cds-common/utils/mockUtils' ;
1718import { useTheme } from '@coinbase/cds-mobile' ;
19+ import { DataCard } from '@coinbase/cds-mobile/alpha/data-card/DataCard' ;
1820import { Button , IconButton } from '@coinbase/cds-mobile/buttons' ;
1921import { ListCell } from '@coinbase/cds-mobile/cells' ;
20- import { Example , ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen' ;
22+ import { ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen' ;
2123import { Box , type BoxBaseProps , HStack , VStack } from '@coinbase/cds-mobile/layout' ;
2224import { Avatar , RemoteImage } from '@coinbase/cds-mobile/media' ;
25+ import { NavigationTitleSelect } from '@coinbase/cds-mobile/navigation' ;
2326import { SectionHeader } from '@coinbase/cds-mobile/section-header/SectionHeader' ;
2427import { Pressable } from '@coinbase/cds-mobile/system' ;
2528import { type TabComponent , type TabsActiveIndicatorProps } from '@coinbase/cds-mobile/tabs' ;
@@ -38,7 +41,7 @@ import {
3841
3942import { Area , DottedArea , type DottedAreaProps } from '../../area' ;
4043import { DefaultAxisTickLabel , XAxis , YAxis } from '../../axis' ;
41- import { BarChart , type BarComponentProps , BarPlot } from '../../bar' ;
44+ import { type BarComponentProps , BarPlot } from '../../bar' ;
4245import { CartesianChart } from '../../CartesianChart' ;
4346import { useCartesianChartContext } from '../../ChartProvider' ;
4447import { PeriodSelector , PeriodSelectorActiveIndicator } from '../../PeriodSelector' ;
@@ -2281,6 +2284,106 @@ function TwoLineScrubberLabel() {
22812284 </ VStack >
22822285 ) ;
22832286}
2287+ function DataCardWithLineChart ( ) {
2288+ const exampleThumbnail = (
2289+ < RemoteImage accessibilityLabel = "Ethereum" source = { ethBackground } testID = "thumbnail" />
2290+ ) ;
2291+
2292+ const getLineChartSeries = ( ) => [
2293+ {
2294+ id : 'price' ,
2295+ data : prices . slice ( 0 , 30 ) . map ( ( price : string ) => parseFloat ( price ) ) ,
2296+ color : 'accentBoldBlue' ,
2297+ } ,
2298+ ] ;
2299+
2300+ const lineChartSeries = useMemo ( ( ) => getLineChartSeries ( ) , [ ] ) ;
2301+ const lineChartSeries2 = useMemo ( ( ) => getLineChartSeries ( ) , [ ] ) ;
2302+ const ref = useRef < View > ( null ) ;
2303+
2304+ return (
2305+ < VStack gap = { 2 } >
2306+ < DataCard
2307+ layout = "vertical"
2308+ subtitle = "Price trend"
2309+ thumbnail = { exampleThumbnail }
2310+ title = "Line Chart Card"
2311+ >
2312+ < LineChart
2313+ showArea
2314+ accessibilityLabel = "Ethereum price chart"
2315+ areaType = "dotted"
2316+ height = { 120 }
2317+ inset = { 0 }
2318+ series = { lineChartSeries }
2319+ />
2320+ </ DataCard >
2321+ < DataCard
2322+ layout = "vertical"
2323+ subtitle = "Price trend"
2324+ tag = "Trending"
2325+ thumbnail = { exampleThumbnail }
2326+ title = "Line Chart with Tag"
2327+ >
2328+ < LineChart
2329+ showArea
2330+ accessibilityLabel = "Ethereum price chart"
2331+ areaType = "dotted"
2332+ height = { 100 }
2333+ inset = { 0 }
2334+ series = { lineChartSeries }
2335+ />
2336+ </ DataCard >
2337+ < DataCard
2338+ ref = { ref }
2339+ renderAsPressable
2340+ layout = "vertical"
2341+ onPress = { NoopFn }
2342+ subtitle = "Clickable line chart card"
2343+ tag = "Interactive"
2344+ thumbnail = { exampleThumbnail }
2345+ title = "Actionable Line Chart"
2346+ >
2347+ < LineChart
2348+ showArea
2349+ accessibilityLabel = "Ethereum price chart"
2350+ areaType = "dotted"
2351+ height = { 120 }
2352+ inset = { 0 }
2353+ series = { lineChartSeries }
2354+ showXAxis = { false }
2355+ showYAxis = { false }
2356+ />
2357+ </ DataCard >
2358+ < DataCard
2359+ layout = "vertical"
2360+ subtitle = "Price trend"
2361+ tag = "Trending"
2362+ thumbnail = {
2363+ < RemoteImage
2364+ accessibilityLabel = "Bitcoin"
2365+ shape = "circle"
2366+ size = "l"
2367+ source = { assets . btc . imageUrl }
2368+ testID = "thumbnail"
2369+ />
2370+ }
2371+ title = "Card with Line Chart"
2372+ >
2373+ < LineChart
2374+ showArea
2375+ accessibilityLabel = "Price chart"
2376+ areaType = "dotted"
2377+ height = { 100 }
2378+ inset = { 0 }
2379+ series = { lineChartSeries2 }
2380+ showXAxis = { false }
2381+ showYAxis = { false }
2382+ />
2383+ </ DataCard >
2384+ </ VStack >
2385+ ) ;
2386+ }
22842387
22852388type ExampleItem = {
22862389 title : string ;
@@ -2542,20 +2645,22 @@ function ExampleNavigator() {
25422645 title : 'Two-Line Scrubber Label' ,
25432646 component : < TwoLineScrubberLabel /> ,
25442647 } ,
2648+ {
2649+ title : 'In DataCard' ,
2650+ component : < DataCardWithLineChart /> ,
2651+ } ,
25452652 ] ,
25462653 [ theme . color . fg , theme . color . fgPositive , theme . spectrum . gray50 ] ,
25472654 ) ;
25482655
25492656 const currentExample = examples [ currentIndex ] ;
2550- const isFirstExample = currentIndex === 0 ;
2551- const isLastExample = currentIndex === examples . length - 1 ;
25522657
25532658 const handlePrevious = useCallback ( ( ) => {
2554- setCurrentIndex ( ( prev ) => Math . max ( 0 , prev - 1 ) ) ;
2555- } , [ ] ) ;
2659+ setCurrentIndex ( ( prev ) => ( prev - 1 + examples . length ) % examples . length ) ;
2660+ } , [ examples . length ] ) ;
25562661
25572662 const handleNext = useCallback ( ( ) => {
2558- setCurrentIndex ( ( prev ) => Math . min ( examples . length - 1 , prev + 1 ) ) ;
2663+ setCurrentIndex ( ( prev ) => ( prev + 1 + examples . length ) % examples . length ) ;
25592664 } , [ examples . length ] ) ;
25602665
25612666 return (
@@ -2565,12 +2670,11 @@ function ExampleNavigator() {
25652670 < IconButton
25662671 accessibilityHint = "Navigate to previous example"
25672672 accessibilityLabel = "Previous"
2568- disabled = { isFirstExample }
25692673 name = "arrowLeft"
25702674 onPress = { handlePrevious }
25712675 variant = "secondary"
25722676 />
2573- < VStack alignItems = "center" gap = { 1 } >
2677+ < VStack alignItems = "center" >
25742678 < Text font = "title3" > { currentExample . title } </ Text >
25752679 < Text color = "fgMuted" font = "label1" >
25762680 { currentIndex + 1 } / { examples . length }
@@ -2579,7 +2683,6 @@ function ExampleNavigator() {
25792683 < IconButton
25802684 accessibilityHint = "Navigate to next example"
25812685 accessibilityLabel = "Next"
2582- disabled = { isLastExample }
25832686 name = "arrowRight"
25842687 onPress = { handleNext }
25852688 variant = "secondary"
0 commit comments