Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[High Contrast Mode] Panels, modals, flyouts, toasts, popovers, and tooltips #8174

Merged
merged 16 commits into from
Nov 27, 2024

Conversation

cee-chen
Copy link
Member

@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`
@@ -140,9 +140,17 @@ export const euiBorderColor = (
case 'subdued':
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
Member 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

packages/eui/src/components/tool_tip/tool_tip.styles.ts Outdated Show resolved Hide resolved
packages/eui/src/components/tool_tip/tool_tip.styles.ts Outdated Show resolved Hide resolved
packages/eui/src/global_styling/mixins/_color.ts Outdated Show resolved Hide resolved
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
Copy link
Member 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
Member 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
Member 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
Member 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
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