use % change to affect chart color

This commit is contained in:
tjs 2022-07-15 16:26:29 -04:00
parent b4cddd1b19
commit e7cfa4dd80
2 changed files with 15 additions and 3 deletions

View File

@ -11,6 +11,7 @@ import {
} from 'recharts' } from 'recharts'
import LineChartIcon from '../icons/LineChartIcon' import LineChartIcon from '../icons/LineChartIcon'
import ContentBox from '../shared/ContentBox' import ContentBox from '../shared/ContentBox'
import { GREEN, RED } from '../../styles/colors'
dayjs.extend(relativeTime) dayjs.extend(relativeTime)
@ -241,15 +242,23 @@ const SwapTokenChart: FunctionComponent<SwapTokenChartProps> = ({
x2="0" x2="0"
y2="1" y2="1"
> >
<stop offset="0%" stopColor="#ffba24" stopOpacity={0.3} /> <stop
<stop offset="80%" stopColor="#ffba24" stopOpacity={0} /> offset="0%"
stopColor={chartChange >= 0 ? GREEN : RED}
stopOpacity={0.15}
/>
<stop
offset="99%"
stopColor={chartChange >= 0 ? GREEN : RED}
stopOpacity={0}
/>
</linearGradient> </linearGradient>
</defs> </defs>
<Area <Area
isAnimationActive={true} isAnimationActive={true}
type="monotone" type="monotone"
dataKey="price" dataKey="price"
stroke="#ffba24" stroke={chartChange >= 0 ? GREEN : RED}
fill="url(#gradientArea)" fill="url(#gradientArea)"
/> />
<XAxis <XAxis

3
styles/colors.ts Normal file
View File

@ -0,0 +1,3 @@
export const PRIMARY = '#F2C94C'
export const GREEN = '#AFD803'
export const RED = '#F84638'