Skip to content

Commit

Permalink
Navigation Block: Fix big spinner (WordPress#48332)
Browse files Browse the repository at this point in the history
* Navigation Block: Fix big spinner

WIP

* Add padding container

* Fix github.dev liniting issues.

* Add padding to container of page list block.
  • Loading branch information
apeatling authored Mar 3, 2023
1 parent 51e25a5 commit f093a0b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 22 deletions.
4 changes: 3 additions & 1 deletion packages/block-library/src/navigation/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,9 @@ function Navigation( {

{ isLoading && (
<TagName { ...blockProps }>
<Spinner className="wp-block-navigation__loading-indicator" />
<div className="wp-block-navigation__loading-indicator-container">
<Spinner className="wp-block-navigation__loading-indicator" />
</div>
</TagName>
) }

Expand Down
43 changes: 23 additions & 20 deletions packages/block-library/src/navigation/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
}

// Only show the flyout on hover if the parent menu item is selected.
.wp-block-navigation:not(.is-selected):not(.has-child-selected)
.has-child:hover {
.wp-block-navigation:not(.is-selected):not(.has-child-selected) .has-child:hover {
> .wp-block-navigation__submenu-container {
opacity: 0;
visibility: hidden;
Expand All @@ -49,6 +48,7 @@

// Styles for submenu flyout.
.has-child {

&.is-selected,
&.has-child-selected {
> .wp-block-navigation__submenu-container {
Expand Down Expand Up @@ -76,8 +76,7 @@
flex-direction: column;
}

.is-dragging-components-draggable
.wp-block-navigation-link > .wp-block-navigation__container {
.is-dragging-components-draggable .wp-block-navigation-link > .wp-block-navigation__container {
// Set opacity to 1 to still be able to show the draggable chip.
opacity: 1;
visibility: hidden;
Expand Down Expand Up @@ -117,6 +116,7 @@
*/

$colors-selector-size: 22px;

.block-library-colors-selector {
width: auto;

Expand Down Expand Up @@ -151,7 +151,7 @@ $colors-selector-size: 22px;
min-width: $colors-selector-size;
height: $colors-selector-size;
min-height: $colors-selector-size;
line-height: ( $colors-selector-size - 2 );
line-height: ($colors-selector-size - 2);
padding: 2px;

> svg {
Expand All @@ -161,6 +161,7 @@ $colors-selector-size: 22px;

// Styling icon color.
&.has-text-color {

> svg,
> svg path {
color: inherit;
Expand All @@ -171,6 +172,7 @@ $colors-selector-size: 22px;

// Colors Selector Popover.
$color-control-label-height: 20px;

.block-library-colors-selector__popover {
.color-palette-controller-container {
padding: 16px;
Expand Down Expand Up @@ -222,13 +224,16 @@ $color-control-label-height: 20px;
0% {
opacity: 1;
}

50% {
opacity: 0.5;
}

100% {
opacity: 1;
}
}

// Unstyle some inherited placeholder component styles.
.components-placeholder.wp-block-navigation-placeholder {
outline: none;
Expand Down Expand Up @@ -271,6 +276,7 @@ $color-control-label-height: 20px;
// against any background color.
color: currentColor;
background: transparent;

&::before {
content: "";
display: block;
Expand Down Expand Up @@ -338,6 +344,7 @@ $color-control-label-height: 20px;
// Hide the navigation indicator when in small contexts.
.is-small &,
.is-medium & {

.wp-block-navigation-placeholder__actions__indicator,
.wp-block-navigation-placeholder__actions__indicator + hr {
display: none;
Expand Down Expand Up @@ -427,15 +434,14 @@ $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;
top: $admin-bar-height-big + $header-height + $block-toolbar-height + $border-width;

@include break-medium() {
top: $admin-bar-height + $header-height + $border-width;
Expand All @@ -445,24 +451,21 @@ $color-control-label-height: 20px;
@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;
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;
top: $admin-bar-height + $header-height + $block-toolbar-height + $border-width;
}

.is-sidebar-opened .wp-block-navigation__responsive-container.is-menu-open {
Expand All @@ -473,9 +476,7 @@ $color-control-label-height: 20px;
.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;
top: $admin-bar-height-big + $header-height + $block-toolbar-height + $border-width;

@include break-medium() {
top: $header-height + $border-width;
Expand All @@ -495,8 +496,7 @@ $color-control-label-height: 20px;
}

// The iframe makes these rules a lot simpler.
body.editor-styles-wrapper
.wp-block-navigation__responsive-container.is-menu-open {
body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-open {
top: 0;
right: 0;
bottom: 0;
Expand Down Expand Up @@ -536,6 +536,7 @@ body.editor-styles-wrapper
.components-heading.wp-block-navigation-off-canvas-editor__title {
margin: 0;
}

.wp-block-navigation-off-canvas-editor__header {
margin-bottom: $grid-unit-10;
}
Expand All @@ -552,14 +553,15 @@ body.editor-styles-wrapper
0% {
opacity: 0;
}

100% {
opacity: 1;
}
}

// Space spinner to give it breathing
// room when block is selected and has focus outline.
.wp-block-navigation .components-spinner {
.wp-block-navigation__loading-indicator-container {
padding: $grid-unit-10 $grid-unit-15;
}

Expand All @@ -571,6 +573,7 @@ body.editor-styles-wrapper
0% {
opacity: 1;
}

100% {
opacity: 0.5;
}
Expand Down
4 changes: 3 additions & 1 deletion packages/block-library/src/page-list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ function BlockContent( {
if ( ! hasResolvedPages ) {
return (
<div { ...blockProps }>
<Spinner />
<div className="wp-block-page-list__loading-indicator-container">
<Spinner className="wp-block-page-list__loading-indicator" />
</div>
</div>
);
}
Expand Down
6 changes: 6 additions & 0 deletions packages/block-library/src/page-list/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,9 @@
.wp-block-page-list .components-notice {
margin-left: 0;
}

// Space spinner to give it breathing
// room when block is selected and has focus outline.
.wp-block-page-list__loading-indicator-container {
padding: $grid-unit-10 $grid-unit-15;
}

0 comments on commit f093a0b

Please sign in to comment.