@automattic/jetpack-components 0.45.5 → 0.45.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/components/boost-score-graph/style.scss +5 -0
- package/components/boost-score-graph/uplot-line-chart.tsx +6 -3
- package/components/record-meter-bar/index.tsx +31 -4
- package/components/theme-provider/index.tsx +1 -1
- package/components/theme-provider/types.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
### This is a list detailing changes for the Jetpack RNA Components package releases.
|
|
4
4
|
|
|
5
|
+
## [0.45.7] - 2023-12-13
|
|
6
|
+
### Added
|
|
7
|
+
- Added `className` prop to RecordMeterBar component [#34182]
|
|
8
|
+
|
|
9
|
+
## [0.45.6] - 2023-12-11
|
|
10
|
+
### Fixed
|
|
11
|
+
- Fixed resizing of the performance history graph. [#34185]
|
|
12
|
+
|
|
5
13
|
## [0.45.5] - 2023-12-06
|
|
6
14
|
### Changed
|
|
7
15
|
- Updated package dependencies. [#34416]
|
|
@@ -894,6 +902,8 @@
|
|
|
894
902
|
### Changed
|
|
895
903
|
- Update node version requirement to 14.16.1
|
|
896
904
|
|
|
905
|
+
[0.45.7]: https://github.com/Automattic/jetpack-components/compare/0.45.6...0.45.7
|
|
906
|
+
[0.45.6]: https://github.com/Automattic/jetpack-components/compare/0.45.5...0.45.6
|
|
897
907
|
[0.45.5]: https://github.com/Automattic/jetpack-components/compare/0.45.4...0.45.5
|
|
898
908
|
[0.45.4]: https://github.com/Automattic/jetpack-components/compare/0.45.3...0.45.4
|
|
899
909
|
[0.45.3]: https://github.com/Automattic/jetpack-components/compare/0.45.2...0.45.3
|
|
@@ -94,6 +94,8 @@ export default function UplotLineChart( { range, periods }: UplotChartProps ) {
|
|
|
94
94
|
const uplot = useRef< uPlot | null >( null );
|
|
95
95
|
const uplotContainer = useRef( null );
|
|
96
96
|
|
|
97
|
+
const width = uplotContainer.current?.clientWidth || DEFAULT_DIMENSIONS.width;
|
|
98
|
+
|
|
97
99
|
let lastDesktopScore = 0;
|
|
98
100
|
let lastMobileScore = 0;
|
|
99
101
|
|
|
@@ -107,7 +109,8 @@ export default function UplotLineChart( { range, periods }: UplotChartProps ) {
|
|
|
107
109
|
const options: uPlot.Options = useMemo( () => {
|
|
108
110
|
const defaultOptions: uPlot.Options = {
|
|
109
111
|
class: 'boost-score-graph',
|
|
110
|
-
|
|
112
|
+
height: DEFAULT_DIMENSIONS.height,
|
|
113
|
+
width: width,
|
|
111
114
|
tzDate: ts => uPlot.tzDate( new Date( ts * 1e3 ), 'Etc/UTC' ),
|
|
112
115
|
fmtDate: ( chartDateStringTemplate: string ) => {
|
|
113
116
|
return date => getDateFormat( chartDateStringTemplate, date, getUserLocale() );
|
|
@@ -178,7 +181,7 @@ export default function UplotLineChart( { range, periods }: UplotChartProps ) {
|
|
|
178
181
|
return {
|
|
179
182
|
...defaultOptions,
|
|
180
183
|
};
|
|
181
|
-
}, [ lastDesktopScore, lastMobileScore, periods, range.endDate, range.startDate ] );
|
|
184
|
+
}, [ width, lastDesktopScore, lastMobileScore, periods, range.endDate, range.startDate ] );
|
|
182
185
|
|
|
183
186
|
useResize( uplot, uplotContainer );
|
|
184
187
|
const onCreate = useCallback( chart => {
|
|
@@ -186,7 +189,7 @@ export default function UplotLineChart( { range, periods }: UplotChartProps ) {
|
|
|
186
189
|
}, [] );
|
|
187
190
|
|
|
188
191
|
return (
|
|
189
|
-
<div ref={ uplotContainer }>
|
|
192
|
+
<div ref={ uplotContainer } className="boost-uplot-container">
|
|
190
193
|
<UplotReact data={ data } onCreate={ onCreate } options={ options } />
|
|
191
194
|
</div>
|
|
192
195
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
|
+
import classNames from 'classnames';
|
|
2
3
|
import React, { useMemo } from 'react';
|
|
3
4
|
import numberFormat from '../number-format';
|
|
4
5
|
|
|
@@ -36,6 +37,26 @@ export type RecordMeterBarProps = {
|
|
|
36
37
|
* The sort style for legend item. If not provided, it defaults to no sorting.
|
|
37
38
|
*/
|
|
38
39
|
sortByCount?: 'ascending' | 'descending';
|
|
40
|
+
/**
|
|
41
|
+
* Additional class name to be added to the component
|
|
42
|
+
*/
|
|
43
|
+
className?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Table caption
|
|
46
|
+
*/
|
|
47
|
+
tableCaption?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Title/label for the legend
|
|
50
|
+
*/
|
|
51
|
+
legendTitle?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Recorc type label for screen readers
|
|
54
|
+
*/
|
|
55
|
+
recordTypeLabel?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Record count label for screen readers
|
|
58
|
+
*/
|
|
59
|
+
recordCountLabel?: string;
|
|
39
60
|
};
|
|
40
61
|
|
|
41
62
|
/**
|
|
@@ -49,6 +70,11 @@ const RecordMeterBar: React.FC< RecordMeterBarProps > = ( {
|
|
|
49
70
|
items = [],
|
|
50
71
|
showLegendLabelBeforeCount = false,
|
|
51
72
|
sortByCount,
|
|
73
|
+
className,
|
|
74
|
+
tableCaption,
|
|
75
|
+
legendTitle,
|
|
76
|
+
recordTypeLabel,
|
|
77
|
+
recordCountLabel,
|
|
52
78
|
} ) => {
|
|
53
79
|
const total = useMemo( () => {
|
|
54
80
|
// If total count is not given, then compute it from items' count
|
|
@@ -71,7 +97,7 @@ const RecordMeterBar: React.FC< RecordMeterBarProps > = ( {
|
|
|
71
97
|
}, [ items, sortByCount ] );
|
|
72
98
|
|
|
73
99
|
return (
|
|
74
|
-
<div className=
|
|
100
|
+
<div className={ classNames( 'record-meter-bar', className ) }>
|
|
75
101
|
<div className="record-meter-bar__items" aria-hidden="true">
|
|
76
102
|
{ itemsToRender.map( ( { count, label, backgroundColor } ) => {
|
|
77
103
|
const widthPercent = ( ( count / total ) * 100 ).toPrecision( 2 );
|
|
@@ -81,6 +107,7 @@ const RecordMeterBar: React.FC< RecordMeterBarProps > = ( {
|
|
|
81
107
|
} ) }
|
|
82
108
|
</div>
|
|
83
109
|
<div className="record-meter-bar__legend" aria-hidden="true">
|
|
110
|
+
{ legendTitle && <div className="record-meter-bar__legend--title">{ legendTitle }</div> }
|
|
84
111
|
<ul className="record-meter-bar__legend--items">
|
|
85
112
|
{ itemsToRender.map( ( { count, label, backgroundColor } ) => {
|
|
86
113
|
const formattedCount = numberFormat( count );
|
|
@@ -112,11 +139,11 @@ const RecordMeterBar: React.FC< RecordMeterBarProps > = ( {
|
|
|
112
139
|
</ul>
|
|
113
140
|
</div>
|
|
114
141
|
<table className="screen-reader-text">
|
|
115
|
-
<caption>{ __( 'Summary of the records', 'jetpack' ) }</caption>
|
|
142
|
+
<caption>{ tableCaption || __( 'Summary of the records', 'jetpack' ) }</caption>
|
|
116
143
|
<tbody>
|
|
117
144
|
<tr>
|
|
118
|
-
<th scope="col">{ __( 'Record type', 'jetpack' ) }</th>
|
|
119
|
-
<th scope="col">{ __( 'Record count', 'jetpack' ) }</th>
|
|
145
|
+
<th scope="col">{ recordTypeLabel || __( 'Record type', 'jetpack' ) }</th>
|
|
146
|
+
<th scope="col">{ recordCountLabel || __( 'Record count', 'jetpack' ) }</th>
|
|
120
147
|
</tr>
|
|
121
148
|
{ itemsToRender.map( ( { label, count } ) => {
|
|
122
149
|
return (
|
|
@@ -142,7 +142,7 @@ const ThemeProvider: React.FC< ThemeProviderProps > = ( {
|
|
|
142
142
|
|
|
143
143
|
// Do not wrap when the DOM element target is defined.
|
|
144
144
|
if ( targetDom ) {
|
|
145
|
-
return children
|
|
145
|
+
return <>{ children }</>;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
return <div ref={ themeWrapperRef }>{ children }</div>;
|