WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.49k stars 4.18k forks source link

Avoid custom styling for any Button in the editor UI #62743

Open afercia opened 4 months ago

afercia commented 4 months ago

Description

Sometimes, some base components like the Buttons use custom styling in the editor UI, thus overriding the default styling of the base components.

As recently discussed in other issues and PRs, custom styling should be avoided. By overriding the default styling:

Ideally a better approach would be:

Cc @DaniGuardiola

A few examples:

I'd agree that the Featured image button and the button to Add a background image (for example in a Group block) are, in a way, special cases because when the image is set they contain the image preview. But... when the image is not set, they are just normal buttons. I don't see any good reason why they should use a custom style. Screenshot:

Screenshot 2024-06-21 at 10 13 48 2

This styling with a grey border (actually a box-shadow) around the button is custom. It's not any of the default Button component variants: Default, Primary, Secondary, Tertiary, Link, Destructive. It's custom, redundant CSS that introduces visual inconsistency in the UI.

Note: the only non-primary default styling that sets a border on the Button is the Secondary variant. It looks like this:

Screenshot 2024-06-21 at 14 30 36

All teh Button variants can be quicly checked in the Storybook.

One more example:

When the featured image is set, the Replace and Remove buttons evolved from standard variants:

featured image ui before

to a custom implementation:

featured image ui after

As far as I can tell, this is a unique styling in the editor UI. I don't see any good reason to not use one of the standard styling variants instead of an ad-hoc (maybe more pleasant?) look and feel. But that's subjective anyways. CSS overrides of the base components should be avoided at all costs. As said, if there's a good use case for some new styling, that should be considered as a new variant. I'd also argue that destructive actions in WordPress should be red. That went lost with the custom styling.

Overall, I'd suggest to only use the base components styling everywhere in the editor. The pros of having a consistent styling for all controls in the UI and having less and more maintainable code largely outweighs any other consideration related to subjective aesthetics.

Step-by-step reproduction instructions

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

afercia commented 4 months ago

CC also @ciampo and @mirka

DaniGuardiola commented 4 months ago

Completely agree. I think we can take the following steps:

  1. Identify all cases of custom styles.
  2. Loop design and product folks in. See if there are strong reasons to differ from base styles. If so, identify and consolidate these cases into variants, implemented directly in base components.
  3. Remove custom styles.

cc @WordPress/gutenberg-design @WordPress/gutenberg-components

richtabor commented 4 months ago

There's a clear reason for the featured image buttons. They went from no styling to thoughtful placement.

And for featured image, I'd treat them more as dropzones rather than buttons.

afercia commented 4 months ago

There's a clear reason for the featured image buttons.

Could you please add more context? What the 'clear reason' is? I'm not sure this kind of statements without any context are any helpful in a collaborative open source project where contributors who land on an issue and are maybe considering to contributes need to understand the reasoning and decisions that were made before actually being able to contribute. Tickets and issues are part of a project history and documentation. As such, I'd encourage everyone to avoid assumptions and always document and clarify their reasoning.

And for featured image, I'd treat them more as dropzones rather than buttons.

Considering a <button> element as a dropzone is already very arguable in terms of semantics and accessibility because that's not what buttona are meant for. Also, while that may apply for the 'set' and 'add' buttons, the replace and remove buttons are not dropzones and there's no funcitonal reason to style them differently.

Screenshot 2024-06-28 at 09 49 29

We agreed in other conversations that the editor is already very complicated. I'm not sure adding unique cases, ad-hoc styling and cognitive load is the best way to make it more simple. Unique styling just adds more complexity.

richtabor commented 3 months ago

Could you please add more context? What the 'clear reason' is? I'm not sure this kind of statements without any context are any helpful in a collaborative open source project where contributors who land on an issue and are maybe considering to contributes need to understand the reasoning and decisions that were made before actually being able to contribute. Tickets and issues are part of a project history and documentation. As such, I'd encourage everyone to avoid assumptions and always document and clarify their reasoning.

The clear reason is a lack of styling from the screenshot you provided. Common sense, not reasoning/discussions etc. You'd be hard pressed to find a that low effort design in many successful software projects.

afercia commented 3 months ago

The clear reason is a lack of styling from the screenshot you provided. Common sense, not reasoning/discussions etc. You'd be hard pressed to find a that low effort design in many successful software projects.

I'm not sure I understand your feedback. Not even sure the tone is fair, but that could be because I'm not a native English speaker.

Anyways, I asked to clarify the statement There's a clear reason for the featured image buttons. and I still don't see the clear reason. On the other hand, I think I clearly explained why base component like Buttons should never be overridden with custom styles or ad-hoc implementations.

jameskoster commented 3 months ago

Replacing / removing a featured image is a relatively uncommon task. Placing the buttons 'on top' of the image avoids adding unnecessary clutter to the UI, indirectly making more common flows easier to navigate. The existing button style variations are not suited to this use case, hence the customisation.

Perhaps there's a case to add a new Button variant for situations like this. It may be useful elsewhere, e.g. the focal point picker:

Screenshot 2024-07-17 at 10 03 54
richtabor commented 3 months ago

Anyways, I asked to clarify the statement There's a clear reason for the featured image buttons. and I still don't see the clear reason.

As pictured in your screenshot above of the previous replace/remove buttons for the featured image, the buttons lack any finesse of styling, layout, and positioning. It's not a thoughtful execution, nor supportive of the experience.

Although the buttons currently have a different look to others, they are much more intentional and thoughtfully executed, not just tossed in.

richtabor commented 3 months ago

Perhaps there's a case to add a new Button variant for situations like this. It may be useful elsewhere, e.g. the focal point picker:

Maybe so.

afercia commented 1 month ago

As pictured in your screenshot above of the previous replace/remove buttons for the featured image ...

Those are not the previous buttons. They are the buttons used on current trunk. Screenshot taken today from trunk:

Screenshot 2024-09-05 at 13 57 59

... the buttons lack any finesse of styling

I agree. And it's because they're custom, ad-hoc, not very well thought implementation.

Placing the buttons 'on top' of the image avoids adding unnecessary clutter to the UI, indirectly making more common flows easier to navigate.

@jameskoster While I do agree avoiding unnecessary clutter does have value, I'd argue that it's a personal opinion anyways. This UI change has not been user tested, not even a simple A/B testing to prove that it's an improvement. It's only based on personal opinions, at the cost of introducing some inconsistency in the design, maintenance cost, etc. My take on these cases is: if there's a case for a new variant for many valid cases then the base component should provide the new variant. Otherwise, refrain from introducing inconsistent design and exceptions. Instead, this is a unique case in the editor. It's completely inconsistent and its value hasn't been proved yet.