Skip to content

Commit

Permalink
feat(button): add tertiary and ghost danger buttons (#7087)
Browse files Browse the repository at this point in the history
* refactor(button): rename danger color token to danger-01

* refactor(button): update documentation to include danger-01 token

* feat(colors): add danger-02 color token

* style(button): add tertiary danger button styles

* style(button): add ghost danger button styles

* docs(button): update Button story to include new danger button kinds

* test(button): add tests for tertiary and ghost danger button variants

* docs(button): update button sass documentation

* refactor(button): consolidate all danger button variants to one story

* docs(button): update button sass documentation

* refactor(button): re-word storybook danger button text

* docs(button): update button docs to include new danger variant examples
  • Loading branch information
AlexanderLyon authored Oct 27, 2020
1 parent 0481dbc commit 262bb9b
Show file tree
Hide file tree
Showing 13 changed files with 350 additions and 59 deletions.
140 changes: 125 additions & 15 deletions packages/components/docs/sass.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@
- [✅inverse-support-03 [variable]](#inverse-support-03-variable)
- [✅inverse-support-04 [variable]](#inverse-support-04-variable)
- [✅overlay-01 [variable]](#overlay-01-variable)
- [✅danger [variable]](#danger-variable)
- [✅danger-01 [variable]](#danger-01-variable)
- [✅danger-02 [variable]](#danger-02-variable)
- [✅focus [variable]](#focus-variable)
- [✅inverse-focus-ui [variable]](#inverse-focus-ui-variable)
- [✅hover-primary [variable]](#hover-primary-variable)
Expand Down Expand Up @@ -4212,7 +4213,8 @@ Define theme variables from a map of tokens
$inverse-support-03: map-get($theme, 'inverse-support-03') !global;
$inverse-support-04: map-get($theme, 'inverse-support-04') !global;
$overlay-01: map-get($theme, 'overlay-01') !global;
$danger: map-get($theme, 'danger') !global;
$danger-01: map-get($theme, 'danger-01') !global;
$danger-02: map-get($theme, 'danger-02') !global;
$focus: map-get($theme, 'focus') !global;
$inverse-focus-ui: map-get($theme, 'inverse-focus-ui') !global;
$hover-primary: map-get($theme, 'hover-primary') !global;
Expand Down Expand Up @@ -4447,9 +4449,13 @@ Define theme variables from a map of tokens
--#{$custom-property-prefix}-overlay-01,
map-get($theme, 'overlay-01')
) !global;
$danger: var(
--#{$custom-property-prefix}-danger,
map-get($theme, 'danger')
$danger-01: var(
--#{$custom-property-prefix}-danger-01,
map-get($theme, 'danger-01')
) !global;
$danger-02: var(
--#{$custom-property-prefix}-danger-02,
map-get($theme, 'danger-02')
) !global;
$focus: var(
--#{$custom-property-prefix}-focus,
Expand Down Expand Up @@ -4978,8 +4984,14 @@ Define theme variables from a map of tokens
@include custom-property('overlay-01', map-get($theme, 'overlay-01'));
}

@if should-emit($theme, $parent-carbon-theme, 'danger', $emit-difference) {
@include custom-property('danger', map-get($theme, 'danger'));
@if should-emit($theme, $parent-carbon-theme, 'danger-01', $emit-difference)
{
@include custom-property('danger-01', map-get($theme, 'danger-01'));
}

@if should-emit($theme, $parent-carbon-theme, 'danger-02', $emit-difference)
{
@include custom-property('danger-02', map-get($theme, 'danger-02'));
}

@if should-emit($theme, $parent-carbon-theme, 'focus', $emit-difference) {
Expand Down Expand Up @@ -6018,7 +6030,8 @@ Define theme variables from a map of tokens
- [inverse-support-03 [variable]](#inverse-support-03-variable)
- [inverse-support-04 [variable]](#inverse-support-04-variable)
- [overlay-01 [variable]](#overlay-01-variable)
- [danger [variable]](#danger-variable)
- [danger-01 [variable]](#danger-01-variable)
- [danger-02 [variable]](#danger-02-variable)
- [focus [variable]](#focus-variable)
- [inverse-focus-ui [variable]](#inverse-focus-ui-variable)
- [hover-primary [variable]](#hover-primary-variable)
Expand Down Expand Up @@ -6181,6 +6194,7 @@ $carbon--theme--g90: map-merge(
inverse-support-02: #24a148,
inverse-support-04: #0f62fe,
overlay-01: rgba(22, 22, 22, 0.7),
danger-02: #ff8389,
focus: #ffffff,
inverse-focus-ui: #0f62fe,
hover-primary-text: #a6c8ff,
Expand Down Expand Up @@ -6258,6 +6272,7 @@ $carbon--theme--g100: map-merge(
inverse-support-02: #24a148,
inverse-support-04: #0f62fe,
overlay-01: rgba(22, 22, 22, 0.7),
danger-02: #fa4d56,
focus: #ffffff,
inverse-focus-ui: #0f62fe,
hover-primary-text: #a6c8ff,
Expand Down Expand Up @@ -6419,7 +6434,8 @@ $carbon--theme: (
inverse-support-03: if(global-variable-exists('inverse-support-03'), $inverse-support-03, map-get($carbon--theme--white, 'inverse-support-03')),
inverse-support-04: if(global-variable-exists('inverse-support-04'), $inverse-support-04, map-get($carbon--theme--white, 'inverse-support-04')),
overlay-01: if(global-variable-exists('overlay-01'), $overlay-01, map-get($carbon--theme--white, 'overlay-01')),
danger: if(global-variable-exists('danger'), $danger, map-get($carbon--theme--white, 'danger')),
danger-01: if(global-variable-exists('danger-01'), $danger-01, map-get($carbon--theme--white, 'danger-01')),
danger-02: if(global-variable-exists('danger-02'), $danger-02, map-get($carbon--theme--white, 'danger-02')),
focus: if(global-variable-exists('focus'), $focus, map-get($carbon--theme--white, 'focus')),
inverse-focus-ui: if(global-variable-exists('inverse-focus-ui'), $inverse-focus-ui, map-get($carbon--theme--white, 'inverse-focus-ui')),
hover-primary: if(global-variable-exists('hover-primary'), $hover-primary, map-get($carbon--theme--white, 'hover-primary')),
Expand Down Expand Up @@ -7623,18 +7639,42 @@ $overlay-01: if(
- [modal [mixin]](#modal-mixin)
- [carbon-side-nav [mixin]](#carbon-side-nav-mixin)

### ✅danger [variable]
### ✅danger-01 [variable]

<details>
<summary>Source code</summary>

```scss
$danger-01: if(
global-variable-exists('carbon--theme') and map-has-key(
$carbon--theme,
'danger-01'
),
map-get($carbon--theme, 'danger-01'),
#da1e28
);
```

</details>

- **Group**: [@carbon/themes](#carbonthemes)
- **Type**: `{undefined}`
- **Used by**:
- [carbon--theme [mixin]](#carbon--theme-mixin)
- [button [mixin]](#button-mixin)

### ✅danger-02 [variable]

<details>
<summary>Source code</summary>

```scss
$danger: if(
$danger-02: if(
global-variable-exists('carbon--theme') and map-has-key(
$carbon--theme,
'danger'
'danger-02'
),
map-get($carbon--theme, 'danger'),
map-get($carbon--theme, 'danger-02'),
#da1e28
);
```
Expand Down Expand Up @@ -14188,7 +14228,7 @@ Button styles

.#{$prefix}--btn--danger {
@include button-theme(
$danger,
$danger-01,
transparent,
$text-04,
$hover-danger,
Expand All @@ -14199,6 +14239,75 @@ Button styles
&:hover {
color: $text-04;
}

&-tertiary {
@include button-theme(
transparent,
$danger-02,
$danger-02,
$hover-danger,
currentColor,
$active-danger
);

&:hover {
color: $text-04;
border-color: $hover-danger;
}

&:focus {
color: $text-04;
background-color: $danger-01;
}

&:active {
color: $text-04;
border-color: $active-danger;
}
}

&-ghost {
@include button-theme(
transparent,
transparent,
$danger-02,
$hover-danger,
currentColor,
$active-danger
);

padding: $button-padding-ghost;

.#{$prefix}--btn__icon {
position: static;
margin-left: $carbon--spacing-03;
}

&:hover,
&:active {
color: $text-04;
}

&:disabled,
&:hover:disabled,
&:focus:disabled,
&.#{$prefix}--btn--disabled,
&.#{$prefix}--btn--disabled:hover,
&.#{$prefix}--btn--disabled:focus {
color: $disabled;
background: transparent;
border-color: transparent;
outline: none;
}

&.#{$prefix}--btn--sm {
padding: $button-padding-ghost-sm;
}

&.#{$prefix}--btn--field {
padding: $button-padding-ghost-field;
}
}
}

.#{$prefix}--btn--sm {
Expand Down Expand Up @@ -14297,9 +14406,10 @@ Button styles
- [hover-primary-text [variable]](#hover-primary-text-variable)
- [icon-01 [variable]](#icon-01-variable)
- [focus [variable]](#focus-variable)
- [danger [variable]](#danger-variable)
- [danger-01 [variable]](#danger-01-variable)
- [hover-danger [variable]](#hover-danger-variable)
- [active-danger [variable]](#active-danger-variable)
- [danger-02 [variable]](#danger-02-variable)
- [button-separator [variable]](#button-separator-variable)

### ❌button-base [mixin]
Expand Down
71 changes: 70 additions & 1 deletion packages/components/src/components/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@

.#{$prefix}--btn--danger {
@include button-theme(
$danger,
$danger-01,
transparent,
$text-04,
$hover-danger,
Expand All @@ -282,6 +282,75 @@
&:hover {
color: $text-04;
}

&-tertiary {
@include button-theme(
transparent,
$danger-02,
$danger-02,
$hover-danger,
currentColor,
$active-danger
);

&:hover {
color: $text-04;
border-color: $hover-danger;
}

&:focus {
color: $text-04;
background-color: $danger-01;
}

&:active {
color: $text-04;
border-color: $active-danger;
}
}

&-ghost {
@include button-theme(
transparent,
transparent,
$danger-02,
$hover-danger,
currentColor,
$active-danger
);

padding: $button-padding-ghost;

.#{$prefix}--btn__icon {
position: static;
margin-left: $carbon--spacing-03;
}

&:hover,
&:active {
color: $text-04;
}

&:disabled,
&:hover:disabled,
&:focus:disabled,
&.#{$prefix}--btn--disabled,
&.#{$prefix}--btn--disabled:hover,
&.#{$prefix}--btn--disabled:focus {
color: $disabled;
background: transparent;
border-color: transparent;
outline: none;
}

&.#{$prefix}--btn--sm {
padding: $button-padding-ghost-sm;
}

&.#{$prefix}--btn--field {
padding: $button-padding-ghost-field;
}
}
}

.#{$prefix}--btn--sm {
Expand Down
Loading

0 comments on commit 262bb9b

Please sign in to comment.