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

Post Author Biography: Add Border Support #64615

Merged
merged 1 commit into from
Aug 21, 2024
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
15 changes: 14 additions & 1 deletion packages/block-library/src/post-author-biography/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@
},
"interactivity": {
"clientNavigation": true
},
"__experimentalBorder": {
"radius": true,
"color": true,
"width": true,
"style": true,
"__experimentalDefaultControls": {
"radius": true,
"color": true,
"width": true,
"style": true
}
}
}
},
"style": "wp-block-post-author-biography"
}
4 changes: 4 additions & 0 deletions packages/block-library/src/post-author-biography/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.wp-block-post-author-biography {
// This block has customizable padding, border-box makes that more predictable.
box-sizing: border-box;
}
Comment on lines +1 to +4
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be a good follow-up to see if we can make a simple generic selector to set border-box sizing on all blocks.

I don't know if we can get away with it but it seems excessive that we have to add a separate rule for almost every block, bloating the CSS in each request.

Maybe it's worth trying something like:

// Or .wp-block-* ?
.wp-block {
    box-sizing: border-box;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

@aaronrobertshaw

Can we use css like this for globally?

[class*="wp-block-"][style*="border"] {
   box-sizing: border-box;
}

Copy link
Member

Choose a reason for hiding this comment

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

That looks promising. The catch is that we'd have to make sure there are wp-block-* classnames on all elements that receive the inline styles.

Some blocks skip serialization and apply styles on inner elements.

I pulled up the obvious example of wp-block-search, whose inline border styles are applied conditionally on the input and button. Fortunately, these elements have wp-block-* classes, so it'd work.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed 👍

We need to review all blocks and verify that box-sizing: border-box is correctly applied (if we use box-sizing:border-box globally)
especially since some blocks have borders on inner elements.

Can I create separate PR for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't mean to derail the PR, that's why I suggested it as a good follow-up given the obvious edge cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

Understood.
I appreciate your suggestion. I agree that it’s important to review and ensure box-sizing: border-box is correctly applied across all blocks, especially given the edge cases with borders on inner elements. I will proceed with creating a separate PR to address this follow-up. Thank you for highlighting it!

1 change: 1 addition & 0 deletions packages/block-library/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
@import "./page-list/style.scss";
@import "./paragraph/style.scss";
@import "./post-author/style.scss";
@import "./post-author-biography/style.scss";
@import "./post-comments-form/style.scss";
@import "./post-content/style.scss";
@import "./post-date/style.scss";
Expand Down
Loading