-
Notifications
You must be signed in to change notification settings - Fork 20
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
Bump @wordpress version and use Modal component for shipping label purchase #2336
Conversation
@@ -250,6 +250,7 @@ | |||
|
|||
// Just the tooltip WordPress Component styles is all we use for now. | |||
@import "~@wordpress/base-styles/colors"; | |||
@import "~@wordpress/base-styles/variables"; |
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.
This has to be manually added here so @WordPress components can find it. I would have thought this would be handled automatically by npm/webpack, but this is also how wc-admin does things.
<FormSectionHeading> | ||
{ translate( 'Create shipping label', 'Create shipping labels', { count: Object.keys( props.form.packages.selected ).length } ) } | ||
</FormSectionHeading> | ||
<Button className="label-purchase-modal__close-button" onClick={ onClose }> |
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.
Button is built into Modal component
@@ -27,10 +27,9 @@ | |||
"license": "GPL-2.0", | |||
"description": "Connect allthethings", | |||
"devDependencies": { | |||
"@slack/web-api": "^5.8.0", | |||
"@slack/web-api": "^5.15.0", |
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.
Several version got bumped to the latest compatible version (by npm update
). I figured this was a good time while we we're tearing everything up anyway 🤷
package.json
Outdated
"@hot-loader/react-dom": "^16.14.0", | ||
"@wordpress/babel-preset-default": "^5.0.1", | ||
"@wordpress/base-styles": "^3.3.0", | ||
"@wordpress/components": "^12.0.7", |
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.
This is a major update of @wordpress/components from 8.5 to 12.0.7
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 went back to 11.1.15 because the dependencies are messy on 12 and I can't fix it so far
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.
Functionally everything worked as expected and visually it all matched up well. I only found two issues, one is a mobile visual issue and the other is a React warning.
The mobile visual issue was with the label purchase modal width and padding. The modal didn't go full screen width and it had padding on the sides which squished everything together causing some overlap.
The Reach warning I got was:
Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state.
in PackageInfo (created by Localized(PackageInfo))
I looked through the PackageInfo component and I'm pretty certain the issue is when a package is not selected for the order and it updates the props inside the render. Everything still worked as expected with the warning, but was wondering if there was a better way to handle that props update?
Line 59 in 40ccf29
props.setPackageType( orderId, siteId, packageId, userMeta.last_box_id ); |
@@ -271,6 +274,43 @@ const tryGetLabelRates = ( orderId, siteId, dispatch, getState ) => { | |||
} ); | |||
}; | |||
|
|||
export const setPackageType = ( orderId, siteId, packageId, boxTypeId ) => ( |
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.
setPackageType is moved up here now so it's defined in time
Good finds, @bborman22. I tweaked the styles for narrow screens. I think it's as good as the previous version at least. You found the right line that was triggering that warning. I moved that functionality into actions to trigger when the printing modal opens up. |
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.
Awesome, that warning is gone now! The modal is looking better, but I am still seeing a gap in the modal on my screen.
I noticed it is coming from this line and the fact that the new modal doesn't have the .dialog.card
classes to set width to 100% at that breakpoint. Not sure if we should add those classes or remove that selector and just apply it right to .label-purchase-modal
which seemed to work?
Lines 7 to 22 in 4666610
&.label-purchase-modal { | |
height: calc(100% - 10vmin); | |
width: calc(100% - 10vmin); | |
max-height: 1080px; | |
max-width: 1920px; | |
box-shadow: rgba(151,150,150,.5) 2px 2px 7px; | |
background-color: $studio-gray-0; | |
@include breakpoint( '<660px' ) { | |
&.dialog.card { | |
height: 100%; | |
max-height: 100%; | |
width: 100%; | |
max-width: 100%; | |
} | |
} |
Thanks for catching that. I'm so blind to these things sometimes on my own PR. 🙈 The card style applies to the cards within the modal and that seems to be working OK. I put a 100% width style in for the modal on narrow screens. Much better now 😄 |
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.
Looks good! I think this is good to go now!
Description
Bumps @WordPress
components
and elements versions up. The updated styling ofcomponents
v11 improved the look and feel of the Modal component. I ran into some dependency road blocks with using v12, so we can save that update for later.Replaces Calypo's
Dialog
component with @WordPress'sModal
component for the shipping label purchase modalThis only replaces the component on the shipping label purchase modal. I'll continue the Dialog replacement efforts on future PRs. I decided to stop here because this was already pretty big (especially given the dependency updates).
The shipping summary has also been nested in a Card component because that worked best with the updated header styles.
There are numerous style updates to make this all work well.
Related issue(s)
#2333
Steps to reproduce & screenshots/GIFs
Testing:
@wordpress
update could affect any part of the JS appI took some liberties with the design. I think we should aim to use the replacement components as intended, so I prioritized trying to make things look nice instead of trying to totally replicate the old design/layout. Let me know if there's any big concerns, otherwise we can get some design feedback once more components have been replaced