diff --git a/client/my-sites/stats/modernized-chart-tabs-styles.scss b/client/my-sites/stats/modernized-chart-tabs-styles.scss index 1282e3b902831..80249d5c05bbf 100644 --- a/client/my-sites/stats/modernized-chart-tabs-styles.scss +++ b/client/my-sites/stats/modernized-chart-tabs-styles.scss @@ -150,6 +150,11 @@ $custom-stats-tab-mobile-break: $break-medium; } } + &.tab-disabled a { + pointer-events: none; + cursor: default; + } + &.is-low { a { .value { @@ -215,6 +220,9 @@ $custom-stats-tab-mobile-break: $break-medium; letter-spacing: -0.24px; margin-left: 8px; } + .stats-tabs__value.value { + display: none; + } @media (min-width: $custom-stats-tab-mobile-break) { & > a { padding: 8px 16px; diff --git a/client/my-sites/stats/site.jsx b/client/my-sites/stats/site.jsx index ac83cd25b78dd..23c87d4dcb836 100644 --- a/client/my-sites/stats/site.jsx +++ b/client/my-sites/stats/site.jsx @@ -352,15 +352,15 @@ class StatsSite extends Component { .format( 'YYYY-MM-DD' ); } + customChartRange.daysInRange = daysInRange; + // TODO: all the date logic should be done in controllers, otherwise it affects the performance. // If it's single day period, redirect to hourly stats. if ( period === 'day' && daysInRange === 1 ) { - page( '/stats/hour/' + slug + window.location.search ); + page.redirect( `/stats/hour/${ slug }${ window.location.search }` ); return; } - customChartRange.daysInRange = daysInRange; - // Calculate diff between requested start and end in `priod` units. // Move end point (most recent) to the end of period to account for partial periods // (e.g. requesting period between June 2020 and Feb 2021 would require 2 `yearly` units but would return 1 unit without the shift to the end of period) diff --git a/client/my-sites/stats/stats-chart-tabs/index.jsx b/client/my-sites/stats/stats-chart-tabs/index.jsx index 44686024cc8ac..74ffefc41263c 100644 --- a/client/my-sites/stats/stats-chart-tabs/index.jsx +++ b/client/my-sites/stats/stats-chart-tabs/index.jsx @@ -100,6 +100,8 @@ class StatModuleChartTabs extends Component { makeQuery = () => { this.props.requestChartCounts( this.props.query ); this.props.queryComp && this.props.requestChartCounts( this.props.queryComp ); + this.props.queryDay && this.props.requestChartCounts( this.props.queryDay ); + this.props.queryDayComp && this.props.requestChartCounts( this.props.queryDayComp ); }; render() { @@ -145,6 +147,8 @@ class StatModuleChartTabs extends Component { { - const hasData = - activeData && activeData[ tab.attr ] >= 0 && activeData[ tab.attr ] !== null; - + const hasTrend = trendData?.[ tab.attr ] >= 0 && trendData[ tab.attr ] !== null; + const hasData = activeData?.[ tab.attr ] >= 0 && activeData[ tab.attr ] !== null; const value = hasData ? activeData[ tab.attr ] : null; - const previousValue = activePreviousData && activePreviousData[ tab.attr ]; + const previousValue = + activePreviousData?.[ tab.attr ] !== null ? activePreviousData[ tab.attr ] : null; const tabOptions = { attr: tab.attr, icon: tab.icon, - className: clsx( tab.className, { 'is-highlighted': aggregate } ), + className: clsx( tab.className, { 'is-highlighted': previousData } ), label: tab.label, loading: ! hasData, selected: selectedTab === tab.attr, - tabClick: switchTab, + tabClick: hasTrend ? switchTab : undefined, value, format: tab.format, }; diff --git a/client/my-sites/stats/stats-tabs/tab.jsx b/client/my-sites/stats/stats-tabs/tab.jsx index ba68eb54a517e..e37e12a88edad 100644 --- a/client/my-sites/stats/stats-tabs/tab.jsx +++ b/client/my-sites/stats/stats-tabs/tab.jsx @@ -55,22 +55,16 @@ class StatsTabsTab extends Component { return ( // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions -
  • - { hasClickAction ? ( - - { tabIcon } - { tabLabel } - { tabValue } - { children } - - ) : ( - - { tabIcon } - { tabLabel } - { tabValue } - { children } - - ) } +
  • + + { tabIcon } + { tabLabel } + { tabValue } + { children } +
  • ); }