diff --git a/src-docs/src/components/guide_page/_guide_page.scss b/src-docs/src/components/guide_page/_guide_page.scss index 1344b4409f9f..806d32ef097c 100644 --- a/src-docs/src/components/guide_page/_guide_page.scss +++ b/src-docs/src/components/guide_page/_guide_page.scss @@ -64,7 +64,11 @@ $guideSideNavWidth: 240px; } .euiSideNavItem--trunk > .euiSideNavItemButton .guideSideNav__item--inSearch .euiMark { - color: $euiColorPrimary; + color: $euiColorPrimaryText; +} + +.guideSideNav__item--openSubTitle { + color: $euiTitleColor; } diff --git a/src-docs/src/components/guide_page/guide_page_chrome.js b/src-docs/src/components/guide_page/guide_page_chrome.js index 738d212db54c..a295ca892701 100644 --- a/src-docs/src/components/guide_page/guide_page_chrome.js +++ b/src-docs/src/components/guide_page/guide_page_chrome.js @@ -101,6 +101,18 @@ export class GuidePageChrome extends Component { return subSectionsWithTitles.map(({ title, sections }) => { const id = slugify(title); + const subSectionHref = `${href}/${id}`; + const subSectionHashIdHref = `${href}#${id}`; + + const sectionHref = sections ? subSectionHref : subSectionHashIdHref; + const subItems = sections + ? this.renderSubSections(sectionHref, sections, searchTerm) + : undefined; + + const isCurrentlyOpenSubSection = window.location.hash.includes( + subSectionHref + ); + let name = title; if (searchTerm) { name = ( @@ -113,21 +125,15 @@ export class GuidePageChrome extends Component { ); } - const subSectionHref = `${href}/${id}`; - const subSectionHashIdHref = `${href}#${id}`; - - const sectionHref = sections ? subSectionHref : subSectionHashIdHref; - const subItems = sections - ? this.renderSubSections(sectionHref, sections, searchTerm) - : undefined; - return { id: sectionHref, - name, + name: isCurrentlyOpenSubSection ? {name} : name, href: sectionHref, + className: isCurrentlyOpenSubSection + ? 'guideSideNav__item--openSubTitle' + : '', items: subItems, - isSelected: window.location.hash.includes(subSectionHref), - forceOpen: !!searchTerm, + forceOpen: !!searchTerm || isCurrentlyOpenSubSection, }; }); }; diff --git a/src-docs/src/components/guide_tabbed_page/guide_tabbed_page.tsx b/src-docs/src/components/guide_tabbed_page/guide_tabbed_page.tsx index e1a5e1b46eae..e751fd8d15d9 100644 --- a/src-docs/src/components/guide_tabbed_page/guide_tabbed_page.tsx +++ b/src-docs/src/components/guide_tabbed_page/guide_tabbed_page.tsx @@ -49,12 +49,13 @@ const GuideTabbedPageComponent: FunctionComponent = ({ const currentLanguage = themeContext.themeLanguage; const showSass = currentLanguage.includes('sass'); - const betaBadge = isBeta && ( - - ); + const betaBadge = + isBeta || (showThemeLanguageToggle && !showSass) ? ( + + ) : undefined; let tabs: | Array<{ diff --git a/src-docs/src/components/with_theme/language_selector.tsx b/src-docs/src/components/with_theme/language_selector.tsx index 93e4e75ce626..45931a8d423b 100644 --- a/src-docs/src/components/with_theme/language_selector.tsx +++ b/src-docs/src/components/with_theme/language_selector.tsx @@ -19,7 +19,7 @@ const NOTIF_STORAGE_VALUE = 'dismissed'; export const LanguageSelector = ({ onChange, - showTour = true, + showTour = false, }: { onChange?: (id: string) => void; showTour?: boolean; diff --git a/src-docs/src/routes.js b/src-docs/src/routes.js index d7b175688e32..75dc7d0fdaae 100644 --- a/src-docs/src/routes.js +++ b/src-docs/src/routes.js @@ -36,8 +36,6 @@ import { SitewideSearchExample } from './views/selectable/selectable_sitewide_te import { ColorPaletteExample } from './views/color_palette/color_palette_example'; -import { ColorExample } from './views/color/color_example'; - import { PrettyDurationExample } from './views/pretty_duration/pretty_duration_example'; import { UtilityClassesExample } from './views/utility_classes/utility_classes_example'; @@ -191,7 +189,6 @@ import { ResizeObserverExample } from './views/resize_observer/resize_observer_e import { ResizableContainerExample } from './views/resizable_container/resizable_container_example'; -import { ResponsiveExample } from './views/responsive/responsive_example'; import { ScrollExample } from './views/scroll/scroll_example'; import { SearchBarExample } from './views/search_bar/search_bar_example'; @@ -220,8 +217,6 @@ import { TextDiffExample } from './views/text_diff/text_diff_example'; import { TextExample } from './views/text/text_example'; -import { TextUtilitiesExample } from './views/text_utilities/text_utilities_example'; - import { TimelineExample } from './views/timeline/timeline_example'; import { TitleExample } from './views/title/title_example'; @@ -242,13 +237,27 @@ import { SuperSelectExample } from './views/super_select/super_select_example'; import { ThemeExample } from './views/theme/theme_example'; import { ColorModeExample } from './views/theme/color_mode/color_mode_example'; -import Breakpoints from './views/theme/breakpoints/breakpoints'; +import { BreakpointsExample } from './views/theme/breakpoints/breakpoints_example'; import Borders, { bordersSections } from './views/theme/borders/borders'; -import Color, { colorsSections } from './views/theme/color/colors'; -import Sizing, { sizingSections } from './views/theme/sizing/sizing'; +import Color, { colorsInfo, colorsSections } from './views/theme/color/tokens'; +import ColorContrast, { contrastSections } from './views/theme/color/contrast'; +import ColorFunctions, { + colorsFunctionsSections, +} from './views/theme/color/functions'; +import Sizing, { + sizingInfo, + sizingSections, +} from './views/theme/sizing/tokens'; +import SizingFunctions, { + sizingFunctionSections, +} from './views/theme/sizing/functions'; import Typography, { + typographyInfo, typographySections, -} from './views/theme/typography/typography'; +} from './views/theme/typography/values'; +import TextUtilities, { + textUtilitiesSections, +} from './views/theme/typography/utilities'; import Other, { otherSections } from './views/theme/other/other'; import ThemeValues from './views/theme/customizing/values'; @@ -398,30 +407,62 @@ const navigation = [ items: [ createExample(ThemeExample, 'Theme provider'), createExample(ColorModeExample), - { - name: 'Breakpoints', - component: Breakpoints, - }, + createTabbedPage(BreakpointsExample), { name: 'Borders', component: Borders, sections: bordersSections, }, - { - name: 'Colors', - component: Color, - sections: colorsSections, - }, - { - name: 'Sizing', - component: Sizing, - sections: sizingSections, - }, - { - name: 'Typography', - component: Typography, - sections: typographySections, - }, + createTabbedPage({ + ...colorsInfo, + pages: [ + { + title: 'Values', + page: Color, + sections: colorsSections, + }, + { + title: 'Utilities', + page: ColorFunctions, + sections: colorsFunctionsSections, + }, + { + title: 'Contrast', + page: ColorContrast, + sections: contrastSections, + }, + ], + }), + createTabbedPage({ + ...sizingInfo, + pages: [ + { + title: 'Values', + page: Sizing, + sections: sizingSections, + }, + { + title: 'Utilities', + page: SizingFunctions, + sections: sizingFunctionSections, + }, + ], + }), + createTabbedPage({ + ...typographyInfo, + pages: [ + { + title: 'Values', + page: Typography, + sections: typographySections, + }, + { + title: 'Utilities', + page: TextUtilities, + sections: textUtilitiesSections, + }, + ], + }), { name: 'More tokens', component: Other, @@ -564,7 +605,6 @@ const navigation = [ AccessibilityExample, AutoSizerExample, BeaconExample, - ColorExample, ColorPaletteExample, CopyExample, UtilityClassesExample, @@ -582,10 +622,8 @@ const navigation = [ PrettyDurationExample, ProviderExample, ResizeObserverExample, - ResponsiveExample, ScrollExample, TextDiffExample, - TextUtilitiesExample, WindowEventExample, ].map((example) => createExample(example)), }, diff --git a/src-docs/src/views/color/color_example.js b/src-docs/src/views/color/color_example.js deleted file mode 100644 index 2692dcb22e31..000000000000 --- a/src-docs/src/views/color/color_example.js +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; - -import { LanguageSelector } from '../../components'; -import Intro from './intro'; - -import { ContrastSections } from './contrast/sections'; -import { TransparencySections } from './transparency/sections'; -import { TintShadeSections } from './tint_shade/sections'; -import { TextSections } from './text/sections'; - -export const ColorExample = { - title: 'Color functions', - intro: , - rightSideItems: [], - sections: [ - { - title: 'Contrast', - wrapText: false, - text: , - }, - { - title: 'Transparency', - wrapText: false, - text: , - }, - { - title: 'Tint and shade', - wrapText: false, - text: , - }, - { - title: 'Light or dark text', - wrapText: false, - text: , - }, - ], -}; diff --git a/src-docs/src/views/color/contrast/contrast.tsx b/src-docs/src/views/color/contrast/contrast.tsx deleted file mode 100644 index 5a23ac93823c..000000000000 --- a/src-docs/src/views/color/contrast/contrast.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import React, { Fragment } from 'react'; -import chroma from 'chroma-js'; -import { css } from '@emotion/react'; - -import { EuiFlexGrid, EuiFlexItem } from '../../../../../src/components'; - -import { - useEuiTheme, - makeHighContrastColor, -} from '../../../../../src/services'; - -export default () => { - const { euiTheme } = useEuiTheme(); - - const BACKGROUND = ['#006837', 'rgb(165,0,38)', 'rgba(0,0,0,1)', 'pink']; - - const FOREGROUND = [ - '#bfa180', - 'rgb(249,133,16)', - 'rgba(0,179,164,1)', - 'white', - ]; - - return ( - - - {BACKGROUND.map((background, i) => { - const color = makeHighContrastColor(FOREGROUND[i])(background); - - return ( - -
- - {chroma.contrast(color, background).toFixed(2)} - {`: makeHighContrastColor(${FOREGROUND[i]}, ${background})`} - -
-
- ); - })} -
-
- ); -}; diff --git a/src-docs/src/views/color/contrast/contrast_body.tsx b/src-docs/src/views/color/contrast/contrast_body.tsx deleted file mode 100644 index cbd46b9152d7..000000000000 --- a/src-docs/src/views/color/contrast/contrast_body.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import React, { Fragment } from 'react'; -import chroma from 'chroma-js'; -import { css } from '@emotion/react'; - -import { - EuiFlexGrid, - EuiFlexItem, - useEuiTheme, - makeHighContrastColor, -} from '../../../../../src'; - -export default () => { - const { euiTheme } = useEuiTheme(); - - const FOREGROUND = [ - '#bfa180', - 'rgb(249,133,16)', - 'rgba(0,179,164,1)', - 'white', - ]; - - return ( - - - {FOREGROUND.map((foreground) => { - const color = makeHighContrastColor(foreground)(euiTheme); - - return ( - -
- - {chroma.contrast(color, euiTheme.colors.body).toFixed(2)} - {`: makeHighContrastColor(${foreground}, euiTheme)`} - -
-
- ); - })} -
-
- ); -}; diff --git a/src-docs/src/views/color/contrast/sections.tsx b/src-docs/src/views/color/contrast/sections.tsx deleted file mode 100644 index 8f3f3fbae0fe..000000000000 --- a/src-docs/src/views/color/contrast/sections.tsx +++ /dev/null @@ -1,123 +0,0 @@ -import React, { useContext } from 'react'; -import { EuiCode, EuiCallOut } from '../../../../../src'; -import { GuideSectionTypes } from '../../../components/guide_section/guide_section_types'; -import { GuideSection } from '../../../components/guide_section/guide_section'; -import { ThemeContext } from '../../../components/with_theme'; - -import Contrast from './contrast'; -const ContrastSource = require('!!raw-loader!./contrast'); -import ContrastBody from './contrast_body'; -const ContrastBodySource = require('!!raw-loader!./contrast_body'); - -const contrastExample = `// Make sure text passes a contrast check -.contrastBox { - $backgroundColor: tintOrShade($euiColorWarning, 90%, 70%); - background: $backgroundColor; - - // Given two colors, adjust the first until contrast is 4.5 - color: makeHighContrastColor($euiColorWarning, $backgroundColor); - padding: $euiSize; - border-left: $euiBorderThick; - border-color: $euiColorWarning; - - // Graphics can have a lower minimum contrast level of 3.0 - .square { - fill: makeGraphicContrastColor($euiColorWarning, $backgroundColor); - } -}`; - -export const ContrastSections = () => { - const themeContext = useContext(ThemeContext); - const currentLanguage = themeContext.themeLanguage; - const showSass = currentLanguage.includes('sass'); - - const contrastFunction = showSass ? ( - - makeHighContrastColor($foreground, $background: $euiPageBackgroundColor, - $ratio: 4.5) - - ) : ( - - makeHighContrastColor(foreground, ratio = 4.5)(background) - - ); - - const source: GuideSection['source'] = [ - showSass - ? { - type: GuideSectionTypes.SASS, - code: contrastExample, - } - : { - type: GuideSectionTypes.JS, - code: ContrastSource, - }, - ]; - - const demo: GuideSection['demo'] = showSass ? ( -
- - - {' '} - This orange text now passes a contrast check! -
- ) : ( - - ); - - const snippet: GuideSection['snippet'] = showSass - ? undefined - : 'const textColor = makeHighContrastColor(foreground)(background);'; - - const text = ( - <> -

- Use {contrastFunction} to calculate the appropriate foreground color - (usually text) based on a background color. -

- -

- Note that color contrast cannot be accurately detected when using - transparency (colors with alpha channels). -

-
- - ); - - let contrastBody; - if (!showSass) { - contrastBody = ( - - If you want to use the same background color that the EUI theme uses - for all of its contrast calculations, you can pass in the{' '} - euiTheme as the background. -

- } - demo={} - snippet={`const { euiTheme } = useEuiTheme(); - const textColor = makeHighContrastColor(foreground)(euiTheme);`} - source={[ - { - type: GuideSectionTypes.JS, - code: ContrastBodySource, - }, - ]} - /> - ); - } - - return ( - <> - - {contrastBody} - - ); -}; diff --git a/src-docs/src/views/color/desaturate.js b/src-docs/src/views/color/desaturate.js deleted file mode 100644 index 698a1314fff6..000000000000 --- a/src-docs/src/views/color/desaturate.js +++ /dev/null @@ -1,28 +0,0 @@ -import React, { Fragment } from 'react'; - -import { desaturate } from '../../../../src/services'; -import { EuiFlexGrid, EuiFlexItem, EuiBadge } from '../../../../src/components'; - -export default () => { - const COLORS = ['#006837', 'rgb(165,0,38)', 'rgba(0,0,0,0.5)', 'pink']; - - return ( - - - {COLORS.map((color) => { - const desaturated = desaturate(color, 0.75); - - return ( - - - desaturate( - {color}, 0.75) ={' '} - {desaturated} - - - ); - })} - - - ); -}; diff --git a/src-docs/src/views/color/intro.tsx b/src-docs/src/views/color/intro.tsx deleted file mode 100644 index 5b348c04b84a..000000000000 --- a/src-docs/src/views/color/intro.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import React, { useContext } from 'react'; - -import { EuiText, EuiLink } from '../../../../src/components'; -import { ThemeContext } from '../../components/with_theme'; - -export default () => { - const themeContext = useContext(ThemeContext); - const currentLanguage = themeContext.themeLanguage; - const showSass = currentLanguage.includes('sass'); - - return ( - - {showSass ? ( -

- EUI provides some Sass color functions that we use throughout - EUI's styling layer for color-specific calculations. When you - need to go beyond the provided color set, always use these functions - to modify. -

- ) : ( -

- EUI's color functions use the lightweight color library{' '} - chroma.js{' '} - for calculations. This means that most functions accept most Chroma{' '} - - Color - {' '} - types. -

- )} -
- ); -}; diff --git a/src-docs/src/views/color/saturate.js b/src-docs/src/views/color/saturate.js deleted file mode 100644 index ced4a116614c..000000000000 --- a/src-docs/src/views/color/saturate.js +++ /dev/null @@ -1,28 +0,0 @@ -import React, { Fragment } from 'react'; - -import { saturate } from '../../../../src/services'; -import { EuiFlexGrid, EuiFlexItem, EuiBadge } from '../../../../src/components'; - -export default () => { - const COLORS = ['#006837', 'rgb(165,0,38)', 'rgba(0,0,0,.5)', 'pink']; - - return ( - - - {COLORS.map((color) => { - const saturated = saturate(color, 0.75); - - return ( - - - saturate( - {color}, 0.75) ={' '} - {saturated} - - - ); - })} - - - ); -}; diff --git a/src-docs/src/views/color/simulating_contrast/contrast_simulated.tsx b/src-docs/src/views/color/simulating_contrast/contrast_simulated.tsx deleted file mode 100644 index ec66b30b20a8..000000000000 --- a/src-docs/src/views/color/simulating_contrast/contrast_simulated.tsx +++ /dev/null @@ -1,109 +0,0 @@ -import React, { Fragment, useState } from 'react'; -import chroma from 'chroma-js'; -import { css } from '@emotion/react'; - -import { - EuiFlexGrid, - EuiFlexItem, - EuiButtonGroup, - EuiHorizontalRule, - EuiIcon, -} from '../../../../../src/components'; - -import { - useEuiTheme, - makeHighContrastColor, - transparentize, - tint, - shade, -} from '../../../../../src/services'; - -export default () => { - const { euiTheme, colorMode } = useEuiTheme(); - const [contrastButtonSelected, setContrastButtonSelected] = useState( - 'transparent' - ); - - const transparency = 0.3; - const BACKGROUND = ['#006837ee', 'rgb(165,0,38)', 'rgb(0,0,0)', 'pink']; - const FOREGROUND = ['#bfa180', 'rgb(249,133,16)', 'rgb(0,179,164)', 'white']; - - return ( - - setContrastButtonSelected(optionId)} - options={[ - { - id: 'incorrect', - label: 'Transparency only', - }, - { - id: 'simulated', - label: 'Simulated background', - }, - { - id: 'transparent', - label: 'Simulated with transparency', - }, - ]} - /> - - - - - {BACKGROUND.map((background, i) => { - const simulated = - colorMode === 'DARK' - ? shade(background, 1 - transparency) - : tint(background, 1 - transparency); - - // Default incorrect calculation - let backgroundColor = transparentize(background, transparency); - let color = makeHighContrastColor(FOREGROUND[i])(backgroundColor); - let iconType = 'crossInACircleFilled'; - let contrastRatio = chroma - .contrast(color, backgroundColor) - .toFixed(2); - - switch (contrastButtonSelected) { - case 'simulated': - backgroundColor = simulated; - color = makeHighContrastColor(FOREGROUND[i])(simulated); - iconType = 'checkInCircleFilled'; - contrastRatio = chroma - .contrast(color, backgroundColor) - .toFixed(2); - break; - case 'transparent': - backgroundColor = transparentize(background, transparency); - color = makeHighContrastColor(FOREGROUND[i])(simulated); - iconType = 'questionInCircle'; - contrastRatio = 'Unknown'; - break; - } - - return ( - -
- {contrastRatio}:{' '} - {contrastButtonSelected} -
-
- ); - })} -
-
- ); -}; diff --git a/src-docs/src/views/color/simulating_contrast/contrast_simulated_body.tsx b/src-docs/src/views/color/simulating_contrast/contrast_simulated_body.tsx deleted file mode 100644 index 4a042e0563e3..000000000000 --- a/src-docs/src/views/color/simulating_contrast/contrast_simulated_body.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import React, { Fragment } from 'react'; -import chroma from 'chroma-js'; -import { css } from '@emotion/react'; - -import { EuiFlexGrid, EuiFlexItem } from '../../../../../src/components'; - -import { - useEuiTheme, - makeHighContrastColor, - transparentize, -} from '../../../../../src/services'; - -export default () => { - const { euiTheme } = useEuiTheme(); - - const transparency = 0.3; - const BACKGROUND = ['#006837ee', 'rgb(165,0,38)', 'rgb(0,0,0)', 'pink']; - const FOREGROUND = ['#bfa180', 'rgb(249,133,16)', 'rgb(0,179,164)', 'white']; - - return ( - - - {BACKGROUND.map((background, i) => { - const simulated = chroma - .mix(background, euiTheme.colors.body, 1 - transparency, 'rgb') - .css(); - const backgroundColor = transparentize(background, transparency); - const color = makeHighContrastColor(FOREGROUND[i])(simulated); - - return ( - -
- {chroma.contrast(color, simulated).toFixed(2)}: Roughly -
-
- ); - })} -
-
- ); -}; diff --git a/src-docs/src/views/color/simulating_contrast/sections.tsx b/src-docs/src/views/color/simulating_contrast/sections.tsx deleted file mode 100644 index 59711d2b1b47..000000000000 --- a/src-docs/src/views/color/simulating_contrast/sections.tsx +++ /dev/null @@ -1,86 +0,0 @@ -import React, { useContext } from 'react'; -import { EuiCode, EuiCallOut } from '../../../../../src'; -import { GuideSectionTypes } from '../../../components/guide_section/guide_section_types'; -import { GuideSection } from '../../../components/guide_section/guide_section'; - -// @ts-ignore Importing from JS file -import ContrastSimulated from './contrast_simulated'; -const ContrastSimulatedSource = require('!!raw-loader!./contrast_simulated'); -// @ts-ignore Importing from JS file -import ContrastSimulatedBody from './contrast_simulated_body'; -import { ThemeContext } from '../../../components/with_theme'; -const ContrastSimulatedBodySource = require('!!raw-loader!./contrast_simulated_body'); - -export const SimulatingSections = () => { - const themeContext = useContext(ThemeContext); - const currentLanguage = themeContext.themeLanguage; - const showSass = currentLanguage.includes('sass'); - - const contrastDemos: GuideSection[] = [ - { - title: 'Simulating contrast with transparency', - source: [ - { - type: GuideSectionTypes.JS, - code: ContrastSimulatedSource, - }, - ], - text: ( - <> -

- The makeHighContrastColor function does not take - alpha channel into account and can therefore lead to incorrect - contrast calculations. -

-

- You can, instead, simulate transparency by first - tinting or shading (depending on the color mode) the background - color with the same transparency ratio. Then use the simulated color - to calculate the contrast with the foreground. -

- -

- This method is not 100% accurate and has some inconstencies in the - way mixing colors are calculated versus transparency. However, it - is more likely to create the right contrast ratio - than using transparency alone. -

-
- - ), - demo: , - snippet: `const { colorMode } = useEuiTheme(); -const transparency = 0.4; -const simulated = colorMode === 'DARK' - ? shade(background, 1 - transparency) - : tint(background, 1 - transparency); -const backgroundColor = transparentize(background, transparency); -const color = makeHighContrastColor(foreground)(simulated);`, - }, - { - source: [ - { - type: GuideSectionTypes.JS, - code: ContrastSimulatedBodySource, - }, - ], - text: ( - <> -

- When EUI simulates or calculates contrast, we typically mix the - background color with euiTheme.colors.body which - is the darkest version of backgrounds we allow. -

-

- This effectively increases the contrast ratio when used on the empty - shade, but ensures proper contrast when the element sits directly on - the body color. -

- - ), - demo: , - }, - ]; - - return showSass ? [undefined] : contrastDemos; -}; diff --git a/src-docs/src/views/color/text/is_color_dark.tsx b/src-docs/src/views/color/text/is_color_dark.tsx deleted file mode 100644 index 9c552f787ccc..000000000000 --- a/src-docs/src/views/color/text/is_color_dark.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import React, { Fragment } from 'react'; -import { css } from '@emotion/react'; - -import { - EuiFlexGrid, - EuiFlexItem, - isColorDark, - useEuiTheme, -} from '../../../../../src'; - -const rgb = (r: number, g: number, b: number) => { - return `rgb(${r}, ${g}, ${b})`; -}; - -export default () => { - const { euiTheme } = useEuiTheme(); - - const SWATCH_STYLE = css` - padding: ${euiTheme.size.base}; - border-radius: ${euiTheme.border.radius.small}; - `; - - const COLORS: Array<[number, number, number]> = [ - [0, 104, 55], - [165, 0, 38], - [0, 0, 0], - [219, 19, 116], - [191, 161, 128], - [249, 133, 16], - [0, 179, 164], - [212, 157, 170], - ]; - - return ( - - - {COLORS.map((color) => ( - -
- {isColorDark(...color) ? 'Dark' : 'Light'} -
-
- ))} -
-
- ); -}; diff --git a/src-docs/src/views/color/text/sections.tsx b/src-docs/src/views/color/text/sections.tsx deleted file mode 100644 index e39458b11f92..000000000000 --- a/src-docs/src/views/color/text/sections.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import React, { useContext } from 'react'; -import { EuiCode } from '../../../../../src'; -import { GuideSectionTypes } from '../../../components/guide_section/guide_section_types'; -import { GuideSection } from '../../../components/guide_section/guide_section'; -import { ThemeContext } from '../../../components/with_theme'; - -// @ts-ignore Importing from JS file -import IsColorDark from './is_color_dark'; -const isColorDarkSource = require('!!raw-loader!./is_color_dark'); - -const contrastExample = `.lightOrDarkText { - padding: $euiSize; - display: inline-block; - margin-right: $euiSize; - - &--primary { - background-color: $euiColorPrimary; - color: chooseLightOrDarkText($euiColorPrimary); - } - - &--success { - background-color: $euiColorSuccess; - color: chooseLightOrDarkText($euiColorSuccess); - } - - &--warning { - background-color: $euiColorWarning; - color: chooseLightOrDarkText($euiColorWarning); - } - - &--danger { - background-color: $euiColorDanger; - color: chooseLightOrDarkText($euiColorDanger); - } -}`; - -export const TextSections = () => { - const themeContext = useContext(ThemeContext); - const currentLanguage = themeContext.themeLanguage; - const showSass = currentLanguage.includes('sass'); - - const source = [ - showSass - ? { - type: GuideSectionTypes.SASS, - code: contrastExample, - } - : { - type: GuideSectionTypes.TSX, - code: isColorDarkSource, - }, - ]; - const text = showSass ? ( - <> - Use{' '} - - chooseLightOrDarkText($background, $lightText: $euiColorGhost, - $darkText: $euiColorInk); - {' '} - to determine whether or not to use light (white) or dark (black) text - against the given background color. The function will return either the - light or dark text parameters depending on the value of the background - color given. - - ) : ( - <> -

- Use isColorDark(red, green, blue) to - determine whether or not to use light or dark text against the given - background color. It requires the values to be passed in as rgb integers - and will return a boolean if the color is dark based - on luminance. -

-

- If the function returns true, use{' '} - euiTheme.colors.ghost otherwise use{' '} - euiTheme.colors.ink as the text color. -

- - ); - const demo = showSass ? ( - ['primary', 'success', 'warning', 'danger'].map((color) => ( -
- Checking {color} -
- )) - ) : ( - - ); - const snippet = showSass - ? undefined - : `const { euiTheme } = useEuiTheme(); -const textColor = isColorDark(color) ? euiTheme.colors.ghost : euiTheme.colors.ink;`; - - return ( - - ); -}; diff --git a/src-docs/src/views/color/tint_shade/sections.tsx b/src-docs/src/views/color/tint_shade/sections.tsx deleted file mode 100644 index 3581dcbd8661..000000000000 --- a/src-docs/src/views/color/tint_shade/sections.tsx +++ /dev/null @@ -1,161 +0,0 @@ -import React, { useContext } from 'react'; -import { EuiCode } from '../../../../../src'; -import { GuideSectionTypes } from '../../../components/guide_section/guide_section_types'; - -// @ts-ignore Importing from JS file -import Tint from './tint'; -const TintSource = require('!!raw-loader!./tint'); -// @ts-ignore Importing from JS file -import Shade from './shade'; -const ShadeSource = require('!!raw-loader!./shade'); - -import { GuideSection } from '../../../components/guide_section/guide_section'; -import { ThemeContext } from '../../../components/with_theme/theme_context'; - -const tintExample = `.tint { - $backgroundColor: tint($euiColorSuccess, 20%); - background: $backgroundColor; - color: chooseLightOrDarkText($backgroundColor); - padding: $euiSize; -}`; - -const shadeExample = `.shade { - $backgroundColor: shade($euiColorSuccess, 20%); - background: $backgroundColor; - color: chooseLightOrDarkText($backgroundColor); - padding: $euiSize; -}`; - -const tintOrShadeExample = `.tintOrShade { - $backgroundColor: tintOrShade($euiColorSuccess, 80%, 80%); - background: $backgroundColor; - color: chooseLightOrDarkText($backgroundColor); - padding: $euiSize; -}`; - -export const TintShadeSections = () => { - const themeContext = useContext(ThemeContext); - const currentLanguage = themeContext.themeLanguage; - const showSass = currentLanguage.includes('sass'); - - const tintFunction = showSass ? ( - tint($color, $percent) - ) : ( - tint(color, ratio: 0-1) - ); - - const shadeFunction = showSass ? ( - shade($color, $percent) - ) : ( - shade(color, ratio: 0-1) - ); - - const source = [ - showSass - ? { - type: GuideSectionTypes.SASS, - code: tintExample, - } - : { - type: GuideSectionTypes.JS, - code: TintSource, - }, - ]; - const text = ( -

- Use {tintFunction} to mix any color with white. The - higher the ratio, the more white will be mixed. -

- ); - const demo = showSass ? ( -
- This is the success color tinted by 20%. -
- ) : ( - - ); - const snippet = showSass ? undefined : 'const tinted = tint(color, 0.75);'; - - const tintSection = ( - - ); - - const source_shade = [ - showSass - ? { - type: GuideSectionTypes.SASS, - code: shadeExample, - } - : { - type: GuideSectionTypes.JS, - code: ShadeSource, - }, - ]; - const text_shade = ( -

- Use {shadeFunction} to mix any color with black. The - higher the ratio, the more black will be mixed. -

- ); - const demo_shade = showSass ? ( -
- This is the success color shaded by 20%. -
- ) : ( - - ); - const snippet_shade = showSass - ? undefined - : 'const shaded = shade(color, 0.5);'; - - const shadeSection = ( - - ); - - let tintShadeSection; - - if (showSass) { - const source = [ - { - type: GuideSectionTypes.SASS, - code: tintOrShadeExample, - }, - ]; - const text = ( -

- If you are affording for both light and dark themes, you can use a - single function{' '} - - tintOrShade($color, $tint_percent, $shade_percent) - {' '} - to shade or tint based on the color mode. Taking the success color above - we can tint the color in the light mode, but shade it in the dark mode. - This makes the background color more subtle in both color modes. The - opposite function{' '} - - shadeOrTint($color, $shade_percent, $tint_percent) - {' '} - also exists. -

- ); - const demo = ( -
- This success color is tinted in light mode and shaded in dark. -
- ); - tintShadeSection = ; - } - - return ( - <> - {shadeSection} - {tintSection} - {tintShadeSection} - - ); -}; diff --git a/src-docs/src/views/color/tint_shade/shade.tsx b/src-docs/src/views/color/tint_shade/shade.tsx deleted file mode 100644 index c61387c0bbc1..000000000000 --- a/src-docs/src/views/color/tint_shade/shade.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import React, { Fragment } from 'react'; - -import { EuiFlexGrid, EuiFlexItem, EuiBadge } from '../../../../../src'; - -import { shade } from '../../../../../src/services'; - -export default () => { - const COLORS = ['#006837', 'rgb(165,0,38)', 'rgba(0,0,0,.5)', 'pink']; - - return ( - - - {COLORS.map((color) => { - const shaded = shade(color, 0.5); - - return ( - - - shade( - {color}, 0.5) ={' '} - {shaded} - - - ); - })} - - - ); -}; diff --git a/src-docs/src/views/color/tint_shade/tint.tsx b/src-docs/src/views/color/tint_shade/tint.tsx deleted file mode 100644 index 351e2e6e059a..000000000000 --- a/src-docs/src/views/color/tint_shade/tint.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import React, { Fragment } from 'react'; - -import { EuiFlexGrid, EuiFlexItem, EuiBadge } from '../../../../../src'; - -import { tint } from '../../../../../src/services'; - -export default () => { - const COLORS = ['#006837', 'rgb(165,0,38)', 'rgba(0,0,0,.5)', 'pink']; - - return ( - - - {COLORS.map((color) => { - const tinted = tint(color, 0.75); - - return ( - - - tint( - {color}, 0.75) ={' '} - {tinted} - - - ); - })} - - - ); -}; diff --git a/src-docs/src/views/color/transparency/sections.tsx b/src-docs/src/views/color/transparency/sections.tsx deleted file mode 100644 index bbd5f1930fae..000000000000 --- a/src-docs/src/views/color/transparency/sections.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import React, { useContext } from 'react'; -import { EuiCode } from '../../../../../src'; -import { GuideSectionTypes } from '../../../components/guide_section/guide_section_types'; -import { ThemeContext } from '../../../components/with_theme'; - -import { GuideSection } from '../../../components/guide_section/guide_section'; - -// @ts-ignore Importing from JS file -import Transparency from './transparency'; -const TransparencySource = require('!!raw-loader!./transparency'); - -const sassExample = `.transparency { - background: transparentize($euiColorPrimary, .2); - padding: $euiSize; -}`; - -export const TransparencySections = () => { - const themeContext = useContext(ThemeContext); - const currentLanguage = themeContext.themeLanguage; - const showSass = currentLanguage.includes('sass'); - - const transparencyFunction = showSass ? ( - transparentize($color, alpha: 0-1) - ) : ( - transparentize(color, alpha: 0-1) - ); - - const source = [ - showSass - ? { - type: GuideSectionTypes.SASS, - code: sassExample, - } - : { - type: GuideSectionTypes.JS, - code: TransparencySource, - }, - ]; - const text = ( -

- Use {transparencyFunction} to convert any color to{' '} - rgba() with the provided alpha value. -

- ); - const demo = showSass ? ( -
- The background is a transparent version of the primary color -
- ) : ( - - ); - const snippet = showSass - ? undefined - : 'const rgba = transparentize(color, 0.75);'; - - return ( - - ); -}; diff --git a/src-docs/src/views/color/transparency/transparency.tsx b/src-docs/src/views/color/transparency/transparency.tsx deleted file mode 100644 index 1dec3bfde046..000000000000 --- a/src-docs/src/views/color/transparency/transparency.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import React, { Fragment } from 'react'; - -import { - EuiFlexGrid, - EuiFlexItem, - EuiBadge, -} from '../../../../../src/components'; - -import { useEuiTheme, transparentize } from '../../../../../src/services'; - -export default () => { - const { euiTheme, colorMode } = useEuiTheme(); - const COLORS = ['#006837', 'rgb(165,0,38)', 'rgba(0,0,0,.5)', 'pink']; - - return ( - - - {COLORS.map((color) => { - const transparent = transparentize(color, 0.25); - - return ( - - - transparentize( - {color}, 0.75) ={' '} - - {transparent} - - - - ); - })} - - - ); -}; diff --git a/src-docs/src/views/guidelines/_index.scss b/src-docs/src/views/guidelines/_index.scss index fb29edb10423..84a4a504f4e2 100644 --- a/src-docs/src/views/guidelines/_index.scss +++ b/src-docs/src/views/guidelines/_index.scss @@ -392,12 +392,10 @@ background: $backgroundColor; color: makeHighContrastColor($euiColorWarning, $backgroundColor); padding: $euiSize; - border-left: $euiBorderThick; - border-color: $euiColorWarning; .square { - fill: makeGraphicContrastColor($euiColorWarning, $backgroundColor); - vertical-align: bottom; + color: makeGraphicContrastColor($euiColorWarning, $backgroundColor); + margin-right: $euiSizeXS; } } @@ -414,7 +412,7 @@ } .guideSass__shadeExample { - $backgroundColor: shade($euiColorSuccess, 20%); + $backgroundColor: shade($euiColorSuccess, 40%); background: $backgroundColor; color: chooseLightOrDarkText($backgroundColor); padding: $euiSize; diff --git a/src-docs/src/views/responsive/responsive_example.js b/src-docs/src/views/responsive/responsive_example.js deleted file mode 100644 index 276bdeae13d5..000000000000 --- a/src-docs/src/views/responsive/responsive_example.js +++ /dev/null @@ -1,91 +0,0 @@ -import React from 'react'; - -import { GuideSectionTypes } from '../../components'; - -import { - EuiCode, - EuiShowFor, - EuiHideFor, - EuiCodeBlock, - EuiSpacer, -} from '../../../../src/components'; - -import { BREAKPOINTS, BREAKPOINT_KEYS } from '../../../../src/services'; -import { EuiBreakpointSize } from '!!prop-loader!../../../../src/services/breakpoint'; - -import Responsive from './responsive'; -const responsiveSource = require('!!raw-loader!./responsive'); -const responsiveSnippet = [ - ` - -`, - ` - -`, -]; - -import UtilityClassesResponsive from './utility_classes_responsive'; - -function renderSizes(size, index) { - let code = `'${size}': ${BREAKPOINTS[size]}px`; - - if (index > 0) { - code += ` (to ${BREAKPOINTS[BREAKPOINT_KEYS[index - 1]] - 1}px)`; - } else { - code += ' +'; - } - - return
{code}
; -} - -export const ResponsiveExample = { - title: 'Responsive', - sections: [ - { - title: 'EuiShowFor and EuiHideFor', - source: [ - { - type: GuideSectionTypes.JS, - code: responsiveSource, - }, - ], - text: ( -
-

- These components will either render or not render their children - based on the current window width. Pass an array of named - breakpoints to the sizes prop to either show or - hide their children respectively. -

- -

- The sizing options correlate with the keys in the{' '} - EuiBreakpoints type. The named - breakpoint starts at the pixel value provided and ends before the - next one. -

- - - {BREAKPOINT_KEYS.map(function (size, index) { - return renderSizes(size, index); - })} - -
- ), - snippet: responsiveSnippet, - props: { EuiShowFor, EuiHideFor, EuiBreakpointSize }, - demo: , - }, - { - title: 'Utility classes', - color: 'subdued', - wrapText: false, - text: ( - <> - - - - ), - }, - ], -}; diff --git a/src-docs/src/views/text_utilities/text_utilities_example.js b/src-docs/src/views/text_utilities/text_utilities_example.js deleted file mode 100644 index d3411803e053..000000000000 --- a/src-docs/src/views/text_utilities/text_utilities_example.js +++ /dev/null @@ -1,47 +0,0 @@ -import React from 'react'; - -import { EuiText } from '../../../../src/components'; - -import TextAlignUtilities from './align'; -import TextWrappingUtilities from './wrapping'; -import TextNumberUtilities from './numbers'; -import TextColorUtilities from './color'; - -export const TextUtilitiesExample = { - title: 'Text', - showThemeLanguageToggle: true, - intro: ( - -

- These text utilities are available primarily as CSS classes to aid in - quickly styling your text. Some utilities are additionally available as - either CSS-in-JS or Sass mixins to optionally compose within your own - custom styles. -

-
- ), - sections: [ - { - title: 'Alignment', - wrapText: false, - text: , - }, - { - title: 'Wrapping', - color: 'subdued', - wrapText: false, - text: , - }, - { - title: 'Numbers', - wrapText: false, - text: , - }, - { - title: 'Color', - color: 'subdued', - wrapText: false, - text: , - }, - ], -}; diff --git a/src-docs/src/views/theme/breakpoints/_breakpoints_js.tsx b/src-docs/src/views/theme/breakpoints/_breakpoints_js.tsx index eae6665883fd..552a10d25ba2 100644 --- a/src-docs/src/views/theme/breakpoints/_breakpoints_js.tsx +++ b/src-docs/src/views/theme/breakpoints/_breakpoints_js.tsx @@ -11,18 +11,23 @@ import { throttle, EuiBreakpointSize, EuiCode, + EuiThemeBreakpoints, } from '../../../../../src'; -import { EuiThemeBreakpoints } from '../_props'; +import { EuiThemeBreakpoints as _EuiThemeBreakpoints } from '../_props'; import { getPropsFromComponent } from '../../../services/props/get_props'; import { ThemeExample } from '../_components/_theme_example'; import { ThemeValuesTable } from '../_components/_theme_values_table'; export default () => { + const { euiTheme } = useEuiTheme(); const isLargeBreakpoint = useIsWithinBreakpoints(['l', 'xl']); const [currentBreakpoint, setCurrentBreakpoint] = useState( - getBreakpoint(typeof window === 'undefined' ? 0 : window.innerWidth) + getBreakpoint( + typeof window === 'undefined' ? 0 : window.innerWidth, + euiTheme.breakpoint + ) ); const [withinBreakpoints, setWithinBreakpoints] = useState( @@ -33,7 +38,7 @@ export default () => { ); const functionToCallOnWindowResize = throttle(() => { - setCurrentBreakpoint(getBreakpoint(window.innerWidth)); + setCurrentBreakpoint(getBreakpoint(window.innerWidth, euiTheme.breakpoint)); setWithinBreakpoints(isWithinBreakpoints(window.innerWidth, ['xs', 's'])); // reacts every 50ms to resize changes and always gets the final update }, 50); @@ -49,7 +54,7 @@ export default () => { return ( <> getBreakpoint(width)} + title={getBreakpoint(width, breakpoints)} type="function" description={

@@ -63,7 +68,7 @@ export default () => { Current breakpoint: {currentBreakpoint}

} - snippet="getBreakpoint(window.innerWidth)" + snippet="getBreakpoint(window.innerWidth, euiTheme.breakpoint)" snippetLanguage="js" /> @@ -134,15 +139,17 @@ export default () => { export const BreakpointValuesJS = () => { const { euiTheme } = useEuiTheme(); const breakpoint = euiTheme.breakpoint; - const breakpointTypes = getPropsFromComponent(EuiThemeBreakpoints); - const breakpoints = Object.keys(breakpointTypes); + const breakpointTypes = getPropsFromComponent(_EuiThemeBreakpoints); const [currentBreakpoint, setCurrentBreakpoint] = useState( - getBreakpoint(typeof window === 'undefined' ? 0 : window.innerWidth) + getBreakpoint( + typeof window === 'undefined' ? 0 : window.innerWidth, + euiTheme.breakpoint + ) ); const functionToCallOnWindowResize = throttle(() => { - setCurrentBreakpoint(getBreakpoint(window.innerWidth)); + setCurrentBreakpoint(getBreakpoint(window.innerWidth, euiTheme.breakpoint)); // reacts every 50ms to resize changes and always gets the final update }, 50); @@ -157,7 +164,7 @@ export const BreakpointValuesJS = () => { return ( <> { + items={EuiThemeBreakpoints.map((size) => { return { id: size, token: `breakpoint.${size}`, diff --git a/src-docs/src/views/theme/breakpoints/breakpoint_utilities.tsx b/src-docs/src/views/theme/breakpoints/breakpoint_utilities.tsx new file mode 100644 index 000000000000..cd2e6bc5344b --- /dev/null +++ b/src-docs/src/views/theme/breakpoints/breakpoint_utilities.tsx @@ -0,0 +1,183 @@ +import React, { useContext } from 'react'; +import { + BREAKPOINT_KEYS, + BREAKPOINTS, + EuiBreakpointSize, + EuiCode, + EuiCodeBlock, + EuiHideFor, + EuiShowFor, + EuiSpacer, + EuiText, +} from '../../../../../src'; + +import { GuideSection } from '../../../components/guide_section/guide_section'; +import { ThemeContext } from '../../../components/with_theme'; + +// @ts-ignore Importing from JS +import { useJsonVars } from '../_json/_get_json_vars'; + +// @ts-expect-error Importing from JS +import { GuideSectionTypes } from '../../../components'; + +import ShowFor from './show_for'; +const showForSource = require('!!raw-loader!./show_for'); + +import HideFor from './hide_for'; +const hideForSource = require('!!raw-loader!./hide_for'); + +import UtilityClassesResponsive from './utility_classes_responsive'; + +function renderJsSizes(size: EuiBreakpointSize, index: number) { + let code = `'${size}': ${BREAKPOINTS[size]}`; + + if (size !== 'xl') { + code += `, // to ${BREAKPOINTS[BREAKPOINT_KEYS[index - 1]] - 1}`; + } else { + code += ', // and up'; + } + + return code; +} + +export const breakpointUtilitySections = [ + { title: 'Show for', id: 'show-for' }, + { title: 'Hide for', id: 'hide-for' }, + { title: 'Responsive classes', id: 'responsive-classes' }, +]; + +export default () => { + const themeContext = useContext(ThemeContext); + const currentLanguage = themeContext.themeLanguage; + const showSass = currentLanguage.includes('sass'); + + const values = useJsonVars(); + const euiBreakpoints = values.euiBreakpoints; + const euiBreakpointKeys = Object.keys(euiBreakpoints).reverse(); + + function renderSassSizes(size: string, index: number) { + let code = `'${size}': (min-width: ${euiBreakpoints[size]})`; + + if (size !== 'xl') { + const next = Number( + euiBreakpoints[euiBreakpointKeys[index - 1]].replace('px', '') + ); + code += ` and (max-width: ${next - 1}px),`; + } else { + code += ','; + } + + return code; + } + + return ( + <> + + +

Screen sizes

+ +

+ The sizing options correlate with the keys in the{' '} + EuiBreakpoints type. The named + breakpoint starts at the pixel value provided and ends before the + next one. +

+
+ + + + + {showSass + ? euiBreakpointKeys + .map(function (size, index) { + return renderSassSizes(size, index); + }) + .join('\n') + : BREAKPOINT_KEYS.map(function ( + size: EuiBreakpointSize, + index: number + ) { + return renderJsSizes(size, index); + }).join('\n')} + +
+ + +

+ The EuiShowFor wrapping utility component will + not render its children unless the window width + matches the range of one of the named breakpoints provided to the{' '} + sizes prop. +

+ + } + snippet={` + +`} + props={{ EuiShowFor }} + demo={} + source={[ + { + type: GuideSectionTypes.JS, + code: showForSource, + }, + ]} + /> + + +

+ The EuiHideFor wrapping utility component will + not render its children while the window width + matches the range of one of the named breakpoints provided to the{' '} + sizes prop. +

+ + } + snippet={` + +`} + props={{ EuiShowFor, EuiHideFor }} + demo={} + source={[ + { + type: GuideSectionTypes.JS, + code: hideForSource, + }, + ]} + /> + + + + + +

{`${breakpointUtilitySections[2].title}`}

+

+ Similar to the wrapping components, these classes will hide or show + the element based on the current current width matching the range of + the declared size. However, they simply utilize + the display property which means they will still + render in the DOM. +

+
+ + +
+ + ); +}; diff --git a/src-docs/src/views/theme/breakpoints/breakpoints.tsx b/src-docs/src/views/theme/breakpoints/breakpoints.tsx index a70761933a7a..ca7f5bb861da 100644 --- a/src-docs/src/views/theme/breakpoints/breakpoints.tsx +++ b/src-docs/src/views/theme/breakpoints/breakpoints.tsx @@ -1,16 +1,16 @@ import React, { useContext, useMemo } from 'react'; -import { Link } from 'react-router-dom'; import { EuiSpacer, EuiText } from '../../../../../src'; -import { GuideTabbedPage } from '../../../components/guide_tabbed_page'; import { GuideSection } from '../../../components/guide_section/guide_section'; import { ThemeContext } from '../../../components/with_theme'; -import { ThemeNotice } from '../_components/_theme_notice'; - import JSContent, { BreakpointValuesJS } from './_breakpoints_js'; import SassContent, { BreakpointValuesSass } from './_breakpoints_sass'; +export const breakpointSections = [ + { title: 'Default values', id: 'default-values' }, +]; + export default () => { const themeContext = useContext(ThemeContext); const currentLanguage = themeContext.themeLanguage; @@ -27,22 +27,12 @@ export default () => { }, [showSass]); return ( - } - showThemeLanguageToggle - description={ - <> - For most of your usages we recommend using the{' '} - responsive utilities{' '} - instead of consuming these theme tokens directly. - - } - > + <> -

Default values

+

{`${breakpointSections[0].title}`}

If you want to align your custom responsive styles with EUI's breakpoints, or when using components that accept our named @@ -56,6 +46,6 @@ export default () => { {valuesContent} - + ); }; diff --git a/src-docs/src/views/theme/breakpoints/breakpoints_example.tsx b/src-docs/src/views/theme/breakpoints/breakpoints_example.tsx new file mode 100644 index 000000000000..8f0925c4fa7c --- /dev/null +++ b/src-docs/src/views/theme/breakpoints/breakpoints_example.tsx @@ -0,0 +1,35 @@ +import React from 'react'; +import { Link } from 'react-router-dom'; + +import { ThemeNotice } from '../_components/_theme_notice'; + +import BreakpointValues, { breakpointSections } from './breakpoints'; + +import BreakpointUtilities, { + breakpointUtilitySections, +} from './breakpoint_utilities'; + +export const BreakpointsExample = { + title: 'Breakpoints', + notice: , + showThemeLanguageToggle: true, + description: ( + <> + For most of your usages we recommend using the{' '} + responsive utilities{' '} + instead of consuming the theme values directly. + + ), + pages: [ + { + title: 'Values', + page: BreakpointValues, + sections: breakpointSections, + }, + { + title: 'Utilities', + page: BreakpointUtilities, + sections: breakpointUtilitySections, + }, + ], +}; diff --git a/src-docs/src/views/theme/breakpoints/hide_for.tsx b/src-docs/src/views/theme/breakpoints/hide_for.tsx new file mode 100644 index 000000000000..dbba715fdee8 --- /dev/null +++ b/src-docs/src/views/theme/breakpoints/hide_for.tsx @@ -0,0 +1,33 @@ +import React from 'react'; + +import { EuiCode, EuiHideFor, EuiText } from '../../../../../src/components'; + +export default () => ( + + +

+ Hiding from {'"none"'} of the screen sizes +

+ + +

+ Hiding from xs screens only +

+
+ +

+ Hiding from xs, s screens +

+
+ +

+ Hiding from xs, s, m, l screens +

+
+ +

+ Hiding from xl screens only +

+
+
+); diff --git a/src-docs/src/views/responsive/responsive.js b/src-docs/src/views/theme/breakpoints/show_for.tsx similarity index 52% rename from src-docs/src/views/responsive/responsive.js rename to src-docs/src/views/theme/breakpoints/show_for.tsx index bfdb456b904a..8dcc4e8d6bd2 100644 --- a/src-docs/src/views/responsive/responsive.js +++ b/src-docs/src/views/theme/breakpoints/show_for.tsx @@ -1,43 +1,9 @@ import React from 'react'; -import { - EuiCode, - EuiHideFor, - EuiShowFor, - EuiText, - EuiSpacer, -} from '../../../../src/components'; +import { EuiCode, EuiShowFor, EuiText } from '../../../../../src/components'; export default () => ( - -

- Hiding from {'"none"'} of the screen sizes -

-
- -

- Hiding from xs screens only -

-
- -

- Hiding from xs, s screens -

-
- -

- Hiding from xs, s, m, l screens -

-
- -

- Hiding from xl screens only -

-
- - -

Showing for {'"all"'} of the screen sizes diff --git a/src-docs/src/views/responsive/utility_classes_responsive.tsx b/src-docs/src/views/theme/breakpoints/utility_classes_responsive.tsx similarity index 89% rename from src-docs/src/views/responsive/utility_classes_responsive.tsx rename to src-docs/src/views/theme/breakpoints/utility_classes_responsive.tsx index a9b0c1e516fb..e0a8c57d70d1 100644 --- a/src-docs/src/views/responsive/utility_classes_responsive.tsx +++ b/src-docs/src/views/theme/breakpoints/utility_classes_responsive.tsx @@ -1,7 +1,7 @@ import React from 'react'; -import { EuiCode, EuiSpacer, EuiText } from '../../../../src/components'; -import { ThemeExample } from '../theme/_components/_theme_example'; +import { EuiCode, EuiSpacer } from '../../../../../src/components'; +import { ThemeExample } from '../_components/_theme_example'; const wrappingExampleStyle = { background: 'rgba(254, 228, 181, 0.5)', @@ -15,13 +15,6 @@ const wrappingDivExampleStyle = { export default () => ( <> - -

- Breakpoint sizes are based on the overall browser window width. They - start at the mininumum values listed below until 1px before the next - breakpoint. -

-
.eui-hideFor--[size]} type="className" diff --git a/src-docs/src/views/theme/color/_color.scss b/src-docs/src/views/theme/color/_color.scss index bb7da11c1e61..7bda82a86cc3 100644 --- a/src-docs/src/views/theme/color/_color.scss +++ b/src-docs/src/views/theme/color/_color.scss @@ -1,7 +1,7 @@ @include euiBreakpoint('m', 'l', 'xl') { .guideColorsPage__stickySlider { position: sticky; - top: $euiHeaderHeightCompensation; + top: 0; z-index: $euiZLevel1 - 1; // Below header } } diff --git a/src-docs/src/views/theme/color/_color_js.tsx b/src-docs/src/views/theme/color/_color_js.tsx index 9f2fe9ae79a4..c64a24581f3f 100644 --- a/src-docs/src/views/theme/color/_color_js.tsx +++ b/src-docs/src/views/theme/color/_color_js.tsx @@ -1,4 +1,4 @@ -import React, { FunctionComponent } from 'react'; +import React, { FunctionComponent, useState } from 'react'; import { Link } from 'react-router-dom'; import { css } from '@emotion/react'; import { transparentize, useEuiTheme } from '../../../../../src/services'; @@ -14,6 +14,11 @@ import { BACKGROUND_COLORS, euiBackgroundColor, useEuiPaddingCSS, + EuiButtonGroup, + EuiDescribedFormGroup, + EuiPanel, + EuiSpacer, + _EuiBackgroundColorOptions, } from '../../../../../src'; import { EuiThemeColors, ThemeRowType } from '../_props'; @@ -305,9 +310,11 @@ const cssStyles = [colorStyles['accent']]; /> useEuiBackgroundColor(color)} + title={useEuiBackgroundColor(color, method?)} type="hook" - props={`color: '${BACKGROUND_COLORS.join("' | '")}';`} + props={`color: '${BACKGROUND_COLORS.join("' | '")}'; + +method? 'opaque' | 'transparent';`} description={

Returns just the computed background color for the given{' '} @@ -333,17 +340,65 @@ const cssStyles = [colorStyles['accent']]; export const UtilsValuesJS = () => { const euiTheme = useEuiTheme(); + const backgroundButtons = ['opaque', 'transparent'].map((m) => { + return { + id: m, + label: m, + }; + }); + const [backgroundSelected, setBackgroundSelected] = useState( + backgroundButtons[0].id + ); return ( - { - return { - id: color, - token: `useEuiBackgroundColor('${color}')`, - value: euiBackgroundColor(euiTheme, color), - }; - })} - render={(item) => } - /> + <> + + Different colors for different contexts} + description={ +

+ While the hook accepts rendering the value as opaque or + transparent, we highly suggest reserving transparent for use only + during interactive states like hover and focus. +

+ } + > + + setBackgroundSelected(id)} + color="accent" + isFullWidth + /> + + + + + { + return { + id: color, + token: + backgroundSelected === 'transparent' + ? `useEuiBackgroundColor('${color}', 'transparent')` + : `useEuiBackgroundColor('${color}')`, + value: euiBackgroundColor(euiTheme, color, { + method: backgroundSelected as _EuiBackgroundColorOptions['method'], + }), + }; + })} + render={(item) => ( + + )} + /> + ); }; diff --git a/src-docs/src/views/theme/color/_contrast_js.tsx b/src-docs/src/views/theme/color/_contrast_js.tsx index 827c6ac07afe..2ff52a5a9c06 100644 --- a/src-docs/src/views/theme/color/_contrast_js.tsx +++ b/src-docs/src/views/theme/color/_contrast_js.tsx @@ -4,20 +4,20 @@ import chroma from 'chroma-js'; import { EuiText, EuiFlexGrid, - EuiBadge, EuiCopy, EuiFlexItem, useEuiTheme, EuiPanel, EuiHorizontalRule, + EuiListGroupItem, } from '../../../../../src'; import { _EuiThemeColorsMode } from '../../../../../src/global_styling/variables/colors'; import { getContrastRatings } from './_contrast_utilities'; import { brandKeys, brandTextKeys, shadeKeys, textKeys } from './_color_js'; -const textColors = [...textKeys, 'ghost', 'ink']; -const allowedColors = [...brandKeys, ...shadeKeys, 'ghost', 'ink']; +const textColors = [...textKeys, 'disabledText', 'ghost', 'ink']; +const allowedColors = [...brandKeys, ...shadeKeys, 'disabled', 'ghost', 'ink']; const textVariants = [...brandTextKeys, ...textColors]; type ColorSection = { @@ -152,12 +152,11 @@ color: $\{euiTheme.colors.${foreground}};`; textToCopy={textToCopy} > {(copy) => ( - // @ts-ignore Bad badge types - - {sanitizeColorName(foreground)} - + label={sanitizeColorName(foreground)} + /> )} diff --git a/src-docs/src/views/theme/color/_contrast_sass.tsx b/src-docs/src/views/theme/color/_contrast_sass.tsx index 537d25635227..eacd2dfd1a79 100644 --- a/src-docs/src/views/theme/color/_contrast_sass.tsx +++ b/src-docs/src/views/theme/color/_contrast_sass.tsx @@ -4,11 +4,12 @@ import React, { FunctionComponent } from 'react'; import { EuiText, EuiFlexGrid, - EuiBadge, EuiCopy, EuiFlexItem, EuiPanel, EuiHorizontalRule, + EuiListGroupItem, + useEuiTheme, } from '../../../../../src'; // @ts-ignore Importing from JS @@ -121,6 +122,7 @@ const ColorsContrastItem: FunctionComponent = ({ background, minimumContrast, }) => { + const { euiTheme } = useEuiTheme(); const palette = useJsonVars(); const backgroundColor = palette[background]; const foregroundColor = palette[foreground]; @@ -168,12 +170,11 @@ color: $${foreground};`; textToCopy={textToCopy} > {(copy) => ( - // @ts-ignore Bad badge types - - {sanitizeColorName(foreground)} - + label={sanitizeColorName(foreground)} + /> )} diff --git a/src-docs/src/views/theme/color/_contrast_slider.tsx b/src-docs/src/views/theme/color/_contrast_slider.tsx index 6dc1607cf485..d3d959dfaa39 100644 --- a/src-docs/src/views/theme/color/_contrast_slider.tsx +++ b/src-docs/src/views/theme/color/_contrast_slider.tsx @@ -9,7 +9,6 @@ import { EuiIcon, EuiSwitch, EuiSpacer, - EuiPanel, EuiFlexGroupProps, EuiRangeProps, } from '../../../../../src/components'; @@ -110,57 +109,49 @@ export const ContrastSlider: FunctionComponent = ({ ]; return ( - + - - + { + setValue(e.currentTarget.value); + // @ts-ignore Help + onChange(e.currentTarget.value, checked); + }} + showTicks + ticks={ticks} + valueAppend="+" fullWidth - > - + + + + +
+ + { - setValue(e.currentTarget.value); + setChecked(e.target.checked); // @ts-ignore Help - onChange(e.currentTarget.value, checked); + onChange(value, e.target.checked); }} - showTicks - ticks={ticks} - valueAppend="+" - fullWidth /> - - - - - - -
- - { - setChecked(e.target.checked); - // @ts-ignore Help - onChange(value, e.target.checked); - }} - /> -
-
-
+
+
); diff --git a/src-docs/src/views/theme/color/_functions_contrast.tsx b/src-docs/src/views/theme/color/_functions_contrast.tsx new file mode 100644 index 000000000000..b37bf0f31e6e --- /dev/null +++ b/src-docs/src/views/theme/color/_functions_contrast.tsx @@ -0,0 +1,139 @@ +import React, { useContext } from 'react'; +import { css } from '@emotion/react'; +import { + EuiCode, + EuiCallOut, + EuiIcon, + useEuiTheme, + makeHighContrastColor, +} from '../../../../../src'; +import { GuideSection } from '../../../components/guide_section/guide_section'; +import { ThemeContext } from '../../../components/with_theme'; + +import { ThemeExample } from '../_components/_theme_example'; +import chroma from 'chroma-js'; + +const contrastExample = `.contrastBox { + $backgroundColor: tintOrShade($euiColorWarning, 90%, 70%); + background: $backgroundColor; + + // Given two colors, adjust the first until contrast is 4.5 + color: makeHighContrastColor($euiColorWarning, $backgroundColor); + + // Graphics can have a lower minimum contrast level of 3.0 + .square { + color: makeGraphicContrastColor($euiColorWarning, $backgroundColor); + } +}`; + +export const ContrastSections = () => { + const { euiTheme } = useEuiTheme(); + const themeContext = useContext(ThemeContext); + const currentLanguage = themeContext.themeLanguage; + const showSass = currentLanguage.includes('sass'); + + const contrastFunction = showSass ? ( + makeHighContrastColor(foreground, background, ratio) + ) : ( + makeHighContrastColor(foreground, ratio)(background) + ); + + const text = ( + <> +

+ Use this function to calculate the appropriate foreground color (usually + text) based on a background color. +

+ + ); + + const props = showSass + ? `foreground: string; +background?: string = $euiPageBackgroundColor; +ratio?: number = 4.5` + : `foreground: string; +ratio?: number = 4.5; +background?: string = euiTheme.colors.body;`; + + const demo: GuideSection['demo'] = showSass ? ( +
+ + This orange text now passes a contrast check! +
+ ) : ( +
+ + {chroma + .contrast(makeHighContrastColor('white')('pink'), 'pink') + .toFixed(2)} + {": makeHighContrastColor('white')('pink')"} + +
+ ); + + const snippet: GuideSection['snippet'] = showSass + ? contrastExample + : 'color: ${makeHighContrastColor(foreground)(background)};'; + + let contrastBody; + if (!showSass) { + contrastBody = ( + + If you want to use the same background color that the EUI theme uses + for all of its contrast calculations, you can pass in the{' '} + euiTheme as the background. + + } + example={ +
+ + {chroma + .contrast( + makeHighContrastColor('#fdc791')(euiTheme), + euiTheme.colors.body + ) + .toFixed(2)} + {': makeHighContrastColor(#fdc791, euiTheme)'} + +
+ } + snippetLanguage="emotion" + snippet={'color: ${makeHighContrastColor(foreground)(euiTheme)};'} + /> + ); + } + + return ( + <> + +

+ Note that color contrast cannot be accurately detected when using + transparency (colors with alpha channels). +

+
+ + {contrastBody} + + ); +}; diff --git a/src-docs/src/views/theme/color/_functions_isDark.tsx b/src-docs/src/views/theme/color/_functions_isDark.tsx new file mode 100644 index 000000000000..a0ad01a56231 --- /dev/null +++ b/src-docs/src/views/theme/color/_functions_isDark.tsx @@ -0,0 +1,89 @@ +import React, { useContext } from 'react'; +import { css } from '@emotion/react'; +import { EuiCode, isColorDark, useEuiTheme } from '../../../../../src'; +import { ThemeContext } from '../../../components/with_theme'; +import { ThemeExample } from '../_components/_theme_example'; + +const contrastExample = `.lightOrDarkText { + background-color: $euiColorPrimary; + color: chooseLightOrDarkText($euiColorPrimary); +}`; + +export const TextSections = () => { + const { euiTheme } = useEuiTheme(); + const themeContext = useContext(ThemeContext); + const currentLanguage = themeContext.themeLanguage; + const showSass = currentLanguage.includes('sass'); + + const title = showSass ? ( + chooseLightOrDarkText(background, lightText, darkText); + ) : ( + isColorDark(red, green, blue) + ); + + const props = showSass + ? `background: string; +lightText? = $euiColorGhost; +darkText? = $euiColorInk;` + : `red: 0-255; +green: 0-255; +blue: 0-255;`; + + const text = showSass ? ( + <> + Use this function to determine whether or not to use light (white) or dark + (black) text against the given background color. The function will return + either the light or dark text parameters depending on the value of the + background color given. + + ) : ( + <> +

+ Use this function to determine whether or not to use light or dark text + against the given background color. It requires the values to be passed + in as rgb integers and will return a boolean if the + color is dark based on luminance. +

+

+ If the function returns true, use{' '} + euiTheme.colors.ghost otherwise use{' '} + euiTheme.colors.ink as the text color. +

+ + ); + const demo = showSass ? ( +
+ Checking against $euiColorPrimary +
+ ) : ( +
+ {isColorDark(0, 179, 164) ? 'Dark' : 'Light'} +
+ ); + + const snippet = showSass + ? contrastExample + : `color: \${isColorDark(color) + ? euiTheme.colors.ghost + : euiTheme.colors.ink;}`; + + return ( + + ); +}; diff --git a/src-docs/src/views/theme/color/_functions_shadeTint.tsx b/src-docs/src/views/theme/color/_functions_shadeTint.tsx new file mode 100644 index 000000000000..3387cb952b5f --- /dev/null +++ b/src-docs/src/views/theme/color/_functions_shadeTint.tsx @@ -0,0 +1,182 @@ +import React, { useContext } from 'react'; +import { + EuiBadge, + EuiCode, + shade, + tint, + useEuiTheme, +} from '../../../../../src'; + +import { ThemeContext } from '../../../components/with_theme/theme_context'; +import { ThemeExample } from '../_components/_theme_example'; + +const tintExample = `.tint { + $backgroundColor: tint($euiColorSuccess, 20%); + background: $backgroundColor; + color: chooseLightOrDarkText($backgroundColor); +}`; + +const shadeExample = `.shade { + $backgroundColor: shade($euiColorSuccess, 40%); + background: $backgroundColor; + color: chooseLightOrDarkText($backgroundColor); +}`; + +const tintOrShadeExample = `.tintOrShade { + $backgroundColor: tintOrShade($euiColorSuccess, 80%, 80%); + background: $backgroundColor; + color: chooseLightOrDarkText($backgroundColor); +}`; + +export const TintShadeSections = () => { + const { euiTheme } = useEuiTheme(); + const themeContext = useContext(ThemeContext); + const currentLanguage = themeContext.themeLanguage; + const showSass = currentLanguage.includes('sass'); + + const props = showSass + ? `color: string; +percent: 0%-100%;` + : `color: string; +ratio: decimal = 0-1;`; + + /** TINT */ + + const tintFunction = showSass ? ( + tint(color, percent) + ) : ( + tint(color, ratio) + ); + + const text = ( +

+ Use this function to mix any color with white. The higher + the ratio, the more white will be mixed. +

+ ); + + const demo = showSass ? ( +
+ This is the success color tinted by 20%. +
+ ) : ( + + tint( + + {euiTheme.colors.danger} + + , 0.75) ={' '} + + {tint(euiTheme.colors.danger, 0.75)} + + + ); + + const snippet = showSass ? tintExample : 'tint(euiTheme.colors.danger, 0.75)'; + + const tintSection = ( + + ); + + /** SHADE */ + + const shadeFunction = showSass ? ( + shade(color, percent) + ) : ( + shade(color, ratio) + ); + + const text_shade = ( +

+ Use this function to mix any color with black. The higher + the ratio, the more black will be mixed. +

+ ); + + const demo_shade = showSass ? ( +
+ This is the success color shaded by 40%. +
+ ) : ( + + shade( + + {euiTheme.colors.danger} + + , 0.75) ={' '} + + {shade(euiTheme.colors.danger, 0.25)} + + + ); + + const snippet_shade = showSass + ? shadeExample + : 'shade(euiTheme.colors.danger, 0.25)'; + + const shadeSection = ( + + ); + + /** SASS tintORShade */ + + let tintShadeSection; + + if (showSass) { + const text = ( +

+ If you are affording for both light and dark themes, you can use this + single function to shade or tint based on the color mode. Taking the + color as the first parameter, it will tint the color in the light mode, + but shade it in the dark mode. This makes the background color more + subtle in both color modes. The opposite function{' '} + + shadeOrTint(color, shade_percent, tint_percent) + {' '} + also exists. +

+ ); + const demo = ( +
+ This success color is tinted in light mode and shaded in dark. +
+ ); + tintShadeSection = ( + tintOrShade(color, tint_percent, shade_percent)} + type="function" + description={text} + props={`color: string; +tint_percent: 0%-100%; +shade_percent: 0%-100%;`} + example={demo} + snippetLanguage={showSass ? 'sass' : 'emotion'} + snippet={tintOrShadeExample} + /> + ); + } + + return ( + <> + {tintSection} + {shadeSection} + {tintShadeSection} + + ); +}; diff --git a/src-docs/src/views/theme/color/_functions_transparency.tsx b/src-docs/src/views/theme/color/_functions_transparency.tsx new file mode 100644 index 000000000000..b6dbb08249b1 --- /dev/null +++ b/src-docs/src/views/theme/color/_functions_transparency.tsx @@ -0,0 +1,63 @@ +import React, { useContext } from 'react'; +import { + EuiBadge, + EuiCode, + transparentize, + useEuiTheme, +} from '../../../../../src'; +import { ThemeContext } from '../../../components/with_theme'; + +import { ThemeExample } from '../_components/_theme_example'; + +const sassExample = `.transparency { + background: transparentize($euiColorPrimary, .8); +}`; + +export const TransparencySections = () => { + const { euiTheme, colorMode } = useEuiTheme(); + const themeContext = useContext(ThemeContext); + const currentLanguage = themeContext.themeLanguage; + const showSass = currentLanguage.includes('sass'); + + const props = `color: string; +alpha: decimal = 0-1;`; + + const text = ( +

+ Use this function to convert any color to rgba() with + the provided alpha value. +

+ ); + const demo = showSass ? ( +
+ The background is a transparent version of the primary color +
+ ) : ( + + transparentize( + #006837, 0.75) ={' '} + + {transparentize('#006837', 0.25)} + + + ); + const snippet = showSass ? sassExample : 'transparentize(color, 0.75)'; + + return ( + transparentize(color, alpha)} + type={'function'} + description={text} + props={props} + example={demo} + snippetLanguage={showSass ? 'sass' : 'tsx'} + snippet={snippet} + /> + ); +}; diff --git a/src-docs/src/views/theme/color/colors.tsx b/src-docs/src/views/theme/color/colors.tsx deleted file mode 100644 index 9a0a9370b83f..000000000000 --- a/src-docs/src/views/theme/color/colors.tsx +++ /dev/null @@ -1,268 +0,0 @@ -import React, { useContext, useMemo, useState } from 'react'; -import { Link } from 'react-router-dom'; - -import { EuiCallOut, EuiCode, EuiSpacer, EuiText } from '../../../../../src'; -import { GuideSection } from '../../../components/guide_section/guide_section'; - -import { GuideTabbedPage } from '../../../components/guide_tabbed_page'; -import { ThemeContext } from '../../../components/with_theme'; - -import { ThemeNotice } from '../_components/_theme_notice'; - -// @ts-ignore Importing JS -import ColorsContrast from './contrast'; - -import { - BrandJS, - BrandValuesJS, - ShadeJS, - ShadeValuesJS, - SpecialJS, - SpecialValuesJS, - TextJS, - TextValuesJS, - UtilsJS, - UtilsValuesJS, -} from './_color_js'; -import { - BrandSass, - BrandValuesSass, - ShadeSass, - ShadeValuesSass, - SpecialSass, - SpecialValuesSass, - TextSass, - TextValuesSass, -} from './_color_sass'; - -const tabs = [ - { - label: 'Values', - id: 'colorsTabs--values', - }, - { - label: 'Contrast checker', - id: 'colorsTabs--contrast', - }, -]; - -// This array is used inside routes.js to create the sidenav sub-sections -export const colorsSections = [ - { title: 'Brand colors', id: 'brand-colors' }, - { title: 'Text colors', id: 'text-colors' }, - { title: 'Shades', id: 'shades' }, - { title: 'Special colors', id: 'special-colors' }, - { title: 'Background colors', id: 'background-colors' }, -]; - -export default () => { - const themeContext = useContext(ThemeContext); - const currentLanguage = themeContext.themeLanguage; - const showSass = currentLanguage.includes('sass'); - - const [selectedTabId, setSelectedTabId] = useState('colorsTabs--values'); - const onSelectedTabChanged = (id: string) => { - setSelectedTabId(id); - }; - - const brandContent = useMemo(() => { - const description = ( -

- Most usages of the colors can be implemented simply by pulling and - applying the values. -

- ); - if (showSass) return ; - return ; - }, [showSass]); - - const textContent = useMemo(() => { - const description = ( -

- Remember, when using any of the EUI colors for text,{' '} - use the text specific variant. -

- ); - if (showSass) return ; - return ; - }, [showSass]); - - const shadesContent = useMemo(() => { - const description = ( - <> -

- Since the EUI colors usually evaluate to a hex value, the easiest way - to perform color operations like transparency, shading, or tinting is - by using the EUI provided methods of{' '} - transparentize(), shade(), and{' '} - tint() respectively. -

-

- For all available color functions see the{' '} - Color Utilities page. -

- - ); - if (showSass) return ; - return ; - }, [showSass]); - - const specialContent = useMemo(() => { - const description = ( -

- Constant colors are those that do not change no matter the theme or - color mode and typically represent the polar extremes. -

- ); - if (showSass) return ; - return ; - }, [showSass]); - - const utilsContent = useMemo(() => { - if (showSass) - return ; - return ; - }, [showSass]); - - return ( - } - showThemeLanguageToggle - tabs={tabs.map((tab) => { - return { - label: tab.label, - id: tab.id, - onClick: () => onSelectedTabChanged(tab.id), - isSelected: tab.id === selectedTabId, - }; - })} - 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 with a six-color grayscale. Variation beyond these colors - is minimal and always done with math manipulation against the - original set. -

-

- When switching between light and dark color modes, the theme keys - do not change, only their values do. This is why most keys are not - named for their evaluated value but by their{' '} - purpose. -

-
- - } - > - {selectedTabId.includes('contrast') ? ( - - ) : ( - <> - - -

{`${colorsSections[0].title}`}

-

- Elastic has two main brand colors. The other three are used for - statefulness like indicating between successful and dangerous - actions. -

-
- - {brandContent} -
- - - {showSass ? : } - - - - -

{`${colorsSections[1].title}`}

-

- Specific text colors calculated off either the brand or shade - colors. -

-

- Each brand color also has a corresponding text variant that has - been calculated for proper (at least 4.5) contrast against{' '} - colors.body and should be used specifically - when coloring text. As is used in{' '} - - EuiTextColor - - . -

-
- - {textContent} -
- - - {showSass ? : } - - - - -

{`${colorsSections[2].title}`}

-

- A six-color grayscale palette. Variation beyond these colors is - minimal and always done through computations against this set. -

-
- - {shadesContent} -
- - - {showSass ? : } - - - - - {' '} -

{`${colorsSections[3].title}`}

-

These are used a lot for special cases.

-
- - {specialContent} -
- - - {showSass ? : } - - - - -

{`${colorsSections[4].title}`}

-
- - - - {utilsContent} -
- - {showSass ? undefined : ( - - {' '} - - - )} - - )} -
- ); -}; diff --git a/src-docs/src/views/theme/color/contrast.tsx b/src-docs/src/views/theme/color/contrast.tsx index 12269d8d02fc..e4e9216ce965 100644 --- a/src-docs/src/views/theme/color/contrast.tsx +++ b/src-docs/src/views/theme/color/contrast.tsx @@ -7,8 +7,10 @@ import { EuiLink, EuiTitle, EuiPanel, - EuiCallOut, EuiCode, + EuiDescribedFormGroup, + EuiButtonGroup, + useEuiTheme, } from '../../../../../src'; import { @@ -23,74 +25,135 @@ import { brandKeys, shadeKeys } from './_color_js'; import { ContrastSlider } from './_contrast_slider'; import { ratingAA } from './_contrast_utilities'; import { _EuiThemeColorsMode } from '../../../../../src/global_styling/variables/colors'; -import { GuideSection } from '../../../components/guide_section/guide_section'; import { BACKGROUND_COLORS, - EuiBackgroundColor, + _EuiBackgroundColor, useEuiBackgroundColor, } from '../../../../../src/global_styling'; +import { + BUTTON_COLORS, + euiButtonColor, + _EuiButtonColor, +} from '../../../../../src/themes/amsterdam/global_styling/mixins/button'; +import { GuideSection } from '../../../components/guide_section/guide_section'; + +// This array is used inside routes.js to create the sidenav sub-sections +export const contrastSections = [ + { title: 'Body background color', id: 'body-background-color' }, + { title: 'Brand colors', id: 'brand-colors' }, + { title: 'Shades', id: 'shades' }, + { title: 'Background colors', id: 'background-colors' }, +]; + +const background_colors = BACKGROUND_COLORS.filter( + (color) => color !== 'transparent' +); export default () => { + const euiTheme = useEuiTheme(); const [showTextVariants, setShowTextVariants] = useState(true); const [contrastValue, setContrastValue] = useState(4.5); - const showSass = useContext(ThemeContext).themeLanguage.includes('sass'); + 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, + }; + }); - return ( - - -

Accessible text contrast

-

- - WCAG specifications - {' '} - defines specific contrast ratios between foreground text and a - background color. The grids below display which color combinations - pass that rating. In general you should try to use a color combination - that is {ratingAA} or above with the exception of using large text. -

-
- - - - -

- Use the slider and toggle to adjust the color combinations shown in - the sections below. -

-
- + const [backgroundColors, setBackgroundColors] = useState( + background_colors + ); + const [backgroundFunction, setBackgroundFunction] = useState( + 'useEuiBackgroundColor' + ); + const [backgroundSelected, setBackgroundSelected] = useState( + backgroundButtons[0].id + ); - {/* This wrapping div for the sticky positioning */} -
- , - toggleChecked: React.SetStateAction - ) => { - setContrastValue(sliderValue); - setShowTextVariants(toggleChecked); - }} - /> - - + const switchBackgroundColors = (id: string) => { + switch (id) { + case 'container': + setBackgroundSelected(id); + setBackgroundColors(background_colors); + setBackgroundFunction('useEuiBackgroundColor(color)'); + break; + case 'hover': + setBackgroundSelected(id); + setBackgroundColors(background_colors); + setBackgroundFunction("useEuiBackgroundColor(color, 'transparent')"); + break; + case 'button': + setBackgroundSelected(id); + setBackgroundColors(BUTTON_COLORS); + setBackgroundFunction('euiButtonColor(color)'); + break; + } + }; + const showSass = useContext(ThemeContext).themeLanguage.includes('sass'); + + return ( + <> + -

{showSass ? 'Page' : 'Body'} background color

+

Accessible text contrast

- In order to meet contrast minimums, the text variants use the page - body color as the denominator for calculating the altered color. - Text placed on backgrounds darker than this cannot guarantee - contrast acceptance. + + WCAG specifications + {' '} + defines specific contrast ratios between foreground text and a + background color. The grids below display which color combinations + pass that rating. In general you should try to use a color + combination that is {ratingAA} or above with the exception of using + large text.

+
+ + {/* This wrapping div for the sticky positioning */} +
+ + +

+ Use the slider and toggle to adjust the color combinations shown + in the sections below. +

+
+ + , + toggleChecked: React.SetStateAction + ) => { + setContrastValue(sliderValue); + setShowTextVariants(toggleChecked); + }} + /> +
- + + +

{`${contrastSections[0].title}`}

+

+ In order to meet contrast minimums, the text variants use the page + body color as the denominator for calculating the altered color. + Text placed on backgrounds darker than this cannot guarantee + contrast acceptance. +

+
+ + - {showSass ? ( { showTextVariants={showTextVariants} /> )} - - - +
- -

Brand colors

-

- We typically only recommend using full black or white on top of - brand colors. This can be in the form of full, empty, ink, or ghost - shades. Never combine two brand colors. -

-
+ + +

{`${contrastSections[1].title}`}

+

+ We typically only recommend using full black or white on top of + brand colors. This can be in the form of full, empty, ink, or + ghost shades. Never combine two brand colors. +

+
- + - {showSass ? sassCoreColors.map((color: string) => { return ( @@ -145,22 +208,22 @@ export default () => { ); })} - +
- + + +

{`${contrastSections[2].title}`}

+

+ Again we recommend sticking with the text variant of brand colors + when possible. The opposite may be true when using darker shades + as backgrounds. +

+
- -

Shades

-

- Again we recommend sticking with the text variant of brand colors - when possible. The opposite may be true when using darker shades as - backgrounds. -

-
- - + - {showSass ? sassGrayColors.map((color: string) => { return ( @@ -188,47 +251,111 @@ export default () => { ); })} - +
- + + +

{`${contrastSections[3].title}`}

+
+ + {showSass ? ( +

+ + Background colors only exist for CSS-in-JS styling. + +

+ ) : ( + <> + + Different colors for different contexts} + description={ +

+ These background colors are pre-defined shades of the + brand colors. They are recalled by using the hook{' '} + {backgroundFunction}. +

+ } + > + + switchBackgroundColors(id)} + color="accent" + isFullWidth + /> +
+
+ - -

Background colors

-

- These background colors are pre-defined shades of the brand colors. - They are recalled by using the hook{' '} - useEuiBackgroundColor(color). -

-
+ {backgroundColors.map((color: string) => { + switch (backgroundSelected) { + case 'container': + return ( + + + + + ); - + case 'hover': + return ( + + + + + ); - - {showSass ? ( - - ) : ( - BACKGROUND_COLORS.map((color: string) => { - return ( - color !== 'transparent' && ( - - - - - ) - ); - }) + case 'button': + return ( + color !== 'disabled' && ( + + + + + ) + ); + } + })} + )} - +
- + ); }; diff --git a/src-docs/src/views/theme/color/functions.tsx b/src-docs/src/views/theme/color/functions.tsx new file mode 100644 index 000000000000..22dd2d0f56a6 --- /dev/null +++ b/src-docs/src/views/theme/color/functions.tsx @@ -0,0 +1,100 @@ +import React, { useContext } from 'react'; +import { ThemeContext } from '../../../components/with_theme'; + +import { EuiCallOut, EuiSpacer, EuiText } from '../../../../../src'; +import { GuideSection } from '../../../components/guide_section/guide_section'; + +import { ContrastSections } from './_functions_contrast'; +import { TextSections } from './_functions_isDark'; +import { TintShadeSections } from './_functions_shadeTint'; +import { TransparencySections } from './_functions_transparency'; + +import { UtilsJS, UtilsValuesJS } from './_color_js'; + +// This array is used inside routes.js to create the sidenav sub-sections +export const colorsFunctionsSections = [ + { + title: 'Background colors', + id: 'background-colors', + }, + { + title: 'Contrast', + id: 'contrast', + }, + { + title: 'Transparency', + id: 'transparency', + }, + { + title: 'Tint and shade', + id: 'tint-and-shade', + }, +]; + +export default () => { + const themeContext = useContext(ThemeContext); + const currentLanguage = themeContext.themeLanguage; + const showSass = currentLanguage.includes('sass'); + + return ( + <> + {showSass ? ( + + + + ) : ( + <> + + +

{`${colorsFunctionsSections[0].title}`}

+
+ + + + +
+ + + + + + )} + + + +

Utilities

+
+ + +

{`${colorsFunctionsSections[1].title}`}

+
+ + +
+ + + +

{`${colorsFunctionsSections[2].title}`}

+
+ + +
+ + + +

{`${colorsFunctionsSections[3].title}`}

+
+ + +
+ + ); +}; diff --git a/src-docs/src/views/theme/color/tokens.tsx b/src-docs/src/views/theme/color/tokens.tsx new file mode 100644 index 000000000000..94678ca39598 --- /dev/null +++ b/src-docs/src/views/theme/color/tokens.tsx @@ -0,0 +1,203 @@ +import React, { useContext, useMemo } from 'react'; +import { Link } from 'react-router-dom'; + +import { EuiCode, EuiSpacer, EuiText } from '../../../../../src'; +import { GuideSection } from '../../../components/guide_section/guide_section'; + +import { ThemeContext } from '../../../components/with_theme'; +import { ThemeNotice } from '../_components/_theme_notice'; + +import { + BrandJS, + BrandValuesJS, + ShadeJS, + ShadeValuesJS, + SpecialJS, + SpecialValuesJS, + TextJS, + TextValuesJS, +} from './_color_js'; +import { + BrandSass, + BrandValuesSass, + ShadeSass, + ShadeValuesSass, + SpecialSass, + SpecialValuesSass, + TextSass, + TextValuesSass, +} from './_color_sass'; + +export const colorsInfo = { + title: 'Colors', + notice: , + showThemeLanguageToggle: true, + description: ( + <> +

+ 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 + with a six-color grayscale. Variation beyond these colors is minimal and + always done with math manipulation against the original set. +

+

+ When switching between light and dark color modes, the theme keys do not + change, only their values do. This is why most keys are not named for + their evaluated value but by their{' '} + purpose. +

+ + ), +}; + +// This array is used inside routes.js to create the sidenav sub-sections +export const colorsSections = [ + { title: 'Brand colors', id: 'brand-colors' }, + { title: 'Text colors', id: 'text-colors' }, + { title: 'Shades', id: 'shades' }, + { title: 'Special colors', id: 'special-colors' }, +]; + +export default () => { + const themeContext = useContext(ThemeContext); + const currentLanguage = themeContext.themeLanguage; + const showSass = currentLanguage.includes('sass'); + + const brandContent = useMemo(() => { + const description = ( +

+ Most usages of the colors can be implemented simply by pulling and + applying the values. +

+ ); + if (showSass) return ; + return ; + }, [showSass]); + + const textContent = useMemo(() => { + const description = ( +

+ Remember, when using any of the EUI colors for text,{' '} + use the text specific variant. +

+ ); + if (showSass) return ; + return ; + }, [showSass]); + + const shadesContent = useMemo(() => { + const description = ( + <> +

+ Since the EUI colors usually evaluate to a hex value, the easiest way + to perform color operations like transparency, shading, or tinting is + by using the EUI provided methods of{' '} + transparentize(), shade(), and{' '} + tint() respectively. +

+

+ For all available color functions see the{' '} + Color Utilities page. +

+ + ); + if (showSass) return ; + return ; + }, [showSass]); + + const specialContent = useMemo(() => { + const description = ( +

+ Constant colors are those that do not change no matter the theme or + color mode and typically represent the polar extremes. +

+ ); + if (showSass) return ; + return ; + }, [showSass]); + + return ( + <> + + +

{`${colorsSections[0].title}`}

+

+ Elastic has two main brand colors. The other three are used for + statefulness like indicating between successful and dangerous + actions. +

+
+ + + + {brandContent} +
+ + + {showSass ? : } + + + + +

{`${colorsSections[1].title}`}

+

+ Specific text colors calculated off either the brand or shade + colors. +

+

+ Each brand color also has a corresponding text variant that has been + calculated for proper (at least 4.5) contrast against{' '} + colors.body and should be used specifically when + coloring text. As is used in{' '} + + EuiTextColor + + . +

+
+ + + + {textContent} +
+ + + {showSass ? : } + + + + +

{`${colorsSections[2].title}`}

+

+ A six-color grayscale palette. Variation beyond these colors is + minimal and always done through computations against this set. +

+
+ + + + {shadesContent} +
+ + + {showSass ? : } + + + + + {' '} +

{`${colorsSections[3].title}`}

+

These are used a lot for special cases.

+
+ + + + {specialContent} +
+ + + {showSass ? : } + + + ); +}; diff --git a/src-docs/src/views/theme/sizing/_sizing_js.tsx b/src-docs/src/views/theme/sizing/_sizing_js.tsx index 5318b809aefb..d42fbd8cbdb9 100644 --- a/src-docs/src/views/theme/sizing/_sizing_js.tsx +++ b/src-docs/src/views/theme/sizing/_sizing_js.tsx @@ -17,6 +17,7 @@ import { EuiAccordion, PADDING_SIZES, LOGICAL_SIDES, + EuiPanel, } from '../../../../../src'; import { ThemeExample } from '../_components/_theme_example'; @@ -240,21 +241,23 @@ export const UtilsJS = () => { snippet={"${logicals['padding-left']}: 100px;"} /> - All supported properties} - paddingSize="m" - > - + All supported properties} + paddingSize="m" > - {Object.keys(logicals).join('\r\n')} - - + + {Object.keys(logicals).join('\r\n')} + + + ); }; diff --git a/src-docs/src/views/theme/sizing/functions.tsx b/src-docs/src/views/theme/sizing/functions.tsx new file mode 100644 index 000000000000..e33839464fde --- /dev/null +++ b/src-docs/src/views/theme/sizing/functions.tsx @@ -0,0 +1,60 @@ +import React, { useContext, useMemo } from 'react'; + +import { EuiCallOut, EuiSpacer, EuiTitle } from '../../../../../src'; + +import { GuideSection } from '../../../components/guide_section/guide_section'; +import { ThemeContext } from '../../../components/with_theme'; + +import { PaddingJS, UtilsJS } from './_sizing_js'; + +// This array is used inside routes.js to create the sidenav sub-sections +export const sizingFunctionSections = [ + { title: 'Logical properties', id: 'logical' }, + { title: 'Padding', id: 'padding' }, +]; + +export default () => { + const themeContext = useContext(ThemeContext); + const currentLanguage = themeContext.themeLanguage; + const showSass = currentLanguage.includes('sass'); + + const utilsContent = useMemo(() => { + if (showSass) + return ; + return ; + }, [showSass]); + + const paddingContent = useMemo(() => { + if (showSass) + return ; + return ; + }, [showSass]); + + return ( + <> + + +

{`${sizingFunctionSections[0].title}`}

+
+ + + + {utilsContent} +
+ + + +

{`${sizingFunctionSections[1].title}`}

+
+ + + + {paddingContent} +
+ + ); +}; diff --git a/src-docs/src/views/theme/sizing/sizing.tsx b/src-docs/src/views/theme/sizing/tokens.tsx similarity index 56% rename from src-docs/src/views/theme/sizing/sizing.tsx rename to src-docs/src/views/theme/sizing/tokens.tsx index 27e61dda3323..6c08b2e3e324 100644 --- a/src-docs/src/views/theme/sizing/sizing.tsx +++ b/src-docs/src/views/theme/sizing/tokens.tsx @@ -1,27 +1,25 @@ import React, { useContext, useMemo } from 'react'; -import { EuiCallOut, EuiSpacer, EuiText, EuiTitle } from '../../../../../src'; +import { EuiSpacer, EuiText, EuiTitle } from '../../../../../src'; -import { GuideTabbedPage } from '../../../components/guide_tabbed_page'; import { GuideSection } from '../../../components/guide_section/guide_section'; import { ThemeContext } from '../../../components/with_theme'; import { ThemeNotice } from '../_components/_theme_notice'; -import JSValues, { - BaseJS, - PaddingJS, - ScaleValuesJS, - UtilsJS, -} from './_sizing_js'; +import JSValues, { BaseJS, ScaleValuesJS } from './_sizing_js'; import SassValues, { BaseSass, ScaleValuesSass } from './_sizing_sass'; +export const sizingInfo = { + title: 'Sizing', + notice: , + showThemeLanguageToggle: true, +}; + // This array is used inside routes.js to create the sidenav sub-sections export const sizingSections = [ { title: 'Base', id: 'base' }, { title: 'Scale', id: 'scale' }, - { title: 'Logical properties', id: 'logical' }, - { title: 'Padding', id: 'padding' }, ]; export default () => { @@ -39,25 +37,8 @@ export default () => { return ; }, [showSass]); - const utilsContent = useMemo(() => { - if (showSass) - return ; - return ; - }, [showSass]); - - const paddingContent = useMemo(() => { - if (showSass) - return ; - return ; - }, [showSass]); - return ( - } - showThemeLanguageToggle - > + <>

{`${sizingSections[0].title}`}

@@ -85,26 +66,6 @@ export default () => { {showSass ? : } - - - -

{`${sizingSections[2].title}`}

-
- - - - {utilsContent} -
- - - -

{`${sizingSections[3].title}`}

-
- - - - {paddingContent} -
-
+ ); }; diff --git a/src-docs/src/views/text_utilities/align.tsx b/src-docs/src/views/theme/typography/_text_align.tsx similarity index 92% rename from src-docs/src/views/text_utilities/align.tsx rename to src-docs/src/views/theme/typography/_text_align.tsx index d37807f60f46..5a3bc061821f 100644 --- a/src-docs/src/views/text_utilities/align.tsx +++ b/src-docs/src/views/theme/typography/_text_align.tsx @@ -1,7 +1,7 @@ import React from 'react'; -import { EuiMark } from '../../../../src'; -import { ThemeExample } from '../theme/_components/_theme_example'; +import { EuiMark } from '../../../../../src'; +import { ThemeExample } from '../_components/_theme_example'; export default () => ( <> diff --git a/src-docs/src/views/text_utilities/color.tsx b/src-docs/src/views/theme/typography/_text_color.tsx similarity index 87% rename from src-docs/src/views/text_utilities/color.tsx rename to src-docs/src/views/theme/typography/_text_color.tsx index fd5f24a0377a..b66c0cacd6f5 100644 --- a/src-docs/src/views/text_utilities/color.tsx +++ b/src-docs/src/views/theme/typography/_text_color.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { Link } from 'react-router-dom'; -import { EuiCode, EuiTextColor } from '../../../../src'; -import { ThemeExample } from '../theme/_components/_theme_example'; +import { EuiCode, EuiTextColor } from '../../../../../src'; +import { ThemeExample } from '../_components/_theme_example'; export default () => ( { const themeContext = useContext(ThemeContext); diff --git a/src-docs/src/views/text_utilities/wrapping.tsx b/src-docs/src/views/theme/typography/_text_wrapping.tsx similarity index 97% rename from src-docs/src/views/text_utilities/wrapping.tsx rename to src-docs/src/views/theme/typography/_text_wrapping.tsx index 7044c735e6f6..897ee87335ce 100644 --- a/src-docs/src/views/text_utilities/wrapping.tsx +++ b/src-docs/src/views/theme/typography/_text_wrapping.tsx @@ -1,15 +1,15 @@ import React, { useContext } from 'react'; +import { css } from '@emotion/react'; -import { ThemeContext } from '../../components/with_theme'; +import { ThemeContext } from '../../../components/with_theme'; import { EuiPanel, EuiCode, euiTextTruncate, euiTextBreakWord, -} from '../../../../src'; -import { ThemeExample } from '../theme/_components/_theme_example'; -import { css } from '@emotion/react'; +} from '../../../../../src'; +import { ThemeExample } from '../_components/_theme_example'; const maxWidth = 300; const longLink = diff --git a/src-docs/src/views/theme/typography/utilities.tsx b/src-docs/src/views/theme/typography/utilities.tsx new file mode 100644 index 000000000000..61ec42704ffd --- /dev/null +++ b/src-docs/src/views/theme/typography/utilities.tsx @@ -0,0 +1,76 @@ +import React from 'react'; + +import { EuiTitle } from '../../../../../src'; + +import { GuideSection } from '../../../components/guide_section/guide_section'; + +import TextAlignUtilities from './_text_align'; +import TextWrappingUtilities from './_text_wrapping'; +import TextNumberUtilities from './_text_numbers'; +import TextColorUtilities from './_text_color'; + +// This array is used inside routes.js to create the sidenav sub-sections +export const textUtilitiesSections = [ + { + title: 'Alignment', + id: 'alignment', + }, + { + title: 'Wrapping', + id: 'wrapping', + }, + { + title: 'Numbers', + id: 'numbers', + }, + { + title: 'Color', + id: 'color', + }, +]; + +export default () => { + return ( + <> + + +

{`${textUtilitiesSections[0].title}`}

+
+ + +
+ + + +

{`${textUtilitiesSections[1].title}`}

+
+ + +
+ + + +

{`${textUtilitiesSections[2].title}`}

+
+ + +
+ + + +

{`${textUtilitiesSections[3].title}`}

+
+ + +
+ + ); +}; diff --git a/src-docs/src/views/theme/typography/typography.tsx b/src-docs/src/views/theme/typography/values.tsx similarity index 90% rename from src-docs/src/views/theme/typography/typography.tsx rename to src-docs/src/views/theme/typography/values.tsx index 494894f22a40..d38145b734ad 100644 --- a/src-docs/src/views/theme/typography/typography.tsx +++ b/src-docs/src/views/theme/typography/values.tsx @@ -5,7 +5,6 @@ import { Link } from 'react-router-dom'; import fonts from '!!sass-vars-to-js-loader?preserveKeys=true!../../../../../src/global_styling/variables/_font_weight.scss'; import { GuideSection } from '../../../components/guide_section/guide_section'; -import { GuideTabbedPage } from '../../../components/guide_tabbed_page'; import { useEuiTheme, @@ -38,6 +37,30 @@ import { FontValuesSass, } from './_typography_sass'; +export const typographyInfo = { + title: 'Typography', + notice: , + showThemeLanguageToggle: true, + description: ( + <> +

+ For most of your usages we recommend using{' '} + + EuiText + {' '} + or{' '} + + EuiTitle + {' '} + components directly instead of these theme tokens. Or + head to the{' '} + text utilities page for + helper classes and functions. +

+ + ), +}; + // This array is used inside routes.js to create the sidenav sub-sections export const typographySections = [ { title: 'Font scale', id: 'font-scale' }, @@ -84,27 +107,7 @@ export default () => { }, [showSass]); return ( - } - showThemeLanguageToggle - description={ - <> - For most of your usages we recommend using{' '} - - EuiText - {' '} - or{' '} - - EuiTitle - {' '} - components directly instead of these theme tokens. Or - head to the text utilities page for - helper classes and functions. - - } - > + <>

{ )} - + ); }; diff --git a/src-docs/src/views/utility_classes/utility_classes_example.js b/src-docs/src/views/utility_classes/utility_classes_example.js index 9aec68e349a0..52bdfb63c5eb 100644 --- a/src-docs/src/views/utility_classes/utility_classes_example.js +++ b/src-docs/src/views/utility_classes/utility_classes_example.js @@ -28,8 +28,8 @@ export const UtilityClassesExample = { For responsive specific utilities, go to the{' '} - - Responsive documentation page + + Breakpoint utilities page . diff --git a/src/components/accordion/__snapshots__/accordion.test.tsx.snap b/src/components/accordion/__snapshots__/accordion.test.tsx.snap index e4bb10f960b7..2694fa8d6ec6 100644 --- a/src/components/accordion/__snapshots__/accordion.test.tsx.snap +++ b/src/components/accordion/__snapshots__/accordion.test.tsx.snap @@ -943,7 +943,7 @@ exports[`EuiAccordion props isLoadingMessage is rendered 1`] = ` role="progressbar" />

Please wait diff --git a/src/components/avatar/__snapshots__/avatar.test.tsx.snap b/src/components/avatar/__snapshots__/avatar.test.tsx.snap index 8789f8839930..b557787740ed 100644 --- a/src/components/avatar/__snapshots__/avatar.test.tsx.snap +++ b/src/components/avatar/__snapshots__/avatar.test.tsx.snap @@ -83,7 +83,7 @@ exports[`EuiAvatar props color as string is rendered 1`] = ` exports[`EuiAvatar props color as subdued is rendered 1`] = `

@@ -883,7 +883,7 @@ exports[`EuiCard props titleElement with nodes 1`] = ` Card title

@@ -908,7 +908,7 @@ exports[`EuiCard props titleSize 1`] = ` Card title

diff --git a/src/components/card/checkable_card/__snapshots__/checkable_card.test.tsx.snap b/src/components/card/checkable_card/__snapshots__/checkable_card.test.tsx.snap index 0cf927ad9d3a..bdf3cebc6414 100644 --- a/src/components/card/checkable_card/__snapshots__/checkable_card.test.tsx.snap +++ b/src/components/card/checkable_card/__snapshots__/checkable_card.test.tsx.snap @@ -5,7 +5,7 @@ exports[`EuiCheckableCard is rendered 1`] = ` class="euiPanel euiPanel--plain euiSplitPanel euiSplitPanel--row euiCheckableCard testClass1 testClass2 css-10vseit-euiPanel-m-plain-hasBorder" >

1 diff --git a/src/components/panel/__snapshots__/panel.test.tsx.snap b/src/components/panel/__snapshots__/panel.test.tsx.snap index 8816b943969f..57bb540fae47 100644 --- a/src/components/panel/__snapshots__/panel.test.tsx.snap +++ b/src/components/panel/__snapshots__/panel.test.tsx.snap @@ -46,7 +46,7 @@ exports[`EuiPanel props color primary is rendered 1`] = ` exports[`EuiPanel props color subdued is rendered 1`] = `
`; diff --git a/src/components/panel/panel.tsx b/src/components/panel/panel.tsx index f465fe6273b0..1c284c769b6d 100644 --- a/src/components/panel/panel.tsx +++ b/src/components/panel/panel.tsx @@ -17,7 +17,7 @@ import { useEuiTheme } from '../../services'; import { useEuiBackgroundColorCSS, useEuiPaddingCSS, - EuiBackgroundColor, + _EuiBackgroundColor, EuiPaddingSize, BACKGROUND_COLORS, PADDING_SIZES, @@ -44,7 +44,7 @@ export const BORDER_RADII = ['none', 'm'] as const; export type PanelBorderRadius = typeof BORDER_RADII[number]; export const COLORS = BACKGROUND_COLORS; -export type PanelColor = EuiBackgroundColor; +export type PanelColor = _EuiBackgroundColor; export interface _EuiPanelProps extends CommonProps { /** diff --git a/src/components/provider/__snapshots__/provider.test.tsx.snap b/src/components/provider/__snapshots__/provider.test.tsx.snap index 171f491a9cf7..41d406129114 100644 --- a/src/components/provider/__snapshots__/provider.test.tsx.snap +++ b/src/components/provider/__snapshots__/provider.test.tsx.snap @@ -177,7 +177,7 @@ exports[`EuiProvider applying modifications propagates \`modify\` 1`] = ` ], }, "lightShade": "#D3DAE6", - "lightestShade": "#F0F4FB", + "lightestShade": "#F1F4FA", "link": Computed { "computer": [Function], "dependencies": Array [ @@ -494,7 +494,7 @@ exports[`EuiProvider changing color modes propagates \`colorMode\` 1`] = ` ], }, "lightShade": "#D3DAE6", - "lightestShade": "#F0F4FB", + "lightestShade": "#F1F4FA", "link": Computed { "computer": [Function], "dependencies": Array [ @@ -810,7 +810,7 @@ exports[`EuiProvider is rendered 1`] = ` ], }, "lightShade": "#D3DAE6", - "lightestShade": "#F0F4FB", + "lightestShade": "#F1F4FA", "link": Computed { "computer": [Function], "dependencies": Array [ @@ -1147,7 +1147,7 @@ exports[`EuiProvider providing an @emotion cache config applies the cache to glo ], }, "lightShade": "#D3DAE6", - "lightestShade": "#F0F4FB", + "lightestShade": "#F1F4FA", "link": Computed { "computer": [Function], "dependencies": Array [ diff --git a/src/components/selectable/__snapshots__/selectable.test.tsx.snap b/src/components/selectable/__snapshots__/selectable.test.tsx.snap index 03fede91ad68..36161f5c9710 100644 --- a/src/components/selectable/__snapshots__/selectable.test.tsx.snap +++ b/src/components/selectable/__snapshots__/selectable.test.tsx.snap @@ -126,7 +126,7 @@ exports[`EuiSelectable errorMessage prop can render an element as the message 1` Filter options

@@ -264,7 +264,7 @@ exports[`EuiSelectable errorMessage prop does renders the message when defined 1 Filter options

@@ -363,7 +363,7 @@ exports[`EuiSelectable search value supports inheriting initialSearchValue from Filter options

diff --git a/src/components/selectable/selectable_message/__snapshots__/selectable_message.test.tsx.snap b/src/components/selectable/selectable_message/__snapshots__/selectable_message.test.tsx.snap index 61cbfba75dd2..0e201690616d 100644 --- a/src/components/selectable/selectable_message/__snapshots__/selectable_message.test.tsx.snap +++ b/src/components/selectable/selectable_message/__snapshots__/selectable_message.test.tsx.snap @@ -2,14 +2,14 @@ exports[`EuiSelectableMessage bordered is rendered 1`] = `
`; exports[`EuiSelectableMessage is rendered 1`] = `
`; diff --git a/src/components/stat/__snapshots__/stat.test.tsx.snap b/src/components/stat/__snapshots__/stat.test.tsx.snap index 0071c3d81991..3122e5e3e703 100644 --- a/src/components/stat/__snapshots__/stat.test.tsx.snap +++ b/src/components/stat/__snapshots__/stat.test.tsx.snap @@ -7,7 +7,7 @@ exports[`EuiStat is rendered 1`] = ` data-test-subj="test subject string" >