diff --git a/packages/docusaurus-theme/changelogs/upcoming/9090.md b/packages/docusaurus-theme/changelogs/upcoming/9090.md new file mode 100644 index 00000000000..f224636cbd9 --- /dev/null +++ b/packages/docusaurus-theme/changelogs/upcoming/9090.md @@ -0,0 +1,5 @@ +- Added `HighContrastModeToggle` component and adds it as main navbar item + +**Breaking changes** + +- Removed `ThemeSwitcher` component \ No newline at end of file diff --git a/packages/docusaurus-theme/src/components/high_contrast_mode_toggle/index.tsx b/packages/docusaurus-theme/src/components/high_contrast_mode_toggle/index.tsx new file mode 100644 index 00000000000..77724568307 --- /dev/null +++ b/packages/docusaurus-theme/src/components/high_contrast_mode_toggle/index.tsx @@ -0,0 +1,28 @@ +import { useContext } from 'react'; +import { useEuiTheme } from '@elastic/eui'; + +import { NavbarItem } from '../navbar_item'; +import { AppThemeContext } from '../theme_context'; + +export const HighContrastModeToggle = () => { + const euiThemeContext = useEuiTheme(); + + const appContext = useContext(AppThemeContext); + const { changeHighContrastMode } = appContext; + + const isForcedContrastMode = euiThemeContext.highContrastMode === 'forced'; + const _highContrastMode = + appContext.highContrastMode && !isForcedContrastMode + ? appContext.highContrastMode + : euiThemeContext.highContrastMode; + + return ( + changeHighContrastMode(!_highContrastMode)} + /> + ); +}; diff --git a/packages/docusaurus-theme/src/components/navbar_item/index.tsx b/packages/docusaurus-theme/src/components/navbar_item/index.tsx index c4adaea68d2..c61cbbf857f 100644 --- a/packages/docusaurus-theme/src/components/navbar_item/index.tsx +++ b/packages/docusaurus-theme/src/components/navbar_item/index.tsx @@ -14,6 +14,7 @@ import { EuiIcon, ExclusiveUnion, IconType, + mathWithUnits, PropsForAnchor, PropsForButton, useEuiMemoizedStyles, @@ -26,6 +27,7 @@ type SharedProps = { icon: IconType; showLabel?: boolean; isMenuItem?: boolean; + isSelected?: boolean; } & CommonProps; type Props = ExclusiveUnion< @@ -44,8 +46,7 @@ export const getStyles = ({ euiTheme }: UseEuiTheme) => ({ transition: background var(--ifm-transition-fast); &:hover { - background-color: ${euiTheme.components.buttons - .backgroundTextHover}; + background-color: ${euiTheme.components.buttons.backgroundTextHover}; color: currentColor; } `, @@ -74,6 +75,10 @@ export const getStyles = ({ euiTheme }: UseEuiTheme) => ({ disabled: css` cursor: not-allowed; `, + selected: css` + background-color: ${euiTheme.colors.backgroundFilledText}; + color: ${euiTheme.colors.textInverse}; + `, title: css` @media (min-width: 997px) { display: none; @@ -97,6 +102,8 @@ export const NavbarItem = (props: Props) => { target, showLabel, isMenuItem = true, + isSelected, + css, } = props; const isBrowser = useIsBrowser(); @@ -109,6 +116,7 @@ export const NavbarItem = (props: Props) => { styles.item, isMenuItem ? styles.menuItem : styles.navItem, !isBrowser && styles.disabled, + isSelected && styles.selected, isDarkMode && styles.darkMode, ]; @@ -148,6 +156,7 @@ export const NavbarItem = (props: Props) => { title={title} aria-label={title} aria-live="polite" + aria-pressed={isSelected != null ? isSelected : undefined} > {content} diff --git a/packages/docusaurus-theme/src/components/theme_context/index.tsx b/packages/docusaurus-theme/src/components/theme_context/index.tsx index b459db9fa51..40ccb53493f 100644 --- a/packages/docusaurus-theme/src/components/theme_context/index.tsx +++ b/packages/docusaurus-theme/src/components/theme_context/index.tsx @@ -11,19 +11,15 @@ import { FunctionComponent, PropsWithChildren, useContext, - useLayoutEffect, + useEffect, useState, } from 'react'; import useIsBrowser from '@docusaurus/useIsBrowser'; import createCache from '@emotion/cache'; import { CacheProvider } from '@emotion/react'; -import { - EUI_THEME, - EuiProvider, - EuiThemeAmsterdam, - EuiThemeColorMode, -} from '@elastic/eui'; +import { EuiProvider, EuiThemeColorMode } from '@elastic/eui'; import { EuiThemeBorealis } from '@elastic/eui-theme-borealis'; +import { type EUI_THEME } from '@elastic/eui-theme-common'; import { EuiThemeOverrides } from './theme_overrides'; @@ -33,11 +29,6 @@ export const AVAILABLE_THEMES: EUI_THEME[] = [ value: EuiThemeBorealis.key, provider: EuiThemeBorealis, }, - { - text: 'Amsterdam', - value: EuiThemeAmsterdam.key, - provider: EuiThemeAmsterdam, - }, ]; const EUI_COLOR_MODES = ['light', 'dark'] as const; @@ -105,18 +96,22 @@ export const AppThemeProvider: FunctionComponent = ({ }); const [highContrastMode, setHighContrastMode] = useState( - () => { - if (isBrowser) { - return localStorage.getItem('highContrastMode') - ? localStorage.getItem('highContrastMode') === 'true' - : defaultState.highContrastMode; - } - - return defaultState.highContrastMode; - } + false ); - const [theme, setTheme] = useState(defaultState.theme); + const getHighContrastModeSetting = () => { + return localStorage?.getItem('highContrastMode') + ? localStorage?.getItem('highContrastMode') === 'true' + : defaultState.highContrastMode; + }; + + useEffect(() => { + if (isBrowser) { + setHighContrastMode(getHighContrastModeSetting()); + } + }, [isBrowser]); + + const [theme, setTheme] = useState(defaultState.theme); const handleChangeTheme = (themeValue: string) => { const matchedTheme = AVAILABLE_THEMES.find((t) => t.value === themeValue); diff --git a/packages/docusaurus-theme/src/components/theme_switcher/index.tsx b/packages/docusaurus-theme/src/components/theme_switcher/index.tsx deleted file mode 100644 index 184b87b52f6..00000000000 --- a/packages/docusaurus-theme/src/components/theme_switcher/index.tsx +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import { useContext, useEffect, useState } from 'react'; -import { css } from '@emotion/react'; -import { - EuiAvatar, - EuiButtonEmpty, - euiFocusRing, - EuiListGroup, - EuiListGroupItem, - EuiPopover, - EuiPopoverFooter, - EuiSwitch, - EuiSwitchEvent, - useEuiMemoizedStyles, - useEuiTheme, - UseEuiTheme, -} from '@elastic/eui'; - -import { AppThemeContext, AVAILABLE_THEMES } from '../theme_context'; - -const getStyles = (euiThemeContext: UseEuiTheme) => { - const { euiTheme } = euiThemeContext; - - return { - button: css` - padding: 0; - width: ${euiTheme.size.xl}; - border-radius: ${euiTheme.size.base}; - `, - listItem: css` - .euiListGroupItem__button:focus-visible { - // overriding the global "outset" style to ensure the focus style is not cut off - ${euiFocusRing(euiThemeContext, 'inset', { - color: euiTheme.colors.primary, - })}; - } - `, - }; -}; - -export const ThemeSwitcher = () => { - const euiThemeContext = useEuiTheme(); - const { euiTheme } = euiThemeContext; - - const [currentTheme, setCurrentTheme] = useState( - AVAILABLE_THEMES[0]?.value ?? '' - ); - const [isPopoverOpen, setPopoverOpen] = useState(false); - const appContext = useContext(AppThemeContext); - const { theme, changeTheme, changeHighContrastMode } = appContext; - - const isForcedContrastMode = euiThemeContext.highContrastMode === 'forced'; - const _highContrastMode = - appContext.colorMode && !isForcedContrastMode - ? appContext.highContrastMode - : euiThemeContext.highContrastMode; - - useEffect(() => { - changeTheme(currentTheme); - }, [currentTheme]); - - const styles = useEuiMemoizedStyles(getStyles); - - const button = ( - setPopoverOpen((isOpen) => !isOpen)} - aria-label={`${theme.text} theme`} - > - - - ); - - return ( - setPopoverOpen(false)} - button={button} - panelPaddingSize="none" - repositionOnScroll - aria-label="EUI theme list" - > - - {AVAILABLE_THEMES && - AVAILABLE_THEMES.map((theme) => { - const isCurrentTheme = currentTheme === theme.value; - - const handleOnClick = () => { - setCurrentTheme(theme.value); - }; - - return ( - - ); - })} - - - { - changeHighContrastMode(!_highContrastMode); - }} - disabled={isForcedContrastMode} - /> - - - ); -}; diff --git a/packages/docusaurus-theme/src/theme/EditThisPage/index.tsx b/packages/docusaurus-theme/src/theme/EditThisPage/index.tsx index 48ef067912f..cc1191b0059 100644 --- a/packages/docusaurus-theme/src/theme/EditThisPage/index.tsx +++ b/packages/docusaurus-theme/src/theme/EditThisPage/index.tsx @@ -10,10 +10,12 @@ import { JSX } from 'react'; import { css } from '@emotion/react'; import Translate from '@docusaurus/Translate'; import type { Props } from '@theme-original/EditThisPage'; -import { EuiButton, useEuiMemoizedStyles, UseEuiTheme } from '@elastic/eui'; -// @ts-ignore - eui only has module declarations for '@elastic/eui/src/themes/amsterdam/global_styling/mixins/button' -// but importing from /src results in "Module not found" error -import { euiButtonColor } from '@elastic/eui/lib/global_styling/mixins/_button'; +import { + EuiButton, + euiButtonColor, + useEuiMemoizedStyles, + UseEuiTheme, +} from '@elastic/eui'; const getStyles = (theme: UseEuiTheme) => { const buttonColor = euiButtonColor(theme, 'primary'); diff --git a/packages/docusaurus-theme/src/theme/Navbar/Content/index.tsx b/packages/docusaurus-theme/src/theme/Navbar/Content/index.tsx index 06543be3b7b..7885bdd763c 100644 --- a/packages/docusaurus-theme/src/theme/Navbar/Content/index.tsx +++ b/packages/docusaurus-theme/src/theme/Navbar/Content/index.tsx @@ -39,7 +39,7 @@ import { VersionSwitcher, VersionSwitcherProps, } from '../../../components/version_switcher'; -import { ThemeSwitcher } from '../../../components/theme_switcher'; +import { HighContrastModeToggle } from '../../../components/high_contrast_mode_toggle'; const DOCS_PATH = '/docs'; @@ -248,13 +248,12 @@ export default function NavbarContent({ )} - - {isBrowser && (
- +
)} + } /> diff --git a/packages/docusaurus-theme/src/theme/Navbar/MobileSidebar/Header/index.tsx b/packages/docusaurus-theme/src/theme/Navbar/MobileSidebar/Header/index.tsx index b9c1ac16f09..68c7c3e6a52 100644 --- a/packages/docusaurus-theme/src/theme/Navbar/MobileSidebar/Header/index.tsx +++ b/packages/docusaurus-theme/src/theme/Navbar/MobileSidebar/Header/index.tsx @@ -15,11 +15,11 @@ import { EuiIcon, useEuiMemoizedStyles, UseEuiTheme } from '@elastic/eui'; import { css } from '@emotion/react'; import useIsBrowser from '@docusaurus/useIsBrowser'; -import { ThemeSwitcher } from '../../../../components/theme_switcher'; import { VersionSwitcher, VersionSwitcherProps, } from '../../../../components/version_switcher'; +import { HighContrastModeToggle } from '../../../../components/high_contrast_mode_toggle'; const getStyles = ({ euiTheme }: UseEuiTheme) => ({ sidebar: css` @@ -81,8 +81,8 @@ export default function NavbarMobileSidebarHeader({ {isBrowser && versionSwitcherOptions && ( )} - {isBrowser && } + {isBrowser && } ); diff --git a/packages/eui-theme-borealis/.stylelintrc.js b/packages/eui-theme-borealis/.stylelintrc.js index 42adc41f28c..b459d263d1b 100644 --- a/packages/eui-theme-borealis/.stylelintrc.js +++ b/packages/eui-theme-borealis/.stylelintrc.js @@ -70,12 +70,6 @@ module.exports = { { // TODO: Remove Sass-specific config & rules once we're completely off Sass files: ['**/*.scss'], - ignoreFiles: [ - 'generator-eui/**/*.scss', - 'src/global_styling/react_date_picker/**/*.scss', - 'src/themes/amsterdam/global_styling/react_date_picker/**/*.scss', - 'src/components/date_picker/react-datepicker/**/*.scss', - ], extends: [ 'stylelint-config-standard-scss', 'stylelint-config-prettier-scss', diff --git a/packages/eui-theme-borealis/changelogs/upcoming/9090.md b/packages/eui-theme-borealis/changelogs/upcoming/9090.md new file mode 100644 index 00000000000..f7adca891b1 --- /dev/null +++ b/packages/eui-theme-borealis/changelogs/upcoming/9090.md @@ -0,0 +1,6 @@ +**Breaking changes** + +- Removed `euiTheme.flags.hasGlobalFocusColor` +- Removed `euiTheme.flags.hasVisColorAdjustment` +- Removed `euiTheme.flags.buttonVariant` and `euiTheme.flags.formVariant` +- Removed `euiTheme.components.keyPadMenuItemBackgroundDisabledSelect` diff --git a/packages/eui-theme-borealis/src/index.ts b/packages/eui-theme-borealis/src/index.ts index eff55ca8ed7..0cbeea36a0a 100644 --- a/packages/eui-theme-borealis/src/index.ts +++ b/packages/eui-theme-borealis/src/index.ts @@ -40,10 +40,6 @@ export const euiThemeBorealis: EuiThemeShape = { focus, components, flags: { - hasGlobalFocusColor: true, - hasVisColorAdjustment: false, - buttonVariant: 'refresh', - formVariant: 'refresh', shadowVariant: 'refresh', }, overrides, diff --git a/packages/eui-theme-borealis/src/variables/_buttons.ts b/packages/eui-theme-borealis/src/variables/_buttons.ts index 60fea4089b2..0ec6e438259 100644 --- a/packages/eui-theme-borealis/src/variables/_buttons.ts +++ b/packages/eui-theme-borealis/src/variables/_buttons.ts @@ -6,30 +6,9 @@ * Side Public License, v 1. */ -import { - _EuiThemeButton, - EuiThemeVariantFlags, - ColorModeSwitch, - computed, -} from '@elastic/eui-theme-common'; +import { _EuiThemeButton, computed } from '@elastic/eui-theme-common'; import { SEMANTIC_COLORS } from './colors/_semantic_colors'; -const getTokenByVariant = ( - buttonVariant: EuiThemeVariantFlags['buttonVariant'], - tokens: { - classic: ColorModeSwitch; - refresh: ColorModeSwitch; - } -) => { - switch (buttonVariant) { - case 'refresh': - return tokens.refresh; - default: { - return tokens.classic; - } - } -}; - const _buttons = { backgroundPrimary: computed( ([backgroundLightPrimary]) => backgroundLightPrimary, @@ -64,17 +43,8 @@ const _buttons = { ['colors.backgroundLightDanger'] ), backgroundText: computed( - ([buttonVariant, backgroundBasePlain, backgroundLightText]) => { - return getTokenByVariant(buttonVariant, { - refresh: backgroundBasePlain, - classic: backgroundLightText, - }); - }, - [ - 'flags.buttonVariant', - 'colors.backgroundBasePlain', - 'colors.backgroundLightText', - ] + ([backgroundBasePlain]) => backgroundBasePlain, + ['colors.backgroundBasePlain'] ), backgroundDisabled: computed( ([backgroundBaseDisabled]) => backgroundBaseDisabled, diff --git a/packages/eui-theme-borealis/src/variables/_components.ts b/packages/eui-theme-borealis/src/variables/_components.ts index c9891724df3..e95f39b40be 100644 --- a/packages/eui-theme-borealis/src/variables/_components.ts +++ b/packages/eui-theme-borealis/src/variables/_components.ts @@ -206,11 +206,6 @@ const component_colors: _EuiThemeComponentColors = { headerDarkSectionItemBackgroundFocus: dark_background_colors.backgroundBasePrimary, - keyPadMenuItemBackgroundDisabledSelect: computed( - ([backgroundBaseDisabled]) => backgroundBaseDisabled, - ['colors.backgroundBaseDisabled'] - ), - listGroupItemBackgroundPrimaryActive: computed( ([backgroundBaseInteractiveSelect]) => backgroundBaseInteractiveSelect, ['colors.backgroundBaseInteractiveSelect'] diff --git a/packages/eui-theme-common/.stylelintrc.js b/packages/eui-theme-common/.stylelintrc.js index 42adc41f28c..b459d263d1b 100644 --- a/packages/eui-theme-common/.stylelintrc.js +++ b/packages/eui-theme-common/.stylelintrc.js @@ -70,12 +70,6 @@ module.exports = { { // TODO: Remove Sass-specific config & rules once we're completely off Sass files: ['**/*.scss'], - ignoreFiles: [ - 'generator-eui/**/*.scss', - 'src/global_styling/react_date_picker/**/*.scss', - 'src/themes/amsterdam/global_styling/react_date_picker/**/*.scss', - 'src/components/date_picker/react-datepicker/**/*.scss', - ], extends: [ 'stylelint-config-standard-scss', 'stylelint-config-prettier-scss', diff --git a/packages/eui-theme-common/changelogs/upcoming/9090.md b/packages/eui-theme-common/changelogs/upcoming/9090.md new file mode 100644 index 00000000000..fb434c2ca3f --- /dev/null +++ b/packages/eui-theme-common/changelogs/upcoming/9090.md @@ -0,0 +1,14 @@ +**Breaking changes** + +- Removed `euiTheme.flags.hasGlobalFocusColor` +- Removed `euiTheme.flags.hasVisColorAdjustment` +- Removed `hasVisColorAdjustment` argument from `EuiVisColorStore` +- Removed `euiTheme.flags.buttonVariant` and `euiTheme.flags.formVariant` +- Removed type for `euiTheme.components.keyPadMenuItemBackgroundDisabledSelect` +- Removed outdated component-specific mixin SCSS files: + - `src/global_styling/mixins/_button.scss` + - `src/global_styling/mixins/_form.scss` + - `src/global_styling/mixins/_link.scss` + - `src/global_styling/mixins/_loading.scss` + - `src/global_styling/mixins/_panel.scss` + - `src/global_styling/mixins/_range.scss` diff --git a/packages/eui-theme-common/src/global_styling/mixins/_button.scss b/packages/eui-theme-common/src/global_styling/mixins/_button.scss deleted file mode 100644 index 47c87b6e742..00000000000 --- a/packages/eui-theme-common/src/global_styling/mixins/_button.scss +++ /dev/null @@ -1,149 +0,0 @@ -// Provides a solid reset and base for handling sizing layout -// Does not include any visual styles -@mixin euiButtonBase { - display: inline-block; - appearance: none; - cursor: pointer; - height: $euiButtonHeight; - line-height: $euiButtonHeight; // prevents descenders from getting cut off - text-align: center; - white-space: nowrap; - max-width: 100%; - vertical-align: middle; -} - -// Adds the focus (and hover) animation for translating up 1px -@mixin euiButtonFocus { - @include euiCanAnimate { - transition: transform $euiAnimSpeedNormal ease-in-out, background-color $euiAnimSpeedNormal ease-in-out; - - &:hover:not(:disabled) { - transform: translateY(-1px); - } - - &:focus { - animation: euiButtonActive $euiAnimSpeedNormal $euiAnimSlightBounce; - } - - &:active:not(:disabled) { - transform: translateY(1px); - } - } -} - -// All of the button base styles including the base, focus, font, and initial styles -// Does not include individual alterations like color or sizes -@mixin euiButton { - @include euiButtonBase; - @include euiFont; - @include euiFontSize; - @include euiButtonFocus; - - font-weight: $euiButtonFontWeight; - text-decoration: none; - outline-offset: -1px; - - &:hover:not(:disabled), - &:focus { - text-decoration: underline; - } -} - -// Correctly lays out the contents of a button when using the proper dom elements of: -// -// 1. Apply margin to all but last item in the flex. -// 2. Margin gets flipped because of the row-reverse. -@mixin euiButtonContent($isReverse: false) { - height: 100%; - width: 100%; - vertical-align: middle; - - .euiButtonContent__icon, - .euiButtonContent__spinner { - flex-shrink: 0; // Ensures the icons/spinner don't scale down below their intended size - } - - @if ($isReverse) { - flex-direction: row-reverse; - - > * + * { - margin-inline-start: 0; // 1, 2 - margin-inline-end: $euiSizeS; // 1, 2 - } - } @else { - display: flex; - justify-content: center; - align-items: center; - - > * + * { - margin-inline-start: $euiSizeS; // 1 - } - } -} - -@mixin euiButtonContentDisabled { - pointer-events: auto; - cursor: not-allowed; - - &:hover, - &:focus, - &:focus-within { - text-decoration: none; - } - - .euiButtonContent__spinner { - border-color: euiLoadingSpinnerBorderColors(currentColor); - } -} - -/* - * Creates the Amsterdam style of button with a transparent background - */ -@mixin euiButtonDefaultStyle($color: 'primary', $includeStates: true, $transparency: $euiButtonDefaultTransparency) { - $backgroundColor: $color; - - @if (map-has-key($euiButtonTypes, $color)) { - $backgroundColor: map-get($euiButtonTypes, $color); - } - - $percentConversion: $transparency * 100%; - // This variable simulates the possibly darkest background the button could be on - // Simulates the 20% opaque color on top of the page background color - $backgroundColorSimulated: mix($euiPageBackgroundColor, $backgroundColor, $percentConversion); - // Then we can calculate the darkest text color needed - color: makeHighContrastColor($backgroundColor, $backgroundColorSimulated); - // But still use transparency - background-color: transparentize($backgroundColor, $transparency); - - @if ($includeStates) { - &:not([class*='isDisabled']) { - &:hover, - &:focus { - // Duplicated from inert state simply to override default theme - background-color: transparentize($backgroundColor, $transparency); - } - } - } -} - -/* - * Creates the Amsterdam style of fill button - */ -@mixin euiButtonFillStyle($color: 'primary') { - $backgroundColor: $color; - - @if (map-has-key($euiButtonTypes, $color)) { - $backgroundColor: map-get($euiButtonTypes, $color); - } - - background-color: $backgroundColor; - color: chooseLightOrDarkText($backgroundColor); -} - -// Keyframe animation declarations can be found in -// utility/animations.scss diff --git a/packages/eui-theme-common/src/global_styling/mixins/_form.scss b/packages/eui-theme-common/src/global_styling/mixins/_form.scss deleted file mode 100644 index 14efe32ce43..00000000000 --- a/packages/eui-theme-common/src/global_styling/mixins/_form.scss +++ /dev/null @@ -1,272 +0,0 @@ -@mixin euiFormControlLayoutPadding($numOfIcons, $side: 'right', $compressed: false) { - $iconSize: $euiSize; - $iconPadding: $euiFormControlPadding; - $marginBetweenIcons: $euiFormControlPadding / 2; - - @if ($compressed) { - $iconPadding: $euiFormControlCompressedPadding; - } - - @if variable-exists(numOfIcons) == false { - @error '$numOfIcons:integer (1-3) must be provided to @mixin euiFormControlLayoutPadding().'; - } @else if $numOfIcons == 1 { - padding-#{$side}: $iconPadding + $iconSize + $iconPadding; - } @else if $numOfIcons == 2 { - padding-#{$side}: $iconPadding + $iconSize + $marginBetweenIcons + $iconSize + $iconPadding; - } @else if $numOfIcons == 3 { - padding-#{$side}: $iconPadding + $iconSize + $marginBetweenIcons + $iconSize + $marginBetweenIcons + $iconSize + $iconPadding; - } -} - -@mixin euiPlaceholderPerBrowser { - // stylelint-disable selector-no-vendor-prefix - // Each prefix must be its own content block - &::-webkit-input-placeholder { @content; opacity: 1; } - &::-moz-placeholder { @content; opacity: 1; } - &:-moz-placeholder { @content; opacity: 1; } - &::placeholder { @content; opacity: 1; } -} - -@function euiFormControlGradient($color: $euiColorPrimary) { - @return linear-gradient(to top, - $color, - $color 2px, - transparent 2px, - transparent 100% - ); -} - -@mixin euiFormControlText { - @include euiFont; - font-size: $euiFontSizeS; - color: $euiColorTextParagraph; - - @include euiPlaceholderPerBrowser { - color: $euiFormControlPlaceholderText; - } -} - -@mixin euiFormControlSize( - $height: $euiFormControlHeight, - $includeAlternates: false -) { - // Default - max-width: $euiFormMaxWidth; - width: 100%; - height: $height; - - @if ($includeAlternates) { - &--fullWidth { - max-width: 100%; - } - - &--compressed { - height: $euiFormControlCompressedHeight; - } - - &--inGroup { - height: 100%; - } - } -} - -@mixin euiFormControlWithIcon($isIconOptional: false, $side: 'left', $compressed: false) { - @if ($isIconOptional) { - @at-root { - #{&}--withIcon { - @include euiFormControlLayoutPadding(1, $side, $compressed); - } - } - } @else { - @include euiFormControlLayoutPadding(1, $side, $compressed); - } -} - -@mixin euiFormControlIsLoading($isNextToIcon: false) { - @at-root { - #{&}-isLoading { - @if ($isNextToIcon) { - @include euiFormControlLayoutPadding(2); - } @else { - @include euiFormControlLayoutPadding(1); - } - } - - #{&}-isLoading#{&}--compressed { - @if ($isNextToIcon) { - @include euiFormControlLayoutPadding(2, $compressed: true); - } @else { - @include euiFormControlLayoutPadding(1, $compressed: true); - } - } - } -} - -// 1. Must supply both values to background-size or some browsers apply the single value to both directions - -@mixin euiFormControlDefaultShadow($borderOnly: false) { - background-color: $euiFormBackgroundColor; - background-repeat: no-repeat; - background-size: 0% 100%; // 1 - - @if ($borderOnly) { - box-shadow: inset 0 0 0 1px $euiFormBorderColor; - } @else { - box-shadow: - #{$euiFormControlBoxShadow}, - inset 0 0 0 1px $euiFormBorderColor; - } - - transition: - box-shadow $euiAnimSpeedFast ease-in, - background-image $euiAnimSpeedFast ease-in, - background-size $euiAnimSpeedFast ease-in, - background-color $euiAnimSpeedFast ease-in; - - // Fixes bug in Firefox where adding a transition to the background-color - // caused a flash of differently styled dropdown. - @supports (-moz-appearance: none) { - // List *must* be in the same order as the above. - transition-property: box-shadow, background-image, background-size; - } -} - -@mixin euiFormControlFocusStyle($borderOnly: false) { - background-color: tintOrShade($euiColorEmptyShade, 0%, 40%); - background-image: euiFormControlGradient(); - background-size: 100% 100%; // 1 - outline: none; // Blanket remove all outlines relying on our own bottom border - - @if ($borderOnly) { - box-shadow: inset 0 0 0 1px $euiFormBorderColor; - } @else { - box-shadow: inset 0 0 0 1px $euiFormBorderColor; - } -} - -@mixin euiFormControlInvalidStyle { - background-image: euiFormControlGradient($euiColorDanger); - background-size: 100%; -} - -@mixin euiFormControlDisabledTextStyle { - color: $euiFormControlDisabledColor; - -webkit-text-fill-color: $euiFormControlDisabledColor; // Required for Safari -} - -@mixin euiFormControlDisabledStyle { - @include euiFormControlDisabledTextStyle; - cursor: not-allowed; - background: $euiFormBackgroundDisabledColor; - box-shadow: inset 0 0 0 1px $euiFormBorderDisabledColor; - - @include euiPlaceholderPerBrowser { - color: $euiFormControlDisabledColor; - } -} - -@mixin euiFormControlReadOnlyStyle { - cursor: default; - color: $euiColorTextParagraph; - -webkit-text-fill-color: $euiColorTextParagraph; // Required for Safari - // Use transparency since there is no border and in case form is on a non-white background - background: $euiFormBackgroundReadOnlyColor; - border-color: transparent; - box-shadow: inset 0 0 0 1px $euiFormBorderDisabledColor; -} - -// 2. Override invalid state with focus state. - -@mixin euiFormControlStyle($borderOnly: false, $includeStates: true, $includeSizes: true) { - @include euiFormControlSize($includeAlternates: $includeSizes); - @include euiFormControlDefaultShadow; - @include euiFormControlText; - - border: none; - border-radius: $euiFormControlBorderRadius; - padding: $euiFormControlPadding; - - @if ($includeStates) { - &:invalid { // 2 - @include euiFormControlInvalidStyle; - } - - &:focus { // 2 - @include euiFormControlFocusStyle; - } - - &:disabled { - @include euiFormControlDisabledStyle; - } - - &[readOnly] { - @include euiFormControlReadOnlyStyle; - } - - // Needs to be set for autofill - &:-webkit-autofill { - -webkit-text-fill-color: lightOrDarkTheme($euiColorDarkestShade, $euiColorLightShade); - - ~ .euiFormControlLayoutIcons { - color: lightOrDarkTheme($euiColorDarkestShade, $euiColorLightShade); - } - } - } - - @if ($includeSizes) { - &--compressed { - @include euiFormControlStyleCompressed($borderOnly, $includeStates); - } - - &--inGroup { - // stylelint-disable-next-line declaration-no-important - box-shadow: none !important; - border-radius: 0; - } - } -} - -@mixin euiFormControlStyleCompressed($borderOnly: false, $includeStates: true) { - @include euiFormControlDefaultShadow($borderOnly: true); - padding: $euiFormControlCompressedPadding; - border-radius: $euiFormControlCompressedBorderRadius; - - @if ($includeStates) { - &:invalid { // 2 - @include euiFormControlInvalidStyle; - } - - &:focus { // 2 - @include euiFormControlFocusStyle($borderOnly: true); - } - - &:disabled { - @include euiFormControlDisabledStyle; - } - - &[readOnly] { - @include euiFormControlReadOnlyStyle; - } - } -} - -@mixin euiHiddenSelectableInput { - position: absolute; - // stylelint-disable-next-line declaration-no-important - opacity: 0 !important; // Make sure it's still hidden when :disabled - width: 100%; - height: 100%; - cursor: pointer; -} - -// Adjusts form controls border radius -@mixin euiFormControlSideBorderRadius($borderRadius, $side, $internal: false) { - @if $internal == true { - $borderRadius: $borderRadius - 1; - } - @if $side == 'left' { - border-radius: $borderRadius 0 0 $borderRadius; - } @else if $side == 'right' { - border-radius: 0 $borderRadius $borderRadius 0; - } -} diff --git a/packages/eui-theme-common/src/global_styling/mixins/_index.scss b/packages/eui-theme-common/src/global_styling/mixins/_index.scss index b570d0e1607..9447c0caacd 100644 --- a/packages/eui-theme-common/src/global_styling/mixins/_index.scss +++ b/packages/eui-theme-common/src/global_styling/mixins/_index.scss @@ -4,10 +4,4 @@ @import 'helpers'; @import 'states'; -@import 'button'; -@import 'form'; -@import 'loading'; -@import 'link'; -@import 'panel'; -@import 'range'; @import 'tool_tip'; diff --git a/packages/eui-theme-common/src/global_styling/mixins/_link.scss b/packages/eui-theme-common/src/global_styling/mixins/_link.scss deleted file mode 100644 index 98dac59b9cc..00000000000 --- a/packages/eui-theme-common/src/global_styling/mixins/_link.scss +++ /dev/null @@ -1,11 +0,0 @@ -@mixin euiLink { - text-align: left; - - &:hover { - text-decoration: underline; - } - - &:focus { - text-decoration: underline; - } -} diff --git a/packages/eui-theme-common/src/global_styling/mixins/_loading.scss b/packages/eui-theme-common/src/global_styling/mixins/_loading.scss deleted file mode 100644 index 0f72a8433f7..00000000000 --- a/packages/eui-theme-common/src/global_styling/mixins/_loading.scss +++ /dev/null @@ -1,6 +0,0 @@ -@function euiLoadingSpinnerBorderColors( - $main: $euiColorLightShade, - $highlight: $euiColorPrimary -) { - @return $highlight $main $main $main; -} diff --git a/packages/eui-theme-common/src/global_styling/mixins/_panel.scss b/packages/eui-theme-common/src/global_styling/mixins/_panel.scss deleted file mode 100644 index 4eb0a5fb55a..00000000000 --- a/packages/eui-theme-common/src/global_styling/mixins/_panel.scss +++ /dev/null @@ -1,55 +0,0 @@ -@mixin euiPanel($selector) { - @if variable-exists(selector) == false { - @error 'A $selector must be provided to @mixin euiPanel().'; - } @else { - #{$selector} { - flex-grow: 1; - - &#{$selector}--flexGrowZero { - flex-grow: 0; - } - - &#{$selector}--hasShadow { - @include euiBottomShadowMedium; - } - - &#{$selector}--hasBorder { - border: $euiBorderThin; - box-shadow: none; - } - - &#{$selector}--isClickable { - // transition the shadow - transition: all $euiAnimSpeedFast $euiAnimSlightResistance; - - &:enabled { // This is a good selector for buttons since it doesn't exist on divs - // in case of button wrapper which inherently is inline-block and no width - display: block; - width: 100%; - text-align: left; - } - - &:hover, - &:focus { - @include euiBottomShadow; - transform: translateY(-2px); - cursor: pointer; - } - } - - // Border Radii - @each $modifier, $amount in $euiPanelBorderRadiusModifiers { - &#{$selector}--#{$modifier} { - border-radius: $amount; - } - } - - // Background colors - @each $modifier, $amount in $euiPanelBackgroundColorModifiers { - &#{$selector}--#{$modifier} { - background-color: $amount; - } - } - } - } -} diff --git a/packages/eui-theme-common/src/global_styling/mixins/_range.scss b/packages/eui-theme-common/src/global_styling/mixins/_range.scss deleted file mode 100644 index 5396d4d1a19..00000000000 --- a/packages/eui-theme-common/src/global_styling/mixins/_range.scss +++ /dev/null @@ -1,59 +0,0 @@ -/* -The CSS in JS version of this file lives in: - - src/components/form/range/range.styles.ts - -The following files still use the Sass version: - - src/themes/amsterdam/overrides/_color_stops.scss - - src/themes/amsterdam/overrides/_hue.scss -*/ - -@mixin euiRangeTrackSize($compressed: false) { - height: $euiRangeTrackHeight; - width: $euiRangeTrackWidth; - - @if ($compressed) { - height: $euiRangeTrackCompressedHeight; - } -} - -@mixin euiRangeTrackPerBrowser { - &::-webkit-slider-runnable-track { @content; } - &::-moz-range-track { @content; } -} - -@mixin euiRangeThumbBorder { - border: 2px solid $euiRangeThumbBorderColor; -} - -@mixin euiRangeThumbBoxShadow { - box-shadow: - 0 0 0 1px $euiRangeThumbBorderColor, - 0 2px 2px -1px rgba($euiShadowColor, .2), - 0 1px 5px -2px rgba($euiShadowColor, .2); -} - -@mixin euiRangeThumbFocusBoxShadow { - box-shadow: 0 0 0 2px $euiFocusRingColor; -} - -@mixin euiRangeThumbStyle { - @include euiRangeThumbBoxShadow; - @include euiRangeThumbBorder; - cursor: pointer; - background-color: $euiRangeThumbBackgroundColor; - padding: 0; - height: $euiRangeThumbHeight; - width: $euiRangeThumbWidth; - box-sizing: border-box; // required for firefox or the border makes the width and height to increase -} - -@mixin euiRangeThumbPerBrowser { - &::-webkit-slider-thumb { @content; } - &::-moz-range-thumb { @content; } -} - -@mixin euiRangeThumbFocus { - @include euiRangeThumbBorder; - @include euiRangeThumbFocusBoxShadow; - background-color: $euiColorPrimary; -} diff --git a/packages/eui-theme-common/src/global_styling/mixins/_states.scss b/packages/eui-theme-common/src/global_styling/mixins/_states.scss index a2d1bc83aef..48e16aba6cb 100644 --- a/packages/eui-theme-common/src/global_styling/mixins/_states.scss +++ b/packages/eui-theme-common/src/global_styling/mixins/_states.scss @@ -1,4 +1,4 @@ -@mixin euiFocusRing($size: 'small', $amsterdamOnlyProp: null) { +@mixin euiFocusRing($size: 'small') { @if $size == 'large' { // It's always OK to use the focus animation. This will take precedence over times we turn it off individually like EuiButtonEmpty // stylelint-disable-next-line declaration-no-important diff --git a/packages/eui-theme-common/src/global_styling/mixins/shadow.ts b/packages/eui-theme-common/src/global_styling/mixins/shadow.ts index 652f704a245..b4dafa2f3c3 100644 --- a/packages/eui-theme-common/src/global_styling/mixins/shadow.ts +++ b/packages/eui-theme-common/src/global_styling/mixins/shadow.ts @@ -158,7 +158,6 @@ export const euiSlightShadowHover = ( /** * @deprecated - use euiShadowXSmall instead * - * Remains for backwards compatibility for the Amsterdam theme. * Similar to shadow medium but without the bottom depth. * Useful for popovers that drop UP rather than DOWN. */ diff --git a/packages/eui-theme-common/src/global_styling/variables/borders.ts b/packages/eui-theme-common/src/global_styling/variables/borders.ts index 4c7b7ba3fa5..084ad6b616d 100644 --- a/packages/eui-theme-common/src/global_styling/variables/borders.ts +++ b/packages/eui-theme-common/src/global_styling/variables/borders.ts @@ -25,7 +25,7 @@ export interface _EuiThemeBorderWidthValues { export interface _EuiThemeBorderRadiusValues { /** * Primary corner radius size - * - Default value: 4px (6px in Amsterdam) + * - Default value: 4px */ medium: CSSProperties['borderRadius']; /** diff --git a/packages/eui-theme-common/src/global_styling/variables/components.ts b/packages/eui-theme-common/src/global_styling/variables/components.ts index cf8ef16ec52..ab9a4ab100a 100644 --- a/packages/eui-theme-common/src/global_styling/variables/components.ts +++ b/packages/eui-theme-common/src/global_styling/variables/components.ts @@ -91,8 +91,6 @@ export type _EuiThemeComponentColors = { flyoutFooterBackground: ColorModeSwitch; flyoutCloseButtonInsideBackground: ColorModeSwitch; - keyPadMenuItemBackgroundDisabledSelect: ColorModeSwitch; - listGroupItemBackgroundPrimaryActive: ColorModeSwitch; listGroupItemBackgroundSubduedActive: ColorModeSwitch; listGroupItemBackgroundHover: ColorModeSwitch; diff --git a/packages/eui-theme-common/src/global_styling/variables/flags.ts b/packages/eui-theme-common/src/global_styling/variables/flags.ts index b9118c0382f..cf5506270d7 100644 --- a/packages/eui-theme-common/src/global_styling/variables/flags.ts +++ b/packages/eui-theme-common/src/global_styling/variables/flags.ts @@ -7,15 +7,10 @@ */ export type EuiThemeVariantFlags = { - buttonVariant: 'classic' | 'refresh'; - formVariant: 'classic' | 'refresh'; shadowVariant: 'classic' | 'refresh'; }; /** * Theme specific setting flags */ -export type _EuiThemeFlags = { - hasGlobalFocusColor: boolean; - hasVisColorAdjustment: boolean; -} & EuiThemeVariantFlags; +export type _EuiThemeFlags = EuiThemeVariantFlags; diff --git a/packages/eui-theme-common/src/services/theme/types.ts b/packages/eui-theme-common/src/services/theme/types.ts index f417c1d9b3b..3d377682323 100644 --- a/packages/eui-theme-common/src/services/theme/types.ts +++ b/packages/eui-theme-common/src/services/theme/types.ts @@ -134,3 +134,9 @@ export interface UseEuiTheme { highContrastMode: EuiThemeHighContrastMode; modifications: EuiThemeModifications; } + +export interface EUI_THEME { + text: string; + value: string; + provider?: EuiThemeSystem; +} diff --git a/packages/eui-theme-common/src/services/vis_color_store.test.ts b/packages/eui-theme-common/src/services/vis_color_store.test.ts index 6405d4e26e2..5e1a31e7a5e 100644 --- a/packages/eui-theme-common/src/services/vis_color_store.test.ts +++ b/packages/eui-theme-common/src/services/vis_color_store.test.ts @@ -16,7 +16,7 @@ const visColors: _EuiThemeVisColors = { } as _EuiThemeVisColors; describe('EuiVisColorStore', () => { - const visColorStore = EuiVisColorStore.getInstance(visColors, false); + const visColorStore = EuiVisColorStore.getInstance(visColors); let updateFn: jest.Mock; beforeEach(() => { @@ -42,12 +42,6 @@ describe('EuiVisColorStore', () => { expect(visColorStore.visColors).toEqual(customColors); }); - - it('updates hasVisColorAdjustment', () => { - visColorStore.setVisColors(customColors, true); - - expect(visColorStore.hasVisColorAdjustment).toEqual(true); - }); }); describe('subcribe and unsubscribe', () => { diff --git a/packages/eui-theme-common/src/services/vis_color_store.ts b/packages/eui-theme-common/src/services/vis_color_store.ts index 57c6d3d62b4..4c46b25b735 100644 --- a/packages/eui-theme-common/src/services/vis_color_store.ts +++ b/packages/eui-theme-common/src/services/vis_color_store.ts @@ -19,50 +19,30 @@ type EventId = string; export type _EuiVisColorStore = { visColors: _EuiThemeVisColors; - hasVisColorAdjustment: boolean; - setVisColors: ( - colors: _EuiThemeVisColors, - hasVisColorAdjustment?: boolean - ) => void; + setVisColors: (colors: _EuiThemeVisColors) => void; subscribe: (eventName: VisColorStoreEvents, callback: any) => EventId; unsubscribe: (eventName: VisColorStoreEvents, id: EventId) => void; }; class EuiVisColorStoreImpl implements _EuiVisColorStore { private _visColors: _EuiVisColorStore['visColors']; - private _hasVisColorAdjustment: _EuiVisColorStore['hasVisColorAdjustment']; private events: Record> = {} as Record< VisColorStoreEvents, Map >; - constructor(dependencies: { - defaultColors: _EuiThemeVisColors; - hasVisColorAdjustment: boolean; - }) { + constructor(dependencies: { defaultColors: _EuiThemeVisColors }) { this._visColors = dependencies.defaultColors; - this._hasVisColorAdjustment = dependencies.hasVisColorAdjustment; } get visColors(): _EuiVisColorStore['visColors'] { return this._visColors; } - get hasVisColorAdjustment(): _EuiVisColorStore['hasVisColorAdjustment'] { - return this._hasVisColorAdjustment; - } - - setVisColors = (colors: _EuiThemeVisColors, hasColorAdjustment?: boolean) => { - if ( - !isEqual(this._visColors, colors) || - hasColorAdjustment !== this._hasVisColorAdjustment - ) { + setVisColors = (colors: _EuiThemeVisColors) => { + if (!isEqual(this._visColors, colors)) { this._visColors = colors; - if (hasColorAdjustment != null) { - this._hasVisColorAdjustment = hasColorAdjustment; - } - this.publishUpdate(VIS_COLOR_STORE_EVENTS.UPDATE, this._visColors); } }; @@ -101,14 +81,10 @@ class EuiVisColorStoreImpl implements _EuiVisColorStore { export class EuiVisColorStore { private static instance: EuiVisColorStoreImpl; - static getInstance( - defaultColors: _EuiThemeVisColors, - hasVisColorAdjustment: boolean - ): EuiVisColorStoreImpl { + static getInstance(defaultColors: _EuiThemeVisColors): EuiVisColorStoreImpl { if (!this.instance) { this.instance = new EuiVisColorStoreImpl({ defaultColors, - hasVisColorAdjustment, }); } diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterButton_Full_Width_And_Grow.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterButton_Full_Width_And_Grow.png index 5e57dee5cee..a4d5c344cb8 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterButton_Full_Width_And_Grow.png and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterButton_Full_Width_And_Grow.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterButton_High_Contrast.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterButton_High_Contrast.png index 0255fb288dc..9c8628ad45e 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterButton_High_Contrast.png and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterButton_High_Contrast.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterButton_Full_Width_And_Grow.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterButton_Full_Width_And_Grow.png index 93c33e61692..db339c60c53 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterButton_Full_Width_And_Grow.png and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterButton_Full_Width_And_Grow.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterButton_High_Contrast.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterButton_High_Contrast.png index d950fa5b9d8..5bf5ca6690a 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterButton_High_Contrast.png and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterButton_High_Contrast.png differ diff --git a/packages/eui/.storybook/decorator.tsx b/packages/eui/.storybook/decorator.tsx index 3a6cf087e96..da63a69fb78 100644 --- a/packages/eui/.storybook/decorator.tsx +++ b/packages/eui/.storybook/decorator.tsx @@ -19,7 +19,6 @@ import { EuiThemeBorealis } from '@elastic/eui-theme-borealis'; import { EuiThemeColorMode } from '../src/services'; import { EuiProvider, EuiProviderProps } from '../src/components/provider'; -import { EuiThemeAmsterdam } from '../src/themes'; export const AVAILABLE_THEMES = [ { @@ -27,11 +26,6 @@ export const AVAILABLE_THEMES = [ value: EuiThemeBorealis.key, provider: EuiThemeBorealis, }, - { - text: 'Amsterdam', - value: EuiThemeAmsterdam.key, - provider: EuiThemeAmsterdam, - }, ]; /** @@ -181,16 +175,4 @@ export const euiProviderDecoratorGlobals: Preview['globalTypes'] = { dynamicTitle: true, }, }, - theme: { - description: 'Theme for EuiProvider', - defaultValue: EuiThemeBorealis.key, - toolbar: { - title: 'Theme', - items: [ - { value: EuiThemeBorealis.key, title: 'Borealis', icon: 'box' }, - { value: EuiThemeAmsterdam.key, title: 'Amsterdam', icon: 'box' }, - ], - dynamicTitle: true, - }, - }, }; diff --git a/packages/eui/.stylelintrc.js b/packages/eui/.stylelintrc.js index 3c973578d39..2ef13e7aef9 100644 --- a/packages/eui/.stylelintrc.js +++ b/packages/eui/.stylelintrc.js @@ -73,7 +73,6 @@ module.exports = { ignoreFiles: [ 'generator-eui/**/*.scss', 'src/global_styling/react_date_picker/**/*.scss', - 'src/themes/amsterdam/global_styling/react_date_picker/**/*.scss', 'src/components/date_picker/react-datepicker/**/*.scss', ], extends: [ diff --git a/packages/eui/changelogs/upcoming/9090.md b/packages/eui/changelogs/upcoming/9090.md new file mode 100644 index 00000000000..34e0c52a406 --- /dev/null +++ b/packages/eui/changelogs/upcoming/9090.md @@ -0,0 +1,10 @@ +**Breaking changes** + +- Removed all "Amsterdam" theme related code in `src/themes/amsterdam` - EUI now only supports the "Borealis" theme in `eui-theme-borealis` +- Removed `euiTheme.flags.hasGlobalFocusColor` +- Removed `euiTheme.flags.hasVisColorAdjustment` +- Removed `hasVisColorAdjustment` argument from color palettes (used in `euiPaletteColorBlindBehindText`, `euiPaletteForTemperature`, `euiPaletteComplementary`, `euiPaletteCool`) +- Removed `euiTheme.flags.buttonVariant` and `euiTheme.flags.formVariant` +- Removed `euiTheme.components.keyPadMenuItemBackgroundDisabledSelect` +- Removed legacy SCSS files from `src/global_styling/variables`, `src/global_styling/mixins` and `src/global_styling/functions` - if needed, use them from `eui-theme-common` instead + diff --git a/packages/eui/package.json b/packages/eui/package.json index 8e9f526d16d..a344f971645 100644 --- a/packages/eui/package.json +++ b/packages/eui/package.json @@ -19,8 +19,7 @@ "build:workspaces": "yarn workspaces foreach -Rti --from @elastic/eui-theme-common run build && yarn workspaces foreach -Rti --from @elastic/eui --exclude @elastic/eui --exclude @elastic/eui-theme-common run build", "build:clean": "rimraf dist lib es optimize test-env eui.d.ts", "build:i18ntokens": "node ./scripts/build_i18ntokens.mjs", - "build:copy-assets": "node ./scripts/build_copy_assets.js", - "build": "yarn build:clean && yarn build:i18ntokens && node ./scripts/compile-eui.js && yarn build:copy-assets", + "build": "yarn build:clean && yarn build:i18ntokens && node ./scripts/compile-eui.js", "build-pack": "yarn build && yarn pack", "compile-icons": "node ./scripts/compile-icons.js && prettier --write --loglevel=warn \"./src/components/icon/assets/**/*.tsx\"", "lint": "yarn tsc --noEmit && yarn lint-es && yarn lint-css-in-js && yarn lint-sass", diff --git a/packages/eui/scripts/build_copy_assets.js b/packages/eui/scripts/build_copy_assets.js deleted file mode 100755 index d6cfa898a5d..00000000000 --- a/packages/eui/scripts/build_copy_assets.js +++ /dev/null @@ -1,31 +0,0 @@ -const { copyFile: copyFilePromise } = require('fs/promises'); - -const chalk = require('chalk'); - -const copyFile = async (source, destination) => { - await copyFilePromise(source, destination); - console.log( - chalk`{green ✔} Copied {gray ${source}} to {gray ${destination}}` - ); -}; - -const copyFiles = () => Promise.all([ - copyFile('src/themes/json/eui_theme_amsterdam_dark.json', 'dist/eui_theme_amsterdam_dark.json'), - copyFile('src/themes/json/eui_theme_amsterdam_dark.json.d.ts', 'dist/eui_theme_amsterdam_dark.json.d.ts'), - - copyFile('src/themes/json/eui_theme_amsterdam_light.json', 'dist/eui_theme_amsterdam_light.json'), - copyFile('src/themes/json/eui_theme_amsterdam_light.json.d.ts', 'dist/eui_theme_amsterdam_light.json.d.ts'), - - /* TODO: temp files only, remove once imports from theme package work as expected */ - copyFile('src/themes/json/eui_theme_borealis_dark.json', 'dist/eui_theme_borealis_dark.json'), - copyFile('src/themes/json/eui_theme_borealis_dark.json.d.ts', 'dist/eui_theme_borealis_dark.json.d.ts'), - - copyFile('src/themes/json/eui_theme_borealis_light.json', 'dist/eui_theme_borealis_light.json'), - copyFile('src/themes/json/eui_theme_borealis_light.json.d.ts', 'dist/eui_theme_borealis_light.json.d.ts'), -]); - -copyFiles().catch((err) => { - console.error('Failed to copy assets'); - console.error(err); - process.exit(1); -}); diff --git a/packages/eui/src/components/badge/beta_badge/beta_badge.styles.ts b/packages/eui/src/components/badge/beta_badge/beta_badge.styles.ts index 1ce81ad3100..0c92cfd73e3 100644 --- a/packages/eui/src/components/badge/beta_badge/beta_badge.styles.ts +++ b/packages/eui/src/components/badge/beta_badge/beta_badge.styles.ts @@ -26,8 +26,6 @@ export const euiBetaBadgeStyles = (euiThemeContext: UseEuiTheme) => { s: mathWithUnits(euiTheme.size.base, (x) => x * 1.25), }; - const hasVisColorAdjustment = euiTheme.flags?.hasVisColorAdjustment; - return { euiBetaBadge: css` display: inline-block; @@ -49,9 +47,7 @@ export const euiBetaBadgeStyles = (euiThemeContext: UseEuiTheme) => { } `, // Colors - accent: hasVisColorAdjustment - ? css(badgeColors.accentText) - : css(badgeColors.accent), + accent: css(badgeColors.accent), subdued: css(badgeColors.subdued), hollow: css` color: ${badgeColors.hollow.color}; diff --git a/packages/eui/src/components/badge/notification_badge/badge_notification.styles.ts b/packages/eui/src/components/badge/notification_badge/badge_notification.styles.ts index 76f708ee5d1..f7cb94b6353 100644 --- a/packages/eui/src/components/badge/notification_badge/badge_notification.styles.ts +++ b/packages/eui/src/components/badge/notification_badge/badge_notification.styles.ts @@ -15,20 +15,17 @@ import { mathWithUnits, } from '../../../global_styling'; import { highContrastModeStyles } from '../../../global_styling/functions/high_contrast'; -import { isEuiThemeRefreshVariant, UseEuiTheme } from '../../../services'; +import { UseEuiTheme } from '../../../services'; import { euiBadgeColors } from '../color_utils'; export const euiNotificationBadgeStyles = (euiThemeContext: UseEuiTheme) => { const { euiTheme } = euiThemeContext; - const isRefreshVariant = isEuiThemeRefreshVariant( - euiThemeContext, - 'buttonVariant' - ); const badgeColors = euiBadgeColors(euiThemeContext); - const borderRadius = isRefreshVariant - ? mathWithUnits(euiTheme.border.radius.small, (x) => x / 2) - : euiTheme.border.radius.small; + const borderRadius = mathWithUnits( + euiTheme.border.radius.small, + (x) => x / 2 + ); return { euiNotificationBadge: css` diff --git a/packages/eui/src/components/button/button_display/_button_display.styles.ts b/packages/eui/src/components/button/button_display/_button_display.styles.ts index fd0d5dfbd36..947c6a83715 100644 --- a/packages/eui/src/components/button/button_display/_button_display.styles.ts +++ b/packages/eui/src/components/button/button_display/_button_display.styles.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ import { css } from '@emotion/react'; -import { isEuiThemeRefreshVariant, UseEuiTheme } from '../../../services'; +import { UseEuiTheme } from '../../../services'; import { euiFontSize, logicalCSS, @@ -32,10 +32,6 @@ export const euiButtonBaseCSS = () => { export const euiButtonDisplayStyles = (euiThemeContext: UseEuiTheme) => { const { euiTheme } = euiThemeContext; - const isRefreshVariant = isEuiThemeRefreshVariant( - euiThemeContext, - 'buttonVariant' - ); const sizes = euiButtonSizeMap(euiThemeContext); @@ -49,21 +45,12 @@ export const euiButtonDisplayStyles = (euiThemeContext: UseEuiTheme) => { `; }; - const classicVariantStyles = ` - &:hover:not(:disabled), - &:focus { - text-decoration: underline; - } - `; - return { // Base euiButtonDisplay: css` ${euiButtonBaseCSS()} font-weight: ${euiTheme.font.weight.medium}; ${logicalShorthandCSS('padding', `0 ${euiTheme.size.m}`)} - - ${!isRefreshVariant && classicVariantStyles} `, // States isDisabled: css` diff --git a/packages/eui/src/components/button/button_display/_button_display_content.styles.ts b/packages/eui/src/components/button/button_display/_button_display_content.styles.ts index 82d37bf8ac9..5461482ec6e 100644 --- a/packages/eui/src/components/button/button_display/_button_display_content.styles.ts +++ b/packages/eui/src/components/button/button_display/_button_display_content.styles.ts @@ -6,24 +6,17 @@ * Side Public License, v 1. */ import { css } from '@emotion/react'; -import { isEuiThemeRefreshVariant, UseEuiTheme } from '../../../services'; +import { UseEuiTheme } from '../../../services'; import { logicalCSS } from '../../../global_styling'; export const euiButtonDisplayContentStyles = (euiThemeContext: UseEuiTheme) => { const { euiTheme } = euiThemeContext; - const isRefreshVariant = isEuiThemeRefreshVariant( - euiThemeContext, - 'buttonVariant' - ); - - const refreshVariantStyles = ` - /* ensure content stays ontop of hover pseudo element */ - position: relative; - `; return { // Base euiButtonDisplayContent: css` + /* ensure content stays ontop of hover pseudo element */ + position: relative; ${logicalCSS('height', '100%')} ${logicalCSS('width', '100%')} display: flex; @@ -31,8 +24,6 @@ export const euiButtonDisplayContentStyles = (euiThemeContext: UseEuiTheme) => { align-items: center; vertical-align: middle; gap: ${euiTheme.size.s}; - - ${isRefreshVariant && refreshVariantStyles} `, }; }; diff --git a/packages/eui/src/components/button/button_empty/button_empty.styles.ts b/packages/eui/src/components/button/button_empty/button_empty.styles.ts index 67570951bc0..8445abf7319 100644 --- a/packages/eui/src/components/button/button_empty/button_empty.styles.ts +++ b/packages/eui/src/components/button/button_empty/button_empty.styles.ts @@ -8,7 +8,7 @@ import { css } from '@emotion/react'; -import { isEuiThemeRefreshVariant, UseEuiTheme } from '../../../services'; +import { UseEuiTheme } from '../../../services'; import { logicalCSS, logicalShorthandCSS, @@ -19,43 +19,12 @@ import { euiButtonDisplayStyles } from '../button_display/_button_display.styles export const euiButtonEmptyStyles = (euiThemeContext: UseEuiTheme) => { const { euiTheme } = euiThemeContext; - const isRefreshVariant = isEuiThemeRefreshVariant( - euiThemeContext, - 'buttonVariant' - ); // EuiButtonEmpty uses the same size/font styling as EuiButtonDisplay, // but does not share enough of the same colors/props to the point // of using the actual component - so we'll reuse its styles instead const displayStyles = euiButtonDisplayStyles(euiThemeContext); - const refreshFlushStyles = ` - /* using duplicate selector to ensure specificity */ - &&:hover, - &&:active { - background-color: transparent; - - /* removes hover overlay */ - &::before { - display: none; - } - } - - &:hover:not(:disabled), - &:focus { - text-decoration: underline; - - ${highContrastModeStyles(euiThemeContext, { - forced: ` - /* hides HCM hover border, flush buttons use text-decoration */ - &::after { - display: none; - } - `, - })} - } - `; - return { euiButtonEmpty: css` ${displayStyles.euiButtonDisplay} @@ -74,15 +43,38 @@ export const euiButtonEmptyStyles = (euiThemeContext: UseEuiTheme) => { // uses array here to prevent adding duplicate "m" classname partial m: [ displayStyles.m, - isRefreshVariant && - ` + ` ${logicalCSS('padding-horizontal', euiTheme.size.m)} `, ], // Flush sides flush: css` padding-inline: 0; - ${isRefreshVariant && refreshFlushStyles} + + /* using duplicate selector to ensure specificity */ + &&:hover, + &&:active { + background-color: transparent; + + /* removes hover overlay */ + &::before { + display: none; + } + } + + &:hover:not(:disabled), + &:focus { + text-decoration: underline; + + ${highContrastModeStyles(euiThemeContext, { + forced: ` + /* hides HCM hover border, flush buttons use text-decoration */ + &::after { + display: none; + } + `, + })} + } `, left: css` ${logicalCSS('margin-right', euiTheme.size.s)} diff --git a/packages/eui/src/components/button/button_group/button_group.styles.ts b/packages/eui/src/components/button/button_group/button_group.styles.ts index 82d92038f11..1acf8e44ea2 100644 --- a/packages/eui/src/components/button/button_group/button_group.styles.ts +++ b/packages/eui/src/components/button/button_group/button_group.styles.ts @@ -7,7 +7,7 @@ */ import { css } from '@emotion/react'; -import { isEuiThemeRefreshVariant, UseEuiTheme } from '../../../services'; +import { UseEuiTheme } from '../../../services'; import { logicalCSS } from '../../../global_styling'; import { highContrastModeStyles, @@ -76,15 +76,6 @@ const _highContrastStyles = ( compressed?: boolean ) => { const { euiTheme } = euiThemeContext; - const isRefreshVariant = isEuiThemeRefreshVariant( - euiThemeContext, - 'buttonVariant' - ); - - // Account for buttons within tooltip wrappers in selectors - const getButtonChildSelectors = (selector: string) => ` - & > .euiButtonGroupButton${selector}, - & > .euiButtonGroup__tooltipWrapper${selector} .euiButtonGroupButton`; return highContrastModeStyles(euiThemeContext, { preferred: compressed @@ -93,40 +84,17 @@ const _highContrastStyles = ( border: none; } ` - : // Conditionally unset the high contrast borders passed by `euiButtonColor` - - // faux borders between selected/unselected buttons are rendered by pseudo elements, - // and can flip colors depending on selected/unselected siblings - ` - ${ - !isRefreshVariant && - ` - ${getButtonChildSelectors(':not(:first-child, :last-child)')} { - ${logicalCSS('border-horizontal', 'none')} - } - ${getButtonChildSelectors(':first-child')} { - ${logicalCSS('border-right', 'none')} - } - ${getButtonChildSelectors(':last-child')} { - ${logicalCSS('border-left', 'none')} - } - ` - } - `, + : '', forced: ` .euiButtonGroupButton-isSelected { ${preventForcedColors(euiThemeContext)} color: ${euiTheme.colors.emptyShade}; background-color: ${euiTheme.colors.fullShade}; - ${ - isRefreshVariant && - ` - &:is(:hover, :focus):not(:disabled) { - &::before { - border-color: ${euiTheme.colors.textInverse}; - } - } - ` + &:is(:hover, :focus):not(:disabled) { + &::before { + border-color: ${euiTheme.colors.textInverse}; + } } } diff --git a/packages/eui/src/components/button/button_group/button_group_button.styles.ts b/packages/eui/src/components/button/button_group/button_group_button.styles.ts index 8ef0693d727..522da1e7bdc 100644 --- a/packages/eui/src/components/button/button_group/button_group_button.styles.ts +++ b/packages/eui/src/components/button/button_group/button_group_button.styles.ts @@ -9,11 +9,7 @@ import { css, type SerializedStyles } from '@emotion/react'; import { CSSProperties } from 'react'; -import { - UseEuiTheme, - isEuiThemeRefreshVariant, - makeDisabledContrastColor, -} from '../../../services'; +import { UseEuiTheme } from '../../../services'; import { mathWithUnits, logicalCSS, @@ -25,7 +21,6 @@ import { highContrastModeStyles, } from '../../../global_styling'; import { - euiButtonFillColor, _EuiButtonColor, BUTTON_COLORS, } from '../../../global_styling/mixins/_button'; @@ -34,16 +29,11 @@ import { euiFormVariables } from '../../form/form.styles'; export const euiButtonGroupButtonStyles = (euiThemeContext: UseEuiTheme) => { const { euiTheme, highContrastMode } = euiThemeContext; - const isRefreshVariant = isEuiThemeRefreshVariant( - euiThemeContext, - 'buttonVariant' - ); - const { controlCompressedHeight, controlCompressedBorderRadius } = - euiFormVariables(euiThemeContext); + const { controlCompressedHeight } = euiFormVariables(euiThemeContext); const compressedButtonHeight = mathWithUnits( [controlCompressedHeight, euiTheme.border.width.thin], - (x, y) => (isRefreshVariant ? x - y * 6 : x - y * 2) + (x, y) => x - y * 6 ); const selectedSelectors = @@ -67,99 +57,6 @@ export const euiButtonGroupButtonStyles = (euiThemeContext: UseEuiTheme) => { } `; - const refreshVariantStyles = ` - &:is(${selectedSelectors}) { - ${highContrastModeStyles(euiThemeContext, { - forced: ` - --highContrastHoverIndicatorColor: ${euiTheme.colors.textInverse}; - border: none; - - /* styles the content manually instead of the button itself to preserve the system - focus style, as otherwise preventForcedColors() would require manual styling */ - > [class*="euiButtonDisplayContent"] { - ${preventForcedColors(euiThemeContext)} - color: ${euiTheme.colors.emptyShade}; - border: none; - } - `, - })} - } - `; - - const uncompressedStyles = isRefreshVariant - ? ` - &:is(${selectedSelectors}):not(:disabled) { - z-index: 1; - /* prevent layout jumps due to missing border for selected/filled buttons */ - border: ${euiTheme.border.width.thin} solid transparent; - - ${highContrastModeStyles(euiThemeContext, { - forced: ` - /* use inset focus outline to ensure visibility, same as custom hover. - NOTE: temp solution - this will be revisited once we handle global focus styles */ - &:focus-visible { - outline-color: ${euiTheme.colors.textInverse}; - /* has to be inset due to overflow: hidden */ - outline-offset: -${mathWithUnits( - euiTheme.border.width.thin, - (x) => x * 4 - )}; - } - `, - })} - } - ` - : ` - &:is(.euiButtonGroupButton-isSelected) { - font-weight: ${euiTheme.font.weight.bold}; - } - `; - - const compressedStyles = isRefreshVariant - ? ` - margin: ${euiTheme.size.xxs}; - border-radius: ${mathWithUnits( - euiTheme.border.radius.small, - (x) => x / 2 - )}; - - & + .euiButtonGroupButton { - ${logicalCSS('margin-left', '0')} - } - - &:is(${selectedSelectors}):not(:disabled) { - /* prevent layout jumps due to missing border for non-selected buttons */ - border: none; - - ${highContrastModeStyles(euiThemeContext, { - forced: ` - /* use inset focus outline to ensure visibility, same as custom hover. - NOTE: temp solution - this will be revisited once we handle global focus styles */ - &:focus-visible { - outline-color: ${euiTheme.colors.textInverse}; - /* has to be inset due to overflow: hidden */ - outline-offset: -${mathWithUnits( - euiTheme.border.width.thin, - (x) => x * 3 - )}; - } - `, - })} - } - ` - : ` - background-clip: content-box; - /* Tweak border radius to account for the padding & background-clip */ - border-radius: ${mathWithUnits( - [controlCompressedBorderRadius, euiTheme.border.width.thin], - (x, y) => x + y - )}; - - &:is(.euiButtonGroupButton-isSelected) { - font-weight: ${euiTheme.font.weight.semiBold}; - } - `; - return { // Base euiButtonGroupButton: css` @@ -178,7 +75,22 @@ export const euiButtonGroupButtonStyles = (euiThemeContext: UseEuiTheme) => { color ${euiTheme.animation.normal} ease-in-out; } - ${isRefreshVariant && refreshVariantStyles} + &:is(${selectedSelectors}) { + ${highContrastModeStyles(euiThemeContext, { + forced: ` + --highContrastHoverIndicatorColor: ${euiTheme.colors.textInverse}; + border: none; + + /* styles the content manually instead of the button itself to preserve the system + focus style, as otherwise preventForcedColors() would require manual styling */ + > [class*="euiButtonDisplayContent"] { + ${preventForcedColors(euiThemeContext)} + color: ${euiTheme.colors.emptyShade}; + border: none; + } + `, + })} + } `, iconOnly: css` padding-inline: ${euiTheme.size.s}; @@ -194,7 +106,26 @@ export const euiButtonGroupButtonStyles = (euiThemeContext: UseEuiTheme) => { )} } - ${uncompressedStyles} + &:is(${selectedSelectors}):not(:disabled) { + z-index: 1; + /* prevent layout jumps due to missing border for selected/filled buttons */ + border: ${euiTheme.border.width.thin} solid transparent; + + ${highContrastModeStyles(euiThemeContext, { + forced: ` + /* use inset focus outline to ensure visibility, same as custom hover. + NOTE: temp solution - this will be revisited once we handle global focus styles */ + &:focus-visible { + outline-color: ${euiTheme.colors.textInverse}; + /* has to be inset due to overflow: hidden */ + outline-offset: -${mathWithUnits( + euiTheme.border.width.thin, + (x) => x * 4 + )}; + } + `, + })} + } `, get borders() { // We use pseudo elements to avoid affecing button width, and to allow @@ -208,46 +139,28 @@ export const euiButtonGroupButtonStyles = (euiThemeContext: UseEuiTheme) => { : euiTheme.components.buttonGroupBorderColor; const borderWidth = euiTheme.border.width.thin; - const borderStyles = isRefreshVariant - ? ` - &:not(:first-child) { - margin-inline-start: -${borderWidth}; - } - - &:is(${selectors}) { - &::before { - position: absolute; - z-index: 1; - ${logicalCSS('left', 0)} - ${logicalCSS('vertical', `-${euiTheme.border.width.thin}`)} - ${logicalCSS('border-left-style', 'solid')} - ${logicalCSS('border-left-width', euiTheme.border.width.thin)} - pointer-events: none; - - ${preventForcedColors(euiThemeContext)} - } - } - ` - : ` - &::before { - position: absolute; - ${logicalCSS('left', 0)} - ${logicalCSS( - 'vertical', - highContrastMode ? `-${euiTheme.border.width.thin}` : 0 - )} - ${logicalCSS('border-left-style', 'solid')} - ${logicalCSS('border-left-width', euiTheme.border.width.thin)} - pointer-events: none; - } - `; - // "Borders" between buttons should be present between two of the same colored buttons, // and absent between selected vs non-selected buttons (different colors) return ` position: relative; - ${borderStyles} + &:not(:first-child) { + margin-inline-start: -${borderWidth}; + } + + &:is(${selectors}) { + &::before { + position: absolute; + z-index: 1; + ${logicalCSS('left', 0)} + ${logicalCSS('vertical', `-${euiTheme.border.width.thin}`)} + ${logicalCSS('border-left-style', 'solid')} + ${logicalCSS('border-left-width', euiTheme.border.width.thin)} + pointer-events: none; + + ${preventForcedColors(euiThemeContext)} + } + } &:not(${selectors}) + *:not(${selectors}) { &::before { @@ -271,9 +184,7 @@ export const euiButtonGroupButtonStyles = (euiThemeContext: UseEuiTheme) => { `; }, get m() { - const radius = isRefreshVariant - ? euiTheme.border.radius.small - : euiTheme.border.radius.medium; + const radius = euiTheme.border.radius.small; return css` ${this.borders} ${uncompressedBorderRadii(radius)} @@ -290,26 +201,46 @@ export const euiButtonGroupButtonStyles = (euiThemeContext: UseEuiTheme) => { font-weight: ${euiTheme.font.weight.medium}; /* Offset the background color from the border by clipping background to before the padding starts */ - padding: ${isRefreshVariant - ? '0' - : mathWithUnits(euiTheme.border.width.thin, (x) => x * 2)}; + padding: 0; + + margin: ${euiTheme.size.xxs}; + border-radius: ${mathWithUnits( + euiTheme.border.radius.small, + (x) => x / 2 + )}; - ${compressedStyles} + & + .euiButtonGroupButton { + ${logicalCSS('margin-left', '0')} + } + + &:is(${selectedSelectors}):not(:disabled) { + /* prevent layout jumps due to missing border for non-selected buttons */ + border: none; + + ${highContrastModeStyles(euiThemeContext, { + forced: ` + /* use inset focus outline to ensure visibility, same as custom hover. + NOTE: temp solution - this will be revisited once we handle global focus styles */ + &:focus-visible { + outline-color: ${euiTheme.colors.textInverse}; + /* has to be inset due to overflow: hidden */ + outline-offset: -${mathWithUnits( + euiTheme.border.width.thin, + (x) => x * 3 + )}; + } + `, + })} + } `, // States disabledAndSelected: css` - color: ${isRefreshVariant - ? euiTheme.colors.textDisabled - : makeDisabledContrastColor(euiTheme.colors.textDisabled)( - euiTheme.components.buttonGroupBackgroundDisabledSelected - )}; + color: ${euiTheme.colors.textDisabled}; background-color: ${euiTheme.components .buttonGroupBackgroundDisabledSelected}; border: ${highContrastMode ? `${euiTheme.border.width.thin} solid ${euiTheme.components.buttonGroupBackgroundDisabledSelected}` - : isRefreshVariant - ? `${euiTheme.border.width.thin} solid ${euiTheme.colors.borderBasePlain}` - : ''}; + : `${euiTheme.border.width.thin} solid ${euiTheme.colors.borderBasePlain}`}; `, // Skip css`` to avoid generating a className hasBorder: ` @@ -347,31 +278,14 @@ export const euiButtonGroupButtonStyles = (euiThemeContext: UseEuiTheme) => { export const _compressedButtonFocusColors = (euiThemeContext: UseEuiTheme) => { const { euiTheme } = euiThemeContext; - const isRefreshVariant = isEuiThemeRefreshVariant( - euiThemeContext, - 'buttonVariant' - ); const colors = [...BUTTON_COLORS, 'disabled'] as const; return colors.reduce((acc, color) => { - const { backgroundColor } = euiButtonFillColor(euiThemeContext, color); - return { ...acc, [color]: css` &:focus-visible { - ${euiOutline( - euiThemeContext, - isRefreshVariant ? 'outset' : 'center', - isRefreshVariant ? euiTheme.focus.color : backgroundColor - )} - - ${!isRefreshVariant && - ` - &:is(.euiButtonGroupButton-isSelected) { - outline-offset: 0; - } - `} + ${euiOutline(euiThemeContext, 'outset', euiTheme.focus.color)} } `, }; diff --git a/packages/eui/src/components/button/button_group/button_group_button.tsx b/packages/eui/src/components/button/button_group/button_group_button.tsx index f385399370e..b3c0727c565 100644 --- a/packages/eui/src/components/button/button_group/button_group_button.tsx +++ b/packages/eui/src/components/button/button_group/button_group_button.tsx @@ -14,11 +14,7 @@ import React, { } from 'react'; import { CSSInterpolation } from '@emotion/css'; -import { - isEuiThemeRefreshVariant, - useEuiMemoizedStyles, - useEuiTheme, -} from '../../../services'; +import { useEuiMemoizedStyles } from '../../../services'; import { useEuiButtonColorCSS } from '../../../global_styling/mixins/_button'; import { useInnerText } from '../../inner_text'; @@ -72,15 +68,9 @@ export const EuiButtonGroupButton: FunctionComponent = ({ contentProps, ...rest }) => { - const euiThemeContext = useEuiTheme(); - const isRefreshVariant = isEuiThemeRefreshVariant( - euiThemeContext, - 'buttonVariant' - ); - const isCompressed = size === 'compressed'; const color = isDisabled ? 'disabled' : _color; - const hasBorder = isRefreshVariant && color !== 'text' && !isCompressed; + const hasBorder = color !== 'text' && !isCompressed; const display = isSelected ? 'fill' : isCompressed || hasBorder diff --git a/packages/eui/src/components/button/button_icon/button_icon.tsx b/packages/eui/src/components/button/button_icon/button_icon.tsx index 77dcf7b8059..d36053e6da8 100644 --- a/packages/eui/src/components/button/button_icon/button_icon.tsx +++ b/packages/eui/src/components/button/button_icon/button_icon.tsx @@ -14,12 +14,7 @@ import React, { } from 'react'; import classNames from 'classnames'; -import { - getSecureRelForTarget, - isEuiThemeRefreshVariant, - useEuiMemoizedStyles, - useEuiTheme, -} from '../../../services'; +import { getSecureRelForTarget, useEuiMemoizedStyles } from '../../../services'; import { CommonProps, ExclusiveUnion, @@ -37,7 +32,7 @@ import { _EuiExtendedButtonColor, } from '../../../global_styling/mixins/_button'; import { isButtonDisabled } from '../button_display/_button_display'; -import { euiButtonIconStyles, _emptyHoverStyles } from './button_icon.styles'; +import { euiButtonIconStyles } from './button_icon.styles'; export const SIZES = ['xs', 's', 'm'] as const; export type EuiButtonIconSizes = (typeof SIZES)[number]; @@ -130,12 +125,6 @@ export const EuiButtonIcon: FunctionComponent = ({ isLoading, ...rest }) => { - const euiThemeContext = useEuiTheme(); - const isRefreshVariant = isEuiThemeRefreshVariant( - euiThemeContext, - 'buttonVariant' - ); - const isDisabled = isButtonDisabled({ isDisabled: _isDisabled || disabled, href, @@ -154,7 +143,6 @@ export const EuiButtonIcon: FunctionComponent = ({ const buttonColorStyles = useEuiButtonColorCSS({ display }); const buttonFocusStyle = useEuiButtonFocusCSS(); - const emptyHoverStyles = useEuiMemoizedStyles(_emptyHoverStyles); const styles = useEuiMemoizedStyles(euiButtonIconStyles); const cssStyles = [ @@ -162,10 +150,6 @@ export const EuiButtonIcon: FunctionComponent = ({ styles[size], buttonColorStyles[isDisabled ? 'disabled' : color], buttonFocusStyle, - !isRefreshVariant && - display === 'empty' && - !isDisabled && - emptyHoverStyles[color], isDisabled && styles.isDisabled, ]; diff --git a/packages/eui/src/components/collapsible_nav_beta/collapsible_nav_beta.styles.ts b/packages/eui/src/components/collapsible_nav_beta/collapsible_nav_beta.styles.ts index d0b7eeb5bce..a80cf38daab 100644 --- a/packages/eui/src/components/collapsible_nav_beta/collapsible_nav_beta.styles.ts +++ b/packages/eui/src/components/collapsible_nav_beta/collapsible_nav_beta.styles.ts @@ -7,9 +7,9 @@ */ import { css } from '@emotion/react'; +import { euiShadowFlat } from '@elastic/eui-theme-common'; import { UseEuiTheme } from '../../services'; import { logicalCSS } from '../../global_styling'; -import { euiShadowFlat } from '../../themes'; import { euiHeaderVariables } from '../header/header.styles'; import { hideScrollbars } from './collapsible_nav_body_footer.styles'; diff --git a/packages/eui/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.styles.ts b/packages/eui/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.styles.ts index 139b0de6178..90e56183c4f 100644 --- a/packages/eui/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.styles.ts +++ b/packages/eui/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.styles.ts @@ -8,13 +8,12 @@ import { css } from '@emotion/react'; -import { isEuiThemeRefreshVariant, UseEuiTheme } from '../../../services'; +import { UseEuiTheme } from '../../../services'; import { logicalCSS, mathWithUnits, euiFontSize, } from '../../../global_styling'; -import { euiButtonColor } from '../../../global_styling/mixins/_button'; /** * Style variables shared between accordion, link, and sub items @@ -23,10 +22,6 @@ export const euiCollapsibleNavItemVariables = ( euiThemeContext: UseEuiTheme ) => { const { euiTheme } = euiThemeContext; - const isRefreshVariant = isEuiThemeRefreshVariant( - euiThemeContext, - 'buttonVariant' - ); return { height: euiTheme.size.xl, @@ -35,9 +30,7 @@ export const euiCollapsibleNavItemVariables = ( animation: `${euiTheme.animation.normal} ease-in-out`, // Matches EuiButton borderRadius: euiTheme.border.radius.small, backgroundHoverColor: euiTheme.colors.lightestShade, - backgroundSelectedColor: isRefreshVariant - ? euiTheme.colors.backgroundBaseInteractiveSelect - : euiButtonColor(euiThemeContext, 'text').backgroundColor, + backgroundSelectedColor: euiTheme.colors.backgroundBaseInteractiveSelect, color: euiTheme.colors.textParagraph, rightIconColor: euiTheme.colors.textDisabled, }; diff --git a/packages/eui/src/components/combo_box/combo_box_input/combo_box_input.styles.ts b/packages/eui/src/components/combo_box/combo_box_input/combo_box_input.styles.ts index 47e3ae1a54f..78f432a6649 100644 --- a/packages/eui/src/components/combo_box/combo_box_input/combo_box_input.styles.ts +++ b/packages/eui/src/components/combo_box/combo_box_input/combo_box_input.styles.ts @@ -8,7 +8,7 @@ import { css } from '@emotion/react'; -import { isEuiThemeRefreshVariant, UseEuiTheme } from '../../../services'; +import { UseEuiTheme } from '../../../services'; import { logicalCSS } from '../../../global_styling'; import { euiFormControlStyles, @@ -18,10 +18,7 @@ import { export const euiComboBoxInputStyles = (euiThemeContext: UseEuiTheme) => { const { euiTheme } = euiThemeContext; - const isRefreshVariant = isEuiThemeRefreshVariant( - euiThemeContext, - 'formVariant' - ); + const formStyles = euiFormControlStyles(euiThemeContext); return { @@ -30,12 +27,9 @@ export const euiComboBoxInputStyles = (euiThemeContext: UseEuiTheme) => { ${euiFormControlDefaultShadow(euiThemeContext)} display: flex; - ${isRefreshVariant && - ` - &:focus-within { - ${formStyles.focus} - } - `} + &:focus-within { + ${formStyles.focus} + } `, multiSelect: css` flex-wrap: wrap; @@ -44,10 +38,7 @@ export const euiComboBoxInputStyles = (euiThemeContext: UseEuiTheme) => { ${formStyles.uncompressed} ${logicalCSS('height', 'auto')} ${logicalCSS('padding-vertical', euiTheme.size.s)} - ${logicalCSS( - 'padding-left', - isRefreshVariant ? euiTheme.size.m : euiTheme.size.s - )} + ${logicalCSS('padding-left', euiTheme.size.m)} column-gap: ${euiTheme.size.s}; row-gap: ${euiTheme.size.xs}; `, diff --git a/packages/eui/src/components/combo_box/combo_box_input/combo_box_input.tsx b/packages/eui/src/components/combo_box/combo_box_input/combo_box_input.tsx index bff9f6d6900..b8ca9f3a479 100644 --- a/packages/eui/src/components/combo_box/combo_box_input/combo_box_input.tsx +++ b/packages/eui/src/components/combo_box/combo_box_input/combo_box_input.tsx @@ -21,8 +21,6 @@ import { keys, CanvasTextUtils, RenderWithEuiStylesMemoizer, - isEuiThemeRefreshVariant, - RenderWithEuiTheme, } from '../../../services'; import { EuiScreenReaderOnly } from '../../accessibility'; import { @@ -319,122 +317,104 @@ export class EuiComboBoxInput extends Component< }); return ( - - {(euiThemeContext) => ( - - {(stylesMemoizer) => { - const styles = stylesMemoizer(euiComboBoxInputStyles); - const isRefreshVariant = isEuiThemeRefreshVariant( - euiThemeContext, - 'formVariant' - ); - - const stateCss = isRefreshVariant - ? isListOpen - ? styles.open - : isInvalid - ? styles.invalid - : undefined - : isInvalid - ? styles.invalid - : isListOpen - ? styles.open - : undefined; - - const cssStyles = [ - styles.euiComboBoxInputWrapper, - !singleSelection && styles.multiSelect, - compressed ? styles.compressed : styles.uncompressed, - ...(this.asPlainText || showPlaceholder - ? [ - styles.plainText.plainText, - compressed - ? styles.plainText.compressed - : styles.plainText.uncompressed, - ] - : []), - isDisabled ? styles.disabled : stateCss, - isInGroup && styles.inGroup, - ]; - const formLayoutStyles = [ - styles.formLayout.euiComboBox__formControlLayout, - !singleSelection && styles.formLayout.multiSelect, - ]; - - return ( - + {(stylesMemoizer) => { + const styles = stylesMemoizer(euiComboBoxInputStyles); + + const stateCss = isListOpen + ? styles.open + : isInvalid + ? styles.invalid + : undefined; + + const cssStyles = [ + styles.euiComboBoxInputWrapper, + !singleSelection && styles.multiSelect, + compressed ? styles.compressed : styles.uncompressed, + ...(this.asPlainText || showPlaceholder + ? [ + styles.plainText.plainText, + compressed + ? styles.plainText.compressed + : styles.plainText.uncompressed, + ] + : []), + isDisabled ? styles.disabled : stateCss, + isInGroup && styles.inGroup, + ]; + const formLayoutStyles = [ + styles.formLayout.euiComboBox__formControlLayout, + !singleSelection && styles.formLayout.multiSelect, + ]; + + return ( + +
+ {this.renderPills()} + -
- {this.renderPills()} - - onChange(event.target.value)} - onFocus={this.onFocus} - onKeyDown={this.onKeyDown} - ref={this.inputRefCallback} - role="combobox" - style={{ - inlineSize: - this.asPlainText || showPlaceholder - ? '100%' - : this.state.inputWidth, - }} - placeholder={showPlaceholder ? placeholder : undefined} - value={this.searchValue} - autoFocus={autoFocus} - autoComplete="off" - // Force the menu to re-open on every input click - only necessary when plain text - onClick={ - this.asPlainText ? (onFocus as any) : undefined - } // Type shenanigans - event should be mostly the same - /> - - {removeOptionMessage} -
- - ); - }} - - )} - + onChange(event.target.value)} + onFocus={this.onFocus} + onKeyDown={this.onKeyDown} + ref={this.inputRefCallback} + role="combobox" + style={{ + inlineSize: + this.asPlainText || showPlaceholder + ? '100%' + : this.state.inputWidth, + }} + placeholder={showPlaceholder ? placeholder : undefined} + value={this.searchValue} + autoFocus={autoFocus} + autoComplete="off" + // Force the menu to re-open on every input click - only necessary when plain text + onClick={this.asPlainText ? (onFocus as any) : undefined} // Type shenanigans - event should be mostly the same + /> +
+ {removeOptionMessage} +
+
+ ); + }} +
); } } diff --git a/packages/eui/src/components/datagrid/controls/column_selector.styles.ts b/packages/eui/src/components/datagrid/controls/column_selector.styles.ts index cd26451674b..6fc5a439ff9 100644 --- a/packages/eui/src/components/datagrid/controls/column_selector.styles.ts +++ b/packages/eui/src/components/datagrid/controls/column_selector.styles.ts @@ -7,6 +7,7 @@ */ import { css } from '@emotion/react'; +import { euiShadowLarge } from '@elastic/eui-theme-common'; import { UseEuiTheme } from '../../../services'; import { @@ -14,7 +15,6 @@ import { logicalCSS, mathWithUnits, } from '../../../global_styling'; -import { euiShadowLarge } from '../../../themes'; export const euiDataGridColumnSelectorStyles = ( euiThemeContext: UseEuiTheme diff --git a/packages/eui/src/components/datagrid/controls/column_sorting.styles.ts b/packages/eui/src/components/datagrid/controls/column_sorting.styles.ts index c2e85b86d6e..c657db7688a 100644 --- a/packages/eui/src/components/datagrid/controls/column_sorting.styles.ts +++ b/packages/eui/src/components/datagrid/controls/column_sorting.styles.ts @@ -7,6 +7,7 @@ */ import { css } from '@emotion/react'; +import { euiShadowLarge } from '@elastic/eui-theme-common'; import { UseEuiTheme } from '../../../services'; import { @@ -17,7 +18,6 @@ import { logicalCSS, mathWithUnits, } from '../../../global_styling'; -import { euiShadowLarge } from '../../../themes'; export const euiDataGridColumnSortingStyles = ( euiThemeContext: UseEuiTheme diff --git a/packages/eui/src/components/datagrid/controls/data_grid_toolbar_control.tsx b/packages/eui/src/components/datagrid/controls/data_grid_toolbar_control.tsx index 1c9303699f6..450e3631635 100644 --- a/packages/eui/src/components/datagrid/controls/data_grid_toolbar_control.tsx +++ b/packages/eui/src/components/datagrid/controls/data_grid_toolbar_control.tsx @@ -11,7 +11,7 @@ import classNames from 'classnames'; import { css } from '@emotion/react'; import { UseEuiTheme } from '@elastic/eui-theme-common'; -import { useEuiTheme, useEuiThemeRefreshVariant } from '../../../services'; +import { useEuiTheme } from '../../../services'; import { EuiButtonEmpty, EuiButtonEmptyProps } from '../../button'; import { EuiNotificationBadge } from '../../badge'; import { useEuiI18n } from '../../i18n'; @@ -24,13 +24,9 @@ export const EuiDataGridToolbarControl: FunctionComponent< EuiDataGridToolbarControlProps > = ({ children, className, badgeContent, textProps, ...rest }) => { const euiThemeContext = useEuiTheme(); - const isRefreshVariant = useEuiThemeRefreshVariant('buttonVariant'); const classes = classNames('euiDataGridToolbarControl', className); - const cssStyles = isRefreshVariant - ? // passes euiThemeContext here instead via `css` to ensure legacy Enzyme tests work - interactiveStyles(euiThemeContext) - : underlineStyles; + const cssStyles = interactiveStyles(euiThemeContext); const badgeAriaLabel = useEuiI18n( 'euiDataGridToolbarControl.badgeAriaLabel', @@ -83,18 +79,6 @@ export const EuiDataGridToolbarControl: FunctionComponent< const betterScreenReaderSlashes = (badgeContent: string) => badgeContent.replaceAll('/', ' out of '); -// Underline actual text, but not the badge -const underlineStyles = css` - &:focus, - &:hover:not(:disabled) { - text-decoration: none; - - .euiDataGridToolbarControl__text { - text-decoration: underline; - } - } -`; - const interactiveStyles = ({ euiTheme }: UseEuiTheme) => css` &:focus, &:hover:not(:disabled) { diff --git a/packages/eui/src/components/datagrid/data_grid.styles.ts b/packages/eui/src/components/datagrid/data_grid.styles.ts index f1a46f4a66c..19e713587ef 100644 --- a/packages/eui/src/components/datagrid/data_grid.styles.ts +++ b/packages/eui/src/components/datagrid/data_grid.styles.ts @@ -234,7 +234,6 @@ export const euiDataGridStyles = (euiThemeContext: UseEuiTheme) => { return css(this.fontSize('m')); }, get l() { - // On the Amsterdam theme, the l fontSize is the same as m return css(this.fontSize('m')); }, }, diff --git a/packages/eui/src/components/date_picker/date_picker.styles.ts b/packages/eui/src/components/date_picker/date_picker.styles.ts index 2e2e171d1d0..ed9fddbb7da 100644 --- a/packages/eui/src/components/date_picker/date_picker.styles.ts +++ b/packages/eui/src/components/date_picker/date_picker.styles.ts @@ -9,7 +9,7 @@ import { css } from '@emotion/react'; import { euiShadowMedium } from '@elastic/eui-theme-common'; -import { isEuiThemeRefreshVariant, UseEuiTheme } from '../../services'; +import { UseEuiTheme } from '../../services'; import { logicalCSS } from '../../global_styling'; import { euiFormControlDisabledStyles, @@ -20,17 +20,6 @@ import { export const euiDatePickerStyles = (euiThemeContext: UseEuiTheme) => { const { euiTheme } = euiThemeContext; - const isRefreshVariant = isEuiThemeRefreshVariant( - euiThemeContext, - 'formVariant' - ); - - const inlineStyles = ` - /* removes form layout border */ - &::after { - display: none; - } - `; return { euiDatePicker: css` @@ -45,7 +34,10 @@ export const euiDatePickerStyles = (euiThemeContext: UseEuiTheme) => { border: none; padding: 0; - ${isRefreshVariant && inlineStyles} + /* removes form layout border */ + &::after { + display: none; + } } .euiFormControlLayout__childrenWrapper { diff --git a/packages/eui/src/components/date_picker/date_picker_range.styles.ts b/packages/eui/src/components/date_picker/date_picker_range.styles.ts index f9ec6f32711..21f2b2d07b4 100644 --- a/packages/eui/src/components/date_picker/date_picker_range.styles.ts +++ b/packages/eui/src/components/date_picker/date_picker_range.styles.ts @@ -10,27 +10,10 @@ import { css } from '@emotion/react'; import { euiShadowMedium } from '@elastic/eui-theme-common'; import { logicalCSS } from '../../global_styling'; -import { isEuiThemeRefreshVariant, UseEuiTheme } from '../../services'; +import { UseEuiTheme } from '../../services'; import { disableFormControlHoverStyles } from '../form/form.styles'; -export const euiDatePickerRangeStyles = (euiThemeContext: UseEuiTheme) => { - const isRefreshVariant = isEuiThemeRefreshVariant( - euiThemeContext, - 'formVariant' - ); - - const refreshStyles = ` - .euiPopover:last-child { - ${logicalCSS('border-top-right-radius', 'inherit')} - ${logicalCSS('border-bottom-right-radius', 'inherit')} - - * { - ${logicalCSS('border-top-right-radius', 'inherit')} - ${logicalCSS('border-bottom-right-radius', 'inherit')} - } - } - `; - +export const euiDatePickerRangeStyles = () => { return { euiDatePickerRange: css` /* Needed for correct focus/invalid underline/linear-gradient styles */ @@ -45,7 +28,15 @@ export const euiDatePickerRangeStyles = (euiThemeContext: UseEuiTheme) => { flex: 1; } - ${isRefreshVariant && refreshStyles} + .euiPopover:last-child { + ${logicalCSS('border-top-right-radius', 'inherit')} + ${logicalCSS('border-bottom-right-radius', 'inherit')} + + * { + ${logicalCSS('border-top-right-radius', 'inherit')} + ${logicalCSS('border-bottom-right-radius', 'inherit')} + } + } `, }; }; @@ -54,10 +45,6 @@ export const euiDatePickerRangeInlineStyles = ( euiThemeContext: UseEuiTheme ) => { const { euiTheme } = euiThemeContext; - const isRefreshVariant = isEuiThemeRefreshVariant( - euiThemeContext, - 'formVariant' - ); // Use a container query to stack date pickers vertically if the container is // not wide enough to fit both. We need a fn for this to render two width queries, @@ -109,12 +96,9 @@ export const euiDatePickerRangeInlineStyles = ( ${logicalCSS('padding-bottom', euiTheme.size.s)} } - ${isRefreshVariant && - ` - &::after { - display: none; - } - `} + &::after { + display: none; + } } /* Make sure the inline date picker sets its absolute positioning based off the correct parent */ @@ -134,16 +118,13 @@ export const euiDatePickerRangeInlineStyles = ( borderAllInHighContrastMode: true, })} - ${isRefreshVariant && - ` - /* the form layout is not part of the interactive behavior but rather a container in this variant */ + /* the form layout is not part of the interactive behavior but rather a container in this variant */ ${disableFormControlHoverStyles()} .euiFormControlLayout__childrenWrapper { - box-shadow: none; - ${disableFormControlHoverStyles()} - } - `} + box-shadow: none; + ${disableFormControlHoverStyles()} + } } `, diff --git a/packages/eui/src/components/date_picker/super_date_picker/super_date_picker.styles.ts b/packages/eui/src/components/date_picker/super_date_picker/super_date_picker.styles.ts index 0e8e460f48a..6188087503e 100644 --- a/packages/eui/src/components/date_picker/super_date_picker/super_date_picker.styles.ts +++ b/packages/eui/src/components/date_picker/super_date_picker/super_date_picker.styles.ts @@ -8,11 +8,7 @@ import { css } from '@emotion/react'; -import { - UseEuiTheme, - isEuiThemeRefreshVariant, - makeHighContrastColor, -} from '../../../services'; +import { UseEuiTheme, makeHighContrastColor } from '../../../services'; import { euiFontSize, euiMaxBreakpoint, @@ -25,17 +21,12 @@ import { euiFormControlDefaultShadow, euiFormControlInvalidStyles, euiFormControlDisabledStyles, - euiFormControlShowBackgroundLine, euiFormControlFocusStyles, euiFormControlHighlightBorderStyles, } from '../../form/form.styles'; export const euiSuperDatePickerStyles = (euiThemeContext: UseEuiTheme) => { const { euiTheme } = euiThemeContext; - const isRefreshVariant = isEuiThemeRefreshVariant( - euiThemeContext, - 'formVariant' - ); const forms = euiFormVariables(euiThemeContext); @@ -63,116 +54,6 @@ export const euiSuperDatePickerStyles = (euiThemeContext: UseEuiTheme) => { needsUpdatingBackgroundColor ); - const formLayoutStyles = ` - /* using wrapper hover styles instead */ - .euiDatePopoverButton:not(.euiDatePopoverButton-isSelected):hover { - outline: none; - } - - .euiPopover { - /* mimic input border-radius */ - border-radius: ${forms.controlBorderRadius}; - - &:first-child { - ${logicalCSS('border-top-left-radius', 'inherit')} - ${logicalCSS('border-bottom-left-radius', 'inherit')} - } - - &:last-child { - ${logicalCSS('border-top-right-radius', 'inherit')} - ${logicalCSS('border-bottom-right-radius', 'inherit')} - } - } - - .euiDatePopoverButton { - background-color: transparent; - border-radius: inherit; - } - `; - - const popoverButtonFocusStyles = isRefreshVariant - ? ` - ${euiFormControlFocusStyles(euiThemeContext)} - ` - : ` - --euiFormControlStateColor: ${euiTheme.colors.primary}; - ${euiFormControlShowBackgroundLine( - euiThemeContext, - euiTheme.colors.primary - )} - `; - - const invalidStyles = isRefreshVariant - ? ` - &:has(.euiPopover-isOpen, .euiDatePopoverButton:focus) { - --euiFormControlStateColor: ${forms.borderColor}; - --euiFormControlStateHoverColor: ${forms.borderHovered}; - } - - &:not(:has(.euiPopover-isOpen, .euiDatePopoverButton:focus)) { - ${euiFormControlInvalidStyles(euiThemeContext)} - } - - .euiDatePopoverButton:focus, - .euiPopover-isOpen .euiDatePopoverButton { - ${euiFormControlFocusStyles(euiThemeContext)} - } - ` - : ` - ${euiFormControlInvalidStyles(euiThemeContext)} - `; - - const needsUpdatingStyles = ` - --euiFormControlStateColor: ${euiTheme.colors.success}; - --euiFormControlStateHoverColor: ${euiTheme.colors.success}; - --euiFormControlStateWidth: ${euiTheme.border.width.thin}; - ${euiFormControlHighlightBorderStyles} - - &:has(.euiPopover-isOpen), - &:focus-within { - --euiFormControlStateColor: ${forms.borderColor}; - --euiFormControlStateHoverColor: ${forms.borderHovered}; - } - `; - - const needsUpdatingPopoverButtonFocusStyles = isRefreshVariant - ? ` - ${euiFormControlFocusStyles(euiThemeContext)} - ` - : ` - --euiFormControlStateColor: ${euiTheme.colors.success}; - ${euiFormControlShowBackgroundLine( - euiThemeContext, - euiTheme.colors.success - )} - - ${highContrastModeStyles(euiThemeContext, { - // Force the fill color of all icons/svgs to give a bit more indication of state, - // since Windows high contrast themes otherwise override background/text color - forced: ` - svg, - & + * svg { - fill: ${euiTheme.colors.success}; - } - `, - })} - `; - - const prettyFormatStyles = ` - --euiFormControlStateHoverColor: ${forms.borderHovered}; - ${euiFormControlDefaultShadow(euiThemeContext)} - - ${highContrastModeStyles(euiThemeContext, { - preferred: ` - border: none; - `, - })} - - &:focus { - ${euiFormControlFocusStyles(euiThemeContext)} - } - `; - return { euiSuperDatePicker: css` display: flex; @@ -255,7 +136,18 @@ export const euiSuperDatePickerStyles = (euiThemeContext: UseEuiTheme) => { ${_buttonStyles(euiThemeContext)} text-align: start; - ${isRefreshVariant && prettyFormatStyles} + --euiFormControlStateHoverColor: ${forms.borderHovered}; + ${euiFormControlDefaultShadow(euiThemeContext)} + + &:focus { + ${euiFormControlFocusStyles(euiThemeContext)} + } + + ${highContrastModeStyles(euiThemeContext, { + preferred: ` + border: none; + `, + })} `, // Form states @@ -263,13 +155,39 @@ export const euiSuperDatePickerStyles = (euiThemeContext: UseEuiTheme) => { euiSuperDatePicker__formControlLayout: css` .euiFormControlLayout__childrenWrapper { --euiFormControlStateHoverColor: ${forms.borderHovered}; - ${euiFormControlDefaultShadow(euiThemeContext)} + ${highContrastModeStyles(euiThemeContext, { - none: 'box-shadow: none;', + none: ` + ${euiFormControlDefaultShadow(euiThemeContext)} + box-shadow: none; + `, preferred: 'border: none;', })} - ${isRefreshVariant && formLayoutStyles} + /* using wrapper hover styles instead */ + .euiDatePopoverButton:not(.euiDatePopoverButton-isSelected):hover { + outline: none; + } + + .euiPopover { + /* mimic input border-radius */ + border-radius: ${forms.controlBorderRadius}; + + &:first-child { + ${logicalCSS('border-top-left-radius', 'inherit')} + ${logicalCSS('border-bottom-left-radius', 'inherit')} + } + + &:last-child { + ${logicalCSS('border-top-right-radius', 'inherit')} + ${logicalCSS('border-bottom-right-radius', 'inherit')} + } + } + + .euiDatePopoverButton { + background-color: transparent; + border-radius: inherit; + } } `, default: css` @@ -281,17 +199,12 @@ export const euiSuperDatePickerStyles = (euiThemeContext: UseEuiTheme) => { /* Focus/selection underline per-button */ .euiDatePopoverButton { --euiFormControlStateHoverColor: ${forms.borderHovered}; - ${!isRefreshVariant && - euiFormControlDefaultShadow(euiThemeContext, { - withBorder: false, - withBackgroundColor: false, - })} box-shadow: none; } .euiDatePopoverButton:focus, .euiPopover-isOpen .euiDatePopoverButton { - ${popoverButtonFocusStyles} + ${euiFormControlFocusStyles(euiThemeContext)} } `, disabled: css` @@ -304,15 +217,37 @@ export const euiSuperDatePickerStyles = (euiThemeContext: UseEuiTheme) => { color: ${euiTheme.colors.textDanger}; background-color: ${forms.backgroundColor}; - ${invalidStyles} + &:has(.euiPopover-isOpen, .euiDatePopoverButton:focus) { + --euiFormControlStateColor: ${forms.borderColor}; + --euiFormControlStateHoverColor: ${forms.borderHovered}; + } + + &:not(:has(.euiPopover-isOpen, .euiDatePopoverButton:focus)) { + ${euiFormControlInvalidStyles(euiThemeContext)} + } + + .euiDatePopoverButton:focus, + .euiPopover-isOpen .euiDatePopoverButton { + ${euiFormControlFocusStyles(euiThemeContext)} + } } `, needsUpdating: css` .euiFormControlLayout__childrenWrapper { + --euiFormControlStateColor: ${euiTheme.colors.success}; + --euiFormControlStateHoverColor: ${euiTheme.colors.success}; + --euiFormControlStateWidth: ${euiTheme.border.width.thin}; + color: ${needsUpdatingTextColor}; background-color: ${needsUpdatingBackgroundColor}; - ${isRefreshVariant && needsUpdatingStyles} + ${euiFormControlHighlightBorderStyles} + + &:has(.euiPopover-isOpen), + &:focus-within { + --euiFormControlStateColor: ${forms.borderColor}; + --euiFormControlStateHoverColor: ${forms.borderHovered}; + } } .euiFormControlLayoutDelimited__delimiter { @@ -331,7 +266,7 @@ export const euiSuperDatePickerStyles = (euiThemeContext: UseEuiTheme) => { .euiDatePopoverButton:focus, .euiPopover-isOpen .euiDatePopoverButton { - ${needsUpdatingPopoverButtonFocusStyles} + ${euiFormControlFocusStyles(euiThemeContext)} } `, }, diff --git a/packages/eui/src/components/filter_group/__snapshots__/filter_button.test.tsx.snap b/packages/eui/src/components/filter_group/__snapshots__/filter_button.test.tsx.snap index 150b37cbeba..6d5c1e5741c 100644 --- a/packages/eui/src/components/filter_group/__snapshots__/filter_button.test.tsx.snap +++ b/packages/eui/src/components/filter_group/__snapshots__/filter_button.test.tsx.snap @@ -2,7 +2,7 @@ exports[`EuiFilterButton does not render a badge or count if numFilters is not passed 1`] = `