Skip to content

Commit a2d92e9

Browse files
adamwoodnzmatticbot
authored andcommitted
Charts: Fix Line Chart Annotations Custom story error in Storybook (#47990)
* Charts: Replace gridicons with inline SVG to fix Storybook Vite transform error The gridicons package is CJS-only, which causes Vite's CJS-to-ESM interop in Storybook to fail when resolving the default export. This results in Gridicon being treated as an object instead of a React component, throwing 'Element type is invalid... got: object' in LineChartAnnotationLabelWithPopover. Replace the single Gridicon usage (cross icon in popover close button) with an inline SVG component using the same path data. This eliminates the CJS interop issue and also removes the gridicons dependency (~106KB) from the charts package. Ref CHARTS-208 * Add changelog entry for CHARTS-208 fix * Charts: Use @wordpress/icons instead of inline SVG for close icon Replace the inline CloseIcon SVG with the close icon from @wordpress/icons to align with WordPress ecosystem conventions. The package is tree-shakeable and already used widely across the monorepo. * Update changelog entry to reflect @wordpress/icons usage * Update changelog Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/24167983418 Upstream-Ref: Automattic/jetpack@0b78e64
1 parent 7086206 commit a2d92e9

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This is an alpha version! The changes listed here are not final.
1414
- Update package dependencies.
1515

1616
### Fixed
17+
- Fix Line Chart Annotations Custom and Alert story errors in Storybook by replacing the CJS-only gridicons dependency with @wordpress/icons.
1718
- Storybook: Replace manual design-system token override with real WPDS ThemeProvider.
1819

1920
## [1.0.2] - 2026-04-06

dist/index.cjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6926,8 +6926,8 @@ var line_chart_module_default = {
69266926

69276927
// src/charts/line-chart/private/line-chart-annotation-label-popover.tsx
69286928

6929+
var _icons = require('@wordpress/icons');
69296930

6930-
var _gridicons = require('gridicons'); var _gridicons2 = _interopRequireDefault(_gridicons);
69316931

69326932

69336933
var POPOVER_BUTTON_SIZE = 44;
@@ -7000,8 +7000,8 @@ var LineChartAnnotationLabelWithPopover = ({
70007000
popovertargetaction: "hide",
70017001
className: line_chart_module_default["line-chart__annotation-label-popover-close-button"],
70027002
"aria-label": _i18n.__.call(void 0, "Close", "jetpack-charts"),
7003-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _gridicons2.default, {
7004-
icon: "cross",
7003+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _icons.Icon, {
7004+
icon: _icons.close,
70057005
size: 16
70067006
})
70077007
})]
@@ -8822,7 +8822,7 @@ var DIRECTION_LABELS = {
88228822
down: "Decrease",
88238823
neutral: "No change"
88248824
};
8825-
var Icon = ({
8825+
var Icon2 = ({
88268826
direction
88278827
}) => {
88288828
if (direction === "neutral") {
@@ -8855,7 +8855,7 @@ function TrendIndicator({
88558855
className: _clsx2.default.call(void 0, trend_indicator_module_default["trend-indicator"], trend_indicator_module_default[`trend-indicator--${direction}`], className),
88568856
style,
88578857
"aria-label": ariaLabel,
8858-
children: [showIcon && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, {
8858+
children: [showIcon && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon2, {
88598859
direction
88608860
}), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", {
88618861
className: trend_indicator_module_default["trend-indicator__value"],

dist/index.cjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@
8383
"@visx/vendor": "^3.12.0",
8484
"@visx/xychart": "^3.12.0",
8585
"@wordpress/i18n": "^6.0.0",
86+
"@wordpress/icons": "^12.0.0",
8687
"@wordpress/theme": "0.10.0",
8788
"@wordpress/ui": "0.9.0",
8889
"clsx": "2.1.1",
8990
"date-fns": "^4.1.0",
9091
"deepmerge": "4.3.1",
9192
"dompurify": "^3.3.3",
9293
"fast-deep-equal": "3.1.3",
93-
"gridicons": "3.4.2",
9494
"react-google-charts": "^5.2.1",
9595
"tslib": "2.8.1"
9696
},

src/charts/line-chart/private/line-chart-annotation-label-popover.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { __ } from '@wordpress/i18n';
2+
import { Icon, close } from '@wordpress/icons';
23
import clsx from 'clsx';
3-
import Gridicon from 'gridicons';
44
import { useEffect, useId, useRef, useState } from 'react';
55
import { isSafari } from '../../../utils';
66
import styles from '../line-chart.module.scss';
@@ -100,7 +100,7 @@ const LineChartAnnotationLabelWithPopover: FC< LineChartAnnotationLabelWithPopov
100100
className={ styles[ 'line-chart__annotation-label-popover-close-button' ] }
101101
aria-label={ __( 'Close', 'jetpack-charts' ) }
102102
>
103-
<Gridicon icon="cross" size={ 16 } />
103+
<Icon icon={ close } size={ 16 } />
104104
</button>
105105
</div>
106106
</div>

0 commit comments

Comments
 (0)