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

Created a euiPaletteColorBlindBehindText variant of the color blind palette #2750

Merged
merged 17 commits into from
Jan 10, 2020
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Converted `EuiRangeInput` to TypeScript ([#2732](https://github.com/elastic/eui/pull/2732))
- Added `bellSlash` glyph to `EuiIcon` ([#2714](https://github.com/elastic/eui/pull/2714))
- Added `legend` prop to `EuiCheckboxGroup` and `EuiRadioGroup` to add `EuiFieldset` wrappers for title the groups ([#2739](https://github.com/elastic/eui/pull/2739))
- Created a `euiPaletteColorBlindBehindText` variant of the color blind palette ([#2750](https://github.com/elastic/eui/pull/2750))

**Bug fixes**

Expand Down
30 changes: 29 additions & 1 deletion src-docs/src/views/color_palette/color_palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ import {
EuiFlexItem,
EuiTitle,
EuiSpacer,
EuiBadge,
EuiFlexGrid,
} from '../../../../src/components';

import { euiPaletteColorBlind } from '../../../../src/services';
import {
euiPaletteColorBlind,
euiPaletteColorBlindBehindText,
} from '../../../../src/services';
import { ColorPaletteFlexItem, ColorPaletteCopyCode } from './shared';

const customPalettes = [
Expand Down Expand Up @@ -65,5 +70,28 @@ export default () => (
<EuiSpacer size="xl" />
</Fragment>
))}
<EuiTitle size="xxs">
<h3>Behind text variant</h3>
</EuiTitle>
<EuiSpacer size="s" />
<EuiFlexGroup alignItems="center">
<EuiFlexItem grow={false} style={{ maxWidth: 240 }}>
<EuiFlexGrid columns={4} gutterSize="s">
{euiPaletteColorBlindBehindText().map((color, i) => (
<EuiFlexItem key={i}>
<span>
<EuiBadge color={color}>Text</EuiBadge>
</span>
</EuiFlexItem>
))}
</EuiFlexGrid>
</EuiFlexItem>
<EuiFlexItem>
<ColorPaletteCopyCode
textToCopy={'euiPaletteColorBlindBehindText()'}
code={'euiPaletteColorBlindBehindText()'}
/>
</EuiFlexItem>
</EuiFlexGroup>
</Fragment>
);
20 changes: 19 additions & 1 deletion src-docs/src/views/color_palette/color_palette_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import { renderToHtml } from '../../services';

import { GuideSectionTypes } from '../../components';

import { EuiCode, EuiText, EuiSpacer } from '../../../../src/components';
import {
EuiCode,
EuiText,
EuiSpacer,
EuiCallOut,
} from '../../../../src/components';

import ColorPalette from './color_palette';
const colorPaletteSource = require('!!raw-loader!./color_palette');
Expand Down Expand Up @@ -58,6 +63,14 @@ export const ColorPaletteExample = {
more groups of 10 which are alternates of the original. This is
better than allowing the initial set to loop.
</p>
<p>
These colors are meant to be used as graphics and contrasted against
the value of <EuiCode>euiColorEmptyShade</EuiCode> for the current
theme. When placing text on top of these colors, use the{' '}
<EuiCode>euiPaletteColorBlindBehindText()</EuiCode> variant. It is a
brightened version of the base palette to create better contrast
with text.
</p>
</div>
),
demo: <ColorPalette />,
Expand Down Expand Up @@ -88,6 +101,11 @@ export const ColorPaletteExample = {
in the number of steps needed and the function will interpolate
between the colors.
</p>
<EuiCallOut
color="warning"
iconType="accessibility"
title="The palette for status is the only palette that has proper contrast ratios. When using the other palettes, consider adding another form of the data for screen readers."
/>
</div>
),
demo: <ColorPaletteQuant />,
Expand Down
29 changes: 18 additions & 11 deletions src-docs/src/views/combo_box/colors.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,65 @@
import React, { Component } from 'react';

import { EuiComboBox } from '../../../../src/components';
import {
euiPaletteColorBlind,
euiPaletteColorBlindBehindText,
} from '../../../../src/services';

export default class extends Component {
constructor(props) {
super(props);

this.visColors = euiPaletteColorBlind();
this.visColorsBehindText = euiPaletteColorBlindBehindText();

this.options = [
{
label: 'Titan',
'data-test-subj': 'titanOption',
color: 'primary',
color: this.visColorsBehindText[0],
},
{
label: 'Enceladus',
color: 'secondary',
color: this.visColorsBehindText[1],
},
{
label: 'Mimas',
color: '#D36086',
color: this.visColorsBehindText[2],
},
{
label: 'Dione',
color: 'accent',
color: this.visColorsBehindText[3],
},
{
label: 'Iapetus',
color: 'warning',
color: this.visColorsBehindText[4],
},
{
label: 'Phoebe',
color: 'danger',
color: this.visColorsBehindText[5],
},
{
label: 'Rhea',
color: 'default',
color: this.visColorsBehindText[6],
},
{
label:
"Pandora is one of Saturn's moons, named for a Titaness of Greek mythology",
color: '#DA8B45',
color: this.visColorsBehindText[7],
},
{
label: 'Tethys',
color: '#CA8EAE',
color: this.visColorsBehindText[8],
},
{
label: 'Hyperion',
color: '#B9A888',
color: this.visColorsBehindText[9],
},
];

this.state = {
selectedOptions: [this.options[2], this.options[4]],
selectedOptions: [this.options[2], this.options[5]],
};
}

Expand Down
32 changes: 20 additions & 12 deletions src-docs/src/views/combo_box/render_option.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,88 +5,95 @@ import {
EuiHighlight,
EuiHealth,
} from '../../../../src/components';
import {
euiPaletteColorBlind,
euiPaletteColorBlindBehindText,
} from '../../../../src/services';

export default class extends Component {
constructor(props) {
super(props);

this.visColors = euiPaletteColorBlind();
this.visColorsBehindText = euiPaletteColorBlindBehindText();

this.options = [
{
value: {
size: 5,
},
label: 'Titan',
'data-test-subj': 'titanOption',
color: 'primary',
color: this.visColorsBehindText[0],
},
{
value: {
size: 2,
},
label: 'Enceladus',
color: 'secondary',
color: this.visColorsBehindText[1],
},
{
value: {
size: 15,
},
label: 'Mimas',
color: '#D36086',
color: this.visColorsBehindText[2],
},
{
value: {
size: 1,
},
label: 'Dione',
color: 'accent',
color: this.visColorsBehindText[3],
},
{
value: {
size: 8,
},
label: 'Iapetus',
color: 'warning',
color: this.visColorsBehindText[4],
},
{
value: {
size: 2,
},
label: 'Phoebe',
color: 'danger',
color: this.visColorsBehindText[5],
},
{
value: {
size: 33,
},
label: 'Rhea',
color: 'default',
color: this.visColorsBehindText[6],
},
{
value: {
size: 18,
},
label:
"Pandora is one of Saturn's moons, named for a Titaness of Greek mythology",
color: '#DA8B45',
color: this.visColorsBehindText[7],
},
{
value: {
size: 9,
},
label: 'Tethys',
color: '#CA8EAE',
color: this.visColorsBehindText[8],
},
{
value: {
size: 4,
},
label: 'Hyperion',
color: '#B9A888',
color: this.visColorsBehindText[9],
},
];

this.state = {
selectedOptions: [this.options[2], this.options[4]],
selectedOptions: [this.options[2], this.options[5]],
};
}

Expand Down Expand Up @@ -129,8 +136,9 @@ export default class extends Component {

renderOption = (option, searchValue, contentClassName) => {
const { color, label, value } = option;
const dotColor = this.visColors[this.visColorsBehindText.indexOf(color)];
return (
<EuiHealth color={color}>
<EuiHealth color={dotColor}>
<span className={contentClassName}>
<EuiHighlight search={searchValue}>{label}</EuiHighlight>
&nbsp;
Expand Down
Loading