Skip to content

Commit

Permalink
Updated color blind viz palette (#2686)
Browse files Browse the repository at this point in the history
* Updated viz color palette

* Use the color palette service for visualization_colors service

* Updated EuiSuggestItem’s tints to just match the whole viz palette sequence

* Revert some token colors to old viz hashes

* Changed color_palette code to use chroma palette functions

* Ammend*

* Clean up color_palette function

* [Breaking] `color_palette` now accepts one parameter that is an array of colors

* [Breaking] EUI palettes are now functions

i.e: `palettes.euiPaletteColorBlind` -> `palettes.euiPaletteColorBlind()`

* Added documentation for custom

* Adding `rotation` and `combined` props to color blind palette

* Updating charts docs examples

* Fix `color_palette.categorical` default

* Finalized palettes

* Finalized palettes

* Added palette switcher to chart example

* Palette again using similar hues as before

* Fixed suggest doc example to match previous

* Fix roundedness of palette display

* typo

* Fix addition of tint10 in new TS file for EuiSuggestItem

* Remove not working props and fix comment

* Update src/services/color/color_palette.ts

Co-Authored-By: Greg Thompson <thompsongl@users.noreply.github.com>

* [Breaking] Remove the `.colors` key from palettes

Now just returns the array of colors

* Change last  prop of palettes.euiPaletteColorBlind to enum of

* Remove `palettes` and just export each named palette

* SLight adjust to status and temp ramp

Co-authored-by: Greg Thompson <thompsongl@users.noreply.github.com>
  • Loading branch information
cchaos and thompsongl authored Jan 3, 2020
1 parent b7cca07 commit a2fbf75
Show file tree
Hide file tree
Showing 48 changed files with 910 additions and 580 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Converted `EuiErrorBoundary` to Typescript ([#2690](https://github.com/elastic/eui/pull/2690))
- Updated `EuiNavDrawer` to accept React fragments ([#2710](https://github.com/elastic/eui/pull/2710))
- Added `EuiFormFieldset` and `EuiFormLegend` components ([#2706](https://github.com/elastic/eui/pull/2706))
- Adjusted colors of color blind viz palette ([#2686](https://github.com/elastic/eui/pull/2686))

**Bug fixes**

Expand All @@ -15,6 +16,12 @@
- Fixed bug in `EuiDataGrid` where resizing columns changed the active DOM element ([#2724](https://github.com/elastic/eui/pull/#2724))
- Fixed position of scrollbar in `EuiCodeBlock` ([#2727](https://github.com/elastic/eui/pull/#2727))

**Breaking changes**

- Changed accepted properties of the `color_palette` method to accept an array of colors ([#2686](https://github.com/elastic/eui/pull/#2686))
- Removed the `palette` export to export each palette function directly ([#2686](https://github.com/elastic/eui/pull/#2686))
- Changed the palette functions to be methods that accept a number of steps and removed `.colors` key ([#2686](https://github.com/elastic/eui/pull/#2686))

## [`17.3.1`](https://github.com/elastic/eui/tree/v17.3.1)

**Bug fixes**
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@
"test-staged"
],
"dependencies": {
"@types/chroma-js": "^1.4.3",
"@types/lodash": "^4.14.116",
"@types/numeral": "^0.0.25",
"@types/react-beautiful-dnd": "^10.1.0",
"classnames": "^2.2.5",
"chroma-js": "^2.0.4",
"highlight.js": "^9.12.0",
"html": "^1.0.0",
"keymirror": "^0.1.1",
Expand Down Expand Up @@ -106,7 +108,6 @@
"chai-webdriverio": "^0.4.3",
"chalk": "^2.4.1",
"chokidar": "^1.7.0",
"chroma-js": "^2.0.4",
"chromedriver": "2.37.0",
"circular-dependency-plugin": "^5.0.2",
"core-js": "^2.5.1",
Expand Down
19 changes: 1 addition & 18 deletions src-docs/src/components/guide_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ $guideZLevelHighest: $euiZLevel9 + 1000;
.guideCharts__customLegend {
font-size: $euiFontSizeXS;
position: absolute;
width: 123px;
width: 93px;
right: 0;
bottom: 0;
padding: $euiSizeXS;
Expand Down Expand Up @@ -229,23 +229,6 @@ $guideZLevelHighest: $euiZLevel9 + 1000;
margin-left: 0;
width: 100%;
}

.euiFlexGroup--responsive > .euiFlexItem.guideColorPalette__swatch {
margin-bottom: 0 !important;

span {
height: $euiSize;
width: $euiSizeL;
}

&:first-child span {
border-radius: $euiBorderRadius $euiBorderRadius 0 0;
}

&:last-child span {
border-radius: 0 0 $euiBorderRadius $euiBorderRadius;
}
}
}

.euiDataGridRowCell--favoriteFranchise {
Expand Down
71 changes: 50 additions & 21 deletions src-docs/src/views/color_palette/color_palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,63 @@ import {
EuiSpacer,
} from '../../../../src/components';

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

const paletteData = palettes;
const paletteNames = Object.keys(paletteData);
const customPalettes = [
{
title: 'Max 10 colors',
palette: euiPaletteColorBlind(),
},
{
title: 'More than 10 colors are needed',
palette: euiPaletteColorBlind(2),
},
{
title:
'Series have multiple metrics and so the colors must coordinate but be distinguishable',
palette: euiPaletteColorBlind(3, 'group'),
},
];

export default () => (
<Fragment>
{paletteNames.map((paletteName, i) => (
<div key={paletteName}>
<EuiTitle key={i} size="xxs">
<h3>{paletteName}</h3>
{customPalettes.map((palette, i) => (
<Fragment key={palette.title}>
<EuiTitle size="xxs">
<h3>{palette.title}</h3>
</EuiTitle>
<EuiSpacer size="s" />
<EuiFlexGroup
gutterSize="none"
alignItems="flexStart"
key={`${paletteName}-${i}`}>
{paletteData[paletteName].colors.map((hexCode, j) => (
<EuiFlexItem
key={`${hexCode}-${j}`}
grow={false}
className={'guideColorPalette__swatch'}>
<span title={hexCode} style={{ backgroundColor: hexCode }} />
</EuiFlexItem>
))}
<EuiFlexGroup alignItems="center">
<EuiFlexItem grow={false} style={{ maxWidth: 240 }}>
<EuiFlexGroup
className="guideColorPalette__swatchHolder"
gutterSize="none"
alignItems="flexStart"
responsive={false}
wrap>
{palette.palette.map(hexCode => (
<ColorPaletteFlexItem
className="guideColorPalette__swatch--notRound"
hexCode={hexCode}
key={hexCode}
/>
))}
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem>
<ColorPaletteCopyCode
textToCopy={`euiPaletteColorBlind(${i > 0 ? i + 1 : ''}${
i > 1 ? ", 'group'" : ''
})`}
code={`euiPaletteColorBlind(${i > 0 ? i + 1 : ''}${
i > 1 ? ", 'group'" : ''
})`}
/>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="l" />
</div>
<EuiSpacer size="xl" />
</Fragment>
))}
</Fragment>
);
115 changes: 57 additions & 58 deletions src-docs/src/views/color_palette/color_palette_custom.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,68 @@
import React, { Fragment } from 'react';
import React, { Fragment, useState } from 'react';

import {
EuiFlexGroup,
EuiFlexItem,
EuiTitle,
EuiRange,
EuiFormRow,
EuiSpacer,
} from '../../../../src/components';

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

const euiColors = palettes.euiPaletteForLightBackground.colors;
const customPalettes = [
[euiPaletteColorBlind()[3]],
[euiPaletteColorBlind()[3], euiPaletteColorBlind()[4]],
[euiPaletteColorBlind()[3], euiPaletteColorBlind()[4]],
];

export default () => (
<Fragment>
<EuiTitle size="xxs">
<h3>For mapping density, low to high</h3>
</EuiTitle>
<EuiSpacer size="s" />
{euiColors.map((color, j) => (
<div key={j}>
<EuiFlexGroup
gutterSize="none"
alignItems="flexStart"
key={`${color}-${j}`}>
{colorPalette('FFFFFF', color, 20).map((hexCode, k) => (
<EuiFlexItem
key={`${hexCode}-${k}`}
grow={false}
className={'guideColorPalette__swatch'}>
<span title={hexCode} style={{ backgroundColor: hexCode }} />
</EuiFlexItem>
))}
export default () => {
const [length, setLength] = useState(10);

const onLengthChange = e => {
setLength(e.currentTarget.value);
};

return (
<Fragment>
<EuiFormRow label="Number of steps" display="columnCompressed">
<EuiRange
value={length}
onChange={onLengthChange}
min={2}
max={20}
compressed
showValue
/>
</EuiFormRow>

<EuiSpacer />

{customPalettes.map((palette, i) => (
<EuiFlexGroup alignItems="center" key={i}>
<EuiFlexItem grow={false}>
<EuiFlexGroup
className="guideColorPalette__swatchHolder"
gutterSize="none"
responsive={false}>
{colorPalette(palette, Number(length), i > 1).map(hexCode => (
<ColorPaletteFlexItem hexCode={hexCode} key={hexCode} />
))}
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem>
<ColorPaletteCopyCode
textToCopy={`colorPalette([], ${length}${
i > 1 ? ', true' : ''
});`}
code={`colorPalette([${palette}], ${length}${
i > 1 ? ', true' : ''
});`}
/>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="m" />
</div>
))}
<EuiSpacer size="l" />
<EuiTitle size="xxs">
<h3>For communicating state, trending negative</h3>
</EuiTitle>
<EuiSpacer size="s" />
<EuiFlexGroup gutterSize="none" alignItems="flexStart">
{colorPalette('#FBEFD3', '#BD4C48').map((hexCode, l) => (
<EuiFlexItem
key={`${hexCode}-${l}`}
grow={false}
className={'guideColorPalette__swatch'}>
<span title={hexCode} style={{ backgroundColor: hexCode }} />
</EuiFlexItem>
))}
</EuiFlexGroup>
<EuiSpacer size="l" />
<EuiTitle size="xxs">
<h3>For communicating state, trending positive</h3>
</EuiTitle>
<EuiSpacer size="s" />
<EuiFlexGroup gutterSize="none" alignItems="flexStart">
{colorPalette('#FFFFE0', '#017F75').map((hexCode, l) => (
<EuiFlexItem
key={`${hexCode}-${l}`}
grow={false}
className={'guideColorPalette__swatch'}>
<span title={hexCode} style={{ backgroundColor: hexCode }} />
</EuiFlexItem>
))}
</EuiFlexGroup>
</Fragment>
);
</Fragment>
);
};
Loading

0 comments on commit a2fbf75

Please sign in to comment.