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 a generic style to the toolbar buttons #21252

Merged
merged 6 commits into from Apr 2, 2020
Merged

Conversation

youknowriad
Copy link
Contributor

@youknowriad youknowriad commented Mar 30, 2020

Alternative to #21064
Related to #20246

Right now the toolbar component has an isPressed state for buttons but the styles are not applied properly. Instead the styles are only applied for block toolbars.

This PR fixes that by providing default styles (based on the regular button sizes) and the block toolbar just overrides the height of these toolbars.

Testing instructions

Check the heading level toolbar on the inspector.

Capture d’écran 2020-03-30 à 10 32 08 AM

@github-actions
Copy link

@github-actions github-actions bot commented Mar 30, 2020

Size Change: -28 B (0%)

Total Size: 883 kB

Filename Size Change
build/block-editor/index.js 102 kB -9 B (0%)
build/block-editor/style-rtl.css 10.7 kB -496 B (4%)
build/block-editor/style.css 10.7 kB -492 B (4%)
build/components/style-rtl.css 16.6 kB +506 B (3%)
build/components/style.css 16.5 kB +499 B (3%)
build/edit-post/style-rtl.css 12 kB -9 B (0%)
build/edit-post/style.css 12 kB -9 B (0%)
build/edit-site/style-rtl.css 4.61 kB -9 B (0%)
build/edit-site/style.css 4.61 kB -9 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.02 kB 0 B
build/annotations/index.js 3.45 kB 0 B
build/api-fetch/index.js 3.8 kB 0 B
build/autop/index.js 2.59 kB 0 B
build/blob/index.js 620 B 0 B
build/block-directory/index.js 6.02 kB 0 B
build/block-directory/style-rtl.css 760 B 0 B
build/block-directory/style.css 760 B 0 B
build/block-library/editor-rtl.css 7.21 kB 0 B
build/block-library/editor.css 7.21 kB 0 B
build/block-library/index.js 110 kB 0 B
build/block-library/style-rtl.css 7.5 kB 0 B
build/block-library/style.css 7.51 kB 0 B
build/block-library/theme-rtl.css 669 B 0 B
build/block-library/theme.css 671 B 0 B
build/block-serialization-default-parser/index.js 1.65 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/blocks/index.js 57.5 kB 0 B
build/components/index.js 195 kB 0 B
build/compose/index.js 6.21 kB 0 B
build/core-data/index.js 10.7 kB 0 B
build/data-controls/index.js 1.03 kB 0 B
build/data/index.js 8.23 kB 0 B
build/date/index.js 5.37 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 569 B 0 B
build/dom/index.js 3.05 kB 0 B
build/edit-navigation/index.js 2.4 kB 0 B
build/edit-navigation/style-rtl.css 95 B 0 B
build/edit-navigation/style.css 95 B 0 B
build/edit-post/index.js 92.3 kB 0 B
build/edit-site/index.js 9.04 kB 0 B
build/edit-widgets/index.js 4.43 kB 0 B
build/edit-widgets/style-rtl.css 3.74 kB 0 B
build/edit-widgets/style.css 3.74 kB 0 B
build/editor/editor-styles-rtl.css 423 B 0 B
build/editor/editor-styles.css 426 B 0 B
build/editor/index.js 42.8 kB 0 B
build/editor/style-rtl.css 3.47 kB 0 B
build/editor/style.css 3.47 kB 0 B
build/element/index.js 4.44 kB 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/index.js 6.94 kB 0 B
build/format-library/style-rtl.css 502 B 0 B
build/format-library/style.css 502 B 0 B
build/hooks/index.js 1.93 kB 0 B
build/html-entities/index.js 622 B 0 B
build/i18n/index.js 3.57 kB 0 B
build/is-shallow-equal/index.js 710 B 0 B
build/keyboard-shortcuts/index.js 2.3 kB 0 B
build/keycodes/index.js 1.7 kB 0 B
build/list-reusable-blocks/index.js 2.99 kB 0 B
build/list-reusable-blocks/style-rtl.css 226 B 0 B
build/list-reusable-blocks/style.css 226 B 0 B
build/media-utils/index.js 4.84 kB 0 B
build/notices/index.js 1.57 kB 0 B
build/nux/index.js 3.01 kB 0 B
build/nux/style-rtl.css 616 B 0 B
build/nux/style.css 613 B 0 B
build/plugins/index.js 2.54 kB 0 B
build/primitives/index.js 1.5 kB 0 B
build/priority-queue/index.js 780 B 0 B
build/redux-routine/index.js 2.84 kB 0 B
build/rich-text/index.js 14.5 kB 0 B
build/server-side-render/index.js 2.54 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.28 kB 0 B
build/url/index.js 4.01 kB 0 B
build/viewport/index.js 1.6 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.17 kB 0 B

compressed-size-action

@jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Mar 30, 2020

I love the simplicity of this fix, it's definitely more solid and future-proof code.

Two things though. The caption inline toolbar is now vertical — probably needs a flex rule it previously inherited:

Screenshot 2020-03-30 at 11 57 16

It might also have inherited other rules that are good to check for. For example the inline buttons in the middle should be 36px wide to optically be balanced. Here's how it's supposed to look:

Screenshot 2020-03-30 at 12 02 37

The other thing is the styling of the "toolbar" when shown in the sidebar. It feels most correct to have the same toolbar styling as exists in the canvas, like so:

Screenshot 2020-03-30 at 12 04 20

Note that the icons above are 20x20 but should be 24x24, so that's a bug in the above which is correct in your branch.

@youknowriad
Copy link
Contributor Author

@youknowriad youknowriad commented Mar 30, 2020

Two things though. The caption inline toolbar is now vertical — probably needs a flex rule it previously inherited:

I switched to inline-flex because we don't want to default toolbar to take the full width available, especially cause it has borders but I wonder if I should revert that change.

The other thing is the styling of the "toolbar" when shown in the sidebar. It feels most correct to have the same toolbar styling as exists in the canvas, like so:

That's the one thing I'm unsure of. The question here is what is the default height for toolbars (regardless of whether they are in blocks or not). Maybe that's 48 (like the block one) and in that case, the fix would be even simpler. The problem is its inconsistency with buttons but maybe it's fine?

@jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Mar 30, 2020

I switched to inline-flex because we don't want to default toolbar to take the full width available, especially cause it has borders but I wonder if I should revert that change.

Inline-flex should be able to have horizontal buttons inside no? flex-direction: row?

The question here is what is the default height for toolbars
Maybe that's 48 (like the block one) and in that case, the fix would be even simpler

It should be, I would say. Do you foresee problems with this?

@youknowriad
Copy link
Contributor Author

@youknowriad youknowriad commented Mar 30, 2020

Inline-flex should be able to have horizontal buttons inside no? flex-direction: row?

It should by default, not sure why the wrapping happens yet.

Do you foresee problems with this?

Not really, just design-wise, it might not be perfect.

@jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Mar 30, 2020

Not really, just design-wise, it might not be perfect.

Just the duplicated toolbar in the sidebar? Yeah it's a little mixing of metaphors, but it seems like the strongest path forward for now.

@youknowriad youknowriad force-pushed the update/toolbar-button-styles branch from 9852031 to cbdbf54 Compare Mar 30, 2020
@youknowriad
Copy link
Contributor Author

@youknowriad youknowriad commented Mar 30, 2020

I applied the styles to all toobars, so now you can see the styles in Storybook and I added a story with several variations.

Capture d’écran 2020-03-30 à 1 55 45 PM

It is becoming an impactful PR though so we need to test well. there might be some dead CSS code as well lingering.

@jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Mar 30, 2020

Wow, that last commit is seriously impressive. This feels like an excellent step in the right direction. This also tested well for me, I tested the demo content and even some plugins. Everything seems to work as it should. I would very much appreciate others also testing, so we can be sure we've dusted off all the corners this might impact, but it feels really worth it.

So I have only one thing:

Screenshot 2020-03-30 at 15 32 18

The toolbar should have rounded corners. border-radius: $radius-block-ui;.

@ZebulanStanphill
Copy link
Member

@ZebulanStanphill ZebulanStanphill commented Mar 30, 2020

In addition to what @jasmussen noticed, one inconsistency I noticed is that the label for the toolbar uses different font styles than other controls. (Not sure if that's how it is in master, but it's not like that in Gutenberg 7.8.1.)

image
image

Other than that, this looks good to me!

@youknowriad
Copy link
Contributor Author

@youknowriad youknowriad commented Mar 31, 2020

Added the rounded borders.

The label was not touched in this PR but yes, it seems like it's not like the remaining ones.

@youknowriad
Copy link
Contributor Author

@youknowriad youknowriad commented Apr 1, 2020

Looks like this is now conflicting with the focus changes you just merged. Would you mind helping with the rebase @jasmussen

@jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Apr 1, 2020

I'll take a look in a moment.

@jasmussen jasmussen force-pushed the update/toolbar-button-styles branch from 6b99f2e to 9642fb3 Compare Apr 1, 2020
@jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Apr 1, 2020

Okay, rebased!

@youknowriad
Copy link
Contributor Author

@youknowriad youknowriad commented Apr 1, 2020

Thanks :)

@youknowriad
Copy link
Contributor Author

@youknowriad youknowriad commented Apr 2, 2020

Is this ready to land ?

@jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Apr 2, 2020

Last I checked, absolutely.

@youknowriad youknowriad merged commit 559655b into master Apr 2, 2020
3 checks passed
@youknowriad youknowriad deleted the update/toolbar-button-styles branch Apr 2, 2020
@github-actions github-actions bot added this to the Gutenberg 7.9 milestone Apr 2, 2020
/>
{ children }
>
{ children }
Copy link
Member

@obenland obenland Apr 20, 2020

Choose a reason for hiding this comment

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

@youknowriad Is it possible that this now overrides what's being passed in extraProps.children?
If you passed a button text to the toolbar previous to 7.9 that button now appears empty: Automattic/jetpack#15459

Copy link
Contributor Author

@youknowriad youknowriad Apr 21, 2020

Choose a reason for hiding this comment

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

For me the change here is not to avoid passing "children" but moving the children position inside the button which makes more sense IMO

Copy link
Contributor Author

@youknowriad youknowriad Apr 21, 2020

Choose a reason for hiding this comment

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

That said, I'm still wondering why it regressed, the children should still show up for toolbar buttons? 🤔

Copy link
Member

@obenland obenland Apr 21, 2020

Choose a reason for hiding this comment

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

It looks like the "inner" children supersedes the children that is passed as a prop?

We fixed it in Automattic/jetpack#15508 through emulating how MediaReplaceFlow does it, so don't feel inclined to change anything on behalf of this. Awareness might be enough in case others run into this at some point

Copy link
Contributor Author

@youknowriad youknowriad Apr 21, 2020

Choose a reason for hiding this comment

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

We can also switch the priorities of the passed children (give the extraProps more priority), it is also weird to have the same prop in two different places, we should consolidate maybe. I wonder where the "extraProp" prop is passed and in which case the children should be extracted and just passed as regular "children" prop.

@RickorDD
Copy link
Contributor

@RickorDD RickorDD commented Jun 7, 2020

Is this the Issue?

When i add the Imageblock the Fontbar hidden the Text.
Remove this Bar to the Top?
Git

@youknowriad
Copy link
Contributor Author

@youknowriad youknowriad commented Jun 8, 2020

@RickorDD yes, seems like a bug. Would you mind creating an issue? It seems the caption input should be hidden unless the image has been selected.

@RickorDD
Copy link
Contributor

@RickorDD RickorDD commented Jun 8, 2020

@youknowriad
We found this Issue with
#22295

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants