Skip to content

Conversation

@cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Nov 21, 2024

Summary

Note

This PR merges into a feature branch. It continues expanding upon the high contrast mode setup (#8142), improving border display at a slightly more granular component level.

The following components with shadows should now have all-around borders in high contrast mode (both MacOS and Windows/emulated forced colors):

Panels:

  • EuiPanels should always have a border around them regardless of hasShadow or hasBorder props. Split panels should not have a border between inner panels (open to feedback on the latter, but it started feeling too visually noisy at that point)
  • (MacOS only, not Windows) EuiCallOuts and other colored panels should have border colors that match the panel background
  • Clickable cards should still have a slight extra border-bottom "shadow" on hover/focus for both MacOS and Windows
MacOS Windows

Portalled components:

Modals Flyouts Toasts

Popovers and tooltips:

Note for tooltips: effects are primarily only visible in dark mode or in forced colors/Windows high contrast mode mode. While I was here, I also added a border for non-high-contrast tooltips in darkmode, as I found the visibility against dark mode background colors to be insufficient to even see the dang tooltip. See the added VRT screenshots.

Popovers in particular required a good amount of custom CSS shenanigans to account for their arrows 😅 See the individual git messages for some details on the CSS tricks used to get them working (primarily using clip-path instead of CSS borders to render a triangle, and using a rotated pseudo element to render the border).

The final effect has some minute pixel aliasing on different zoom levels, but IMO it's Good Enough and way better than just being totally broken:

Popover Tooltips

Windows high contrast:

General checklist

  • Browser QA
    • Checked in both light and dark modes
    • Checked in both MacOS and Windows high contrast modes
    • Checked in mobile
    • Checked in Chrome, Safari, Edge, and Firefox~
      - [ ] Checked for accessibility including keyboard-only and screenreader modes
  • Docs site QA - N/A
  • Code quality checklist
  • Release checklist - N/A, feature branch will have one final changelog
  • Designer checklist - N/A

@cee-chen cee-chen changed the title High contrast mode 2 [High Contrast Mode] Handle components that should replace their shadows with an all-around border Nov 21, 2024
@cee-chen cee-chen changed the title [High Contrast Mode] Handle components that should replace their shadows with an all-around border [High Contrast Mode] Panels, modals, flyouts, toasts, popovers, and tooltips Nov 22, 2024
@cee-chen cee-chen force-pushed the high-contrast-mode-2 branch 2 times, most recently from 8d39de5 to 3eb8a10 Compare November 22, 2024 01:16
@cee-chen cee-chen marked this pull request as ready for review November 22, 2024 01:35
@cee-chen cee-chen requested a review from a team as a code owner November 22, 2024 01:35
… high contrast mode

- have to use actual `border` CSS and not `box-shadow` due to Windows

+ fix obvious components that require this - flyouts, modals, toasts
- add filter workaround for clickable panels/cards
- rewrite arrows completely using `clip-path` instead of CSS borders (required for high contrast themes, which otherwise overrides borders and as such will break on Windows)

- add a pseudo element workaround for high contrast mode to preserve the border - this has some subpixel aliasing issues at different zoom levels, but is good enough IMO
- add a new story for high contrast mode, to catch regressions with the arrow rendering

- fix popover footer/title screenshots to actually capture the portalled popvoer
- background color is ignored in Windows, so we have to rely entirely on borders
+ fix flakiness via `sleep`
@cee-chen cee-chen force-pushed the high-contrast-mode-2 branch from 9589b3f to b601612 Compare November 23, 2024 01:03
return euiTheme.border.color;
case 'warning':
return tintOrShade(euiTheme.colors.warning, 0.4, colorMode);
return tintOrShade(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Borealis note: color calculations were removed in favor of tokens. This will require consolidating.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right yeah, I think I saw that in another PR. I'll need to add a bunch more border tokens in the high contrast mode overrides/modifications

Cleanup:
- remove need for pseudo element
- always render a border (transparent on light mode) and update the the popover arrow position logic to offset for it
- update popover positioning JS to use `100%` positioning instead of a static calculated number
- update EuiToolTip to match rotation + clip-path logic (simpler all around and less chance of the arrow overlapping content)
- requires an extra wrapper due to the arrow's clip-path and transform CSS
@mgadewoll
Copy link
Contributor

The latest changes look good to me!
I see there are some tests failing, I'll wait to approve in case additional changes are needed 🙂

@cee-chen cee-chen force-pushed the high-contrast-mode-2 branch from 5272b62 to 420570d Compare November 26, 2024 21:21
@cee-chen
Copy link
Contributor Author

I see there are some tests failing, I'll wait to approve in case additional changes are needed 🙂

Thanks for the precaution! One was a pretty small pixel update but the other was pretty dang annoying, so I ended up converting to a Storybook VRT test: 8bc755b

Feel free to shout if you have any Storybook preferences there. I went back and forth on making it VRT only vs not, and settled on "not", but I don't feel super strongly either way 🤷

@kibanamachine
Copy link

Preview staging links for this PR:

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

Copy link
Contributor

@mgadewoll mgadewoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 🐈‍⬛ Thanks for the additional changes, they look great! Awesome job on cleaning up code and tests ✨

);

return {
_arrowStyles: `
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the starting underscore for the base styles. Adds some more distinction between same named object and key 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add some more context - I tend to use underscore prefixes to denote private or internal usage. In this case I also don't want Emotion to render this extra label in its generated classNames, hence the underscore and the static string as opposed to css template literal.

@@ -0,0 +1 @@
- Updated `EuiPopover` and `EuiToolTip` to be easier to see in dark mode.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Is this fine to add here already while it's merging into a feature branch?

Copy link
Contributor Author

@cee-chen cee-chen Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I might either collate all the changelogs in the final feature branch PR, or I might leave them as-is. It's not bad to have the changelog pointing at the original PR so it's easier to find the atomic git history and see any discussions for color/context.

@cee-chen
Copy link
Contributor Author

Thanks again for the fantastic review Lene, my code is so much better for it!

@cee-chen cee-chen merged commit ca9a01e into elastic:high-contrast-mode Nov 27, 2024
4 checks passed
@cee-chen cee-chen deleted the high-contrast-mode-2 branch November 27, 2024 17:44
@cee-chen cee-chen mentioned this pull request Dec 12, 2024
10 tasks
mgadewoll pushed a commit to mgadewoll/eui that referenced this pull request Mar 14, 2025
mgadewoll pushed a commit to mgadewoll/eui that referenced this pull request Mar 18, 2025
mgadewoll pushed a commit to mgadewoll/eui that referenced this pull request Mar 18, 2025
mgadewoll pushed a commit to mgadewoll/eui that referenced this pull request Mar 20, 2025
mgadewoll added a commit to elastic/kibana that referenced this pull request Mar 28, 2025
`100.0.0` ⏩ `101.0.1`

[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)

## Package updates

### `@elastic/eui`
[`v101.0.1`](https://github.com/elastic/eui/releases/v101.0.1)

- Updated `EuiProvider` and `EuiThemeProvider` with a new
`highContrastMode` ([#8444](elastic/eui#8444))
- This prop allows toggling a higher contrast visual style that
primarily affects borders and shadows
- On `EuiProvider`, if the `highContrastMode` prop is not passed, this
setting will inherit from the user's OS/system settings
- If the user is using a forced colors mode (e.g. Windows' high contrast
themes), this system setting will take precedence over any
`highContrastMode` or `colorMode` props passed
- Added `highContrastModeStyles` and `preventForcedColors` styling utils
([#8444](elastic/eui#8444))
- Updated `EuiRangeTooltip` to be easier to see in dark mode
([#8444](elastic/eui#8444))
- Updated some deprecated color token usages that have direct
substitutes ([#8444](elastic/eui#8444))
  - `text` -> `textParagraph`
  - `title` -> `textHeading`
  - `subduedText` -> `textSubdued`
  - `disabledText` -> `textDisabled`
  - `accentText` -> `textAccent`
  - `dangerText` -> `textDanger`
  - `warningText` -> `textWarning`
- `useEuiShadow()` now accepts a second `options` argument
([#8234](elastic/eui#8234))
- `useEuiShadowFlat()` now accepts an `options` object instead of only a
color ([#8234](elastic/eui#8234))
- Updated `EuiPopover` and `EuiToolTip` to be easier to see in dark
mode. ([#8174](elastic/eui#8174))

**Bug fixes**

- Fixed a visual bug where a transparent border would create visible
empty space (`LIGHT` mode only) for the components:
([#8427](elastic/eui#8427))
  - `EuiPanel`
  - `EuiPopover`
  - `EuiToolTip`
  - `EuiToast`
  - `EuiTour`
  
  --- 
  
### `@elastic/eui-theme-common`
[`v0.1.0`](https://github.com/elastic/eui/releases/v0.1.0)

- Removed type `EuiShadowCustomColor`
([#8444](elastic/eui#8444))
- Added types:  ([#8444](elastic/eui#8444))
  - `EuiShadowOptions`
  - `EuiThemeHighContrastModeProp`
  - `EuiThemeHighContrastMode`
- Updated shadow utils to accepts a second `options` argument and return
borders in high contrast mode:
([#8444](elastic/eui#8444))
  - `euiShadow`
  - `euiShadowXSmall`
  - `euiShadowSmall`
  - `euiShadowMedium`
  - `euiShadowLarge`
  - `euiSlightShadowHover`
  - `euiShadowFlat`
  
  ---
  
### `@elastic/eui-theme-borealis`
[`v0.1.0`](https://github.com/elastic/eui/releases/v0.1.0)

- Added new component level tokens:
([#8444](elastic/eui#8444))
  - `buttonGroupBackgroundDisabledSelected`
  - `overlayMaskBackground`
  - `overlayMaskBackgroundHighContrast`
  - `skeletonBackgroundSkeletonMiddleHighContrast`
  

## Additional changes

The latest `@elastic/eui` package introduces high contrast mode support.
This PR sets all usages of `EuiProvider` to use
`highContrastMode={false}` to introduce it in disabled state (this
reflects the current functionality in Kibana). This is because the UI
for the high contrast mode functionality (and style adjustments) need to
first be implemented on Kibana side (by shared-ux).

## QA

Adding high contrast mode in disabled state should result in no visual
changes in Kibana. Please ensure your product view remain unchanged.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
mgadewoll added a commit to mgadewoll/kibana that referenced this pull request Mar 28, 2025
`100.0.0` ⏩ `101.0.1`

[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)

## Package updates

### `@elastic/eui`
[`v101.0.1`](https://github.com/elastic/eui/releases/v101.0.1)

- Updated `EuiProvider` and `EuiThemeProvider` with a new
`highContrastMode` ([elastic#8444](elastic/eui#8444))
- This prop allows toggling a higher contrast visual style that
primarily affects borders and shadows
- On `EuiProvider`, if the `highContrastMode` prop is not passed, this
setting will inherit from the user's OS/system settings
- If the user is using a forced colors mode (e.g. Windows' high contrast
themes), this system setting will take precedence over any
`highContrastMode` or `colorMode` props passed
- Added `highContrastModeStyles` and `preventForcedColors` styling utils
([elastic#8444](elastic/eui#8444))
- Updated `EuiRangeTooltip` to be easier to see in dark mode
([elastic#8444](elastic/eui#8444))
- Updated some deprecated color token usages that have direct
substitutes ([elastic#8444](elastic/eui#8444))
  - `text` -> `textParagraph`
  - `title` -> `textHeading`
  - `subduedText` -> `textSubdued`
  - `disabledText` -> `textDisabled`
  - `accentText` -> `textAccent`
  - `dangerText` -> `textDanger`
  - `warningText` -> `textWarning`
- `useEuiShadow()` now accepts a second `options` argument
([elastic#8234](elastic/eui#8234))
- `useEuiShadowFlat()` now accepts an `options` object instead of only a
color ([elastic#8234](elastic/eui#8234))
- Updated `EuiPopover` and `EuiToolTip` to be easier to see in dark
mode. ([elastic#8174](elastic/eui#8174))

**Bug fixes**

- Fixed a visual bug where a transparent border would create visible
empty space (`LIGHT` mode only) for the components:
([elastic#8427](elastic/eui#8427))
  - `EuiPanel`
  - `EuiPopover`
  - `EuiToolTip`
  - `EuiToast`
  - `EuiTour`

  ---

### `@elastic/eui-theme-common`
[`v0.1.0`](https://github.com/elastic/eui/releases/v0.1.0)

- Removed type `EuiShadowCustomColor`
([elastic#8444](elastic/eui#8444))
- Added types:  ([elastic#8444](elastic/eui#8444))
  - `EuiShadowOptions`
  - `EuiThemeHighContrastModeProp`
  - `EuiThemeHighContrastMode`
- Updated shadow utils to accepts a second `options` argument and return
borders in high contrast mode:
([elastic#8444](elastic/eui#8444))
  - `euiShadow`
  - `euiShadowXSmall`
  - `euiShadowSmall`
  - `euiShadowMedium`
  - `euiShadowLarge`
  - `euiSlightShadowHover`
  - `euiShadowFlat`

  ---

### `@elastic/eui-theme-borealis`
[`v0.1.0`](https://github.com/elastic/eui/releases/v0.1.0)

- Added new component level tokens:
([elastic#8444](elastic/eui#8444))
  - `buttonGroupBackgroundDisabledSelected`
  - `overlayMaskBackground`
  - `overlayMaskBackgroundHighContrast`
  - `skeletonBackgroundSkeletonMiddleHighContrast`

## Additional changes

The latest `@elastic/eui` package introduces high contrast mode support.
This PR sets all usages of `EuiProvider` to use
`highContrastMode={false}` to introduce it in disabled state (this
reflects the current functionality in Kibana). This is because the UI
for the high contrast mode functionality (and style adjustments) need to
first be implemented on Kibana side (by shared-ux).

## QA

Adding high contrast mode in disabled state should result in no visual
changes in Kibana. Please ensure your product view remain unchanged.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit 2cd777d)

# Conflicts:
#	src/platform/plugins/shared/discover/public/application/main/components/layout/discover_layout.test.tsx
cqliu1 pushed a commit to cqliu1/kibana that referenced this pull request Mar 31, 2025
`100.0.0` ⏩ `101.0.1`

[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)

## Package updates

### `@elastic/eui`
[`v101.0.1`](https://github.com/elastic/eui/releases/v101.0.1)

- Updated `EuiProvider` and `EuiThemeProvider` with a new
`highContrastMode` ([elastic#8444](elastic/eui#8444))
- This prop allows toggling a higher contrast visual style that
primarily affects borders and shadows
- On `EuiProvider`, if the `highContrastMode` prop is not passed, this
setting will inherit from the user's OS/system settings
- If the user is using a forced colors mode (e.g. Windows' high contrast
themes), this system setting will take precedence over any
`highContrastMode` or `colorMode` props passed
- Added `highContrastModeStyles` and `preventForcedColors` styling utils
([elastic#8444](elastic/eui#8444))
- Updated `EuiRangeTooltip` to be easier to see in dark mode
([elastic#8444](elastic/eui#8444))
- Updated some deprecated color token usages that have direct
substitutes ([elastic#8444](elastic/eui#8444))
  - `text` -> `textParagraph`
  - `title` -> `textHeading`
  - `subduedText` -> `textSubdued`
  - `disabledText` -> `textDisabled`
  - `accentText` -> `textAccent`
  - `dangerText` -> `textDanger`
  - `warningText` -> `textWarning`
- `useEuiShadow()` now accepts a second `options` argument
([elastic#8234](elastic/eui#8234))
- `useEuiShadowFlat()` now accepts an `options` object instead of only a
color ([elastic#8234](elastic/eui#8234))
- Updated `EuiPopover` and `EuiToolTip` to be easier to see in dark
mode. ([elastic#8174](elastic/eui#8174))

**Bug fixes**

- Fixed a visual bug where a transparent border would create visible
empty space (`LIGHT` mode only) for the components:
([elastic#8427](elastic/eui#8427))
  - `EuiPanel`
  - `EuiPopover`
  - `EuiToolTip`
  - `EuiToast`
  - `EuiTour`
  
  --- 
  
### `@elastic/eui-theme-common`
[`v0.1.0`](https://github.com/elastic/eui/releases/v0.1.0)

- Removed type `EuiShadowCustomColor`
([elastic#8444](elastic/eui#8444))
- Added types:  ([elastic#8444](elastic/eui#8444))
  - `EuiShadowOptions`
  - `EuiThemeHighContrastModeProp`
  - `EuiThemeHighContrastMode`
- Updated shadow utils to accepts a second `options` argument and return
borders in high contrast mode:
([elastic#8444](elastic/eui#8444))
  - `euiShadow`
  - `euiShadowXSmall`
  - `euiShadowSmall`
  - `euiShadowMedium`
  - `euiShadowLarge`
  - `euiSlightShadowHover`
  - `euiShadowFlat`
  
  ---
  
### `@elastic/eui-theme-borealis`
[`v0.1.0`](https://github.com/elastic/eui/releases/v0.1.0)

- Added new component level tokens:
([elastic#8444](elastic/eui#8444))
  - `buttonGroupBackgroundDisabledSelected`
  - `overlayMaskBackground`
  - `overlayMaskBackgroundHighContrast`
  - `skeletonBackgroundSkeletonMiddleHighContrast`
  

## Additional changes

The latest `@elastic/eui` package introduces high contrast mode support.
This PR sets all usages of `EuiProvider` to use
`highContrastMode={false}` to introduce it in disabled state (this
reflects the current functionality in Kibana). This is because the UI
for the high contrast mode functionality (and style adjustments) need to
first be implemented on Kibana side (by shared-ux).

## QA

Adding high contrast mode in disabled state should result in no visual
changes in Kibana. Please ensure your product view remain unchanged.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
mgadewoll added a commit to elastic/kibana that referenced this pull request Apr 3, 2025
>[!IMPORtANT]
This PR is the direct, manual backport to `8.x` for [this
PR](#215698) that's being merged
to `main`.
The reason it's handled manually is that `8.x` receives a custom EUI
release that still has the "Amsterdam" theme as default theme enabled.

---

`100.0.0` ⏩ `101.1.0`

[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)

## Package updates

### `@elastic/eui`
[`v101.1.0`](https://github.com/elastic/eui/releases/v101.1.0)

- Updates `EuiTableRow` styles to check support for `:has(+)` selector
([#8498](elastic/eui#8498))

### `@elastic/eui`
[`v101.0.1`](https://github.com/elastic/eui/releases/v101.0.1)

- Updated `EuiProvider` and `EuiThemeProvider` with a new
`highContrastMode` ([#8444](elastic/eui#8444))
- This prop allows toggling a higher contrast visual style that
primarily affects borders and shadows
- On `EuiProvider`, if the `highContrastMode` prop is not passed, this
setting will inherit from the user's OS/system settings
- If the user is using a forced colors mode (e.g. Windows' high contrast
themes), this system setting will take precedence over any
`highContrastMode` or `colorMode` props passed
- Added `highContrastModeStyles` and `preventForcedColors` styling utils
([#8444](elastic/eui#8444))
- Updated `EuiRangeTooltip` to be easier to see in dark mode
([#8444](elastic/eui#8444))
- Updated some deprecated color token usages that have direct
substitutes ([#8444](elastic/eui#8444))
  - `text` -> `textParagraph`
  - `title` -> `textHeading`
  - `subduedText` -> `textSubdued`
  - `disabledText` -> `textDisabled`
  - `accentText` -> `textAccent`
  - `dangerText` -> `textDanger`
  - `warningText` -> `textWarning`
- `useEuiShadow()` now accepts a second `options` argument
([#8234](elastic/eui#8234))
- `useEuiShadowFlat()` now accepts an `options` object instead of only a
color ([#8234](elastic/eui#8234))
- Updated `EuiPopover` and `EuiToolTip` to be easier to see in dark
mode. ([#8174](elastic/eui#8174))

**Bug fixes**

- Fixed a visual bug where a transparent border would create visible
empty space (`LIGHT` mode only) for the components:
([#8427](elastic/eui#8427))
  - `EuiPanel`
  - `EuiPopover`
  - `EuiToolTip`
  - `EuiToast`
  - `EuiTour`
  
  --- 
  
### `@elastic/eui-theme-common`
[`v0.1.0`](https://github.com/elastic/eui/releases/v0.1.0)

- Removed type `EuiShadowCustomColor`
([#8444](elastic/eui#8444))
- Added types:  ([#8444](elastic/eui#8444))
  - `EuiShadowOptions`
  - `EuiThemeHighContrastModeProp`
  - `EuiThemeHighContrastMode`
- Updated shadow utils to accepts a second `options` argument and return
borders in high contrast mode:
([#8444](elastic/eui#8444))
  - `euiShadow`
  - `euiShadowXSmall`
  - `euiShadowSmall`
  - `euiShadowMedium`
  - `euiShadowLarge`
  - `euiSlightShadowHover`
  - `euiShadowFlat`
  
  ---
  
### `@elastic/eui-theme-borealis`
[`v0.1.0`](https://github.com/elastic/eui/releases/v0.1.0)

- Added new component level tokens:
([#8444](elastic/eui#8444))
  - `buttonGroupBackgroundDisabledSelected`
  - `overlayMaskBackground`
  - `overlayMaskBackgroundHighContrast`
  - `skeletonBackgroundSkeletonMiddleHighContrast`
  

## Additional changes

The latest `@elastic/eui` package introduces high contrast mode support.
This PR sets the root `EuiProvider` to use `highContrastMode={false}` to
introduce it in disabled state (this reflects the current functionality
in Kibana).
Cloud-UI can enable this whenever it's tested and supported from their
end.

## QA

Adding high contrast mode in disabled state should result in no visual
changes to the UI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants