Skip to content

Commit

Permalink
Fix for site editor.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmussen committed Apr 8, 2021
1 parent 8007a10 commit 2be7654
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@

// Block toolbar when fixed to the top of the screen.
.edit-post-header__block-toolbar {
&:empty {
display: none;
}

height: $block-toolbar-height;
.block-editor-block-toolbar .components-toolbar-group,
.block-editor-block-toolbar .components-toolbar {
border-top: none;
Expand Down
10 changes: 4 additions & 6 deletions packages/edit-post/src/components/header/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// This CSS is largely copied for the site editor (.edit-site-header).
// Please keep them in sync.
.edit-post-header {
min-height: $header-height;
background: $white;
display: flex;
justify-content: flex-start;
Expand All @@ -11,12 +14,6 @@
flex-wrap: nowrap;
}

// Set height of toolbar depending on fixed toolbar toggle.
height: $header-height;
.has-fixed-toolbar & {
height: $header-height + $block-toolbar-height;
}

// Some browsers, most notably IE11, honor an older version of the flexbox spec
// which takes absolutely positioned items into account when calculating `space-between`.
// https://www.w3.org/TR/2012/WD-css3-flexbox-20120612/#abspos-flex-items
Expand Down Expand Up @@ -45,6 +42,7 @@

.edit-post-header__toolbar {
height: $header-height;
justify-content: space-between;
border-bottom: $border-width solid $gray-300;
}

Expand Down
20 changes: 9 additions & 11 deletions packages/edit-site/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ export default function Header( { openEntitiesSavedStates } ) {

return (
<div className="edit-site-header">
<div className="edit-site-header_start">
<div className="edit-site-header__toolbar">
<div className="edit-site-header__toolbar">
<div className="edit-site-header__toolbar-actions">
<Button
ref={ inserterButton }
isPrimary
Expand Down Expand Up @@ -130,15 +130,8 @@ export default function Header( { openEntitiesSavedStates } ) {
/>
</>
) }
{ displayBlockToolbar && (
<div className="edit-site-header-toolbar__block-toolbar">
<BlockToolbar hideDragHandle />
</div>
) }
</div>
</div>

<div className="edit-site-header_center">
{ 'wp_template' === templateType && (
<DocumentActions
entityTitle={ entityTitle }
Expand All @@ -152,15 +145,14 @@ export default function Header( { openEntitiesSavedStates } ) {
) }
</DocumentActions>
) }

{ 'wp_template_part' === templateType && (
<DocumentActions
entityTitle={ entityTitle }
entityLabel="template part"
/>
) }
</div>

<div className="edit-site-header_end">
<div className="edit-site-header__actions">
<PreviewOptions
deviceType={ deviceType }
Expand All @@ -173,6 +165,12 @@ export default function Header( { openEntitiesSavedStates } ) {
<MoreMenu />
</div>
</div>

{ displayBlockToolbar && (
<div className="edit-site-header-toolbar__block-toolbar">
<BlockToolbar hideDragHandle />
</div>
) }
</div>
);
}
99 changes: 31 additions & 68 deletions packages/edit-site/src/components/header/style.scss
Original file line number Diff line number Diff line change
@@ -1,40 +1,26 @@
$header-toolbar-min-width: 335px;

// This CSS is largely copied for the post editor (.edit-post-header).
// Please keep them in sync.
.edit-site-header {
align-items: center;
min-height: $header-height;
background-color: $white;
display: flex;
height: $header-height;
box-sizing: border-box;
width: 100%;
justify-content: space-between;
justify-content: flex-start;
flex-direction: column;
// The header should never be wider than the viewport, or buttons might be hidden. Especially relevant at high zoom levels. Related to https://core.trac.wordpress.org/ticket/47603#ticket.
max-width: 100vw;

// Make toolbar sticky on larger breakpoints
@include break-zoomed-in {
flex-wrap: nowrap;
}

// Add transition for the menu.
body.is-fullscreen-mode & {
padding-left: 60px;
transition: padding-left 20ms linear;
transition-delay: 80ms;
@include reduce-motion("transition");
}

.edit-site-header_start,
.edit-site-header_end {
display: flex;
}

.edit-site-header_center {
display: flex;
align-items: center;
height: 100%;
// Flex items will, by default, refuse to shrink below a minimum
// intrinsic width. In order to shrink this flexbox item, and
// subsequently truncate child text, we set an explicit min-width.
// See https://dev.w3.org/csswg/css-flexbox/#min-size-auto
min-width: 0;
}

.edit-site-header_end {
justify-content: flex-end;
}
}

// Keeps the document title centered when the sidebar is open
Expand All @@ -60,7 +46,24 @@ body.is-navigation-sidebar-open {
}
}

// Make both the default header toolbar and the toggled top toolbar be full-width.
.edit-site-header__toolbar,
.edit-site-header__block-toolbar {
display: flex;
flex-wrap: wrap;
}

.edit-site-header__toolbar {
height: $header-height;
justify-content: space-between;
border-bottom: $border-width solid $gray-300;
}

.edit-site-header__block-toolbar {
height: $block-toolbar-height;
}

.edit-site-header__toolbar-actions {
display: flex;
align-items: center;
padding-left: $grid-unit-10;
Expand Down Expand Up @@ -165,57 +168,17 @@ body.is-navigation-sidebar-open {

// Block toolbar when fixed to the top of the screen.
.edit-site-header-toolbar__block-toolbar {
// Stack toolbar below Editor Bar.
position: absolute;
top: $header-height + $border-width;
left: 0;
right: 0;
background: $white;
border-bottom: $border-width solid $gray-300;

&:empty {
display: none;
}

height: $block-toolbar-height;
.block-editor-block-toolbar .components-toolbar-group,
.block-editor-block-toolbar .components-toolbar {
border-top: none;
border-bottom: none;
}

.is-sidebar-opened & {
display: none;
}

@include break-medium {
.is-sidebar-opened & {
display: block;
right: $sidebar-width;
}
}

// Move toolbar into top Editor Bar.
@include break-wide {
padding-left: $grid-unit-10;
position: static;
left: auto;
right: auto;
background: none;
border-bottom: none;

.is-sidebar-opened & {
right: auto;
}

.block-editor-block-toolbar {
border-left: $border-width solid $gray-300;
}

.block-editor-block-toolbar .components-toolbar-group,
.block-editor-block-toolbar .components-toolbar {
$top-toolbar-padding: ( $header-height - $grid-unit-60 ) / 2;
height: $header-height;
padding: $top-toolbar-padding 0;
}
}
}

0 comments on commit 2be7654

Please sign in to comment.