Skip to content

Commit

Permalink
Merge pull request #1739 from woocommerce/fix/1736-visually-hidden-style
Browse files Browse the repository at this point in the history
WP 6.1 Compatibility: Fix the giant icons in the `DatePicker` component
  • Loading branch information
eason9487 authored Nov 11, 2022
2 parents b75164e + aecd97f commit 23c09d8
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
3 changes: 3 additions & 0 deletions js/src/components/app-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ const AppModal = ( {
...rest
} ) => {
const modalClassName = classnames(
// gla-admin-page is for scoping particular styles to components that are used by
// a GLA admin page and are rendered via ReactDOM.createPortal.
'gla-admin-page',
'app-modal',
overflowStyleName[ overflow ],
className
Expand Down
24 changes: 24 additions & 0 deletions js/src/components/withAdminPageShell.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* External dependencies
*/
import { createHigherOrderComponent } from '@wordpress/compose';

/**
* A higher-order component for wrapping the app shell on top of the GLA admin page.
* Cross-page shared things could be handled here.
*
* @param {JSX.Element} Page Top-level admin page component to be wrapped by app shell.
*/
const withAdminPageShell = createHigherOrderComponent(
( Page ) => ( props ) => {
return (
// gla-admin-page is for scoping particular styles to a GLA admin page.
<div className="gla-admin-page">
<Page { ...props } />;
</div>
);
},
'withAdminPageShell'
);

export default withAdminPageShell;
10 changes: 10 additions & 0 deletions js/src/css/shared/_gutenberg-components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
@import "node_modules/@wordpress/components/src/button/style"; // required for tab-panel
@import "node_modules/@wordpress/components/src/panel/style";

// Scope the old styles of core components to GLA pages to avoid styling conflicts with other non-GLA pages.
.gla-admin-page {
// WP 6.1 Compatibility (@wordpress/components 21.0.6 imported by @woocommerce/components)
// The style of `DatePicker` component was significantly changed as per the new implementations.
// This import could be removed after:
// - It's fixed from @woocommerce/components
// - or @wordpress/components is changed to be imported via (WC)DEWP
@import "node_modules/@wordpress/components/src/date-time/datepicker"; /* stylelint-disable-line no-invalid-position-at-import-rule */
}

.components-button {
// Hack to show correct font color for disabled primary destructive button.
// The color style is copied from https://github.com/WordPress/gutenberg/blob/%40wordpress/components%4012.0.8/packages/components/src/button/style.scss#L67-L72
Expand Down
10 changes: 8 additions & 2 deletions js/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { getSetting } from '@woocommerce/settings'; // eslint-disable-line impor
* Internal dependencies
*/
import './css/index.scss';
import withAdminPageShell from '.~/components/withAdminPageShell';
import GetStartedPage from './get-started-page';
import SetupMC from './setup-mc';
import SetupAds from './setup-ads';
Expand Down Expand Up @@ -48,8 +49,7 @@ addFilter(
__( 'Google Listings & Ads', 'google-listings-and-ads' )
);

return [
...pages,
const pluginAdminPages = [
{
breadcrumbs: [ ...initialBreadcrumbs ],
container: GetStartedPage,
Expand Down Expand Up @@ -124,5 +124,11 @@ addFilter(
},
},
];

pluginAdminPages.forEach( ( page ) => {
page.container = withAdminPageShell( page.container );
} );

return pages.concat( pluginAdminPages );
}
);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
},
{
"path": "./js/build/index.css",
"maxSize": "12 kB"
"maxSize": "15.4 kB"
},
{
"path": "./google-listings-and-ads.zip",
Expand Down

0 comments on commit 23c09d8

Please sign in to comment.