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

Add some documentation about the Styles UI components #49720

Merged
merged 2 commits into from
Apr 12, 2023

Conversation

youknowriad
Copy link
Contributor

@youknowriad youknowriad commented Apr 11, 2023

WHAT

🤖 Generated by Copilot at c8e596d

This pull request improves the documentation of the global styles system in the block editor in ./packages/block-editor/src/components/global-styles/README.md.

🤖 Generated by Copilot at c8e596d

global-styles docs
reformatted with care and skill
autumn leaves of code

WHY

Hopefully this sets some guidelines for folks as they touch and evolve these components and also helps people understand what they should do build new similar components.

Todo: As a follow-up, I think we should consider adding Storybook stories for all of these components.

@youknowriad youknowriad force-pushed the add/documentation-global-styles-ui branch from c8e596d to c46616a Compare April 11, 2023 12:23
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.

LGTM!

✅ New UI components section reads well and makes sense

Tiny nit: The indentation for the value prop example contains a mixture of spaces and tabs.

Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

This all reads nicely to me, too, LGTM aside from the whitespace issue that Aaron raised. Thanks for updating the docs!

Just added a comment to connect the discussion you started on the child layout controls about the default controls values.

Comment on lines +182 to +190
- `defaultControls`: The default controls are the controls that are used by default to render the UI. They are used to provide the UI components with the necessary information to render the UI. An example value for the default controls for the `ColorPanel` component is:

```js
{
background: true,
text: true,
link: true,
},
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for starting the discussion about what the defaults for each of the panels should be over in #49389 (comment).

Something I was wondering about from that comment — should the defaults across the components be defaulting to false to follow the behaviour in block.json where we explicitly flag which ones we reveal? I know that in the site editor they're all displayed by default, but at the component level, I wasn't sure which idea would be preferable. Some example ideas:

  • The component as it lives in the block editor package specifies the defaults across the board (e.g. most are hidden by default, except for child layout controls). It is then up to other use cases (e.g. global styles) to specify if they'd like to reveal more controls by default. Or:
  • At the component level, we default to displaying everything by default. It is then up to the consumer to be more restrictive if it so wishes (e.g. the block.json behaviour).

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My strong opinion is that the behavior should be the same.
My other opinion that is a bit less strong is that there's also a third option which is for us to be opinionated about what the defaults should be, that way consumers of the component (think of a component as its own unit, independent of the existing usage) itself shouldn't have to provide that prop or a big object to actually choose what to show, they should have sane defaults. And since we control what is shown or hidden on Global Styles (as opposed to the blocks), I don't see why global styles shouldn't be using these sane defaults. (at least at the root level, as there's an argument that block level should also follow the block.json config)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anyway, let's continue this discussion with Isabel in the other thread and update the documentation when we find a solution.

Co-authored-by: Aaron Robertshaw <[email protected]>
@youknowriad youknowriad enabled auto-merge (squash) April 12, 2023 09:32
@youknowriad youknowriad merged commit c5e6a18 into trunk Apr 12, 2023
@youknowriad youknowriad deleted the add/documentation-global-styles-ui branch April 12, 2023 10:01
@github-actions github-actions bot added this to the Gutenberg 15.6 milestone Apr 12, 2023
@github-actions
Copy link

Flaky tests detected in f026f53.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4676749929
📝 Reported issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants