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 isDestructive style to Button #22921

Merged

Conversation

ArnaudBan
Copy link
Contributor

@ArnaudBan ArnaudBan commented Jun 4, 2020

Description

Fixes #18674.

Add style for button component with the isDestructive props. I follow the figma design find on the issue #18674

How has this been tested?

This is just adding style, not removing any. A did test by looking a the new style on my local instalation

Screenshots

isDestructive :
isDestructive

isDestructive hover :
isDestructive-hover

isDestructive focus :
isDestructive-focus

isDestructive active :
isDestructive-active

isDestructive disabled :
isDestructive-disabled

Types of changes

Add CSS Style

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

@ocean90 ocean90 changed the title Fix #18671 by adding isDestructive style to Button Add isDestructive style to Button Jun 4, 2020
@gziolo gziolo added [Type] Bug An existing feature does not function as intended [Package] Components /packages/components labels Jun 5, 2020
@ArnaudBan
Copy link
Contributor Author

I don't understand how my change make the Travis CI test fail

@youknowriad
Copy link
Contributor

@ArnaudBan the test failure is unrelated, don't worry about it.

Do you think you can add an example to the storybook buttons story? (run locally by doing npm run storybook:dev

@youknowriad youknowriad added the Needs Design Feedback Needs general design feedback. label Jun 5, 2020
@ArnaudBan
Copy link
Contributor Author

@youknowriad Yes i can try that. I will update this PR when it's done. Thank you.

@@ -194,7 +194,41 @@

// Link buttons that are red to indicate destructive behavior.
&.is-link.is-destructive {
color: $alert-red;
color: #b52727;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a new color, which is fine, but we should change the variable contents instead of adding a new color, that way all elements that reference $alert-red will benefit from the change, and the color will be consistent.

This picture shows the existing $alert-red in the top left corner, the new color you added in the bottom, and a suggestion on the right.

Group 50

The existing alert red is a little soft. Your new color is better, but I wonder if there's a 3rd option, which I suggested on the right, it's a bit between them and with higher saturation. What do you think? That new color is #CC1818

}

/**
* Destructive buttons.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nicely commented. I think we should use a single space instead of a tab between the asterisk and comment, i.e. * Destructive....

*/

&.is-destructive {
color: #b52727;
Copy link
Contributor

@jasmussen jasmussen Jun 5, 2020

Choose a reason for hiding this comment

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

These should all leverage the same $alert-red variable.

box-shadow: inset 0 0 0 $border-width #b52727;

&:hover:not(:disabled) {
color: #a02222;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a darker version of your red:

Rectangle 201

It's a good call for the hover, however we should probably use some SCSS smarts so we can reuse the variable. You could, for example, use color: darken($alert-red, 20%);.

@jasmussen
Copy link
Contributor

What a wonderful PR, thank you! Things are looking generally good, and I left a few comments to use some variables instead. Let me know if that works for you!

@enriquesanchez
Copy link
Contributor

I'm having trouble with my dev environment and I can't, at the moment, test this PR. However, looking at the screenshot, it looks like in the isDestructuve hover state, the background stays the same color.

@jasmussen I'm wondering if this should follow the WP component guidelines in Figma? Where the background gets sligthly darker.

@jasmussen
Copy link
Contributor

@jasmussen I'm wondering if this should follow the WP component guidelines in Figma? Where the background gets sligthly darker.

Sounds good to me!

@ArnaudBan ArnaudBan force-pushed the fix/18674-isDestructive-button branch from 133ac44 to bc6e3fe Compare June 5, 2020 19:53
@ArnaudBan
Copy link
Contributor Author

@jasmussen Thank you for kind remark. I update the PR with le use of SASS variable and a change the $alert-red variable value.

I also add a story for the Button component showing the isDestructive variante as @youknowriad suggest

@ocean90
Copy link
Member

ocean90 commented Jun 5, 2020

The new styles will break current buttons with isLink and isDestructive props:

destructive-link

Added a story in cf4fb78.

@ArnaudBan ArnaudBan force-pushed the fix/18674-isDestructive-button branch from cf4fb78 to 4529645 Compare June 5, 2020 21:59
@ArnaudBan
Copy link
Contributor Author

Thank you @ocean90 i had missed that my PR had broken the destructive link Button

@youknowriad
Copy link
Contributor

@jasmussen would you mind doing a final check here when you have time?

@jasmussen
Copy link
Contributor

This is what I see:

destructive

Looks good, compared to secondary buttons too:

secondary

Looking at the code, though, it repeated some styles that I believe it could inherit from .components-button, so I pushed a small tweak to reduce the code (a2a7a37), and it still looks good.

tweaked

Note that I didn't find anywhere in our block editor that currently uses this button style — so I inspected it into the save draft button. But the result should be the same.

@ArnaudBan
Copy link
Contributor Author

@youknowriad Everything looks good to me. Can we think about mergin this Pull Request now ?

@youknowriad
Copy link
Contributor

Sorry for missing this @ArnaudBan do you think you can rebase the PR?

@ArnaudBan ArnaudBan force-pushed the fix/18674-isDestructive-button branch from a2a7a37 to c826426 Compare July 20, 2020 19:17
@ArnaudBan
Copy link
Contributor Author

@youknowriad I rebase and had to make some changes because variable color add been updated ( seem that you are now using css variable )
Everythings still look fine for me in StoryBook
stroryBookIsDestructiveButton

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

Thanks. This is looking good.

@youknowriad youknowriad merged commit 8d64aa3 into WordPress:master Jul 20, 2020
@github-actions github-actions bot added this to the Gutenberg 8.7 milestone Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Design Feedback Needs general design feedback. [Package] Components /packages/components [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Button Component isDestructive not showing red text-based style as indicated
6 participants