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

WordPress 5.9 overrides theme font sizes #40

Closed
luminuu opened this issue Jan 27, 2022 · 7 comments
Closed

WordPress 5.9 overrides theme font sizes #40

luminuu opened this issue Jan 27, 2022 · 7 comments

Comments

@luminuu
Copy link

luminuu commented Jan 27, 2022

Hi, I'm not sure if you noticed this already: in WP 5.9, changes to the default variables for e. g. defined font sizes were made. This happens if a theme does not provide a theme.json file.

grafik

In my example I use the font size "Large" which is set by the theme to 20px. However with 5.9, these pre-defined classes get overwritten by the new default styles, which sets the font size to 36px. The other paragraphs in the screenshot are set to 21px.

Here's the corresponding issue at the Gutenberg repo: WordPress/gutenberg#38252

And the mentioned changes in the dev note: https://make.wordpress.org/core/2022/01/08/updates-for-settings-styles-and-theme-json/#changes-to-the-global-stylesheet

@mapsteps
Copy link
Owner

mapsteps commented Jan 27, 2022

Hey @luminuu,

I noticed the font-size selection is gone entirely. Instead I can choose a size between 1-4 where none of them indicate a size.
That's a bit strange. So adding additional CSS to fix this would be for backwards-compatibility only if I understand this correctly?

Thanks for reporting! :)

grafik

@luminuu
Copy link
Author

luminuu commented Jan 27, 2022

🤔 Now I'm a bit confused. The 1, 2, 3, 4 font size selection is something I see in Twenty Twenty-Two, but when I activate Page Builder Framework, it looks like this on a paragraph block:

grafik

Which are defined here in PBF: https://github.com/MapSteps/Page-Builder-Framework/blob/2327e25502f3b592efb7b682d91c5041ba7e1856/inc/integration/gutenberg/gutenberg.php#L33

Tested on a fresh 5.9 install with PBF activated, no child theme. Screenshot in my first comment was from a project with a child theme but it's the same there. Also no Gutenberg plugin active too on both sites.

@mapsteps
Copy link
Owner

My bad, I had 2022 installed, lol. I'm on it & will report back asap :)

@mapsteps
Copy link
Owner

mapsteps commented Jan 27, 2022

I wonder what the proper way would be to tackle this. Sure, I could add some custom CSS to just override what's happening here. I tried prefixing the CSS with the p but that obviously won't override the default added by WordPress since it's using !important for some reason. Geez.

I'm wondering if overriding the CSS variables is a good idea or not.

grafik

@mapsteps
Copy link
Owner

@mapsteps
Copy link
Owner

Okay so I could just add a theme.json file like this:

{
	"settings": {
		"typography": {
			"fontSizes": [{
				"name": "Tiny",
				"size": "12px",
				"slug": "tiny"
			}, {
				"name": "Small",
				"size": "14px",
				"slug": "small"
			}, {
				"name": "Regular",
				"size": "1rem",
				"slug": "regular"
			}, {
				"name": "Large",
				"size": "20px",
				"slug": "large"
			}, {
				"name": "Larger",
				"size": "32px",
				"slug": "larger"
			}, {
				"name": "Extra Large",
				"size": "44px",
				"slug": "extra"
			}]
		}
	}
}

The only downside would be that we're losing the following logic that was quite handy because it inherited the font size defined in the customizer setting:

grafik

@mapsteps
Copy link
Owner

mapsteps commented Jan 27, 2022

Fixed it by simply adopting & configuring the theme.json for typography :)

a026b9b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants