mirror of
https://github.com/plausible/analytics.git
synced 2024-12-30 13:03:23 +03:00
5159e683cc
This commit adds support for comparing the actual showed period on the main graph with the previous one. This is a first pass and it's hidden under a feature flag because it's not feature complete yet as we want to support other comparison modes.
24 lines
887 B
JavaScript
24 lines
887 B
JavaScript
import React from 'react'
|
|
import { withRouter } from "react-router-dom";
|
|
import { navigateToQuery } from './query'
|
|
|
|
export const COMPARISON_DISABLED_PERIODS = ['realtime', 'all']
|
|
|
|
const ComparisonInput = function({ site, query, history }) {
|
|
if (!site.flags.comparisons) return null
|
|
if (COMPARISON_DISABLED_PERIODS.includes(query.period)) return null
|
|
|
|
function update(event) {
|
|
navigateToQuery(history, query, { comparison: event.target.checked })
|
|
}
|
|
|
|
return (
|
|
<div className="flex-none mx-3">
|
|
<input id="comparison-input" type="checkbox" onChange={update} checked={query.comparison} className="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500" />
|
|
<label htmlFor="comparison-input" className="ml-1.5 font-medium text-xs md:text-sm text-gray-700 dark:text-white">Compare</label>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default withRouter(ComparisonInput)
|