diff --git a/src-docs/src/views/theme/color/_contrast_js.tsx b/src-docs/src/views/theme/color/_contrast_js.tsx index e2bcb001eb8..ca98bc014b7 100644 --- a/src-docs/src/views/theme/color/_contrast_js.tsx +++ b/src-docs/src/views/theme/color/_contrast_js.tsx @@ -56,7 +56,12 @@ export const ColorSectionJS: FunctionComponent = ({ }} > - + {showTextVariants && colorIsCore(colorValue) && ( )} diff --git a/src-docs/src/views/theme/color/_contrast_sass.tsx b/src-docs/src/views/theme/color/_contrast_sass.tsx index cb3836195f0..ade9ce9dde9 100644 --- a/src-docs/src/views/theme/color/_contrast_sass.tsx +++ b/src-docs/src/views/theme/color/_contrast_sass.tsx @@ -83,7 +83,12 @@ export const ColorSectionSass: FunctionComponent = ({ style={{ background: matchPanelColor ? palette[color] : undefined }} > - + {showTextVariants && colorIsCore(color) && ( )} diff --git a/src-docs/src/views/theme/color/_contrast_slider.tsx b/src-docs/src/views/theme/color/_contrast_slider.tsx index d3d959dfaa3..71cdd587c4c 100644 --- a/src-docs/src/views/theme/color/_contrast_slider.tsx +++ b/src-docs/src/views/theme/color/_contrast_slider.tsx @@ -21,7 +21,7 @@ import { ratingAll, } from './_contrast_utilities'; -type ContrastSlider = EuiFlexGroupProps & { +type ContrastSlider = Omit & { contrastValue: EuiRangeProps['value']; showTextVariants: boolean; onChange?: (value: number | string, checked: boolean) => void; diff --git a/src-docs/src/views/theme/color/contrast.tsx b/src-docs/src/views/theme/color/contrast.tsx index b4b3efa0da3..e9a96a4c286 100644 --- a/src-docs/src/views/theme/color/contrast.tsx +++ b/src-docs/src/views/theme/color/contrast.tsx @@ -1,4 +1,4 @@ -import React, { useState, useContext } from 'react'; +import React, { useState, useContext, useCallback } from 'react'; import { ThemeContext } from '../../../components/with_theme'; import { @@ -28,7 +28,7 @@ import { _EuiThemeColorsMode } from '../../../../../src/global_styling/variables import { BACKGROUND_COLORS, _EuiBackgroundColor, - useEuiBackgroundColor, + euiBackgroundColor, } from '../../../../../src/global_styling'; import { BUTTON_COLORS, @@ -48,23 +48,22 @@ export const contrastSections = [ const background_colors = BACKGROUND_COLORS.filter( (color) => color !== 'transparent' ); +const backgroundButtons = [ + 'container', + // 'hover', Commenting out for now since contrast can't be calculated on transparent values + 'button', +].map((m) => { + return { + id: m, + label: m, + }; +}); export default () => { const euiTheme = useEuiTheme(); const [showTextVariants, setShowTextVariants] = useState(true); const [contrastValue, setContrastValue] = useState(4.5); - const backgroundButtons = [ - 'container', - // 'hover', Commenting out for now since contrast can't be calculated on transparent values - 'button', - ].map((m) => { - return { - id: m, - label: m, - }; - }); - const [backgroundColors, setBackgroundColors] = useState(background_colors); const [backgroundFunction, setBackgroundFunction] = useState( @@ -74,7 +73,7 @@ export default () => { backgroundButtons[0].id ); - const switchBackgroundColors = (id: string) => { + const switchBackgroundColors = useCallback((id: string) => { switch (id) { case 'container': setBackgroundSelected(id); @@ -92,7 +91,7 @@ export default () => { setBackgroundFunction('euiButtonColor(color)'); break; } - }; + }, []); const showSass = useContext(ThemeContext).themeLanguage.includes('sass'); @@ -127,12 +126,8 @@ export default () => { , - toggleChecked: React.SetStateAction - ) => { - setContrastValue(sliderValue); + onChange={(sliderValue, toggleChecked) => { + setContrastValue(Number(sliderValue)); setShowTextVariants(toggleChecked); }} /> @@ -301,7 +296,9 @@ export default () => { { , showThemeLanguageToggle: true, - description: ( - <> + intro: ( +

Elastic UI builds with a very limited palette. It uses a core set of three colors with a green / orange / red qualitative set and combined @@ -46,7 +46,7 @@ export const colorsInfo = { their evaluated value but by their{' '} purpose.

- +
), };