@@ -111,12 +111,14 @@ const getDynamicTitle = metric => {
111111 * @param {object } props.counts - Counts object for the current period.
112112 * @param {object } props.previousCounts - Counts object for the previous period.
113113 * @param {number } props.headingLevel - Heading level between 1 and 6.
114- * @param {Array } props.chartData - Chart data for the bar chart visualization.
114+ * @param {?object } props.chartData - Chart data for the bar chart visualization.
115115 * @param {boolean } props.isLoading - Whether the data is loading.
116116 * @param {string } props.detailedStatsHref - Destination of the detailed stats link.
117117 * @param {Function } props.onDetailedStatsClick - Function to handle detailed stats click.
118+ * @param {boolean } [props.hideTitle] - Whether to leave out the linked title, when a container already has one.
119+ * @param {boolean } [props.chartBelowCounts] - Whether to show the chart after the counts instead of before them.
118120 *
119- * @return {object } StatsCards React component.
121+ * @return {import('react').JSX.Element } StatsCards React component.
120122 */
121123const StatsCards = ( {
122124 counts,
@@ -126,6 +128,8 @@ const StatsCards = ( {
126128 isLoading,
127129 detailedStatsHref,
128130 onDetailedStatsClick,
131+ hideTitle = false ,
132+ chartBelowCounts = false ,
129133} ) => {
130134 const Heading = `h${ headingLevel >= 1 && headingLevel <= 6 ? headingLevel : 3 } ` ;
131135
@@ -169,30 +173,36 @@ const StatsCards = ( {
169173 return icons [ metric ] || icons . views ;
170174 } , [ ] ) ;
171175
176+ const chart = (
177+ < StatsChart
178+ data = { transformedChartData }
179+ isLoading = { isLoading }
180+ href = { detailedStatsHref }
181+ onClick = { onDetailedStatsClick }
182+ selectedMetric = { selectedMetric }
183+ metricIcon = { getMetricIcon ( selectedMetric ) }
184+ />
185+ ) ;
186+
172187 return (
173188 < div className = { styles [ 'section-stats-highlights' ] } >
174- < Link
175- tone = "neutral"
176- className = { styles [ 'section-title-container' ] }
177- href = { detailedStatsHref }
178- onClick = { detailedStatsHref ? onDetailedStatsClick : undefined }
179- >
180- < Heading className = { styles [ 'section-title' ] } >
181- < span > { getDynamicTitle ( selectedMetric ) } </ span >
182- </ Heading >
183- < div >
184- < Icon icon = { chevronRight } />
185- </ div >
186- </ Link >
189+ { ! hideTitle && (
190+ < Link
191+ tone = "neutral"
192+ className = { styles [ 'section-title-container' ] }
193+ href = { detailedStatsHref }
194+ onClick = { detailedStatsHref ? onDetailedStatsClick : undefined }
195+ >
196+ < Heading className = { styles [ 'section-title' ] } >
197+ < span > { getDynamicTitle ( selectedMetric ) } </ span >
198+ </ Heading >
199+ < div >
200+ < Icon icon = { chevronRight } />
201+ </ div >
202+ </ Link >
203+ ) }
187204
188- < StatsChart
189- data = { transformedChartData }
190- isLoading = { isLoading }
191- href = { detailedStatsHref }
192- onClick = { onDetailedStatsClick }
193- selectedMetric = { selectedMetric }
194- metricIcon = { getMetricIcon ( selectedMetric ) }
195- />
205+ { ! chartBelowCounts && chart }
196206
197207 < ul className = { clsx ( styles [ 'cards-list' ] , styles [ 'my-jetpack-stats-cards' ] ) } >
198208 < CountComparisonCard
@@ -256,6 +266,7 @@ const StatsCards = ( {
256266 onClick = { handleCommentsClick }
257267 />
258268 </ ul >
269+ { chartBelowCounts && chart }
259270 </ div >
260271 ) ;
261272} ;
0 commit comments