11import CurrencyLogo from 'components/CurrencyLogo'
22import { useCurrency , useToken } from 'hooks/Tokens'
3+ import { TimePeriod } from 'hooks/useTopTokens'
34import { atom , useAtom } from 'jotai'
5+ import { useState } from 'react'
46import { ArrowDownRight , ArrowLeft , ArrowUpRight , Heart , Share } from 'react-feather'
57import { Link } from 'react-router-dom'
68import styled , { useTheme } from 'styled-components/macro'
79
810import { favoritesAtom } from './TokenTable'
911
12+ const TIME_DISPLAYS : Record < TimePeriod , string > = {
13+ [ TimePeriod . hour ] : '1H' ,
14+ [ TimePeriod . day ] : '1D' ,
15+ [ TimePeriod . week ] : '1W' ,
16+ [ TimePeriod . month ] : '1M' ,
17+ [ TimePeriod . year ] : '1Y' ,
18+ }
19+ const TIME_PERIODS = [ TimePeriod . hour , TimePeriod . day , TimePeriod . week , TimePeriod . month , TimePeriod . year ]
20+
1021const ArrowCell = styled . div `
1122 padding-left: 2px;
1223 display: flex;
@@ -32,10 +43,30 @@ const ChartHeader = styled.div`
3243 color: ${ ( { theme } ) => theme . text1 } ;
3344 gap: 4px;
3445`
46+ const ChartContainer = styled . div `
47+ height: 332px;
48+ border-bottom: 1px solid ${ ( { theme } ) => theme . bg3 } ;
49+ `
3550const DeltaContainer = styled . div `
3651 display: flex;
3752 align-items: center;
3853`
54+
55+ const TimeButton = styled . button < { active : boolean } > `
56+ background-color: ${ ( { theme, active } ) => ( active ? theme . primary1 : 'transparent' ) } ;
57+ font-size: 14px;
58+ width: 36px;
59+ height: 36px;
60+ border-radius: 12px;
61+ border: none;
62+ cursor: pointer;
63+ color: ${ ( { theme } ) => theme . text1 } ;
64+ `
65+ const TimeOptionsContainer = styled . div `
66+ display: flex;
67+ justify-content: flex-end;
68+ gap: 4px;
69+ `
3970const TokenNameCell = styled . div `
4071 display: flex;
4172 gap: 8px;
@@ -70,6 +101,7 @@ export default function TokenDetail({ address }: { address: string }) {
70101 const currency = useCurrency ( address )
71102 const [ favoriteTokens ] = useAtom ( favoritesAtom )
72103 const isFavorited = atom < boolean > ( favoriteTokens . includes ( address ) )
104+ const [ activeTimePeriod , setTimePeriod ] = useState ( TimePeriod . hour )
73105
74106 // catch token error and loading state
75107 if ( ! token ) {
@@ -79,7 +111,7 @@ export default function TokenDetail({ address }: { address: string }) {
79111 const tokenSymbol = token . symbol
80112
81113 // dummy data for now until Jordan writes token detail hooks
82- // format price
114+ // TODO: format price, add sparkline
83115 const tokenPrice = '3,243.22'
84116 const tokenDelta = 1.22
85117 const isPositive = Math . sign ( tokenDelta ) > 0
@@ -119,6 +151,20 @@ export default function TokenDetail({ address }: { address: string }) {
119151 ) }
120152 </ ArrowCell >
121153 </ DeltaContainer >
154+ < ChartContainer > </ ChartContainer >
155+ < TimeOptionsContainer >
156+ { TIME_PERIODS . map ( ( timePeriod ) => {
157+ return (
158+ < TimeButton
159+ key = { timePeriod }
160+ active = { activeTimePeriod === timePeriod }
161+ onClick = { ( ) => setTimePeriod ( timePeriod ) }
162+ >
163+ { TIME_DISPLAYS [ timePeriod ] }
164+ </ TimeButton >
165+ )
166+ } ) }
167+ </ TimeOptionsContainer >
122168 </ ChartHeader >
123169 </ TopArea >
124170 )
0 commit comments