[wp-trac] [WordPress Trac] #58542: Theme.json / Restricting general settings like font sizes on blocks generates a lot of duplication

WordPress Trac noreply at wordpress.org
Thu Jun 15 10:21:56 UTC 2023


#58542: Theme.json / Restricting general settings like font sizes on blocks
generates a lot of duplication
-----------------------------+-----------------------------
 Reporter:  jdmweb           |      Owner:  (none)
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Themes           |    Version:
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 Hello.

 In my theme.json file, let's say I declare 20 font sizes in my settings /
 typography / fontSizes section. As per the official schema, it is an array
 of objects with a size, slug, and name property. I've seen a project
 declaring 20 of those.

 Then I would like to restrict core/paragraphs to use only 5 of them, and
 core/headings to use only three.

 With the current theme.json implementation, I need to declare a settings /
 blocks / "core/paragraph" object, then copy / paste the 5 font sizes
 objects I allow to my user to use with paragraphs.

 The current problems I face are as follows :
 - It generates a lot of code duplication
 - The two declarations are not linked together, which can be used as an
 advantage, but also seen as an inconvenient, especially when adjusting
 main settings, which would then not be updated in blocks.

 Proposal :
 - Add a new attribute to the blocks settings, like "restrict", "include"
 or "exclude" which would be an array of slugs coming from the main
 settings declaration.
 - It could work with color palettes, fontSizes, spaces, or any array that
 supports slugs.
 - This way when declaring block specific settings, we could have less
 duplication, and a synchronization with main settings.

 Example:
 {{{#!json
 {
     "blocks": {
         "core/button": {
             "typography": {
                 "fontSizesInclude": ["sizeSlugA","sizeSlugB"]
             },
             "color": {
                 "paletteExclude": ["colorSlugA","colorSlugB"]
             }
         }
     }
 }
 }}}

 Thank you for your work and your time reading me.

 Best Regards.

 Jeremy.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58542>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list