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

[EuiIcon, EuiButtonIcon] Improved contrast for named colors #4049

Merged
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
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;
cchaos marked this conversation as resolved.
Show resolved Hide resolved
}

.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">
cchaos marked this conversation as resolved.
Show resolved Hide resolved
<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
cchaos marked this conversation as resolved.
Show resolved Hide resolved
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'
elizabetdev marked this conversation as resolved.
Show resolved Hide resolved
| '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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these all the same values used in EuiHealth? If so, I think it's ok to let the EuiIcon color handle the coloring without actually needing to re-apply the coloring in EuiHealth specifically.

Meaning passing color="accent" from EuiHealth to the embedded EuiIcon will produce the same rendered color (makeHighContrast), so why not just complicate it less.

Though there can be the argument that also having the custom coloring in EuiHealth helps ensure EuiHealth can maintain it's own coloring.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted the EuiHealth code to what it was originally. This way the EuiIcon is handling the color for it.

This was actually how I started the PR by just changing the EuiIcon colors so I believe it's the best way.

);

$euiIconSizes: (
Expand Down