Skip to content

Commit

Permalink
[EuiIcon, EuiButtonIcon] Improved contrast for named colors (#4049)
Browse files Browse the repository at this point in the history
* Improved constrast for icons named colors

* Changelog

* Improved contrast only for EuiHealth named colors

* Fixing button icon color

* Icons colors with graphic contrast levels. Button icon colors with text contrast levels.

* CL and snapshots

* reverting euiHealth code to use euiIcon color prop

* Reverting euiHealth code

* Better CL
  • Loading branch information
elizabetdev authored Sep 24, 2020
1 parent c94385e commit 4ed1089
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 73 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Improved contrast for `EuiIcon` and `EuiButtonIcon` named colors. This affects `EuiHealth` which uses the `EuiIcon` colors. ([#4049](https://github.com/elastic/eui/pull/4049))
- Added color `accent` to `EuiButtonIcon` ([#4049](https://github.com/elastic/eui/pull/4049))

**Theme: Amsterdam**

- Removed `border-radius` from `EuiCallout` ([#4066](https://github.com/elastic/eui/pull/4066))
Expand Down
1 change: 0 additions & 1 deletion src-docs/src/components/guide_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ $guideZLevelHighest: $euiZLevel9 + 1000;
@if (lightness($euiTextColor) < 50) {
background: $euiColorDarkestShade;
}
padding: $euiSizeL;
}

.guideDemo__icon {
Expand Down
113 changes: 57 additions & 56 deletions src-docs/src/views/button/button_ghost.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
EuiFlexGroup,
EuiFlexItem,
EuiButtonToggle,
EuiPanel,
} from '../../../../src/components';

export default () => {
Expand All @@ -17,67 +18,67 @@ export default () => {
};

return (
<EuiFlexGroup
wrap
gutterSize="s"
alignItems="center"
className="guideDemo__ghostBackground">
<EuiFlexItem grow={false}>
<EuiButton color="ghost" onClick={() => window.alert('Button clicked')}>
Ghost
</EuiButton>
</EuiFlexItem>
<EuiPanel paddingSize="l" className="guideDemo__ghostBackground">
<EuiFlexGroup wrap gutterSize="s" alignItems="center">
<EuiFlexItem grow={false}>
<EuiButton
color="ghost"
onClick={() => window.alert('Button clicked')}>
Ghost
</EuiButton>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiButton
fill
color="ghost"
size="s"
iconType="check"
onClick={() => window.alert('Button clicked')}>
Filled
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
fill
color="ghost"
size="s"
iconType="check"
onClick={() => window.alert('Button clicked')}>
Filled
</EuiButton>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiButtonEmpty
size="s"
color="ghost"
onClick={() => window.alert('Button clicked')}>
small
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty
size="s"
color="ghost"
onClick={() => window.alert('Button clicked')}>
small
</EuiButtonEmpty>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiButtonIcon
size="s"
color="ghost"
iconType="user"
onClick={() => window.alert('Button clicked')}
aria-label="Your account"
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
size="s"
color="ghost"
iconType="user"
onClick={() => window.alert('Button clicked')}
aria-label="Your account"
/>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiButton color="ghost" isLoading fill size="s">
Loading&hellip;
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton color="ghost" isLoading fill size="s">
Loading&hellip;
</EuiButton>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiButton color="ghost" isLoading>
Loading&hellip;
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton color="ghost" isLoading>
Loading&hellip;
</EuiButton>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiButtonToggle
color="ghost"
label="Toggle Me"
fill={toggle0On}
onChange={onToggle0Change}
/>
</EuiFlexItem>
</EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiButtonToggle
color="ghost"
label="Toggle Me"
fill={toggle0On}
onChange={onToggle0Change}
/>
</EuiFlexItem>
</EuiFlexGroup>
</EuiPanel>
);
};
1 change: 1 addition & 0 deletions src-docs/src/views/button/button_icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
const colors = [
'primary',
'text',
'accent',
'subdued',
'success',
'warning',
Expand Down
6 changes: 5 additions & 1 deletion src-docs/src/views/health/health.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { EuiHealth, EuiSpacer } from '../../../../src/components';

export default () => (
<div>
<EuiHealth color="subdued">Unknown</EuiHealth>
<EuiHealth color="subdued">Inactive</EuiHealth>

<EuiSpacer />

<EuiHealth color="primary">Active</EuiHealth>

<EuiSpacer />

Expand Down
13 changes: 10 additions & 3 deletions src-docs/src/views/icon/icon_colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import React from 'react';

import classNames from 'classnames';

import {
EuiFlexGrid,
EuiFlexItem,
Expand All @@ -24,7 +26,7 @@ import {
const iconColors = [
'default',
'primary',
'secondary',
'success',
'accent',
'warning',
'danger',
Expand All @@ -44,9 +46,14 @@ export default () => (
className="guideDemo__icon"
key={iconColor}
style={{ width: '340px' }}>
<EuiPanel>
<EuiPanel
className={classNames({
guideDemo__ghostBackground: iconColor === 'ghost',
})}>
<EuiIcon type="brush" color={iconColor} />
<EuiText size="s">
<EuiText
size="s"
color={iconColor === 'ghost' ? 'ghost' : 'default'}>
<p>{iconColor}</p>
</EuiText>
</EuiPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ exports[`EuiButtonIcon is rendered 1`] = `
/>
`;

exports[`EuiButtonIcon props color accent is rendered 1`] = `
<button
aria-label="button"
class="euiButtonIcon euiButtonIcon--accent"
type="button"
/>
`;

exports[`EuiButtonIcon props color danger is rendered 1`] = `
<button
aria-label="button"
Expand Down
9 changes: 5 additions & 4 deletions src/components/button/button_icon/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Modifier naming and colors.
$euiButtonIconTypes: (
danger: $euiColorDanger,
accent: $euiColorAccentText,
danger: $euiColorDangerText,
disabled: $euiButtonColorDisabledText,
ghost: $euiColorGhost,
primary: $euiColorPrimary,
primary: $euiColorPrimaryText,
subdued: $euiTextSubduedColor,
success: $euiColorSuccess,
success: $euiColorSuccessText,
text: $euiTextColor,
warning: $euiColorWarning,
warning: $euiColorWarningText,
);
2 changes: 2 additions & 0 deletions src/components/button/button_icon/button_icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { IconType, IconSize, EuiIcon } from '../../icon';
import { ButtonSize } from '../button';

export type EuiButtonIconColor =
| 'accent'
| 'danger'
| 'disabled'
| 'ghost'
Expand Down Expand Up @@ -82,6 +83,7 @@ type Props = ExclusiveUnion<
>;

const colorToClassNameMap: { [color in EuiButtonIconColor]: string } = {
accent: 'euiButtonIcon--accent',
danger: 'euiButtonIcon--danger',
disabled: 'euiButtonIcon--disabled',
ghost: 'euiButtonIcon--ghost',
Expand Down
16 changes: 8 additions & 8 deletions src/components/icon/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ $euiIconLoadingOpacity: .05;

// Modifier naming and colors.
$euiIconColors: (
text: $euiTextColor,
subdued: $euiTextSubduedColor,
primary: $euiColorPrimaryText,
secondary: $euiColorSecondaryText,
success: $euiColorSuccessText,
accent: $euiColorAccentText,
warning: $euiColorWarningText,
danger: $euiColorDangerText,
accent: makeGraphicContrastColor($euiColorAccent),
danger: makeGraphicContrastColor($euiColorDanger),
ghost: $euiColorGhost,
primary: makeGraphicContrastColor($euiColorPrimary),
secondary: makeGraphicContrastColor($euiColorSecondary),
success: makeGraphicContrastColor($euiColorSuccess),
subdued: $euiTextSubduedColor,
text: $euiTextColor,
warning: makeGraphicContrastColor($euiColorWarning),
);

$euiIconSizes: (
Expand Down

0 comments on commit 4ed1089

Please sign in to comment.