Skip to content

Block Styles Breakdown #20331

Closed
Closed

Description

@mtias

This is an overview of the concrete tasks needed to proceed with the project scope of #9534 (see also #19611). It operates on three levels, or style origins: local blocks, theme defaults, and global modifications.

Screenshot 2020-03-11 at 19 59 19

First 🌊

Goal: prototype a system that connects the three style origins and demonstrates how it works for a few top-level blocks.

Infrastructure

Ensure at all times the editor reflects the front faithfully.

Interface

These are the different tools that interact with appearance values.

Second 🌊

Goal: develop all necessary sub-systems.

Infrastructure

Interface

Third 🌊

Goal: merge the non UI parts of global styles in WordPress 5.8.

block.json / block supports:

theme.json:

Internationalization:

Docs:

Extensibility:

Bug fixes

Fourth 🌊

Follow-ups to WordPress 5.8 release.

Block supports:

theme.json:

Stylesheet:

Performance:

Interface

Backlog

The things listed here don't need to be necessarily implemented, but should be considered.

block.json: nothing planned

theme.json

Expand to more style properties:

Extensibility:

Interface:

Iterate on design tools:

Misc:

Activity

  1. added
    Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json
    on Feb 20, 2020
  2. added
    [Feature] Design ToolsTools that impact the appearance of blocks both to expand the number of tools and improve the experi
    on Mar 9, 2020
  3. jorgefilipecosta commented on May 7, 2020

    @jorgefilipecosta
    Member

    Sharing some thoughts on the current status for infrastructure/ my interpretation of some infrastructure tasks:

    Create the concept of implicit attributes for appearance pairing

    It seems the style attribute we are using for colors introduced in #21021 addressed this part we are also using it for lineHeight with success and without the need to register new attributes.

    Hook appearance variables to the editor rendering.

    It seems this is about making sure styles are regenerated when the structure that holds global style changes. For example, #20530 accomplishes this by compiling the styles on GlobalStylesProvider.

    Look at style variations as packages of style attribute sets.

    We can achieve this by adding a styles structure to theme.json:

    {
        ...
        styles: {
            ‘core/paragraph’: {
                ‘huge’: {
                    fontSize: 14,
                }
            }
        }
    }
    

    We may also achieve the "Custom User Styles" part of #7551 by just allowing the user to save the current block style attributes as a customization of the theme.json structure.

  4. added
    [Type] OverviewComprehensive, high level view of an area of focus often with multiple tracking issues
    on May 26, 2020
  5. kjellr commented on Oct 9, 2020

    @kjellr
    Contributor

    At this week's Block-based Themes meeting, the group discussed some of the upcoming design tools in this ticket, and whether they should be opt-in or opt-out for themes. Here are our notes:

    • If a theme has theme.json, it seems ok to have all new design tools be opt-out.
    • Otherwise, if the feature is expected to “just work” with themes without breaking something, it’s probably ok to enable it by default. Otherwise, they should be opt-in.
    • If these are “editor” features, and not something the theme needs to explicitly build in support for, then it may be confusing to use add_theme_support() for them.
    • We should keep in mind that if users move between block-based themes and non-block-based themes, it will likely be confusing for seemingly unrelated features to turn on and off.

    More details in the meeting notes.

  6. jorgefilipecosta commented on Nov 23, 2020

    @jorgefilipecosta
    Member

    With the first beta version of WordPress 5.7 not very far away I'm sharing this summary after some discussion with @nosolosw specifying what are the tasks we think should be part of v1 and/or that may be part of v1.

    What we will do next?

    These are the tasks we will work on and plan to have ready soon. Are the most prioritary tasks.

    What we can do next?

    Tasks we can work on, it would be nice to have but are not a must and are lower priority may or may not be part of v1.

    • Create a JSON schema specification for theme.json. Developers can use the schema to validate if their theme.json files are correct and easily locate errors. Improving the developer experience of using theme.json. We can use the scheme in the core to remove invalid paths etc. Add type validation and/or theme.json schema #26955

    Things for the future

    Not part of a first version. Things we may consider in the future.

    Related tasks but that initially will not use theme.json/global styles mechanisms.

    What decisions do we need to do?

    • Are the APIs we offer themes enough to have control about which UI components are surfaced to the user in the global styles sidebar? OR should we expand our API’s? Should our API's allow to specify that the user can change a given style property like line-height at the global styles level, but not at the block level (block inspector).
    • If a block does not support something like line-height, but the theme specifies a line-height for that block. Should we output a line-height style anyway?
    • What are the controls that are available per block? Which blocks by default have font size available? Which have text color? Which have line-height?

    What’s next on the UI/UX side?

    The first beta of WordPress 5.7 goes out in January, so we need to have a v1 for the UI ready sometime before the first beta.

    • Typography tools are going to be g2 based (or at least some parts like font size control). So we need to merge (at least parts of) g2 in order to have the typography tools ready.

    • Extensibility mechanism for 3rd party

    • It seems the global styles although functional does not provide a good experience, panels inside panels, a gigantic list of panels (one per each block). What is the plan for the other parts of UI? What are the things we should improve on the UI of these other parts to make them ready for the first version?

      • Navigation between all the different blocks that we can apply global styles to and between the global context.

      • Color options (text, background, and link).

      • Color palette editor.

    cc: @nosolosw, @shaunandrews, @jasmussen, @ItsJonQ, @mcsf, @youknowriad

  7. youknowriad commented on Nov 24, 2020

    @youknowriad
    Contributor

    Thanks for the summary @jorgefilipecosta here's the questions/feedback I have:

    (In progress) Improve the way client-side metadata is structured, make sure it matches server metadata shape, and try to avoid metadata duplication.

    Shooting for consistency between client and server consistency is not always good thing. It's better to think of client packages as their own unit in isolation. Sometimes the config that the server has does make sense in the context of a package, sometimes it doesn't. Semantics > consistency. Just something to keep in mind while designing the APIs of the client.

    Look into the alignment issues #26633

    this is also something I've been thinking of, It's not clear whether I'll have the time to look deeper into it but keep me on the loop. My idea is to first make InnerBlocks provide an API to define the alignments and output the CSS for it without relying on themes to provide that CSS. Once we have that, adding support for this into theme.json is easy.

    Responsive styles/media queries (styles depending on window size).

    Same here, I wonder if we should start at the block level IMO and see what makes sense as a "style" attribute, and what make sense as UI and expand to theme.json

    Are the APIs we offer themes enough to have control about which UI components are surfaced to the user in the global styles sidebar? OR should we expand our API’s? Should our API's allow to specify that the user can change a given style property like line-height at the global styles level, but not at the block level (block inspector).

    I still feel this is the missing piece in terms of features.

    • How do I enable colors everywhere but only allow changing the main one in the Global styles Ui
    • How do I disable line-height choices in all blocks but allow it at the global level.

    I see the current "global" config as a way to define a config for all blocks but not as a way to define what UI is available in the global styles panel.

  8. aristath commented on Nov 24, 2020

    @aristath
    Member

    Thank you @jorgefilipecosta, that comment offers a great overview and sums up pretty nicely where we're going. ❤️
    Are all items in separate issues already? The comment will be lost in all the noise, so should we create issues for any items on that list (or maybe just tag existing issues properly so they're easier to find)?

  9. francescamarano commented on Nov 24, 2020

    @francescamarano

    I second @aristath comment. It would also be great to see them in the FSE project so it's easy to track things visually. And make liberal use of tags, so people can work on priorities. Thanks!

  10. jorgefilipecosta commented on Nov 24, 2020

    @jorgefilipecosta
    Member

    Hi @youknowriad,
    Regarding alignment issues and responsive styles, I agree with you. These things should be solved at the block level without touching global style mechanics, at least initially. I moved them to a new section, called "Related tasks but that initially will not use theme.json/global styles mechanisms.".

    I see the current "global" config as a way to define a config for all blocks but not as a way to define what UI is available in the global styles panel.

    Currently, the global config is a way to define what UI is available at the global styles panel. The other blocks inherit it if they don't have a specific config for them.

    Basically, before global styles, one could not have control if a feature is enabled or disabled in a specific block. Our API changed that. With our new API, one can also specify if things in a particular block (or even in blocks with specific attributes) are available or not and overwrite what was defined globally. Our API just added block-level controls, but we don't have things like selectors that select multiple blocks, etc., ways to disable inheritance, etc. Themes always need to select each block individually.

    How do I enable colors everywhere but only allow changing the main one in the Global styles UI

    We don't the concept of "main color". The user can edit, text color, background color, and link color, at the global level and at the level of blocks that support these colors. One can't enable text color but disable background color. All the colors are either enabled or disabled.
    Besides that, the user can change the color presets, and if there is a color like "primary" used in multiple places, the user changing the preset will change the color in multiple places. It is not possible to say only this preset is editable. Do you think we should change some of these in the first version?

    How do I disable line-height choices in all blocks but allow it at the global level.

    The current API does not offer a way to select all the blocks. Achieving this would require to enable line-height at the global level, and then explicitly disable it for all the block contexts. I guess it could be done using a PHP filter that loops through all the selectors and injects the setting to disable line-height keeping it enabled for the global context, which is not ideal.
    I see two options to achieve:

    • Have a selector similar to "" that selects all the blocks? We enable line-height at the global level but disable it for all the blocks because all match the "" selector.
    • Have something like non inherited settings so we could use this to change line-height in global to true, making sure all the blocks below will not inherit the setting and have line-height enabled.

    None of these options seem good. Do you have a different idea in mind?

    There is a tradeoff between supporting more use cases and making theme.json structure and the engine implementing these rules more complex. I think in a declarative approach, there will always be things that will not be possible to achieve and we should draw a line. I guess we need to decide between what we allow and what we don't allow, and make any required engine updates as soon as possible.

    Do you think there is a simple theme.json change we can make that would allow the use cases you referred? Are there other use cases besides the ones you already referred that you think should be possible?

    Thank you a lot for looking into this and sharing your insights/questions!

  11. jorgefilipecosta commented on Nov 24, 2020

    @jorgefilipecosta
    Member

    Hi @aristath, @francescamarano,
    Thank you for your comments! To make things easier to navigate, I updated the comment linking to the issues/PR's and also added more prioritary issues to the Full Site Editing board.

  12. youknowriad commented on Nov 24, 2020

    @youknowriad
    Contributor

    Currently, the global config is a way to define what UI is available at the global styles panel. The other blocks inherit it if they don't have a specific config for them.

    And I'm saying it shouldn't be the case, we should have two distinct things (both in theme.json):

    • A way to disable and enable things for all blocks (without explicitly listing the blocks)
    • And a way to enable/disable things on the global panel UI

    (maybe a "global"l key and a "UI" or "*" and "global" or something like that)

    These things should be different. Once they are, the use-cases I shared will be solved.

    When I was referring to "main" color, for me this was just a custom CSS variable editable on the global styles UI and that you can use as a value of of the palette colors or not, you can also just use it to style some blocks in theme.json directly. (provide default values)

  13. cliffordp commented on Nov 24, 2020

    @cliffordp
    Contributor

    Just chiming in to say https://wordpress.org/plugins/kt-tinymce-color-grid/ is an excellent plugin that works for Classic, Block, and Customizer. It adds CSS variables with the name you choose for each color (e.g. brand-main, brand-secondary, brand-accent, sheepish-white, creamy-gray, deep taupe), and it has import/export functionality.

    I hope it can inspire.

  14. jorgefilipecosta commented on Nov 25, 2020

    @jorgefilipecosta
    Member

    Hi @youknowriad, thank you for clarifying your thoughts.

    And I'm saying it shouldn't be the case, we should have two distinct things (both in theme.json):

    A way to disable and enable things for all blocks (without explicitly listing the blocks)
    And a way to enable/disable things on the global panel UI
    (maybe a "global"l key and a "UI" or "*" and "global" or something like that)

    I guess we can accomplish these requirements in two possible ways:

    • Two selectors a "" selector that is inherited by every context (including the global one). Equivalent to our current "global". A global context that just affects the global panel and is not inherited. There is no explicit inheritance of styles so styles would still be defined on "global". "" Selector would just support settings which is the only place where we are inhering things right now.

    • Keeping everything as it is, but add a new special settings only context called "global-panel". This panel just affects global context settings without any inheritance. On the global context, if this context contains settings it overwrites what was defined in global.

    Do you think these solutions are acceptable? Do you have any preferences? Also cc: @nosolosw, in case you have some thoughts.

    When I was referring to "main" color, for me this was just a custom CSS variable editable on the global styles UI and that you can use as a value of of the palette colors or not, you can also just use it to style some blocks in theme.json directly. (provide default values).

    Well, one can edit presets, they are variables. One can have a preset called the main color. Editing that preset would be equivalent to edit a variable used all around the site.
    But besides the color presets, and, the link color (which is also a CSS variable), there are no plans as part of Global Styles V1 to have a mechanism that allows someone to expose a UI in the global styles panel that allows controlling the value of a CSS variable. Do you think need to have for V1 something that allows controlling custom CSS variables (besides color presets and link color)?

  15. jorgefilipecosta commented on Nov 25, 2020

    @jorgefilipecosta
    Member

    Just chiming in to say wordpress.org/plugins/kt-tinymce-color-grid is an excellent plugin that works for Classic, Block, and Customizer. It adds CSS variables with the name you choose for each color (e.g. brand-main, brand-secondary, brand-accent, sheepish-white, creamy-gray, deep taupe), and it has import/export functionality.

    Hi @cliffordp,

    Thank you for bringing this plugin to our attention. It has considerable usage, which means users really want the power of changing color palettes and things like that, so it reinforces that we are working on something relevant.
    It is also a good test case to make sure what we are doing is back-compatible and does not breaks plugins. E.g: that plugin should still work and the colors users apply with it should still be applied on global styles (unless the user then changes the colors on global styles).

  16. 10 remaining items

  17. oandregal commented on Mar 24, 2021

    @oandregal
    Member

    This week in global styles:

    Ongoing/Next tasks necessary for MVP:

    And more:

  18. oandregal commented on Mar 24, 2021

    @oandregal
    Member

    Just added #30191 to the list as well (under the theme.json group).

  19. oandregal commented on Mar 31, 2021

    @oandregal
    Member
  20. oandregal commented on Apr 7, 2021

    @oandregal
    Member

    This week's status report:

    Shipped

    Ongoing

  21. oandregal commented on Apr 14, 2021

    @oandregal
    Member

    This week in global styles:

    Landed

    Ongoing

  22. oandregal commented on Apr 21, 2021

    @oandregal
    Member

    This week in global styles:

    Landed

    theme.json with elements #29891

    Block Supports & theme.json properties:

    Bugfixes, code quality

    Ongoing

    theme.json with elements #29891

    Block Supports:

    Bugfixes:

    Priorities

    The priority continues to be shipping #29891 as soon as possible to unblock related work.

    #28913 is a good issue to look at if you can lend a hand (help with reviews, migrate more blocks, more properties, etc).

  23. oandregal commented on Apr 28, 2021

    @oandregal
    Member

    Weekly status report for core-editor meeting.

    Shipped this week

    theme.json

    block.json / block supports

    Internationalization

    KSES

    Site editor:

    Ongoing

    theme.json

    block.json / block supports

    New style properties

    Misc

    Priorities

    The priority continues to be shipping #29891 as soon as possible to unblock related work.

    #28913 is a good issue to look at if you can lend a hand (help with reviews, migrate more blocks, more properties, etc).

  24. oandregal commented on May 5, 2021

    @oandregal
    Member

    Status report for core-editor meeting.

    Shipped this week:

    block.json / block supports:

    theme.json

    Extensibility:

    Site editor:

    Ongoing:

    block.json / block supports:

    theme.json

    Priorities

    After having landed #29891 via #30541 the priority is to tie up the loose ends before preparing the core patch for 5.8.

    Worth highlighting is that there're two new issues to switching away from CSS Custom Properties for link #31488 and font-family #31489 (see rationale in each issue).

  25. oandregal commented on May 12, 2021

    @oandregal
    Member

    This week report for core-editor.

    Shipped this week

    block supports

    theme.json

    site editor:

    Ongoing

    block supports:

    theme.json

    Priorities

    Start the merge process for theme.json APIs.

  26. oandregal commented on May 19, 2021

    @oandregal
    Member

    Status report (core-editor):

    This week's focus was on getting things ready for Gutenberg 10.7 (landed most of the things we needed, there are a couple in flight) and start the merge process in core (got an initial PR for this).

    Shipped this week

    block supports:

    settings:

    Ongoing

    block supports:

    theme.json

    core merge

    Priorities

    Merge process for theme.json APIS in core.

  27. oandregal commented on May 26, 2021

    @oandregal
    Member

    Status Report (core-editor meeting).

    Global Styles and Global Settings have been ported to WordPress core and will be part of the WordPress 5.8 release. The focus now is on polishing and fixing bugs as we find them. The issue description & tasks have been triaged and there're two new sections: "bugfixes" and "docs" with tasks to be worked on in the upcoming weeks.

    Now that the 1.0 version of this feature has been shipped and we need to revisit focuses, I thought it'd be a good time to pause these reports while we figure out the next steps. Anything relevant should still be posted here but on an on-demand basis not weekly.

    Supported settings & styles that landed core

    There's a task above to update this in the docs but wanted to share what we have now.

    • The following settings & styles are still experimental and only work with the plugin: border, font-family, font-style, font-weight, text-decoration, text-transform. The rest are part of WordPress core now, so they work without the plugin as well.
    • Layout is enabled for themes with theme.json support.
    • The default theme.json settings we landed in core work like this:
      • If the settings had a corresponding theme support, it works the same as before. Settings that are enabled by default are color.custom, color.customGradient, typography.customFontSize, typography.dropCap. Settings that are disabled by default are spacing.customMargin, spacing.customPadding, typography.lineHeight. Units can be filtered.
      • Link color is stable, landed into 5.8, and it's disabled by default. Need to make a decision on what to do with the existing add_theme_support('experimental-link-color'). It seems that we can keep it in the plugin and remove it when the minimum WordPress version is 5.8.

    Shipped this week

    Port to core:

    Block Supports:

    theme.json

    Misc:

  28. oandregal commented on Dec 21, 2021

    @oandregal
    Member

    We're shipping a first version of the GS interface in 5.9, so it looks like this issue could be closed. Both for having a sense of progress but also because the activity has already moved to other smaller and more focused issues (designer tools, site editor improvements, framework changes, etc).

  29. oandregal commented on Dec 21, 2021

    @oandregal
    Member

    I've created #37550 to track some gaps we still have from the original vision of styles at the framework level.

  30. mtias commented on Dec 21, 2021

    @mtias
    MemberAuthor

    Really wonderful work and progress here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Feature] Design ToolsTools that impact the appearance of blocks both to expand the number of tools and improve the experi[Type] OverviewComprehensive, high level view of an area of focus often with multiple tracking issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions