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

Embed: Fix failure placeholder alignment/sizing #19673

Merged
merged 3 commits into from
Jan 21, 2020
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
14 changes: 8 additions & 6 deletions packages/block-library/src/embed/embed-placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@ const EmbedPlaceholder = ( props ) => {
>
{ _x( 'Embed', 'button label' ) }
</Button>
{ cannotEmbed &&
<p className="components-placeholder__error">
{ __( 'Sorry, this content could not be embedded.' ) }<br />
<Button isSecondary onClick={ tryAgain }>{ _x( 'Try again', 'button label' ) }</Button> <Button isSecondary onClick={ fallback }>{ _x( 'Convert to link', 'button label' ) }</Button>
</p>
}
</form>
<div className="components-placeholder__learn-more">
<ExternalLink href={ __( 'https://wordpress.org/support/article/embeds/' ) }>
{ __( 'Learn more about embeds' ) }
</ExternalLink>
</div>
{ cannotEmbed &&
<div className="components-placeholder__error">
<div className="components-placeholder__instructions">
Comment on lines +37 to +39
Copy link
Member

@aduth aduth Jan 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the precedent existed previously, but this change contributed further to it:

components-placeholder__instructions is not a valid class name to use in this context.

A component's class name should never be used outside its own folder (with rare exceptions such as _z-index.scss). If you need to inherit styles of another component in your own components, you should render an instance of that other component. At worst, you should duplicate the styles within your own component's stylesheet. This is intended to improve maintainability by isolating shared components as a reusable interface, reducing the surface area of similar UI elements by adapting a limited set of common components to support a varied set of use-cases.

https://github.com/WordPress/gutenberg/blob/master/docs/contributors/coding-guidelines.md#naming

This feels like something where we should be taking advantage of a prop offered by the Placeholder component, and if those props are insufficient, then we need to address this at Placeholder, and not reuse these classes in an ad hoc manner.

{ __( 'Sorry, this content could not be embedded.' ) }
</div>
<Button isSecondary onClick={ tryAgain }>{ _x( 'Try again', 'button label' ) }</Button> <Button isSecondary onClick={ fallback }>{ _x( 'Convert to link', 'button label' ) }</Button>
</div>
}
</Placeholder>
);
};
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/table/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
}
}

.components-base-control__field {
margin-bottom: 0;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes the bottom margins of the input fields, allowing the Inputs + Button to align correctly.

}

.wp-block-table__placeholder-button {
margin-top: auto;
margin-right: auto;
Expand Down
6 changes: 6 additions & 0 deletions packages/components/src/placeholder/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
}
}

.components-placeholder__error,
.components-placeholder__instructions,
.components-placeholder__label,
.components-placeholder__fieldset {
Expand Down Expand Up @@ -74,6 +75,11 @@
margin-bottom: 1em;
}

.components-placeholder__error {
margin-top: 1em;
width: 100%;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required to render underneath the help text, considering the display: flex based wrapper.

}

.components-placeholder__preview img {
margin: 3%;
width: 50%;
Expand Down