Skip to content
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

Snackbar: Update snackbar position when list view or inserter opened #47298

Closed
wants to merge 9 commits into from
1 change: 0 additions & 1 deletion packages/components/src/snackbar/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export function SnackbarList( {

return (
<motion.div
layout={ ! isReducedMotion } // See https://www.framer.com/docs/animation/#layout-animations
initial={ 'init' }
animate={ 'open' }
exit={ 'exit' }
Expand Down
21 changes: 12 additions & 9 deletions packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ function Layout( { styles } ) {

const isDistractionFree = isDistractionFreeMode && isLargeViewport;

const className = classnames( 'edit-post-layout', 'is-mode-' + mode, {
'is-sidebar-opened': sidebarIsOpened,
'has-fixed-toolbar': hasFixedToolbar,
'has-metaboxes': hasActiveMetaboxes,
'show-icon-labels': showIconLabels,
'is-distraction-free': isDistractionFree,
'is-inserter-opened': isInserterOpened,
'is-list-view-opened': isListViewOpened,
'is-entity-save-view-open': !! entitiesSavedStatesCallback,
'has-secondary-sidebar': isListViewOpened || isInserterOpened,
} );

const openSidebarPanel = () =>
openGeneralSidebar(
hasBlockSelected ? 'edit-post/block' : 'edit-post/document'
Expand Down Expand Up @@ -159,15 +171,6 @@ function Layout( { styles } ) {
[ entitiesSavedStatesCallback ]
);

const className = classnames( 'edit-post-layout', 'is-mode-' + mode, {
'is-sidebar-opened': sidebarIsOpened,
'has-fixed-toolbar': hasFixedToolbar,
'has-metaboxes': hasActiveMetaboxes,
'show-icon-labels': showIconLabels,
'is-distraction-free': isDistractionFree,
'is-entity-save-view-open': !! entitiesSavedStatesCallback,
} );

const secondarySidebarLabel = isListViewOpened
? __( 'Document Overview' )
: __( 'Block Library' );
Expand Down
14 changes: 10 additions & 4 deletions packages/edit-post/src/components/layout/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@
.edit-post-layout .components-editor-notices__snackbar {
position: fixed;
right: 0;
bottom: 40px;
padding-left: 16px;
padding-right: 16px;
bottom: $grid-unit-50;
padding-left: $grid-unit-20;
padding-right: $grid-unit-20;
}

.is-distraction-free {
.components-editor-notices__snackbar {
bottom: 20px;
bottom: math.div($grid-unit-50, 2);
}
}

.has-secondary-sidebar {
.components-editor-notices__snackbar {
padding-left: $grid-unit-20 + $nav-sidebar-width;
}
}

Expand Down
14 changes: 11 additions & 3 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import classnames from 'classnames';

/**
* WordPress dependencies
*/
Expand Down Expand Up @@ -148,6 +153,11 @@ export default function Editor() {
return <CanvasSpinner />;
}

const className = classnames( {
'show-icon-labels': showIconLabels,
'has-secondary-sidebar': isListViewOpen || isInserterOpen,
} );

return (
<>
{ isEditMode && <WelcomeGuide /> }
Expand All @@ -163,9 +173,7 @@ export default function Editor() {
{ isEditMode && <StartTemplateOptions /> }
<InterfaceSkeleton
enableRegionNavigation={ false }
className={
showIconLabels && 'show-icon-labels'
}
className={ className }
notices={ isEditMode && <EditorSnackbars /> }
content={
<>
Expand Down
20 changes: 14 additions & 6 deletions packages/edit-site/src/components/editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@
}

// Adjust the position of the notices
.edit-site .components-editor-notices__snackbar {
position: fixed;
right: 0;
bottom: 40px;
padding-left: 16px;
padding-right: 16px;
.edit-site {
.components-editor-notices__snackbar {
position: fixed;
right: 0;
bottom: $grid-unit-50;
padding-left: $grid-unit-20;
padding-right: $grid-unit-20;
}

@include break-medium {
.has-secondary-sidebar .components-editor-notices__snackbar {
padding-left: $grid-unit-20 + $nav-sidebar-width;
}
}
}
@include editor-left(".edit-site .components-editor-notices__snackbar")