diff --git a/packages/frontend/src/app/validator/[hash]/BlocksChart.js b/packages/frontend/src/app/validator/[hash]/BlocksChart.js index c2d1e7c15..f2ae698c4 100644 --- a/packages/frontend/src/app/validator/[hash]/BlocksChart.js +++ b/packages/frontend/src/app/validator/[hash]/BlocksChart.js @@ -1,13 +1,11 @@ +import { useState, useEffect, useRef } from 'react' import { fetchHandlerSuccess, fetchHandlerError } from '../../../util' -import { useState, useEffect } from 'react' -import { LineChart } from './../../../components/charts' +import { LineChart, TimeframeMenu } from './../../../components/charts' import * as Api from '../../../util/Api' import { Button } from '@chakra-ui/react' import { CalendarIcon } from './../../../components/ui/icons' import { ErrorMessageBlock } from '../../../components/Errors' -import { DateRangePicker } from '../../../components/calendar' import './TimeframeSelector.scss' -import './TimeframeMenu.scss' import './TabsChart.scss' const chartConfig = { @@ -34,13 +32,14 @@ const chartConfig = { } } -const TimeframeSelector = ({ config, isActive, changeCallback, openStateCallback }) => { +const TimeframeSelector = ({ config, isActive, changeCallback, openStateCallback, menuRef }) => { const [timespan, setTimespan] = useState(chartConfig.timespan.values[chartConfig.timespan.defaultIndex]) const [menuIsOpen, setMenuIsOpen] = useState(false) const changeHandler = (value) => { setTimespan(value) if (typeof changeCallback === 'function') changeCallback(value) + setMenuIsOpen(false) } useEffect(() => { @@ -51,43 +50,14 @@ const TimeframeSelector = ({ config, isActive, changeCallback, openStateCallback if (typeof openStateCallback === 'function') openStateCallback(menuIsOpen) }, [menuIsOpen]) - const calendarHandler = (value) => {} - return (
-
-
-
- Select a day, period or Timeframe: -
- -
- {config.timespan.values.map((iTimespan, i) => ( - - ))} -
-
- -
- -
-
+ + ))} +
+ + +
+ +
+ + ) +}) + +export default TimeframeMenu diff --git a/packages/frontend/src/app/validator/[hash]/TimeframeMenu.scss b/packages/frontend/src/components/charts/TimeframeMenu.scss similarity index 95% rename from packages/frontend/src/app/validator/[hash]/TimeframeMenu.scss rename to packages/frontend/src/components/charts/TimeframeMenu.scss index 8f5a75e73..991726dbf 100644 --- a/packages/frontend/src/app/validator/[hash]/TimeframeMenu.scss +++ b/packages/frontend/src/components/charts/TimeframeMenu.scss @@ -1,5 +1,5 @@ -@use '../../../styles/mixins.scss'; -@import '../../../styles/variables.scss'; +@use '../../styles/mixins.scss'; +@import '../../styles/variables.scss'; .TimeframeMenu { padding: 12px; diff --git a/packages/frontend/src/components/charts/index.js b/packages/frontend/src/components/charts/index.js index 79743e88b..b51f56d3b 100644 --- a/packages/frontend/src/components/charts/index.js +++ b/packages/frontend/src/components/charts/index.js @@ -4,6 +4,7 @@ import * as d3 from 'd3' import './charts.scss' import { Container } from '@chakra-ui/react' import theme from '../../styles/theme' +import TimeframeMenu from './TimeframeMenu' function getDatesTicks (dates, numTicks) { if (!dates.length) return [] @@ -438,5 +439,6 @@ const LineGraph = ({ } export { - LineChart + LineChart, + TimeframeMenu }