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

Navigation Overlay: Improve handling of open overlay. #32886

Merged
merged 2 commits into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 55 additions & 5 deletions packages/block-library/src/navigation/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -385,20 +385,70 @@ $color-control-label-height: 20px;
}

// Emulate the fullscreen editing inside the editor.
// Most of this can be removed when the iframe lands.

// When not fullscreen.
.wp-block-navigation__responsive-container.is-menu-open {
position: fixed;
top: $admin-bar-height-big + $header-height + $block-toolbar-height + $border-width;

@include break-medium() {
top: $admin-bar-height + $header-height + $border-width;
}

// Navigation sidebar rules.
@include break-medium() {
left: $admin-sidebar-width-collapsed;
}
@include break-large() {
left: $admin-sidebar-width;
}
}

.has-fixed-toolbar .wp-block-navigation__responsive-container.is-menu-open {
@include break-medium() {
top: $admin-bar-height + $header-height + $block-toolbar-height + $border-width;
}
}

.is-mobile-preview .wp-block-navigation__responsive-container.is-menu-open,
.is-tablet-preview .wp-block-navigation__responsive-container.is-menu-open {
top: $admin-bar-height + $header-height + $block-toolbar-height + $border-width;
}

.is-sidebar-opened .wp-block-navigation__responsive-container.is-menu-open {
right: $sidebar-width;
}

// Handle top position.
// For now, the editing of menu items in the mobile view only happens <600px.
// That means we only have to consider the big adminbar height (<783px).
// And in that view we also know that the toolbar is stacked.
body.admin-bar & {
// When fullscreen.
.is-fullscreen-mode {
.wp-block-navigation__responsive-container.is-menu-open {
left: 0; // Unset the value from non fullscreen mode.
top: $admin-bar-height-big + $header-height + $block-toolbar-height + $border-width;

@include break-medium() {
top: $header-height + $border-width;
}
}

.has-fixed-toolbar .wp-block-navigation__responsive-container.is-menu-open {
@include break-medium() {
top: $header-height + $block-toolbar-height + $border-width;
}
}

.is-mobile-preview .wp-block-navigation__responsive-container.is-menu-open,
.is-tablet-preview .wp-block-navigation__responsive-container.is-menu-open {
top: $header-height + $block-toolbar-height + $border-width;
}
}

// The iframe makes these rules a lot simpler.
body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-open {
top: 0;
right: 0;
bottom: 0;
left: 0;
}

// Without this, the block cannot be selected, nor does the right container get focus.
Expand Down
2 changes: 2 additions & 0 deletions packages/edit-post/src/components/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export default function VisualEditor( { styles } ) {
const resizedCanvasStyles = useResizeCanvas( deviceType, isTemplateMode );
const defaultLayout = useSetting( 'layout' );
const { contentSize, wideSize } = defaultLayout || {};
const previewMode = 'is-' + deviceType.toLowerCase() + '-preview';

let animatedStyles = isTemplateMode
? templateModeStyles
Expand Down Expand Up @@ -219,6 +220,7 @@ export default function VisualEditor( { styles } ) {
<motion.div
animate={ animatedStyles }
initial={ desktopCanvasStyles }
className={ previewMode }
>
<MaybeIframe
isTemplateMode={ isTemplateMode }
Expand Down