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: Remove blobs that look like a loading state (alternate version) #37144

Closed
wants to merge 4 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,19 @@
*/
import classnames from 'classnames';

/**
* WordPress dependencies
*/
import { Icon, search } from '@wordpress/icons';

const PlaceholderPreview = ( { isLoading } ) => {
return (
<ul
className={ classnames(
'wp-block-navigation-placeholder__preview',
'wp-block-navigation__container',
{ 'is-loading': isLoading }
) }
>
<li className="wp-block-navigation-item">&#8203;</li>
<li className="wp-block-navigation-item">&#8203;</li>
<li className="wp-block-navigation-item">&#8203;</li>
<li className="wp-block-navigation-placeholder__preview-search-icon">
<Icon icon={ search } />
</li>
<li>&#8203;</li>
<li>&#8203;</li>
<li>&#8203;</li>
<li>&#8203;</li>
<li>&#8203;</li>
</ul>
);
};
Expand Down
133 changes: 55 additions & 78 deletions packages/block-library/src/navigation/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,23 @@ $color-control-label-height: 20px;
justify-content: flex-start;
}


/**
* Setup state
*/

// Loading state.
@keyframes loadingpulse {
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 All @@ -204,8 +217,10 @@ $color-control-label-height: 20px;
min-height: 0;

// Needed for the preview menu items to match actual menu items.
gap: inherit;
.components-placeholder__fieldset {
font-size: inherit;
gap: inherit;
}

.components-placeholder__fieldset .components-button {
Expand All @@ -220,116 +235,78 @@ $color-control-label-height: 20px;
}
}

// Spinner.
.wp-block-navigation-placeholder .components-spinner {
margin-top: -4px;
margin-left: 4px;
vertical-align: middle;
margin-right: 7px;
}

@keyframes loadingpulse {
0% {
opacity: 1;
}
50% {
opacity: 0.5;
}
100% {
opacity: 1;
}
}

// Unselected state.
.wp-block-navigation-placeholder__preview {
display: flex;
flex-direction: row;
align-items: center;
flex-wrap: nowrap;
width: 100%;
overflow: hidden;
padding: $grid-unit-05 $grid-unit-10 $grid-unit-05 $grid-unit-15;
min-width: $grid-unit-10 * 12;

&.is-loading {
animation: loadingpulse 1s linear infinite;
animation-delay: 0.5s; // avoid animating for fast network responses
}
// Make it at least as high as the smallest placeholder.
min-height: $button-size + $grid-unit-05 + $grid-unit-05;

// Style skeleton elements to mostly match the metrics of actual menu items.
// Needs specificity.
.wp-block-navigation-item.wp-block-navigation-item {
position: relative;
min-width: 72px;

&::before {
display: block;
content: "";
border-radius: $radius-block-ui;
background: currentColor;
height: $grid-unit-20;
width: 100%;
}
// Hide when selected.
.wp-block-navigation.is-selected & {
display: none;
}

.wp-block-navigation-placeholder__preview-search-icon {
height: $icon-size;
svg {
fill: currentColor;
}
}
/*// Draw the dashed outline.
// By setting the dashed border to currentColor, we ensure it's visible
// against any background color.
color: currentColor;
background: transparent;
&::before {
content: "";
display: block;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
border: $border-width dashed currentColor;
opacity: 0.4;
pointer-events: none;

.wp-block-navigation-item.wp-block-navigation-item,
.wp-block-navigation-placeholder__preview-search-icon {
opacity: 0.3;
}
// Inherit border radius from style variations.
border-radius: inherit;
}*/

&:not(.is-loading) {
// Don't show the preview boxes for an empty nav block,
// but be technically present to help size the empty state.
.wp-block-navigation.is-selected & {
display: flex;
opacity: 0;
width: 0;
overflow: hidden;
flex-wrap: nowrap;
flex: 0;
}
// Draw navigation placeholder indicators.
gap: inherit;

// Hide entirely when vertical.
.wp-block-navigation.is-selected .is-small &,
.wp-block-navigation.is-selected .is-medium & {
display: none;
}
li {
border: $border-width dashed currentColor;
opacity: 0.45;
height: 1em;
width: 4em;
border-radius: $radius-block-ui;
}
}

// Selected state.
.wp-block-navigation-placeholder__controls {
padding: $grid-unit-10;
padding: $grid-unit-05 $grid-unit-10;
border-radius: $radius-block-ui;
background-color: $white;
box-shadow: inset 0 0 0 $border-width $gray-900;
display: none;
flex-direction: row;
align-items: center;
display: none;
position: relative;
z-index: 1;

// Adjust padding for when shown horizontally.
.is-large & {
padding: $grid-unit-05 $grid-unit-10;
// Show when selected.
.wp-block-navigation.is-selected & {
display: flex;
}


// If an ancestor has a text-decoration property applied, it is inherited regardless of
// the specificity of a child element. Only pulling the child out of the flow fixes it.
// See also https://www.w3.org/TR/CSS21/text.html#propdef-text-decoration.
float: left;
width: 100%;

// Show when selected.
.wp-block-navigation.is-selected & {
display: flex;
}

// Show stacked for the vertical navigation, or small placeholders.
.is-small &,
.is-medium & {
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/post-featured-image/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
bottom: 0;
left: 0;
border: $border-width dashed currentColor;
opacity: 0.4;
opacity: 0.45;
pointer-events: none;

// Inherit border radius from style variations.
Expand Down Expand Up @@ -93,7 +93,7 @@
height: 100%;
stroke: currentColor;
stroke-dasharray: 3;
opacity: 0.4;
opacity: 0.45;
}

// Show default placeholder height when not resized.
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/site-logo/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
bottom: 0;
left: 0;
border: $border-width dashed currentColor;
opacity: 0.4;
opacity: 0.45;
pointer-events: none;

// Inherit border radius from style variations.
Expand Down Expand Up @@ -155,7 +155,7 @@
height: 100%;
stroke: currentColor;
stroke-dasharray: 3;
opacity: 0.4;
opacity: 0.45;
}
}

Expand Down