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

Site Title, Post Title: Fix typography for blocks with a children #64911

Merged
merged 3 commits into from
Sep 5, 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
5 changes: 4 additions & 1 deletion packages/block-library/src/post-title/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,8 @@
}
}
},
"style": "wp-block-post-title"
"style": "wp-block-post-title",
"selectors": {
"typography": ".wp-block-post-title, .wp-block-post-title > a"
}
}
24 changes: 24 additions & 0 deletions packages/block-library/src/post-title/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@
// This block has customizable padding, border-box makes that more predictable.
box-sizing: border-box;

&[style*="font-weight"] :where(a) {
Copy link
Member

Choose a reason for hiding this comment

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

If we add more styling options we need to create another selector following the same logic. Plus these selectors don't look ideal and we are sending many bytes over the wise but it seems a fair trade-off.

font-weight: inherit;
}
&[class*="-font-family"] :where(a),
&[style*="font-family"] :where(a) {
font-family: inherit;
}
&[class*="-font-size"] :where(a),
&[style*="font-size"] :where(a) {
font-size: inherit;
}
&[style*="line-height"] :where(a) {
line-height: inherit;
}
&[style*="font-style"] :where(a) {
font-style: inherit;
}
&[style*="letter-spacing"] :where(a) {
letter-spacing: inherit;
}
&[style*="text-decoration"] :where(a) {
text-decoration: inherit;
}

a {
display: inline-block;
}
Expand Down
5 changes: 4 additions & 1 deletion packages/block-library/src/site-title/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,8 @@
}
},
"editorStyle": "wp-block-site-title-editor",
"style": "wp-block-site-title"
"style": "wp-block-site-title",
"selectors": {
"typography": ".wp-block-site-title > span, .wp-block-site-title > a"
Copy link
Contributor

Choose a reason for hiding this comment

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

This introduces a regression where the editor and frontend apply different styles. The Site Title block doesn't render an inner span on the frontend.

As proposed over on #65169, I have some ideas to address this and the other issue flagged in #64911 (comment).

I'll get a draft PR up soon.

}
}
24 changes: 24 additions & 0 deletions packages/block-library/src/site-title/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@
// This block has customizable padding, border-box makes that more predictable.
box-sizing: border-box;

&[style*="font-weight"] :where(a) {
font-weight: inherit;
}
&[class*="-font-family"] :where(a),
&[style*="font-family"] :where(a) {
font-family: inherit;
}
&[class*="-font-size"] :where(a),
&[style*="font-size"] :where(a) {
font-size: inherit;
}
&[style*="line-height"] :where(a) {
line-height: inherit;
}
&[style*="font-style"] :where(a) {
font-style: inherit;
}
&[style*="letter-spacing"] :where(a) {
letter-spacing: inherit;
}
&[style*="text-decoration"] :where(a) {
text-decoration: inherit;
}

:where(a) {
color: inherit;
}
Expand Down
Loading