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

Use culturally inclusive palette names #7570

Merged
merged 6 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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 changelogs/upcoming/7570.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Deprecations**

- Deprecated `euiPalettePositive` and `euiPaletteNegative` in favour of a more culturally inclusive `euiPaletteGreen` and `euiPaletteRed` ([#7570](https://github.com/elastic/eui/pull/7570))
cee-chen marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ import {
euiPaletteForTemperature,
euiPaletteCool,
euiPaletteWarm,
euiPaletteNegative,
euiPalettePositive,
euiPaletteRed,
euiPaletteGreen,
euiPaletteGray,
} from '../../../../src/services';
const paletteData = {
euiPaletteForStatus,
euiPaletteForTemperature,
euiPaletteComplementary,
euiPaletteNegative,
euiPalettePositive,
euiPaletteRed,
euiPaletteGreen,
euiPaletteCool,
euiPaletteWarm,
euiPaletteGray,
Expand Down
8 changes: 4 additions & 4 deletions src-docs/src/views/color_picker/color_palette_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
euiPaletteForStatus,
euiPaletteForTemperature,
euiPaletteComplementary,
euiPaletteNegative,
euiPalettePositive,
euiPaletteRed,
euiPaletteGreen,
euiPaletteCool,
euiPaletteWarm,
euiPaletteGray,
Expand Down Expand Up @@ -50,8 +50,8 @@ const paletteData = {
euiPaletteForStatus,
euiPaletteForTemperature,
euiPaletteComplementary,
euiPaletteNegative,
euiPalettePositive,
euiPaletteRed,
euiPaletteGreen,
euiPaletteCool,
euiPaletteWarm,
euiPaletteGray,
Expand Down
6 changes: 3 additions & 3 deletions src-docs/src/views/elastic_charts/accessibility_bullet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Chart, Settings, Goal } from '@elastic/charts';
import { EuiSpacer, EuiTitle } from '../../../../src/components';
import {
htmlIdGenerator,
euiPalettePositive,
euiPaletteGreen,
colorPalette,
euiPaletteGray,
useEuiTheme,
Expand All @@ -28,8 +28,8 @@ export default () => {
const bandLabels = ['freezing', 'cold', 'brisk', 'warm', 'hot'];
const bands = [0, 100, 125, 150, 250];

let spectrum = euiPalettePositive(5);
// For dark theme, start with the brightest positive color and create a palette that goes to dark gray instead of light
let spectrum = euiPaletteGreen(5);
// For dark theme, start with the brightest green color and create a palette that goes to dark gray instead of light
if (isDarkTheme) {
spectrum = colorPalette([spectrum[4], euiPaletteGray(5)[4]], 5).reverse();
}
Expand Down
4 changes: 2 additions & 2 deletions src-docs/src/views/elastic_charts/goal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
htmlIdGenerator,
useEuiTheme,
useIsWithinBreakpoints,
euiPalettePositive,
euiPaletteGreen,
} from '../../../../src/services';
import { EuiFlexGrid, EuiFlexItem } from '../../../../src/components/flex';

Expand All @@ -27,7 +27,7 @@ export const GoalChart = () => {
const bandLabels = ['', 'freezing', 'cold', 'warm', 'hot'];
const bands = [-10, 0, 15, 25, 40];

const spectrum = euiPalettePositive(5);
const spectrum = euiPaletteGreen(5);
const opacityMapHex: Record<number, string> = {
'-10': spectrum[0],
'0': spectrum[1],
Expand Down
8 changes: 4 additions & 4 deletions src-docs/src/views/elastic_charts/theming.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import {
euiPaletteForTemperature,
euiPaletteCool,
euiPaletteWarm,
euiPaletteNegative,
euiPalettePositive,
euiPaletteRed,
euiPaletteGreen,
euiPaletteGray,
useEuiTheme,
} from '../../../../src/services';
Expand All @@ -39,8 +39,8 @@ const paletteData = {
euiPaletteForStatus,
euiPaletteForTemperature,
euiPaletteComplementary,
euiPaletteNegative,
euiPalettePositive,
euiPaletteRed,
euiPaletteGreen,
euiPaletteCool,
euiPaletteWarm,
euiPaletteGray,
Expand Down
4 changes: 2 additions & 2 deletions src-docs/src/views/elastic_charts/theming_categorical.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
import { CHART_COMPONENTS, type ChartType, ChartCard } from './shared';
import {
euiPaletteColorBlind,
euiPalettePositive,
euiPaletteGreen,
euiPaletteForStatus,
euiPaletteGray,
useEuiTheme,
Expand Down Expand Up @@ -118,7 +118,7 @@ export default () => {
};

const createQuantityChart = (numCharts: number) => {
const vizColors = euiPalettePositive(numCharts);
const vizColors = euiPaletteGreen(numCharts);

// convert series labels to percentages
const dg = new DataGenerator();
Expand Down
7 changes: 3 additions & 4 deletions src-docs/src/views/elastic_charts/theming_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ const euiTheme = isDarkTheme ? EUI_CHARTS_THEME_DARK.theme : EUI_CHARTS_THEME_LI
</p>

<EuiCodeBlock language="javascript" isCopyable fontSize="s">
{`import { euiPalettePositive } from '../../../../src/services';
{`import { euiPaletteGreen } from '../../../../src/services';

const customColors = {
colors: {
vizColors: euiPalettePositive(5),
vizColors: euiPaletteGreen(5),
},
};

Expand Down Expand Up @@ -134,8 +134,7 @@ const customColors = {
a single color that spans from light colors for low amounts to dark
colors for high amounts. If the data signifies{' '}
<strong>trends</strong>, use a two-color divergent scheme, with the
darkest colors at the extremes. Remember that red means bad/negative
and green is good/positive.
darkest colors at the extremes.
</p>
<p>
Whan signifying quantities, group values into intervals instead of a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import {
euiPaletteForStatus,
euiPaletteForTemperature,
euiPaletteGray,
euiPaletteNegative,
euiPalettePositive,
euiPaletteRed,
euiPaletteGreen,
euiPaletteWarm,
} from '../../../../src/services';
import { getDefaultEuiMarkdownUiPlugins } from '../../../../src/components/markdown_editor';
Expand All @@ -52,8 +52,8 @@ const paletteData = {
euiPaletteForStatus,
euiPaletteForTemperature,
euiPaletteComplementary,
euiPaletteNegative,
euiPalettePositive,
euiPaletteRed,
euiPaletteGreen,
euiPaletteCool,
euiPaletteWarm,
euiPaletteGray,
Expand Down
39 changes: 24 additions & 15 deletions src/services/color/eui_palettes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,30 +141,30 @@ export const euiPaletteForDarkBackground = function (): EuiPalette {
return ['#1BA9F5', '#7DE2D1', '#F990C0', '#F66', '#FFCE7A'];
};

const positiveColor: HEX = '#209280';
const negativeColor: HEX = '#CC5642';
const lightNegativeColor: HEX = euiPaletteColorBlind()[9];
const greenColor: HEX = '#209280';
const redColor: HEX = '#CC5642';
const lightRedColor: HEX = euiPaletteColorBlind()[9];
const coolArray: HEX[] = [euiPaletteColorBlind()[1], '#6092C0'];
const warmArray: HEX[] = [euiPaletteColorBlind()[7], euiPaletteColorBlind()[9]];

export const euiPaletteForStatus = function (steps: number): EuiPalette {
if (steps === 1) {
return [positiveColor];
return [greenColor];
}
if (steps <= 3) {
return euiPalette(
[positiveColor, euiPaletteColorBlind()[5], negativeColor],
[greenColor, euiPaletteColorBlind()[5], redColor],
steps,
true
);
}
return euiPalette(
[
positiveColor,
greenColor,
euiPaletteColorBlind()[0],
euiPaletteColorBlind()[5],
lightNegativeColor,
negativeColor,
lightRedColor,
redColor,
],
steps,
true
Expand All @@ -178,7 +178,7 @@ export const euiPaletteForTemperature = function (steps: number): EuiPalette {
if (steps === 1) {
return [cools[0]];
} else if (steps <= 3) {
return euiPalette([cools[0], lightNegativeColor], steps, true);
return euiPalette([cools[0], lightRedColor], steps, true);
}

return euiPalette([...cools, ...warms], steps, true);
Expand All @@ -196,22 +196,31 @@ export const euiPaletteComplementary = function (steps: number): EuiPalette {
);
};

export const euiPaletteNegative = function (steps: number): EuiPalette {
export const euiPaletteRed = function (steps: number): EuiPalette {
if (steps === 1) {
return [lightNegativeColor];
return [lightRedColor];
}

return euiPalette(['white', negativeColor], steps);
return euiPalette(['white', redColor], steps);
};
/**
* @deprecated - use `euiPaletteRed` instead
*/
export const euiPaletteNegative = euiPaletteRed;

export const euiPalettePositive = function (steps: number): EuiPalette {
export const euiPaletteGreen = function (steps: number): EuiPalette {
if (steps === 1) {
return [euiPaletteColorBlind()[0]];
}

return euiPalette(['white', positiveColor], steps);
return euiPalette(['white', greenColor], steps);
};

/**
cee-chen marked this conversation as resolved.
Show resolved Hide resolved
* @deprecated - use `euiPaletteGreen` instead
*/
export const euiPalettePositive = euiPaletteGreen;

export const euiPaletteCool = function (steps: number): EuiPalette {
if (steps === 1) {
return [coolArray[1]];
Expand All @@ -222,7 +231,7 @@ export const euiPaletteCool = function (steps: number): EuiPalette {

export const euiPaletteWarm = function (steps: number): EuiPalette {
if (steps === 1) {
return [lightNegativeColor];
return [lightRedColor];
}

return euiPalette(['#FBFBDC', ...warmArray], steps);
Expand Down
2 changes: 2 additions & 0 deletions src/services/color/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export {
euiPaletteForStatus,
euiPaletteForTemperature,
euiPaletteComplementary,
euiPaletteRed,
euiPaletteGreen,
euiPaletteNegative,
euiPalettePositive,
euiPaletteCool,
Expand Down
4 changes: 3 additions & 1 deletion src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ export {
euiPaletteForStatus,
euiPaletteForTemperature,
euiPaletteGray,
euiPaletteNegative,
euiPaletteRed,
euiPaletteGreen,
euiPalettePositive,
euiPaletteNegative,
euiPaletteWarm,
getSteppedGradient,
hexToHsv,
Expand Down
Loading