Commit c1042c6b authored by ianlapham's avatar ianlapham

update chart font

parent 3cb38237
import React, { useRef, useState, useEffect, useCallback, Dispatch, SetStateAction, ReactNode } from 'react' import React, { useRef, useState, useEffect, useCallback, Dispatch, SetStateAction, ReactNode } from 'react'
import { createChart, IChartApi, ISeriesApi } from 'lightweight-charts' import { createChart, IChartApi } from 'lightweight-charts'
import { darken } from 'polished' import { darken } from 'polished'
import { RowBetween } from 'components/Row' import { RowBetween } from 'components/Row'
import Card from '../Card' import Card from '../Card'
import styled from 'styled-components' import styled from 'styled-components'
import useTheme from 'hooks/useTheme' import useTheme from 'hooks/useTheme'
import { useDarkModeManager } from 'state/user/hooks'
import usePrevious from 'hooks/usePrevious'
const Wrapper = styled(Card)` const Wrapper = styled(Card)`
width: 100%; width: 100%;
...@@ -69,22 +67,7 @@ const LineChart = ({ ...@@ -69,22 +67,7 @@ const LineChart = ({
return () => window.removeEventListener('resize', handleResize) return () => window.removeEventListener('resize', handleResize)
}, [isClient, chartRef, handleResize]) // Empty array ensures that effect is only run on mount and unmount }, [isClient, chartRef, handleResize]) // Empty array ensures that effect is only run on mount and unmount
const [currentTheme] = useDarkModeManager()
const textColor = theme.text2 const textColor = theme.text2
const previousTheme = usePrevious(currentTheme)
const [activeSeries, setActiveSeries] = useState<ISeriesApi<'Area'> | undefined>(undefined)
// reset the chart if theme switches
useEffect(() => {
if (chartCreated && activeSeries && previousTheme && previousTheme !== currentTheme) {
// remove the tooltip element
chartCreated.removeSeries(activeSeries)
chartCreated.resize(0, 0)
setActiveSeries(undefined)
setChart(undefined)
}
}, [activeSeries, chartCreated, currentTheme, previousTheme])
// if chart not instantiated in canvas, create it // if chart not instantiated in canvas, create it
useEffect(() => { useEffect(() => {
...@@ -95,6 +78,7 @@ const LineChart = ({ ...@@ -95,6 +78,7 @@ const LineChart = ({
layout: { layout: {
backgroundColor: 'transparent', backgroundColor: 'transparent',
textColor: textColor, textColor: textColor,
fontFamily: 'Inter',
}, },
rightPriceScale: { rightPriceScale: {
scaleMargins: { scaleMargins: {
...@@ -143,7 +127,6 @@ const LineChart = ({ ...@@ -143,7 +127,6 @@ const LineChart = ({
priceLineVisible: false, priceLineVisible: false,
}) })
setActiveSeries(series)
series.setData(data) series.setData(data)
// update the title when hovering on the chart // update the title when hovering on the chart
......
...@@ -48,6 +48,8 @@ import Loader from '../../components/Loader' ...@@ -48,6 +48,8 @@ import Loader from '../../components/Loader'
import { useIsTransactionUnsupported } from 'hooks/Trades' import { useIsTransactionUnsupported } from 'hooks/Trades'
import UnsupportedCurrencyFooter from 'components/swap/UnsupportedCurrencyFooter' import UnsupportedCurrencyFooter from 'components/swap/UnsupportedCurrencyFooter'
import { isTradeBetter } from 'utils/trades' import { isTradeBetter } from 'utils/trades'
import LineChart from 'components/LineChart'
import { dummyData } from 'components/LineChart/data'
export default function Swap() { export default function Swap() {
const loadedUrlParams = useDefaultsFromURLSearch() const loadedUrlParams = useDefaultsFromURLSearch()
...@@ -300,6 +302,7 @@ export default function Swap() { ...@@ -300,6 +302,7 @@ export default function Swap() {
/> />
<SwapPoolTabs active={'swap'} /> <SwapPoolTabs active={'swap'} />
<AppBody> <AppBody>
<LineChart data={dummyData} />
<SwapHeader /> <SwapHeader />
<Wrapper id="swap-page"> <Wrapper id="swap-page">
<ConfirmSwapModal <ConfirmSwapModal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment