-
Notifications
You must be signed in to change notification settings - Fork 891
Premium Analytics: port the Average items per order widget #49505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
adamwoodnz
merged 24 commits into
trunk
from
add/wooa7s-1460-port-woo-widget-average-items-per-order
Jun 24, 2026
Merged
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
71c036f
premium-analytics: port average-items-per-order widget
nerrad 51bcc3d
premium-analytics: wire the Range editor from the fields package
nerrad 2c13a12
Premium Analytics: address average items widget review feedback
nerrad f74be68
Premium Analytics: add average items widget story
nerrad 3fd2b9e
Premium Analytics: align average items story sizes
nerrad 5aa81b1
Premium Analytics: fix compact comparison legend wrapping
nerrad 823d865
Premium Analytics: add dashboard-sized average items stories
nerrad e561ace
Premium Analytics: refine compact legend alignment
nerrad 1445987
Premium Analytics: prevent compact chart legend clipping
nerrad b36b9e4
Premium Analytics: constrain comparative chart layout
nerrad ee62a69
Premium Analytics: fix narrow comparison legend clipping
nerrad e5d6596
Premium Analytics: add global error provider stories
nerrad 2668de0
Premium Analytics: show widget error stories
nerrad e898276
Premium Analytics: move widget errors into dashboard chrome
nerrad 82b6825
Premium Analytics: stabilize widget error stories
nerrad c8412a6
Premium Analytics: Remove extracted widget error handling
nerrad 12023b6
Premium Analytics: Fix comparative legend wrapping
nerrad 36dccff
Premium Analytics: Stabilize comparative legend wrapping
nerrad 6228f46
Premium Analytics: Consolidate dashboard widget stories
nerrad 79a97e9
Premium Analytics: Use WordPress widget packages in stories
nerrad 11af3a3
Premium Analytics: Clean widget port config
nerrad 9479027
Premium Analytics: Refine average items Storybook stories
nerrad 428a124
Premium Analytics: Use datetime presets in story
nerrad 3c87144
Premium Analytics: Use Stack for comparative chart layout
nerrad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
projects/js-packages/storybook/changelog/add-average-items-order-widget-story
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Significance: patch | ||
| Type: added | ||
|
|
||
| Add a Premium Analytics Average items per order widget story. |
4 changes: 4 additions & 0 deletions
4
projects/packages/premium-analytics/changelog/add-average-items-per-order-widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Significance: patch | ||
| Type: added | ||
|
|
||
| Port the Average items per order dashboard widget from next-woocommerce-analytics, composed from the widgets-toolkit and data packages. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 26 additions & 3 deletions
29
.../widgets-toolkit/src/components/chart-comparative-line/comparative-line-chart.module.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
projects/packages/premium-analytics/widgets/average-items-per-order/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "name": "@automattic/jetpack-premium-analytics-widget-average-items-per-order", | ||
| "version": "0.1.0-alpha", | ||
| "private": true, | ||
| "type": "module", | ||
| "dependencies": { | ||
| "@jetpack-premium-analytics/widgets-toolkit": "link:../../packages/widgets-toolkit", | ||
| "@wordpress/i18n": "^6.9.0", | ||
| "@wordpress/icons": "^13.0.0", | ||
| "@wordpress/ui": "0.13.0", | ||
| "react": "18.3.1" | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
projects/packages/premium-analytics/widgets/average-items-per-order/render.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { | ||
| OrderMetricWidget, | ||
| WidgetRoot, | ||
| type ReportParamsFieldAttributes, | ||
| } from '@jetpack-premium-analytics/widgets-toolkit'; | ||
|
|
||
| type AverageItemsPerOrderRenderProps = { | ||
| attributes?: Partial< ReportParamsFieldAttributes >; | ||
| }; | ||
|
|
||
| /** | ||
| * Average items per order widget. | ||
| * | ||
| * Thin composition over the widgets-toolkit: WidgetRoot provides the query | ||
| * client, chart theme, and resolved report params; OrderMetricWidget fetches | ||
| * the orders report and renders the avg_items metric with a comparison delta | ||
| * and sparkline. | ||
| */ | ||
| export default function AverageItemsPerOrderRender( { | ||
| attributes, | ||
| }: AverageItemsPerOrderRenderProps ) { | ||
| return ( | ||
| <WidgetRoot attributes={ attributes } options={ { from: '/' } }> | ||
| <OrderMetricWidget metricKey="avg_items" /> | ||
| </WidgetRoot> | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should replace the regular div with the
chartclass with a Stack component. It's acting like a part of the component layout.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'm not sure what the purpose of these styles is. I guess we're trying to force the widget to take the whole height, but I thought that
height: 100%should be enough?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, it's needed to stretch its immediate children. Below:
Using this
> divclass doesn't look good .There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good points, I've replaced with Stack, but it looks like here are still some style tweaks needed. This particular component is in the widgets-toolkit package and is one of the ones that should be migrated to
@automattic/chartsas a part of the composite chart components. So I think this can help inform that eventual migration (and further SCSS edits can happen as a part of that).