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

[Amsterdam] Updating button styles #2874

Merged
merged 28 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
39f850e
Saturating colors and providing contrast mixin for text.
daveyholler Feb 19, 2020
3752715
Adding text-specific color variables and updating components to use t…
daveyholler Feb 20, 2020
c500652
Adding a danger text color as well.
daveyholler Feb 20, 2020
a5b5ec7
Update some more downstream components
Feb 21, 2020
e91899e
Added toggle to color guidelines to show text variant in amsterdam-li…
Feb 21, 2020
31a0dcf
Updating button styles.
daveyholler Feb 19, 2020
1207429
Updating button styles.
daveyholler Feb 19, 2020
f31068a
Figuring out a better way to override
Feb 20, 2020
e272091
Fixing the ghost colored disabled buttons
Feb 20, 2020
57665dc
Woking on getting the colors and states right.
daveyholler Feb 25, 2020
d976768
Removing rogue mixin import.
daveyholler Feb 25, 2020
a470496
Merge remote-tracking branch 'upstream/master' into am/updating-buttons
daveyholler Feb 25, 2020
eb1601c
Merge conflict in colors.js.
daveyholler Feb 25, 2020
f16ef46
CL
daveyholler Feb 26, 2020
f92986c
Picking up requested changes.
daveyholler Feb 26, 2020
f176d83
moving the button icon color map into global variables.
daveyholler Feb 26, 2020
4edd570
Removing text button style from docs example and setting up deprecation
Feb 26, 2020
c020b01
Added `$euiButtonColorDisabledText` and refactored for its usage
Feb 26, 2020
a7cbf02
Merge branch 'master' into am/updating-buttons
cchaos Feb 27, 2020
6c65e3c
A little cleanup
Feb 27, 2020
f27a937
cl
cchaos Feb 27, 2020
bafd0f7
addressing button states in dark mode.
daveyholler Feb 27, 2020
74cdbfa
Changing transparency instead of shade
Feb 27, 2020
dcaab4c
Fix contrast of filled ghost disabled button
Feb 28, 2020
8575def
Temporarily fix context menu
Feb 28, 2020
a260cb3
Merge branch 'master' into am/updating-buttons
cchaos Feb 28, 2020
54a5eb2
Revert "Temporarily fix context menu"
Feb 28, 2020
6656f3a
Merge branch 'master' into am/updating-buttons
cchaos Mar 4, 2020
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
**Bug fixes**

- Fixed `EuiTitle` not rendering child classes ([#2926](https://github.com/elastic/eui/pull/2926))
- Fixed `EuiButton` and other textual components' disabled contrast ([#2874](https://github.com/elastic/eui/pull/2874))

**Theme: Amsterdam**

- Buttons have a new visual style ([#2874](https://github.com/elastic/eui/pull/2874))
- Altered `secondary`, `accent` colors to be more saturated ([#2873](https://github.com/elastic/eui/pull/2873))


Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/views/button/button_ghost.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class extends Component {
<EuiButton
color="ghost"
onClick={() => window.alert('Button clicked')}>
Primary
Ghost
</EuiButton>
</EuiFlexItem>

Expand Down
2 changes: 1 addition & 1 deletion src/components/badge/_badge.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// sass-lint:disable-block no-important
// Using !important to override inline styles
background-color: $euiButtonColorDisabled !important;
color: $euiColorEmptyShade !important;
color: $euiButtonColorDisabledText !important;
}

&:focus-within {
Expand Down
37 changes: 23 additions & 14 deletions src/components/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
}

&:disabled {
color: $euiButtonColorDisabled;
color: $euiButtonColorDisabledText;
border-color: $euiButtonColorDisabled;
pointer-events: none;

Expand All @@ -53,8 +53,13 @@
cursor: not-allowed;
}

.euiButton__spinner {
border-color: euiLoadingSpinnerBorderColors(currentColor);
}

&.euiButton--fill {
color: $euiColorGhost;
// Only increase the contrast of background color to text to 2.0 for disabled
color: makeHighContrastColor($euiButtonColorDisabled, $euiButtonColorDisabled, 2);
background-color: $euiButtonColorDisabled;
border-color: $euiButtonColorDisabled;

Expand Down Expand Up @@ -85,7 +90,7 @@
color: $euiTextColor;
} @else {
// Other colors need to check their contrast against the page background color.
color: makeHighContrastColor($color, $euiColorEmptyShade);
color: makeHighContrastColor($color, $euiPageBackgroundColor);
}

border-color: $color;
Expand All @@ -106,10 +111,6 @@
border-color: darken($color, 5%);
}
}

&:disabled .euiButton__spinner {
border-color: euiLoadingSpinnerBorderColors(transparentize($fillTextColor, .3));
}
}

&:enabled {
Expand All @@ -133,14 +134,22 @@
}
}
}
}
}

&:disabled,
&:disabled:hover,
&:disabled:focus {
@if ($name == 'ghost') {
@include euiSlightShadow($euiColorInk);
}
}
// Fix ghost/disabled look specifically
.euiButton:disabled.euiButton--ghost {
&,
&:hover,
&:focus {
@include euiSlightShadow($euiColorInk);
color: $euiButtonColorGhostDisabled;
border-color: $euiButtonColorGhostDisabled;
}

&.euiButton--fill {
background-color: $euiButtonColorGhostDisabled;
color: $euiColorInk;
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/components/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export type ButtonColor =
| 'warning'
| 'danger'
| 'ghost'
/**
* Set for deprecation 2/26/20
* This color button can easily be confused with disabled, it should not be used
*/
| 'text';

export type ButtonSize = 's' | 'm';
Expand Down Expand Up @@ -61,6 +65,9 @@ export interface EuiButtonProps extends CommonProps {
iconType?: IconType;
iconSide?: ButtonIconSide;
fill?: boolean;
/**
* `text` color is set for deprecation
*/
color?: ButtonColor;
size?: ButtonSize;
isLoading?: boolean;
Expand Down
6 changes: 3 additions & 3 deletions src/components/button/button_empty/_button_empty.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
}

&:disabled {
color: $euiButtonColorDisabled;
color: $euiButtonColorDisabledText;
pointer-events: none;

.euiButtonEmpty__content {
Expand All @@ -50,7 +50,7 @@
}

.euiButtonEmpty__icon {
fill: $euiButtonColorDisabled;
fill: currentColor;
}

&:focus {
Expand All @@ -68,7 +68,7 @@
$euiButtonEmptyTypes: (
primary: $euiColorPrimary,
danger: $euiColorDanger,
disabled: tintOrShade($euiTextColor, 70%, 80%),
disabled: $euiButtonColorDisabledText,
ghost: $euiColorGhost,
text: $euiTextColor,
);
Expand Down
14 changes: 1 addition & 13 deletions src/components/button/button_icon/_button_icon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}

&:disabled {
color: $euiButtonColorDisabled;
color: $euiButtonColorDisabledText;
pointer-events: none;

.euiButtonIcon__icon {
Expand All @@ -34,18 +34,6 @@
}
}

// Modifier naming and colors.
$euiButtonIconTypes: (
danger: $euiColorDanger,
disabled: $euiButtonColorDisabled,
ghost: $euiColorGhost,
primary: $euiColorPrimary,
subdued: $euiColorDarkShade,
success: $euiColorSuccess,
text: $euiTextColor,
warning: $euiColorWarning,
);

// Create button modifiders based upon the map.
@each $name, $color in $euiButtonIconTypes {
.euiButtonIcon--#{$name} {
Expand Down
1 change: 1 addition & 0 deletions src/components/button/button_icon/_index.scss
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import 'variables';
@import 'button_icon';
11 changes: 11 additions & 0 deletions src/components/button/button_icon/_variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Modifier naming and colors.
$euiButtonIconTypes: (
danger: $euiColorDanger,
disabled: $euiButtonColorDisabledText,
ghost: $euiColorGhost,
primary: $euiColorPrimary,
subdued: $euiColorDarkShade,
success: $euiColorSuccess,
text: $euiTextColor,
warning: $euiColorWarning,
);
2 changes: 1 addition & 1 deletion src/components/context_menu/_context_menu_item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}

&.euiContextMenuItem-isDisabled {
color: $euiButtonColorDisabled;
color: $euiButtonColorDisabledText;
cursor: default;

&:hover,
Expand Down
2 changes: 1 addition & 1 deletion src/components/facet/_facet_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}

&:disabled {
color: $euiButtonColorDisabled;
color: $euiButtonColorDisabledText;
pointer-events: none;

.euiFacetButton__content {
Expand Down
2 changes: 1 addition & 1 deletion src/components/filter_group/_filter_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
font-size: $euiFontSizeS;

&:disabled {
color: $euiButtonColorDisabled;
color: $euiButtonColorDisabledText;
pointer-events: none;

.euiFilterButton__notification {
Expand Down
4 changes: 2 additions & 2 deletions src/components/key_pad_menu/_key_pad_menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
}

&:disabled {
color: $euiButtonColorDisabled;
color: $euiButtonColorDisabledText;
cursor: not-allowed;

.euiKeyPadMenuItem__icon {
filter: grayscale(100%);

svg * { // sass-lint:disable-line nesting-depth
fill: $euiButtonColorDisabled;
fill: $euiButtonColorDisabledText;
}
}

Expand Down
1 change: 0 additions & 1 deletion src/global_styling/functions/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,3 @@
@function makeGraphicContrastColor($color, $background: $euiPageBackgroundColor) {
@return makeHighContrastColor($color, $background, 3);
}

48 changes: 35 additions & 13 deletions src/global_styling/mixins/_button.scss
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
@mixin euiButton {
@include euiFont;
@include euiFontSize;

// Provides a solid reset and base for handling sizing layout
// Does not include any visual styles
@mixin euiButtonBase {
display: inline-block;
appearance: none;
cursor: pointer;
height: $euiButtonHeight;
line-height: $euiButtonHeight; // prevents descenders from getting cut off
text-decoration: none;
border: solid 1px transparent;
text-align: center;
transition: all $euiAnimSpeedNormal $euiAnimSlightBounce;
white-space: nowrap;
max-width: 100%;
vertical-align: middle;
}

// Adds the focus (and hover) animation for translating up 1px
@mixin euiButtonFocus {
transition: all $euiAnimSpeedNormal ease-in-out;

&:hover:not(:disabled) {
transform: translateY(-1px);
}

&:hover:not(:disabled),
&:focus {
text-decoration: underline;
}

&:focus {
animation: euiButtonActive $euiAnimSpeedNormal $euiAnimSlightBounce;
}
Expand All @@ -33,9 +29,35 @@
}
}

// All of the button base styles including the base, focus, font, and initial styles
// Does not include individual alterations like color or sizes
@mixin euiButton {
@include euiButtonBase;
@include euiFont;
@include euiFontSize;

text-decoration: none;
border: solid 1px transparent;

// sass-lint:disable mixins-before-declarations
// focus states should come after all default styles
@include euiButtonFocus;

&:hover:not(:disabled),
&:focus {
text-decoration: underline;
}
}

// Correctly lays out the contents of a button when using the proper dom elements of:
// <button>
// <span className="__content">
// {icon/spinner}
// {child}
// </span>
// </button>
// 1. Apply margin to all but last item in the flex.
// 2. Margin gets flipped because of the row-reverse.

@mixin euiButtonContent($isReverse: false) {
height: 100%;
width: 100%;
Expand Down
3 changes: 3 additions & 0 deletions src/global_styling/variables/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ $euiButtonHeight: $euiSizeXXL !default;
$euiButtonHeightSmall: $euiSizeXL !default;

$euiButtonColorDisabled: tintOrShade($euiTextColor, 70%, 70%) !default;
// Only increase the contrast of background color to text to 2.0 for disabled
$euiButtonColorDisabledText: makeHighContrastColor($euiButtonColorDisabled, $euiPageBackgroundColor, 2) !default;
$euiButtonColorGhostDisabled: lightOrDarkTheme($euiColorDarkShade, $euiColorLightShade) !default;
$euiButtonToggleBorderColor: $euiColorLightShade !default;

// Modifier naming and colors.
Expand Down
4 changes: 4 additions & 0 deletions src/theme_amsterdam_dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@

// Packages
@import '../packages/index';

// Component overrides
// Comes after the component import and overrides via cascade
@import 'themes/eui-amsterdam/overrides/index';
4 changes: 4 additions & 0 deletions src/theme_amsterdam_light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@

// Packages
@import '../packages/index';

// Component overrides
// Comes after the component import and overrides via cascade
@import 'themes/eui-amsterdam/overrides/index';
1 change: 1 addition & 0 deletions src/themes/eui-amsterdam/global_styling/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

// Variables come next, and are used in some mixins
@import '../../../global_styling/variables/index';
@import 'variables/index';

// Mixins provide generic code expansion through helpers
@import '../../../global_styling/mixins/index';
Expand Down
18 changes: 18 additions & 0 deletions src/themes/eui-amsterdam/global_styling/mixins/_button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@mixin euiButton {
@include euiButtonBase;
@include euiFont;
@include euiFontSize;

font-weight: $euiFontWeightMedium;
text-decoration: none;
transition: all $euiAnimSpeedNormal $euiAnimSlightBounce;

// sass-lint:disable mixins-before-declarations
// focus states should come after all default styles
@include euiButtonFocus;

&:hover:not(:disabled),
&:focus {
text-decoration: underline;
}
}
1 change: 1 addition & 0 deletions src/themes/eui-amsterdam/global_styling/mixins/_index.scss
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import 'panel';
@import 'button';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$euiBorderRadius: $euiSizeS * .75;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$euiButtonColorDisabled: tintOrShade($euiTextColor, 75%, 70%);
2 changes: 2 additions & 0 deletions src/themes/eui-amsterdam/global_styling/variables/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import 'buttons';
@import 'borders';
Loading