Skip to content

Commit

Permalink
style(button): fix various button bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
tw15egan committed Oct 19, 2020
1 parent 5bba369 commit 832ee56
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 66 deletions.
120 changes: 66 additions & 54 deletions packages/components/src/components/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,57 +18,6 @@
/// @access private
/// @group button
@mixin button {
// button set styles
.#{$prefix}--btn-set {
display: flex;
}

.#{$prefix}--btn-set--stacked {
flex-direction: column;
}

.#{$prefix}--btn-set .#{$prefix}--btn {
width: 100%;
// 196px from design kit
max-width: rem(196px);

&:not(:focus) {
box-shadow: rem(-1px) 0 0 0 $button-separator;
}

&:first-of-type:not(:focus) {
box-shadow: inherit;
}
}

.#{$prefix}--btn-set .#{$prefix}--btn:focus + .#{$prefix}--btn {
box-shadow: inherit;
}

.#{$prefix}--btn-set--stacked .#{$prefix}--btn:not(:focus) {
box-shadow: 0 rem(-1px) 0 0 $button-separator;
}

.#{$prefix}--btn-set--stacked .#{$prefix}--btn:first-of-type:not(:focus) {
box-shadow: inherit;
}

.#{$prefix}--btn-set .#{$prefix}--btn.#{$prefix}--btn--disabled {
box-shadow: rem(-1px) 0 0 0 $disabled-03;

&:first-of-type {
box-shadow: none;
}
}

.#{$prefix}--btn-set--stacked .#{$prefix}--btn.#{$prefix}--btn--disabled {
box-shadow: 0 rem(-1px) 0 0 $disabled-03;

&:first-of-type {
box-shadow: none;
}
}

.#{$prefix}--btn {
@include button-base;
}
Expand Down Expand Up @@ -130,6 +79,7 @@
}

&:active {
background-color: $active-tertiary;
border-color: transparent;
}

Expand All @@ -139,7 +89,7 @@
&.#{$prefix}--btn--disabled,
&.#{$prefix}--btn--disabled:hover,
&.#{$prefix}--btn--disabled:focus {
color: $disabled;
color: $disabled-03;
background: transparent;
outline: none;
}
Expand Down Expand Up @@ -177,7 +127,7 @@
&.#{$prefix}--btn--disabled,
&.#{$prefix}--btn--disabled:hover,
&.#{$prefix}--btn--disabled:focus {
color: $disabled;
color: $disabled-03;
background: transparent;
border-color: transparent;
outline: none;
Expand Down Expand Up @@ -221,11 +171,22 @@
}
}

.#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$prefix}--tooltip__trigger:active:not([disabled]) {
border-color: transparent;
}

.#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$prefix}--tooltip__trigger:focus
svg {
outline-color: transparent;
}

.#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$prefix}--tooltip__trigger[disabled]:hover,
.#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$prefix}--tooltip__trigger[disabled]:focus,
.#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$prefix}--tooltip__trigger[disabled]:active {
cursor: not-allowed;
fill: $disabled-03;
}

.#{$prefix}--btn--icon-only--top {
@include tooltip--trigger('icon', 'top');
@include tooltip--placement('icon', 'top', 'center');
Expand Down Expand Up @@ -282,7 +243,7 @@
.#{$prefix}--btn__icon,
.#{$prefix}--btn.#{$prefix}--btn--icon-only.#{$prefix}--btn--ghost[disabled]:hover
.#{$prefix}--btn__icon {
fill: $disabled-02;
fill: $disabled-03;

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
Expand Down Expand Up @@ -339,6 +300,57 @@

width: rem(150px);
}

// button set styles
.#{$prefix}--btn-set {
display: flex;
}

.#{$prefix}--btn-set--stacked {
flex-direction: column;
}

.#{$prefix}--btn-set .#{$prefix}--btn {
width: 100%;
// 196px from design kit
max-width: rem(196px);

&:not(:focus) {
box-shadow: rem(-1px) 0 0 0 $button-separator;
}

&:first-of-type:not(:focus) {
box-shadow: inherit;
}
}

.#{$prefix}--btn-set .#{$prefix}--btn:focus + .#{$prefix}--btn {
box-shadow: inherit;
}

.#{$prefix}--btn-set--stacked .#{$prefix}--btn:not(:focus) {
box-shadow: 0 rem(-1px) 0 0 $button-separator;
}

.#{$prefix}--btn-set--stacked .#{$prefix}--btn:first-of-type:not(:focus) {
box-shadow: inherit;
}

.#{$prefix}--btn-set .#{$prefix}--btn.#{$prefix}--btn--disabled {
box-shadow: rem(-1px) 0 0 0 $disabled-03;

&:first-of-type {
box-shadow: none;
}
}

.#{$prefix}--btn-set--stacked .#{$prefix}--btn.#{$prefix}--btn--disabled {
box-shadow: 0 rem(-1px) 0 0 $disabled-03;

&:first-of-type {
box-shadow: none;
}
}
}

@include exports('button') {
Expand Down
13 changes: 1 addition & 12 deletions packages/components/src/components/button/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
&:focus {
border-color: $focus;
box-shadow: inset 0 0 0 $button-outline-width $focus,
inset 0 0 0 $button-border-width $ui-02;
inset 0 0 0 $button-border-width $ui-background;

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
Expand All @@ -91,17 +91,6 @@
}
}

&:disabled:hover,
&:disabled:focus,
&:hover.#{$prefix}--btn--disabled,
&:focus.#{$prefix}--btn--disabled {
color: $ui-04;
text-decoration: none;
background-color: $disabled-02;
border-color: $disabled-02;
box-shadow: none;
}

&:active {
background-color: $active-color;
}
Expand Down
6 changes: 6 additions & 0 deletions packages/components/src/globals/scss/_tooltip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@
opacity: 0;
animation: none;
}

&.#{$prefix}--btn--disabled.#{$prefix}--tooltip--a11y::before,
&.#{$prefix}--btn--disabled.#{$prefix}--tooltip--a11y::after,
&.#{$prefix}--btn--disabled .#{$prefix}--assistive-text {
display: none;
}
}

// Tooltip
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/components/Button/Button-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const props = {
'Secondary button (secondary)': 'secondary',
'Tertiary button (tertiary)': 'tertiary',
'Ghost button (ghost)': 'ghost',
'Danger button (danger)': 'danger',
},
'primary'
),
Expand Down

0 comments on commit 832ee56

Please sign in to comment.