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

Block Styles Breakdown #20331

Open
mtias opened this issue Feb 20, 2020 · 26 comments
Open

Block Styles Breakdown #20331

mtias opened this issue Feb 20, 2020 · 26 comments

Comments

@mtias
Copy link
Contributor

@mtias mtias commented Feb 20, 2020

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.

  • Create the concept of implicit style attributes to control the appearance of the block. #15450 #21021
  • Centralize style mappings #25051
  • Migrate existing attributes (font-size, color) and introduce missing properties (line-height, family). #22700
  • Evolve a theme.json specification for controlling the editor and the style attributes of different origins. #22518 #20588
  • Merge the different style origins (block, theme, user). #20047 #20290
  • Generate front-end styles using the new system. #19883
  • Generate editor styles using the new system. #22520

Interface

These are the different tools that interact with appearance values.

  • Expose global styles tool in edit-site. This should be a straightforward rendering of a sidebar in the site editor displaying the global values and palette. #24250
  • Allow users to modify some style attributes in the global styles panel. #20367
    • colors: link colors (link, hover / focus, active) #21032
    • typography: font families, font size, line height. #21030 #21028 #20773
    • reset modifications to theme defaults. #20868
  • Develop interface components to operate with new attributes. Prior art in font sizes and color panel. #20367
    • line-height to Paragraph and Heading inspectors. #20339

Second 🌊

Goal: develop all necessary sub-systems.

Infrastructure

  • Stabilize:
    • (one pr remaining to merge) Client: review there's no duplication and improve the way metadata is structured.
    • Server-client metadata: do not send data we already have #26802
    • Server: consolidate theme.json entity #26802
    • Server: consolidate theme.json processor #27237
    • Prepare a core patch for 5.7 (closed) #27506
  • theme.json
    • Consolidate dynamic selectors (selectors for blocks that represent multiple HTML elements, such as heading or list). #24423 #26945
    • Control design tools visibility (superseded) #27295
    • Make settings & styles top-level keys #28163
    • Split global selector into defaults and root #28533
      /24165.
  • Style properties
  • Presets

Interface

Third 🌊

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

block.json

  • #28913 (add support for skip serialization to all properties, core blocks can be migrated iteratively)

theme.json:

  • #29891 Changes to theme.json
  • #27230 (comment) Versioning. We need this for the above task, in which we aim to support the existing and the new format.
  • #29568 colors: allow having defaults, theme, and custom
  • #29778 Theme authors should be able to use any styles in theme.json independently from the block.json support.
  • Mobile: confirm there are not blockers to make theme.json cross-platform (web & mobile) #24165
  • Use wp_theme taxonomy instead of post_name to associate user styles with particular themes #30191

Internationalization:

  • theme.json: customTemplates #29828
  • block supports: allow changing UI control labels #29155

KSES, port changes to core:

  • Fix link color for author role #25151 #25411
  • Port changes to use kses in import contexts and when user doesn't have unfiltered_html permissions #28061

Extensibility:

  • Hooking into the lifecycle of GS: stabilize API and define what sort of hooks do we need. #27504
  • Block editor settings & global styles settings #30082

Expand to more style properties:

Backlog 🌊

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

block.json: nothing planned

theme.json

  • Consider a standardized way to modify hover/focus/active states for blocks #27075
  • Allow all block-editor theme support options to be defined via theme.json #26901
  • Consider allowing themes to enqueue stylesheets in theme.json #26902
  • Integrate style variations as packages of style attributes. (use case for margin)
  • How to express nested content
    • Use a flat structure of selectors core/group core/paragraph. #28163
    • We could have separate files for template parts (in addition to the theme.json for the site or main "document", see #27233
    • We could create CSS vars for container blocks #29714 (comment)
  • Do we need to support dynamic values that change depending on other values? Example for colors #24166
  • Consolidate block attributes, block supports, and theme.json shape #22887
  • Schema and type validation #26955
  • Allow CSS properties that we don't manage? #27231
  • Responsive styles/media queries (styles depending on window size). #20244
  • Define if global attributes (base font, color, page background) can be conceptualized as attributes of a root Site block. #16998 Related: consider global site width and padding #20771

Expand to more style properties:

  • height #28409
  • margin #25988
  • border #29616
  • Free-form custom CSS area. Consider whether this should be per-block as in #25413 or global to all of them?
  • API for loading font families. This should be inherently extensible and likely unopinionated. Maybe explore an API like wp_register_font_family.
  • Justified text #27300

Extensibility:

  • Support for child themes #25612
  • Export theme.json configs (including user preferences) as part of exporting templates & template parts #27941 #27528
  • UI extensibility: allow 3rd parties to hook into it, etc.

Interface:

  • Global styles sidebar: labels for panels in the global styles sidebar (the subtitle of the "headings" panel, for example, "Headings (h1)", is taken from the __experimentalSelector of the heading block). How is this in the new UI?
  • Implement the proposal at #27473 (comment)
  • Integrate new component system #28399 https://status.g2-components.com/
  • Do not show-sidebar if the theme doesn't have theme.json support #27394
  • Custom controls for the Global Styles sidebar. #29778
  • Themes can control the visibility of UI controls. Relates to sidebars #27331 and the old proposal to control visibility #27295 If something is disabled via theme.json it should be disabled for both the global styles and the block sidebar.
  • Blue dot on block panels that have modifications #27474
  • Flow for editing the specific styles of a specific block type #27393
  • Advanced panels of blocks should show which Global Styles are affecting it #27475
  • Exploring beyond a sidebar for exposing styling tools #20212
  • Explore combining all style-related attributes of a block into a "Style" tab in the inspector separate from "Settings".
  • Explore a way to lift local modifications on blocks to global (apply certain modifications to all paragraphs or to all blocks that consume an attribute).
  • Explore if it's needed to show locally on blocks when they are inheriting from a global or theme setting.
  • Allow granular saving options #29388

Iterate on design tools:

  • Add background editing tools to Cover. #20193
  • Add spacing control to Gallery. #20705
  • Establish background tools components hooked to the relevant attributes. #16479
  • Look at how to absorb units for font-size #25137 #23323

Misc:

  • Try using transient attributes on global styles entity #25138
  • Dark mode: editor #28200 authors #24368
  • Do not create revisions for the CPT used by global styles #30132
@jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented May 7, 2020

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.

@kjellr
Copy link
Contributor

@kjellr kjellr commented Oct 9, 2020

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.

@jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Nov 23, 2020

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.

  • Versioning. #27230

    • This needs exploration. One option is that theme.json files have a version number, similarly to block.json files. so if we need to make a breaking change we can still keep code that is able to deal with files from a previous version.
  • Child theme support. #25612

    • A child theme inherits theme.json from parents(s) can add new properties or overwrite existing properties.
  • (In progress) Padding support on global styles. #27154

  • (In progress) Refactor our code and merge it into the core. A PR that started the refactoring #26803.

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

  • Update KSES to accept our link color styles. #25151 Revive: #25411

  • (In progress) Expose a structure in the core that wp-cli can use to know what theme.json strings are translatable. wp-cli/i18n-command#224

  • Discuss mobile support #24165 and have some double-checking if the current theme.json functionality can work well on mobile.

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. #26955

Things for the future

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

  • Nested styles for semantic contexts. For example, apply a specific base font size for things inside a sidebar. #27233

  • Allow CSS properties that we don't manage at the moment. E.g: apply a specific CSS property like textShadow. #27231

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

  • Look into the alignment issues #26633

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

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

@youknowriad
Copy link
Contributor

@youknowriad youknowriad commented Nov 26, 2020

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

Yes, I think this is good. I'd love more thoughts on my intuition here though, especially from theme authors, let's not rush implementation.

Do you think need to have for V1 something that allows controlling custom CSS variables (besides color presets and link color)?

Same here, I do think it's a valuable addition especially since you can use this value in different places in theme.json. But I agree it may not be important for V1.

@nosolosw
Copy link
Member

@nosolosw nosolosw commented Nov 26, 2020

@youknowriad @jorgefilipecosta I've taken your comments here, created an issue to discuss this separately, and added my own thoughts as well. See #27295

@jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Dec 4, 2020

It is time for another update on Global Styles :)

Updates on the must-have items

We got some traction on the i18n of theme.json:
#27380
We hope to merge this PR soon. And that should conclude the i18n work of theme.json on the Gutenberg side. It still needs work on wp-cli side to extract the strings. Now we expose a structure that can be consumed.

We also have some updates on the client-side metadata:
#27453 is ready for review.
#27449 was merged.
When we merge the remaining PR, that part of the work for v1 is done.

Regarding child theme support, that work was put on on pause as @nosolosw referred:

I've seen there's rapid movement in the FSE/templates area and I believe when that's more settled I can resume this work.

Design tools visibility discussion

Regarding the question we had on the last update:

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).

There were some discussions on this issue, and an issue for it was created #27295. Solving this challenge and updating the theme.json shape for this is the biggest priority we have right now. If you have insights for this discussion, please share them on the issue.

UI/UX

The big question we had on the last update was the UI/UX, and on that front, there are important updates.
The first version should implement the prototype that is available at https://g2-components.xyz/iframe.html?id=examples-wip-globalstylessidebar--default&viewMode=story#.
It will involve enhancing many of the current components we have to offer that UI.
The issue to track this UI update is available at #27473. And the part related to the specific components is available at #27331.
After this update, there are several small enhancements we can make to make the user experience better:

Given that we already have considerable progress on the infrastructure part, the UI is considered a high priority. We will give a bigger focus to the UI work. The only two things considered higher priority are the i18n work and the issue #27295 already referred.

@nosolosw
Copy link
Member

@nosolosw nosolosw commented Feb 3, 2021

👋 Here's the current status for this task.

Latest changes:

  • Gutenberg 9.9 will come with a new format for the theme.json, see docs. #28110 #28533
  • The TT1-blocks theme has been updated to the new format, although not published in the WordPress repo yet. WordPress/theme-experiments#182 WordPress/theme-experiments#175
  • Presets:
    • Set up was added to translate them when declared via theme.json. It won't be necessary to declare them in functions.php as well when this lands in WordPress core. It still is necessary while we iterate in the plugin. #27380
    • Font style, weight, decoration, and transforms are no longer presets. #27555
  • Support for new properties at the infrastructure level: border-radius, border-color, border-width, border-style. #28049 #27791 #25791
  • UI controls: added padding to the global sidebar. #27154
  • Custom spacing has been ported to WordPress core and will be part of 5.7 WordPress/wordpress-develop#951
  • Continuous documentation updates, fixes, and general polishing.
  • Many blocks were updated to expose more UI controls for style properties.

What's next?

  • Immediate: list the new UI controls for styles as a "dev note" for 5.7, so themes are aware of the new things users can tweak #28539
  • Immediate: finish some loose ends #27506 #28163
  • We've been working towards shipping parts of theme.json to 5.7 #27506 While there was a lot of progress, it proved premature given two outstanding issues that are unresolved in the format: how to express different templates/nested contexts & support the new direction for sidebars (controls that are shown/hidden) #28533 (comment) #27331 Addressing these issues would be our next focus.

Expect some issue triage in the coming days, as well as updates to this issue description.

@nosolosw
Copy link
Member

@nosolosw nosolosw commented Feb 10, 2021

For the people following this task's updates: the issue description has been updated and there's now a third iteration that includes an initial set of tasks to be developed for April's MVP. All the rest has been moved to the backlog or is done.

@nosolosw
Copy link
Member

@nosolosw nosolosw commented Mar 3, 2021

Update on this: the core feature we wanted for block supports (see #28913) to be able to absorb more use cases is now working on the buttons block (color hook). There're some loose ends I plan to keep working on in the coming days. There are also more hooks and blocks to support and I listed them as individual tasks on 28913, in case anyone finds time to help with them).

@nosolosw nosolosw mentioned this issue Mar 8, 2021
0 of 5 tasks complete
@nosolosw
Copy link
Member

@nosolosw nosolosw commented Mar 9, 2021

Added two ongoing tasks for internationalization in the issue description. I'm looking at #28163 these days to see what's left / what needs to be done for 5.8.

@nosolosw nosolosw mentioned this issue Mar 9, 2021
10 of 11 tasks complete
@nosolosw
Copy link
Member

@nosolosw nosolosw commented Mar 10, 2021

Update for this week's core-editor meeting:

  • Block supports: landed the first implementation that doesn't serialize the block attributes. The overview task lists other properties we should migrate and potential blocks #28913 This is a good place to start looking at for anyone interested in helping with global styles.

  • Internationalization. There's going to be some work in the translation areas for theme.json & block supports in the next weeks (@gziolo). See #28783 and #29155

  • theme.json. I'm going to resume work on some of the things we wanted to do for theme.json in the next few days #28163

@nosolosw
Copy link
Member

@nosolosw nosolosw commented Mar 16, 2021

There're some changes coming to the theme.json format as per #29891 I'll update this issue's description and the affected tasks in the next few days.

@nosolosw
Copy link
Member

@nosolosw nosolosw commented Mar 17, 2021

Update for this week core-editor chat:

  • The last round of mockups for the global styles sidebar are live. It has provided a good ground to re-evaluate the theme.json format and there's going to be some formalization of the concept of "elements", see #29891 for details.
  • There's ongoing work for translations #29828 and iterate to offer higher-level APIs in the server #29667 #29905
  • We landed some fixes for sub-properties (padding) as well #29712

This issue description has been updated to focus on the infrastructure parts of global styles, that we aim to ship in 5.8. The UI tasks have been moved to the backlog for clarity but will be re-evaluated at a later point.

@nosolosw
Copy link
Member

@nosolosw nosolosw commented Mar 24, 2021

This week in global styles:

Ongoing/Next tasks necessary for MVP:

And more:

@nosolosw
Copy link
Member

@nosolosw nosolosw commented Mar 24, 2021

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

@nosolosw
Copy link
Member

@nosolosw nosolosw commented Mar 31, 2021

This week's status report: ongoing work for the major tasks necessary for the MVP.

@nosolosw
Copy link
Member

@nosolosw nosolosw commented Apr 7, 2021

This week's status report:

Shipped

  • Block Supports: added a gutenberg_block_has_support helper function and support for padding in dynamic blocks 30322, border for search block #30227

  • Fixes: title in the save panel of the site editor 30521, fix for themes without theme.json support but with experimental link color support 30452

Ongoing

  • Block supports:

  • Theme.json

    • Update format #29891 There's now a draft PR at #30541
    • Conversation about whether and how to expand the use of CSS Custom Properties #29714
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
9 participants