-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Button Component: Update styling to avoid relying on Core Styles making it reusable #6562
Conversation
components/button/index.js
Outdated
'is-toggled': isToggled, | ||
'is-busy': isBusy, | ||
'is-link': isLink, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are way too many button states here, but this matches Core, we can try to rethink some of them later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to replace all these booleans with a more enum-like API? e.g. <Button style="link">
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know maybe later, let's not change all the buttons today :)
There's one thing I've noticed also previously and this PR improves it but still a bit weird: when I try to make an IconButton have also some text, the position of the icon is OK if the button is a real button, but it's not OK when it's actually a link. Seems it happens in Chrome, Firefox is OK. Seems the Chrome: Firefox: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this. I'll see if I can get time today to push a few visual fixes directly to this branch to address Roberts notes. |
Pushed a fix to the alignment issue. Will look at some other issues with focus styles and admin theme colors in a minute.
Is this specific to this PR or was it also an issue before? The text-indent is definitely there to indent the text when there's an icon, and combined with flex it seems to have worked decently well. However if it doesn't work well in all situations or browsers, then I can take a look (as I added this initially). Feel free to create a new issue and assign me, and I'll look at it if it's not specific to this branch. |
@youknowriad The theme colors regressed in this, because the CSS classes changed and additional specificity is required. That means the red color that the midnight theme applies to buttons with I can fix that in our Otherwise we're overriding buttons, and overriding theme styles. We're already doing this in a few places, sure, but if this is the path forward, we might as well detach these buttons as much as possible from the core UI, and see how many One other challenge with overriding the theme styles is additional colors. In the admin schemes mixin I've tried to limit things to two colors, the primary spot color and the secondary spot color. I've then used SCSS darken to create the additional shades necessary for the candy-colored "saving" indicator. For the primary button I'm going to need all sorts of shades of the spot-color, for the border, for the pressed state, for the shadow, even the text shadow. I can try and re-create these using darken, but that won't be 100% accurate. The alternative is to duplicate every is-primary style for every admin scheme there is — but then we're duplicating yet again. Is there any way we can keep using the core "button-primary" styles, instead of re-creating the |
Thanks for the fixes @jasmussen :)
I'm fine with that, that's exactly what this PR is doing, just leaving the same styles for now.
I think we can make try to automatically generated this mixin in the future. Like browsing our stylesheets and automatically add additional styles when we detect the usage of theme colors (similar to the RTL plugin). I think with good webpack skills (cc @aduth 😄 ), we can achieve that and don't think about these admin styles anymore. The good thing about such approach is that the theme styles would be loaded by stylesheet and not globally in a single stylesheet.
That defeats the purpose of this PR. We'll style rely on Core style in that case which needs specificity and break reusability. |
I'll keep thinking about this and take a look next week if I have bandwidth. |
89d5d36
to
712c093
Compare
Now that the post-css plugin is merged, I rebased this PR and updated the primary buttons styles to use theme colors. They don't match the current buttons perfectly but they're close enough. What do you think @jasmussen |
I pushed some fixes, Riad. Can you take a look and see how it feels? Otherwise, feels like we're VERY close! |
Looks good to me :) Let's get some eyes and keep this for the next release. |
CC: @karmatosed let me know if you'd like some GIFs as the buttons change a little. |
Also, the focus styles changed, let's make sure these are kosher. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks.
e587426
to
2465dc4
Compare
|
||
/* Buttons that look like links, for a cross of good semantics with the visual */ | ||
&.is-link { | ||
margin: 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regression: This selector is more specific than (well, equal specific but out of order from) and thus overrides the margin applied from .components-color-palette_clear
:
margin-right: 20px; |
v4.9.2 | #6562 |
---|---|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, we shouldn't need margin here for the button. The color palette panel shouldn't be doing a negative margin. It should have a container and spread the options via display: flex
& align-items: space-between
Right now, the button component is relying heavily on core styles. This has some issues:
.core-ui
to any place where we want to extend the default button stylesThis PR copies the styles from Core into the
components-button
className to solve this.Notes
I probably need to update the default styles according to the WP theme cc @jasmussen (I might need some help here)
Testing instructions
Navigate in the Gutenberg UI and check that the styling of the different buttons didn't regress.