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

Change color on destructive button focus state #44427

Merged
merged 9 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

### Bug Fix

- `Button`: Tweak the destructive button primary, link, and default variants ([#44427](https://github.com/WordPress/gutenberg/pull/44427)).
- `UnitControl`: Fix `disabled` style is overridden by core `form.css` style ([#45250](https://github.com/WordPress/gutenberg/pull/45250)).
- `Button`: Fix RTL alignment for buttons containing an icon and text ([#44787](https://github.com/WordPress/gutenberg/pull/44787)).
- `TabPanel`: Call `onSelect()` on every tab selection, regardless of whether it was triggered by user interaction ([#44028](https://github.com/WordPress/gutenberg/pull/44028)).
Expand Down
69 changes: 16 additions & 53 deletions packages/components/src/button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -171,52 +171,30 @@
/**
* Destructive buttons.
*/

&.is-destructive {
color: $alert-red;
box-shadow: inset 0 0 0 $border-width $alert-red;

&:hover:not(:disabled) {
color: darken($alert-red, 20%);
box-shadow: inset 0 0 0 $border-width darken($alert-red, 20%);
}

&:focus:not(:disabled) {
color: $components-color-accent;
}

&:active:not(:disabled) {
background: $gray-400;
}
}
--wp-components-color-accent: #{$alert-red};
--wp-components-color-accent-darker-10: #{darken($alert-red, 10%)};
--wp-components-color-accent-darker-20: #{darken($alert-red, 20%)};

&.is-destructive.is-primary {
color: #fff;
background: $alert-red;
box-shadow: inset 0 0 0 $border-width $alert-red;

&:hover:not(:disabled) {
color: #fff;
background: darken($alert-red, 20%);
box-shadow: inset 0 0 0 $border-width darken($alert-red, 20%);
}
}
// Only the default variant is styled differently from the non-destructive counterparts.
&:not(.is-primary):not(.is-secondary):not(.is-tertiary):not(.is-link) {
color: $alert-red;
box-shadow: inset 0 0 0 $border-width $alert-red;

&.is-destructive.is-tertiary {
box-shadow: none;
&:hover:not(:disabled) {
color: darken($alert-red, 20%);
}

&:hover:not(:disabled) {
box-shadow: inset 0 0 0 $border-width $alert-red;
color: $alert-red;
}
&:focus:not(:disabled) {
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) $alert-red;
}

&:focus:not(:disabled) {
box-shadow: inset 0 0 0 1px $white, 0 0 0 var(--wp-admin-border-width-focus) $alert-red;
color: $alert-red;
&:active:not(:disabled) {
background: $gray-400;
}
}
}


/**
* Link buttons.
*/
Expand All @@ -241,21 +219,6 @@
&:focus {
border-radius: $radius-block-ui;
}

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

&:active:not(:disabled),
&:hover:not(:disabled) {
color: darken($alert-red, 20%);
background: none;
}

&:focus:not(:disabled) {
color: $components-color-accent;
}
}
}

&:not([aria-disabled="true"]):active {
Expand Down