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

Remove Font style, weight, decoration, and transform presets #27555

Merged

Conversation

jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Dec 7, 2020

We added Font weight, style decoration, and transforms styles for now only in the navigation block. These styles contain presets.

The other presets we have are color, gradients, font sizes, and font families.

The colors and gradients presets can be semantic eg: Primary Color, and then the color can be changed.
The font size and font family presets can also be semantic e.g: "Huge", or "Monospace" and then the value itself is changed.

The style, weight, decoration, and transforms are not semantic and the variables/class names generated are the value itself. E.g: It does not make sense to change the font-weight 900 preset to have a value of 800.

We are generating this type of block markup:

<!-- wp:navigation {"orientation":"horizontal","style":{"typography":{"textTransform":"var:preset|text-transform|lowercase","textDecoration":"var:preset|text-decoration|strikethrough","fontStyle":"var:preset|font-style|italic","fontWeight":"var:preset|font-weight|100"}}} -->
<!-- wp:navigation-link {"label":"WordPress","url":"https://www.wordpress.org/"} /-->
<!-- /wp:navigation -->

Changing any of the preset variable value breaks the expectation given that the variable contains the value in the name.
So using variables is not bringing any advantage, I think it would be better to just use-values.
E.g:

<!-- wp:navigation {"orientation":"horizontal","style":{"typography":{"textTransform":"lowercase","textDecoration":"line-through","fontStyle":"italic","fontWeight":"100"}}} -->
<!-- wp:navigation-link {"label":"WordPress","url":"https://www.wordpress.org/"} /-->
<!-- /wp:navigation -->

Using values for style attributes is something always supported, and if needed we can always add presets in the future. Removing the presets once shipped into core is not something we can do.
Given that there are even explorations of typographic presets that cover multiple typographic attributes see: #27331, I think it is better to not add all these presets for now.

The other presets we had besides the font family were all of the old, and the font family core is not even shipping any default presets yet.

For now, only the navigation block was using these styles so I'm adding code that makes sure we are back-compatible with markup using the presets.

If these styles are added to more blocks (e.g: non-dynamic blocks) and we continue with presets if we need to remove these presets (e.g: to instead have general typographic presets as the mockups are proposing), being back-compatible will be much harder.

cc: @@aaronrobertshaw

How has this been tested?

I added a navigation block.
I verified I could change Font Appearance, Decoration, and transforms, and the styles worked as expected in the editor and the front end.
In the site editor, I added a navigation block. I went to the global styles, I opened the navigation block panel. I applied Font Appearance, Decoration, and transforms, and the styles worked as expected in the editor and the front end.
I created a post with the following markup of a navigation block relying on presets:

<!-- wp:navigation {"orientation":"horizontal","style":{"typography":{"textTransform":"var:preset|text-transform|lowercase","textDecoration":"var:preset|text-decoration|strikethrough","fontStyle":"var:preset|font-style|italic","fontWeight":"var:preset|font-weight|100"}}} -->
<!-- wp:navigation-link {"label":"WordPress","url":"https://www.wordpress.org/"} /-->
<!-- /wp:navigation -->

I verified the block looked as expected on the editor and the front end. I verified the block was automatically migrated to the markup without presets once opened on the editor.

@github-actions
Copy link

github-actions bot commented Dec 7, 2020

Size Change: -39 B (0%)

Total Size: 1.28 MB

Filename Size Change
build/block-editor/index.js 128 kB -127 B (0%)
build/block-library/index.js 150 kB +231 B (0%)
build/edit-site/index.js 24.3 kB -143 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.81 kB 0 B
build/api-fetch/index.js 3.42 kB 0 B
build/autop/index.js 2.83 kB 0 B
build/blob/index.js 665 B 0 B
build/block-directory/index.js 8.72 kB 0 B
build/block-directory/style-rtl.css 943 B 0 B
build/block-directory/style.css 942 B 0 B
build/block-editor/style-rtl.css 11.2 kB 0 B
build/block-editor/style.css 11.2 kB 0 B
build/block-library/blocks/archives/editor-rtl.css 120 B 0 B
build/block-library/blocks/archives/editor.css 119 B 0 B
build/block-library/blocks/audio/editor-rtl.css 118 B 0 B
build/block-library/blocks/audio/editor.css 118 B 0 B
build/block-library/blocks/audio/style-rtl.css 152 B 0 B
build/block-library/blocks/audio/style.css 152 B 0 B
build/block-library/blocks/block/editor-rtl.css 211 B 0 B
build/block-library/blocks/block/editor.css 211 B 0 B
build/block-library/blocks/button/editor-rtl.css 513 B 0 B
build/block-library/blocks/button/editor.css 513 B 0 B
build/block-library/blocks/button/style-rtl.css 488 B 0 B
build/block-library/blocks/button/style.css 488 B 0 B
build/block-library/blocks/buttons/editor-rtl.css 275 B 0 B
build/block-library/blocks/buttons/editor.css 275 B 0 B
build/block-library/blocks/buttons/style-rtl.css 346 B 0 B
build/block-library/blocks/buttons/style.css 346 B 0 B
build/block-library/blocks/calendar/style-rtl.css 249 B 0 B
build/block-library/blocks/calendar/style.css 249 B 0 B
build/block-library/blocks/categories/editor-rtl.css 135 B 0 B
build/block-library/blocks/categories/editor.css 135 B 0 B
build/block-library/blocks/categories/style-rtl.css 132 B 0 B
build/block-library/blocks/categories/style.css 132 B 0 B
build/block-library/blocks/code/style-rtl.css 152 B 0 B
build/block-library/blocks/code/style.css 152 B 0 B
build/block-library/blocks/columns/editor-rtl.css 239 B 0 B
build/block-library/blocks/columns/editor.css 239 B 0 B
build/block-library/blocks/columns/style-rtl.css 467 B 0 B
build/block-library/blocks/columns/style.css 466 B 0 B
build/block-library/blocks/cover/editor-rtl.css 440 B 0 B
build/block-library/blocks/cover/editor.css 438 B 0 B
build/block-library/blocks/cover/style-rtl.css 1.27 kB 0 B
build/block-library/blocks/cover/style.css 1.27 kB 0 B
build/block-library/blocks/embed/editor-rtl.css 529 B 0 B
build/block-library/blocks/embed/editor.css 529 B 0 B
build/block-library/blocks/embed/style-rtl.css 419 B 0 B
build/block-library/blocks/embed/style.css 419 B 0 B
build/block-library/blocks/file/editor-rtl.css 246 B 0 B
build/block-library/blocks/file/editor.css 245 B 0 B
build/block-library/blocks/file/style-rtl.css 288 B 0 B
build/block-library/blocks/file/style.css 289 B 0 B
build/block-library/blocks/freeform/editor-rtl.css 2.49 kB 0 B
build/block-library/blocks/freeform/editor.css 2.49 kB 0 B
build/block-library/blocks/gallery/editor-rtl.css 692 B 0 B
build/block-library/blocks/gallery/editor.css 693 B 0 B
build/block-library/blocks/gallery/style-rtl.css 1.11 kB 0 B
build/block-library/blocks/gallery/style.css 1.11 kB 0 B
build/block-library/blocks/group/editor-rtl.css 364 B 0 B
build/block-library/blocks/group/editor.css 364 B 0 B
build/block-library/blocks/group/style-rtl.css 117 B 0 B
build/block-library/blocks/group/style.css 117 B 0 B
build/block-library/blocks/heading/editor-rtl.css 174 B 0 B
build/block-library/blocks/heading/editor.css 174 B 0 B
build/block-library/blocks/heading/style-rtl.css 137 B 0 B
build/block-library/blocks/heading/style.css 137 B 0 B
build/block-library/blocks/html/editor-rtl.css 324 B 0 B
build/block-library/blocks/html/editor.css 325 B 0 B
build/block-library/blocks/image/editor-rtl.css 738 B 0 B
build/block-library/blocks/image/editor.css 737 B 0 B
build/block-library/blocks/image/style-rtl.css 510 B 0 B
build/block-library/blocks/image/style.css 511 B 0 B
build/block-library/blocks/latest-comments/editor-rtl.css 201 B 0 B
build/block-library/blocks/latest-comments/editor.css 200 B 0 B
build/block-library/blocks/latest-comments/style-rtl.css 315 B 0 B
build/block-library/blocks/latest-comments/style.css 315 B 0 B
build/block-library/blocks/latest-posts/editor-rtl.css 183 B 0 B
build/block-library/blocks/latest-posts/editor.css 183 B 0 B
build/block-library/blocks/latest-posts/style-rtl.css 568 B 0 B
build/block-library/blocks/latest-posts/style.css 567 B 0 B
build/block-library/blocks/list/editor-rtl.css 129 B 0 B
build/block-library/blocks/list/editor.css 129 B 0 B
build/block-library/blocks/list/style-rtl.css 127 B 0 B
build/block-library/blocks/list/style.css 127 B 0 B
build/block-library/blocks/media-text/editor-rtl.css 240 B 0 B
build/block-library/blocks/media-text/editor.css 240 B 0 B
build/block-library/blocks/media-text/style-rtl.css 579 B 0 B
build/block-library/blocks/media-text/style.css 577 B 0 B
build/block-library/blocks/more/editor-rtl.css 479 B 0 B
build/block-library/blocks/more/editor.css 479 B 0 B
build/block-library/blocks/navigation-link/editor-rtl.css 438 B 0 B
build/block-library/blocks/navigation-link/editor.css 440 B 0 B
build/block-library/blocks/navigation-link/style-rtl.css 747 B 0 B
build/block-library/blocks/navigation-link/style.css 745 B 0 B
build/block-library/blocks/navigation/editor-rtl.css 1.31 kB 0 B
build/block-library/blocks/navigation/editor.css 1.31 kB 0 B
build/block-library/blocks/navigation/style-rtl.css 222 B 0 B
build/block-library/blocks/navigation/style.css 222 B 0 B
build/block-library/blocks/nextpage/editor-rtl.css 440 B 0 B
build/block-library/blocks/nextpage/editor.css 440 B 0 B
build/block-library/blocks/paragraph/editor-rtl.css 161 B 0 B
build/block-library/blocks/paragraph/editor.css 161 B 0 B
build/block-library/blocks/paragraph/style-rtl.css 279 B 0 B
build/block-library/blocks/paragraph/style.css 279 B 0 B
build/block-library/blocks/post-author/editor-rtl.css 255 B 0 B
build/block-library/blocks/post-author/editor.css 255 B 0 B
build/block-library/blocks/post-author/style-rtl.css 229 B 0 B
build/block-library/blocks/post-author/style.css 230 B 0 B
build/block-library/blocks/post-content/editor-rtl.css 187 B 0 B
build/block-library/blocks/post-content/editor.css 187 B 0 B
build/block-library/blocks/post-excerpt/editor-rtl.css 134 B 0 B
build/block-library/blocks/post-excerpt/editor.css 134 B 0 B
build/block-library/blocks/post-featured-image/editor-rtl.css 387 B 0 B
build/block-library/blocks/post-featured-image/editor.css 386 B 0 B
build/block-library/blocks/post-featured-image/style-rtl.css 149 B 0 B
build/block-library/blocks/post-featured-image/style.css 149 B 0 B
build/block-library/blocks/pullquote/editor-rtl.css 231 B 0 B
build/block-library/blocks/pullquote/editor.css 231 B 0 B
build/block-library/blocks/pullquote/style-rtl.css 359 B 0 B
build/block-library/blocks/pullquote/style.css 359 B 0 B
build/block-library/blocks/query-loop/editor-rtl.css 142 B 0 B
build/block-library/blocks/query-loop/editor.css 141 B 0 B
build/block-library/blocks/query-loop/style-rtl.css 361 B 0 B
build/block-library/blocks/query-loop/style.css 363 B 0 B
build/block-library/blocks/query/editor-rtl.css 179 B 0 B
build/block-library/blocks/query/editor.css 179 B 0 B
build/block-library/blocks/quote/editor-rtl.css 121 B 0 B
build/block-library/blocks/quote/editor.css 121 B 0 B
build/block-library/blocks/quote/style-rtl.css 215 B 0 B
build/block-library/blocks/quote/style.css 214 B 0 B
build/block-library/blocks/rss/editor-rtl.css 270 B 0 B
build/block-library/blocks/rss/editor.css 270 B 0 B
build/block-library/blocks/rss/style-rtl.css 314 B 0 B
build/block-library/blocks/rss/style.css 313 B 0 B
build/block-library/blocks/search/editor-rtl.css 213 B 0 B
build/block-library/blocks/search/editor.css 213 B 0 B
build/block-library/blocks/search/style-rtl.css 384 B 0 B
build/block-library/blocks/search/style.css 386 B 0 B
build/block-library/blocks/separator/editor-rtl.css 151 B 0 B
build/block-library/blocks/separator/editor.css 151 B 0 B
build/block-library/blocks/separator/style-rtl.css 281 B 0 B
build/block-library/blocks/separator/style.css 281 B 0 B
build/block-library/blocks/shortcode/editor-rtl.css 547 B 0 B
build/block-library/blocks/shortcode/editor.css 547 B 0 B
build/block-library/blocks/site-logo/editor-rtl.css 251 B 0 B
build/block-library/blocks/site-logo/editor.css 251 B 0 B
build/block-library/blocks/site-logo/style-rtl.css 166 B 0 B
build/block-library/blocks/site-logo/style.css 166 B 0 B
build/block-library/blocks/social-link/editor-rtl.css 211 B 0 B
build/block-library/blocks/social-link/editor.css 211 B 0 B
build/block-library/blocks/social-links/editor-rtl.css 749 B 0 B
build/block-library/blocks/social-links/editor.css 749 B 0 B
build/block-library/blocks/social-links/style-rtl.css 1.37 kB 0 B
build/block-library/blocks/social-links/style.css 1.37 kB 0 B
build/block-library/blocks/spacer/editor-rtl.css 321 B 0 B
build/block-library/blocks/spacer/editor.css 321 B 0 B
build/block-library/blocks/spacer/style-rtl.css 107 B 0 B
build/block-library/blocks/spacer/style.css 107 B 0 B
build/block-library/blocks/subhead/editor-rtl.css 148 B 0 B
build/block-library/blocks/subhead/editor.css 148 B 0 B
build/block-library/blocks/subhead/style-rtl.css 134 B 0 B
build/block-library/blocks/subhead/style.css 134 B 0 B
build/block-library/blocks/table/editor-rtl.css 530 B 0 B
build/block-library/blocks/table/editor.css 530 B 0 B
build/block-library/blocks/table/style-rtl.css 433 B 0 B
build/block-library/blocks/table/style.css 433 B 0 B
build/block-library/blocks/tag-cloud/editor-rtl.css 162 B 0 B
build/block-library/blocks/tag-cloud/editor.css 162 B 0 B
build/block-library/blocks/tag-cloud/style-rtl.css 145 B 0 B
build/block-library/blocks/tag-cloud/style.css 145 B 0 B
build/block-library/blocks/template-part/editor-rtl.css 644 B 0 B
build/block-library/blocks/template-part/editor.css 645 B 0 B
build/block-library/blocks/text-columns/editor-rtl.css 146 B 0 B
build/block-library/blocks/text-columns/editor.css 146 B 0 B
build/block-library/blocks/text-columns/style-rtl.css 209 B 0 B
build/block-library/blocks/text-columns/style.css 209 B 0 B
build/block-library/blocks/verse/editor-rtl.css 153 B 0 B
build/block-library/blocks/verse/editor.css 153 B 0 B
build/block-library/blocks/verse/style-rtl.css 117 B 0 B
build/block-library/blocks/verse/style.css 117 B 0 B
build/block-library/blocks/video/editor-rtl.css 547 B 0 B
build/block-library/blocks/video/editor.css 548 B 0 B
build/block-library/blocks/video/style-rtl.css 241 B 0 B
build/block-library/blocks/video/style.css 241 B 0 B
build/block-library/common-rtl.css 940 B 0 B
build/block-library/common.css 937 B 0 B
build/block-library/editor-rtl.css 9.07 kB 0 B
build/block-library/editor.css 9.07 kB 0 B
build/block-library/style-rtl.css 8.34 kB 0 B
build/block-library/style.css 8.34 kB 0 B
build/block-library/theme-rtl.css 789 B 0 B
build/block-library/theme.css 790 B 0 B
build/block-serialization-default-parser/index.js 1.88 kB 0 B
build/block-serialization-spec-parser/index.js 3.06 kB 0 B
build/blocks/index.js 48.1 kB 0 B
build/components/index.js 171 kB 0 B
build/components/style-rtl.css 15.4 kB 0 B
build/components/style.css 15.4 kB 0 B
build/compose/index.js 11 kB 0 B
build/core-data/index.js 15.4 kB 0 B
build/data-controls/index.js 827 B 0 B
build/data/index.js 8.98 kB 0 B
build/date/index.js 31.8 kB 0 B
build/deprecated/index.js 769 B 0 B
build/dom-ready/index.js 571 B 0 B
build/dom/index.js 4.95 kB 0 B
build/edit-navigation/index.js 11.1 kB 0 B
build/edit-navigation/style-rtl.css 881 B 0 B
build/edit-navigation/style.css 885 B 0 B
build/edit-post/index.js 306 kB 0 B
build/edit-post/style-rtl.css 6.47 kB 0 B
build/edit-post/style.css 6.45 kB 0 B
build/edit-site/style-rtl.css 3.91 kB 0 B
build/edit-site/style.css 3.91 kB 0 B
build/edit-widgets/index.js 26.3 kB 0 B
build/edit-widgets/style-rtl.css 3.1 kB 0 B
build/edit-widgets/style.css 3.1 kB 0 B
build/editor/editor-styles-rtl.css 476 B 0 B
build/editor/editor-styles.css 478 B 0 B
build/editor/index.js 43.3 kB 0 B
build/editor/style-rtl.css 3.84 kB 0 B
build/editor/style.css 3.84 kB 0 B
build/element/index.js 4.63 kB 0 B
build/escape-html/index.js 735 B 0 B
build/format-library/index.js 6.74 kB 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/hooks/index.js 2.27 kB 0 B
build/html-entities/index.js 623 B 0 B
build/i18n/index.js 3.57 kB 0 B
build/is-shallow-equal/index.js 697 B 0 B
build/keyboard-shortcuts/index.js 2.54 kB 0 B
build/keycodes/index.js 1.94 kB 0 B
build/list-reusable-blocks/index.js 3.1 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/media-utils/index.js 5.32 kB 0 B
build/notices/index.js 1.85 kB 0 B
build/nux/index.js 3.42 kB 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/plugins/index.js 2.54 kB 0 B
build/primitives/index.js 1.43 kB 0 B
build/priority-queue/index.js 790 B 0 B
build/redux-routine/index.js 2.84 kB 0 B
build/reusable-blocks/index.js 2.92 kB 0 B
build/rich-text/index.js 13.4 kB 0 B
build/server-side-render/index.js 2.77 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.27 kB 0 B
build/url/index.js 2.84 kB 0 B
build/viewport/index.js 1.86 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.22 kB 0 B

compressed-size-action

@jorgefilipecosta jorgefilipecosta force-pushed the remove/style-weight-decoration-and-transform-presets branch 2 times, most recently from 71362e2 to c5ef934 Compare December 7, 2020 17:48
Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

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

Great work @jorgefilipecosta, thank you for all the effort! 👍

Functionally everything works well for me. The only minor issue I ran into was the application of ariaLabel on the buttons. That throws an error in the console expecting aria-label.

The steps I took to test were:

  1. Loaded an old post in the editor that had a navigation block relying on the presets
  2. Checked out this PR
  3. Reloaded the post in the editor and confirmed it appeared correctly
  4. Tested all the controls for decoration, transform and weight worked and updated the block as expected.
  5. Confirmed block looked correct on the frontend
  6. Tested the deprecation again via pasting the supplied code into the code editor view (this was when I noticed the console error regarding the aria label)
  7. Added a new navigation block and repeated tests using that.
  8. Ran the full-content.test.js - all the deprecation fixtures were green

In terms of the overall reasoning and approach, it makes sense to me but it would be good to have a second set of eyes on this to approve.

@oandregal
Copy link
Member

👋 @jorgefilipecosta This change looks fine to me, given that the values for these properties are a closed set defined by the standard ― they're not an open set of values that would be variable by theme.

I've tested that this still works as expected, and that blocks created before this change also work.

One thing I'd like your thoughts on is customFontWeights and customFontStyles. At the moment, when any of them is enabled the control is shown and the list contains all the weights and the styles. So, disabling only one of them via theme.json does nothing. I wonder if we should make it behave in one of these ways instead:

  • have a unique customFontAppearance setting
  • be able to disable customFontWeights and customFontStyles individually: the control is not shown if both are false, the list of values is filtered when only one of them is shown

We also need to keep the documentation for theme.json updated.

},
];

const FONT_WEIGHTS = [
Copy link
Member

Choose a reason for hiding this comment

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

I know this wasn't introduced in this PR but wanted to confirm anyway.

I've cross-checked the names of the numbered values in the standard with what we have here, and this is what I saw:

Value Name in the standard Our current name
100 Thin Ultralight
200 Extra Light (Ultra Light) Thin
300 Light Light
400 Normal Regular
500 Medium Medium
600 Semi Bold (Demi Bold) Semibold
700 Bold Bold
800 Extra Bold (Ultra Bold) Heavy
900 Black (Heavy) Black

Wanted to check if this is fine or whether we want to align with the standard. These being values that core will provide, I'd lean to align their names with the standard. However, I understand that there may be a different "industry standard", so would like to hear what other people think of this. cc @kjellr @jasmussen

Copy link
Contributor

Choose a reason for hiding this comment

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

Their names should definitely be industry standard, except for "Normal", which should be "Regular", or it will confuse the interface when selected.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, we should be fine with the standard you noted here.

@jorgefilipecosta jorgefilipecosta force-pushed the remove/style-weight-decoration-and-transform-presets branch 2 times, most recently from 24d58b0 to 7cc6bd2 Compare December 11, 2020 17:23
@jorgefilipecosta jorgefilipecosta force-pushed the remove/style-weight-decoration-and-transform-presets branch from 7cc6bd2 to aa0f1f1 Compare December 11, 2020 17:25
@gziolo gziolo added the Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json label Dec 12, 2020
…ndex.js

Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> (+4 squashed commits)
Squashed commits:
[84854a6ef8] Update packages/block-editor/src/components/text-transform-control/index.js

Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com>
[c5ef934] Add deprecation fixtures
[a57bcb8] Backcompatibility
[8c5cc3e] Remove Font style, weight, decoration, and transform presets
@jorgefilipecosta jorgefilipecosta force-pushed the remove/style-weight-decoration-and-transform-presets branch from aa0f1f1 to 8a32163 Compare December 14, 2020 12:21
@jorgefilipecosta
Copy link
Member Author

Thank you for the reviews all the feedback related to this PR was applied :)

@jorgefilipecosta jorgefilipecosta merged commit d8e3d82 into master Dec 14, 2020
@jorgefilipecosta jorgefilipecosta deleted the remove/style-weight-decoration-and-transform-presets branch December 14, 2020 13:02
@github-actions github-actions bot added this to the Gutenberg 9.6 milestone Dec 14, 2020
@oandregal
Copy link
Member

We've missed this proposal #27555 (comment) so I've prepared a PR to address that #27718

@ErikBernskiold
Copy link

I found this while trying to figure out why our experimental theme project suddenly had no font weights anymore. It took some searching...

This has me curious to the reasoning behind removing Font Weights specifically from theme.json. Hence my comment here. :)

While I agree that it makes little sense overriding a variable for example saying that "font weight 600 is now 500", that's not all that the theme.json spec provided:

What has me, personally, really excited about theme.json is being able to more strongly customize Gutenberg and remove things that don't make sense from a theme point-of-view in the editor. Especially in terms of defaults.

Typically, we use a very limited set of font weights in a project. Both because font weights vary depending on the font used, and because we want to limit users choices for font weights. The previous implementation offered us the ability of creating an allow-list of weights.

Also, these limited weights mean we typically map them to a more common wording depending on the font family - font weight combination and appearance. For example, bold is strictly defined as 700, but for a given font, it makes more sense for the wording "bold" to be defined as "800". It's "bold" for the user, even though it technically isn't.

If you think about a variable as --font-weight--600, it doesn't make sense to ever change. If you think of it as --font-weight--medium, it does.

I guess the specific points I'm trying to make are:

  • While theme.json gives us a chance to customize options available to the user in the editor, this change directly works against this. (Unless I'm missing another way to globally set this that isn't the documentation?)
  • It's crucial to remember that these kinds of changes, even within experimental features, need to be communicated well, including documentation update.

@gaambo
Copy link
Contributor

gaambo commented Jun 29, 2021

The server-side migration of these attributes via render_block_data added here in d8e3d82 won't work if the navigation block is nested inside any other block (like a group etc), because render_block_data is only run for top-level blocks - see #25900 and the trac ticket

@oandregal
Copy link
Member

Follow-up at #35881 to remove these from the theme-i18n.json file as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants