forked from woocommerce/woocommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix double scrollbars on product editor page (woocommerce#38281)
* Refactor Layout component to functional component * Add class to pages based on page path * Add styling for interface skeleton on product pages * Add changelog entries * Move product page styles out of product editor package and into client * Fix linting issues * Check for location before checking path in page tracking * Dont add body classes when no page path exists * Record page view without router location for embed pages
- Loading branch information
Showing
10 changed files
with
313 additions
and
233 deletions.
There are no files selected for viewing
This file contains 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: minor | ||
Type: fix | ||
|
||
Fix double scrollbars on product editor page |
17 changes: 0 additions & 17 deletions
17
packages/js/product-editor/src/components/editor/style.scss
This file contains 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 |
---|---|---|
@@ -1,18 +1 @@ | ||
@import '@wordpress/interface/src/style.scss'; | ||
|
||
.interface-interface-skeleton { | ||
@include breakpoint( '<782px' ) { | ||
top: $adminbar-height-mobile; | ||
} | ||
top: $adminbar-height; | ||
background-color: $white; | ||
} | ||
|
||
.interface-interface-skeleton__sidebar { | ||
width: 280px; | ||
} | ||
|
||
.interface-interface-skeleton__header { | ||
// Higher than the sidebar which has a z-index of 90. | ||
z-index: 100; | ||
} |
56 changes: 56 additions & 0 deletions
56
plugins/woocommerce-admin/client/layout/hooks/use-page-classes.ts
This file contains 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,56 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { useEffect } from '@wordpress/element'; | ||
import { RouteMatch } from 'react-router-dom'; | ||
|
||
type Page = { | ||
container: JSX.Element; | ||
path: string; | ||
breadcrumbs: | ||
| string[] | ||
| ( ( { match }: { match: RouteMatch } ) => string[] ); | ||
wpOpenMenu: string; | ||
navArgs: { | ||
id: string; | ||
}; | ||
capability: string; | ||
}; | ||
|
||
export function usePageClasses( page: Page ) { | ||
function convertCamelCaseToKebabCase( str: string ) { | ||
return str.replace( | ||
/[A-Z]/g, | ||
( letter ) => `-${ letter.toLowerCase() }` | ||
); | ||
} | ||
|
||
function getPathClassName( path: string ) { | ||
const suffix = | ||
path === '/' | ||
? '_home' | ||
: path | ||
.replace( /:[a-zA-Z?]+/g, function ( match ) { | ||
return convertCamelCaseToKebabCase( match ).replace( | ||
':', | ||
'' | ||
); | ||
} ) | ||
.replace( /\//g, '_' ); | ||
|
||
return `woocommerce-admin-page_${ suffix }`; | ||
} | ||
|
||
useEffect( () => { | ||
if ( ! page.path ) { | ||
return; | ||
} | ||
|
||
const classes = getPathClassName( page.path ); | ||
|
||
document.body.classList.add( classes ); | ||
return () => { | ||
document.body.classList.remove( classes ); | ||
}; | ||
}, [ page.path ] ); | ||
} |
This file contains 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
Oops, something went wrong.