Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix typo
  • Loading branch information
aaronrobertshaw committed Feb 7, 2023
commit 47bfcc077f4800921d3cdc3f9606e1513f1386b5
2 changes: 1 addition & 1 deletion packages/block-library/src/button/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ div[data-type="core/button"] {

.editor-styles-wrapper .wp-block-button .wp-block-button__link {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not a huge fan of having to add this much CSS to provide defaults that can overcome styles in core. If anyone has any ideas on a better approach, I'd be happy to evolve this one.

Without these tweaks the user has to set multiple fields before a border shows up. Even now the default border color is currentColor so when the background is white and the button text is white, the border isn't really visible.

Copy link
Contributor

@glendaviesnz glendaviesnz Feb 7, 2023

Choose a reason for hiding this comment

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

It doesn't seem like we need to replicate this in editor.scss and styles.scss - if I removed this section from here the CSS from styles.scss seemed to be applied in the editor and the frontend? I did a fresh build and a hard reload to make sure it wasn't just a case of the editor styles being cached.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do need to add this CSS to overcome core's theme.json button element styles which reset border-width to 0.

The theme.json styles get the .editor-styles-wrapper class prefixed to their selectors in the editor. As a result, those styles override the styles in the frontend style.scss.

Without these styles, a user needs to adjust the border width before they can see any border.

To witness this behaviour:

  1. Delete or disable the styles here in the editor.scss file
  2. Make sure you don't have any core/button styles in your theme.json
  3. Edit a post and add a button
  4. Select the button and select only a border color
  5. Note that there is no visible border due to the core theme.json border width reset for button elements.
Screen.Recording.2023-02-07.at.3.13.43.pm.mp4

Copy link
Contributor

@glendaviesnz glendaviesnz Feb 7, 2023

Choose a reason for hiding this comment

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

Thanks for the extra detail - I was adding the border width and then the color so wasn't picking this up - if I had read back through the old comments I would have picked all that up - sorry for wasting your time here!

I have modified the comment to specify this detail like the one in style.scss does.

// The following styles smooth out the experience editing borders for individual
// buttons. They override the `button-width: 0;` applied by core's theme.json
// buttons. They override the `border-width: 0;` applied by core's theme.json
// via the Elements API button.
&:where(.has-border-color) {
border-width: initial;
Expand Down