Skip to content

Commit

Permalink
Site Title, Post Title: Fix typography for blocks with a children (#…
Browse files Browse the repository at this point in the history
…64911)

* Apply styles for element + `a` child when present

* Inherit styles from parent element when present

* Add missing `-font-family` attribute selector
  • Loading branch information
rafaelgallani authored Sep 5, 2024
1 parent 2fe092e commit bc96d19
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
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) {
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"
}
}
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

0 comments on commit bc96d19

Please sign in to comment.