Skip to content

Commit f275192

Browse files
[Deprecation Schedule] Remove deprecated palette functions (elastic#9296)
1 parent 1b54f49 commit f275192

File tree

6 files changed

+8
-106
lines changed

6 files changed

+8
-106
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**Breaking changes**
2+
3+
- Removed `euiPaletteForLightBackground` and `euiPaletteForDarkBackground` deprecated palette functions. Use `euiTheme.colors.vis.euiColorVisText{NUMBER}` tokens instead.

packages/eui/src/services/color/eui_palettes.test.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import {
1313
euiPaletteColorBlindBehindText,
1414
euiPaletteComplementary,
1515
euiPaletteCool,
16-
euiPaletteForDarkBackground,
17-
euiPaletteForLightBackground,
1816
euiPaletteForStatus,
1917
euiPaletteForTemperature,
2018
euiPaletteGray,
@@ -59,38 +57,6 @@ describe('euiPaletteColorBlindBehindText', () => {
5957
});
6058
});
6159

62-
describe('euiPaletteForLightBackground', () => {
63-
it('should return custom colors', () => {
64-
const customColor = '#00ff00';
65-
const colors = {
66-
...colorVis,
67-
euiColorVisText0: customColor,
68-
};
69-
70-
const result = euiPaletteForLightBackground({
71-
colors,
72-
});
73-
74-
expect(result[0]).toEqual(customColor);
75-
});
76-
});
77-
78-
describe('euiPaletteForDarkBackground', () => {
79-
it('should return custom colors', () => {
80-
const customColor = '#00ff00';
81-
const colors = {
82-
...colorVis,
83-
euiColorVisText0: customColor,
84-
};
85-
86-
const result = euiPaletteForDarkBackground({
87-
colors,
88-
});
89-
90-
expect(result[0]).toEqual(customColor);
91-
});
92-
});
93-
9460
describe('euiPaletteForStatus', () => {
9561
it('should return correct colors', () => {
9662
const colors = colorVis;

packages/eui/src/services/color/eui_palettes.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -162,50 +162,6 @@ export const euiPaletteColorBlindBehindText = (
162162
return originalPalette;
163163
};
164164

165-
const _getVisColorsAsText = (
166-
visColors: _EuiThemeVisColors,
167-
keys: Array<keyof _EuiThemeVisColors>
168-
) =>
169-
keys.reduce((colors, curr) => {
170-
return [...colors, visColors[curr]];
171-
}, [] as EuiPalette);
172-
173-
/**
174-
* @deprecated - use `euiColorVisText{NUMBER}` tokens directly
175-
*
176-
* NOTE: This function is not pure. It relies on `EUI_VIS_COLOR_STORE` which is updated by the
177-
* EuiProvider on theme change. Ensure to recall the function on theme change or subscribe to the store.
178-
*/
179-
export const euiPaletteForLightBackground = function ({
180-
colors,
181-
}: EuiPaletteCommonProps = {}): EuiPalette {
182-
const visColors = colors ?? EUI_VIS_COLOR_STORE.visColors;
183-
184-
const visColorsAsTextKeys = Object.keys(visColors).filter((color) =>
185-
color.includes('euiColorVisText')
186-
) as Array<keyof typeof visColors>;
187-
188-
return _getVisColorsAsText(visColors, visColorsAsTextKeys);
189-
};
190-
191-
/**
192-
* @deprecated - use `euiColorVisText{NUMBER}` tokens directly
193-
*
194-
* NOTE: This function is not pure. It relies on `EUI_VIS_COLOR_STORE` which is updated by the
195-
* EuiProvider on theme change. Ensure to recall the function on theme change or subscribe to the store.
196-
*/
197-
export const euiPaletteForDarkBackground = function ({
198-
colors,
199-
}: EuiPaletteCommonProps = {}): EuiPalette {
200-
const visColors = colors ?? EUI_VIS_COLOR_STORE.visColors;
201-
202-
const visColorsAsTextKeys = Object.keys(visColors).filter((color) =>
203-
color.includes('euiColorVisText')
204-
) as Array<keyof typeof visColors>;
205-
206-
return _getVisColorsAsText(visColors, visColorsAsTextKeys);
207-
};
208-
209165
/**
210166
* For usage in React use the `useEuiPaletteForStatus` hook instead.
211167
*

packages/eui/src/services/color/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ export {
2525
export { EUI_VIS_COLOR_STORE } from './vis_color_store';
2626
export { colorPalette } from './color_palette';
2727
export {
28-
euiPaletteForLightBackground,
29-
euiPaletteForDarkBackground,
3028
euiPaletteColorBlind,
3129
euiPaletteColorBlindBehindText,
3230
euiPaletteForStatus,

packages/eui/src/services/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ export {
3333
euiPaletteColorBlindBehindText,
3434
euiPaletteComplementary,
3535
euiPaletteCool,
36-
euiPaletteForDarkBackground,
37-
euiPaletteForLightBackground,
3836
euiPaletteForStatus,
3937
euiPaletteForTemperature,
4038
euiPaletteGray,

packages/website/docs/dataviz/sizing.mdx

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ import { useChartBaseTheme } from './use_chart_base_theme';
6161
EuiIcon,
6262
EuiSpacer,
6363
EuiText,
64-
euiPaletteForDarkBackground,
65-
euiPaletteForLightBackground,
6664
useEuiTheme,
6765
} from '@elastic/eui';
6866
import {
@@ -116,8 +114,7 @@ import { useChartBaseTheme } from './use_chart_base_theme';
116114

117115
export default () => {
118116
const chartBaseTheme = useChartBaseTheme();
119-
const { colorMode } = useEuiTheme();
120-
const isDarkTheme = colorMode === 'DARK';
117+
const { euiTheme } = useEuiTheme();
121118

122119
return (
123120
<>
@@ -138,11 +135,7 @@ import { useChartBaseTheme } from './use_chart_base_theme';
138135
data={TIME_DATA_SMALL}
139136
xAccessor={0}
140137
yAccessors={[1]}
141-
color={[
142-
isDarkTheme
143-
? euiPaletteForDarkBackground()[1]
144-
: euiPaletteForLightBackground()[1],
145-
]}
138+
color={[euiTheme.colors.vis.euiColorVisText1]}
146139
/>
147140
</Chart>
148141
</EuiStat>
@@ -169,11 +162,7 @@ import { useChartBaseTheme } from './use_chart_base_theme';
169162
data={TIME_DATA_SMALL}
170163
xAccessor={0}
171164
yAccessors={[1]}
172-
color={[
173-
isDarkTheme
174-
? euiPaletteForDarkBackground()[1]
175-
: euiPaletteForLightBackground()[1],
176-
]}
165+
color={[euiTheme.colors.vis.euiColorVisText1]}
177166
/>
178167
</Chart>
179168
<EuiSpacer size="s" />
@@ -208,11 +197,7 @@ import { useChartBaseTheme } from './use_chart_base_theme';
208197
data={TIME_DATA_MAJOR}
209198
xAccessor={0}
210199
yAccessors={[1]}
211-
color={[
212-
isDarkTheme
213-
? euiPaletteForDarkBackground()[3]
214-
: euiPaletteForLightBackground()[3],
215-
]}
200+
color={[euiTheme.colors.vis.euiColorVisText3]}
216201
/>
217202
</Chart>
218203
</EuiStat>
@@ -239,11 +224,7 @@ import { useChartBaseTheme } from './use_chart_base_theme';
239224
data={TIME_DATA_SMALL_REVERSE}
240225
xAccessor={0}
241226
yAccessors={[1]}
242-
color={[
243-
isDarkTheme
244-
? euiPaletteForDarkBackground()[3]
245-
: euiPaletteForLightBackground()[3],
246-
]}
227+
color={[euiTheme.colors.vis.euiColorVisText3]}
247228
/>
248229
</Chart>
249230
<EuiSpacer size="s" />

0 commit comments

Comments
 (0)