From cfa84f4ef25114b1edae62537dd006dfd9fc5cf9 Mon Sep 17 00:00:00 2001
From: Cee Chen <549407+cee-chen@users.noreply.github.com>
Date: Mon, 30 Oct 2023 12:26:37 -0700
Subject: [PATCH] [EuiPopover] Increase visibility in dark mode (#7310)
---
.stylelintrc.js | 1 +
.../__snapshots__/breadcrumb.test.tsx.snap | 2 +-
.../code_block_annotations.test.tsx.snap | 2 +-
.../collapsed_nav_popover.test.tsx.snap | 2 +-
.../__snapshots__/combo_box.test.tsx.snap | 2 +-
.../column_selector.test.tsx.snap | 6 ++---
.../column_sorting.test.tsx.snap | 6 ++---
.../keyboard_shortcuts.test.tsx.snap | 6 ++---
.../range/__snapshots__/range.test.tsx.snap | 2 +-
.../__snapshots__/super_select.test.tsx.snap | 8 +++----
.../__snapshots__/popover.rtl.test.tsx.snap | 2 +-
.../__snapshots__/popover.test.tsx.snap | 22 +++++++++----------
src/components/popover/popover.tsx | 5 ++++-
.../popover_arrow/_popover_arrow.styles.ts | 9 ++------
.../_popover_panel.test.tsx.snap | 16 +++++++-------
.../popover_panel/_popover_panel.styles.ts | 12 +++++++++-
.../popover/popover_panel/_popover_panel.tsx | 9 +++++++-
.../table_pagination.test.tsx.snap | 2 +-
.../__snapshots__/tour_step.test.tsx.snap | 12 +++++-----
upcoming_changelogs/7310.md | 1 +
20 files changed, 72 insertions(+), 55 deletions(-)
create mode 100644 upcoming_changelogs/7310.md
diff --git a/.stylelintrc.js b/.stylelintrc.js
index a9f4a8aa115..800fcafa1ff 100644
--- a/.stylelintrc.js
+++ b/.stylelintrc.js
@@ -8,6 +8,7 @@ module.exports = {
// Enforce camelCase naming
'selector-class-pattern': camelCaseRegex,
'keyframes-name-pattern': camelCaseRegex,
+ 'custom-property-pattern': camelCaseRegex,
// Opinionated rules
'declaration-no-important': true,
diff --git a/src/components/breadcrumbs/__snapshots__/breadcrumb.test.tsx.snap b/src/components/breadcrumbs/__snapshots__/breadcrumb.test.tsx.snap
index 262b3d4247c..dd549f47e9c 100644
--- a/src/components/breadcrumbs/__snapshots__/breadcrumb.test.tsx.snap
+++ b/src/components/breadcrumbs/__snapshots__/breadcrumb.test.tsx.snap
@@ -42,7 +42,7 @@ exports[`EuiBreadcrumbContent renders breadcrumbs with \`popoverContent\` with p
aria-describedby="generated-id"
aria-live="off"
aria-modal="true"
- class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel emotion-euiPanel-grow-m-m-plain-euiPopover__panel-isOpen-hasTransform-bottom"
+ class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel emotion-euiPanel-grow-m-m-plain-euiPopover__panel-light-isOpen-hasTransform-bottom"
data-autofocus="true"
data-popover-open="true"
data-popover-panel="true"
diff --git a/src/components/code/__snapshots__/code_block_annotations.test.tsx.snap b/src/components/code/__snapshots__/code_block_annotations.test.tsx.snap
index a4b92f4e7c6..dda64206c41 100644
--- a/src/components/code/__snapshots__/code_block_annotations.test.tsx.snap
+++ b/src/components/code/__snapshots__/code_block_annotations.test.tsx.snap
@@ -39,7 +39,7 @@ exports[`EuiCodeBlockAnnotation renders 1`] = `
aria-label="aria-label"
aria-live="off"
aria-modal="true"
- class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel emotion-euiPanel-grow-m-m-plain-euiPopover__panel-isOpen-hasTransform-bottom"
+ class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel emotion-euiPanel-grow-m-m-plain-euiPopover__panel-light-isOpen-hasTransform-bottom"
data-autofocus="true"
data-popover-open="true"
data-popover-panel="true"
diff --git a/src/components/collapsible_nav_beta/collapsible_nav_item/collapsed/__snapshots__/collapsed_nav_popover.test.tsx.snap b/src/components/collapsible_nav_beta/collapsible_nav_item/collapsed/__snapshots__/collapsed_nav_popover.test.tsx.snap
index 40a7cb91633..adbd5df22ba 100644
--- a/src/components/collapsible_nav_beta/collapsible_nav_item/collapsed/__snapshots__/collapsed_nav_popover.test.tsx.snap
+++ b/src/components/collapsible_nav_beta/collapsible_nav_item/collapsed/__snapshots__/collapsed_nav_popover.test.tsx.snap
@@ -46,7 +46,7 @@ exports[`EuiCollapsedNavPopover renders the title and sub-items within the popov
aria-label="aria-label"
aria-live="off"
aria-modal="true"
- class="euiPanel euiPanel--plain euiPopover__panel emotion-euiPanel-grow-m-plain-euiPopover__panel-isOpen-hasTransform-right-euiCollapsedNavPopover__panel"
+ class="euiPanel euiPanel--plain euiPopover__panel emotion-euiPanel-grow-m-plain-euiPopover__panel-light-isOpen-hasTransform-right-euiCollapsedNavPopover__panel"
data-autofocus="true"
data-popover-open="true"
data-popover-panel="true"
diff --git a/src/components/combo_box/__snapshots__/combo_box.test.tsx.snap b/src/components/combo_box/__snapshots__/combo_box.test.tsx.snap
index a1e7f5f4028..fa570cd0649 100644
--- a/src/components/combo_box/__snapshots__/combo_box.test.tsx.snap
+++ b/src/components/combo_box/__snapshots__/combo_box.test.tsx.snap
@@ -134,7 +134,7 @@ exports[`EuiComboBox renders the options list dropdown 1`] = `
;
+ panelProps?: Omit<
+ EuiPopoverPanelProps,
+ 'style' | 'hasShadow' | 'hasBorder' | 'color'
+ >;
panelRef?: RefCallback
;
/**
* Optional screen reader instructions to announce upon popover open,
diff --git a/src/components/popover/popover_arrow/_popover_arrow.styles.ts b/src/components/popover/popover_arrow/_popover_arrow.styles.ts
index 27ae9bb190a..c1d911738df 100644
--- a/src/components/popover/popover_arrow/_popover_arrow.styles.ts
+++ b/src/components/popover/popover_arrow/_popover_arrow.styles.ts
@@ -7,11 +7,7 @@
*/
import { css } from '@emotion/react';
-import {
- euiBackgroundColor,
- logicals,
- logicalSizeCSS,
-} from '../../../global_styling';
+import { logicals, logicalSizeCSS } from '../../../global_styling';
import { UseEuiTheme } from '../../../services';
export const popoverArrowSize = 'm';
@@ -19,8 +15,7 @@ export const popoverArrowSize = 'm';
export const euiPopoverArrowStyles = (euiThemeContext: UseEuiTheme) => {
const { euiTheme } = euiThemeContext;
- // Match the background color of panels
- const borderColor = euiBackgroundColor(euiThemeContext, 'plain');
+ const borderColor = 'var(--euiPopoverBackgroundColor)';
const arrowSize = euiTheme.size[popoverArrowSize];
return {
diff --git a/src/components/popover/popover_panel/__snapshots__/_popover_panel.test.tsx.snap b/src/components/popover/popover_panel/__snapshots__/_popover_panel.test.tsx.snap
index 82568c7fe34..f95ad7de7c2 100644
--- a/src/components/popover/popover_panel/__snapshots__/_popover_panel.test.tsx.snap
+++ b/src/components/popover/popover_panel/__snapshots__/_popover_panel.test.tsx.snap
@@ -3,7 +3,7 @@
exports[`EuiPopoverPanel is rendered 1`] = `
@@ -11,14 +11,14 @@ exports[`EuiPopoverPanel is rendered 1`] = `
exports[`EuiPopoverPanel props hasDragDrop is rendered 1`] = `
`;
exports[`EuiPopoverPanel props isAttached is rendered 1`] = `
@@ -26,7 +26,7 @@ exports[`EuiPopoverPanel props isAttached is rendered 1`] = `
exports[`EuiPopoverPanel props isOpen is rendered 1`] = `
@@ -34,28 +34,28 @@ exports[`EuiPopoverPanel props isOpen is rendered 1`] = `
exports[`EuiPopoverPanel props position bottom is rendered 1`] = `
`;
exports[`EuiPopoverPanel props position left is rendered 1`] = `
`;
exports[`EuiPopoverPanel props position right is rendered 1`] = `
`;
exports[`EuiPopoverPanel props position top is rendered 1`] = `
`;
diff --git a/src/components/popover/popover_panel/_popover_panel.styles.ts b/src/components/popover/popover_panel/_popover_panel.styles.ts
index 80b1f37b4f2..f31ce85e5a1 100644
--- a/src/components/popover/popover_panel/_popover_panel.styles.ts
+++ b/src/components/popover/popover_panel/_popover_panel.styles.ts
@@ -13,7 +13,7 @@ import {
euiShadowMedium,
} from '../../../themes/amsterdam/global_styling/mixins';
import { getShadowColor } from '../../../themes/amsterdam/global_styling/functions';
-import { UseEuiTheme } from '../../../services';
+import { UseEuiTheme, tint } from '../../../services';
import {
euiCanAnimate,
logicalCSS,
@@ -26,6 +26,7 @@ export const openAnimationTiming = 'slow';
* 1. Can expand further, but it looks weird if it's smaller than the originating button.
* 2. Animation happens on the panel. But don't animate position when using the attached mode like for inputs
* 3. Make sure the panel stays within the window.
+ * 4. Make the popover lighter on dark mode (too hard to distinguish from plain bgs otherwise), and set a CSS var for the arrow to use
*/
export const euiPopoverPanelStyles = (euiThemeContext: UseEuiTheme) => {
@@ -48,6 +49,7 @@ export const euiPopoverPanelStyles = (euiThemeContext: UseEuiTheme) => {
backface-visibility: hidden;
pointer-events: none;
opacity: 0; /* 2 */
+ background-color: var(--euiPopoverBackgroundColor); /* 4 */
${euiCanAnimate} {
/* 2 */
@@ -63,6 +65,14 @@ export const euiPopoverPanelStyles = (euiThemeContext: UseEuiTheme) => {
pointer-events: auto;
`,
+ /* 4 */
+ light: css`
+ --euiPopoverBackgroundColor: ${euiTheme.colors.emptyShade};
+ `,
+ dark: css`
+ --euiPopoverBackgroundColor: ${tint(euiTheme.colors.emptyShade, 0.025)};
+ `,
+
// Regular popover with an arrow, a transform animation/transition, and a
// drop shadow via `filter` (which automatically handles the arrow)
hasTransform: {
diff --git a/src/components/popover/popover_panel/_popover_panel.tsx b/src/components/popover/popover_panel/_popover_panel.tsx
index 4f5bc3ea889..5bf66472a10 100644
--- a/src/components/popover/popover_panel/_popover_panel.tsx
+++ b/src/components/popover/popover_panel/_popover_panel.tsx
@@ -51,8 +51,15 @@ export const EuiPopoverPanel: FunctionComponent<
const euiThemeContext = useEuiTheme();
const cssStyles = useMemo(() => {
const styles = euiPopoverPanelStyles(euiThemeContext);
+ const colorMode = euiThemeContext.colorMode.toLowerCase() as Lowercase<
+ 'LIGHT' | 'DARK'
+ >;
- const sharedStyles = [styles.euiPopover__panel, isOpen && styles.isOpen];
+ const sharedStyles = [
+ styles.euiPopover__panel,
+ styles[colorMode],
+ isOpen && styles.isOpen,
+ ];
if (hasDragDrop) {
return [
diff --git a/src/components/table/table_pagination/__snapshots__/table_pagination.test.tsx.snap b/src/components/table/table_pagination/__snapshots__/table_pagination.test.tsx.snap
index f04c07d60e8..5f468124f99 100644
--- a/src/components/table/table_pagination/__snapshots__/table_pagination.test.tsx.snap
+++ b/src/components/table/table_pagination/__snapshots__/table_pagination.test.tsx.snap
@@ -209,7 +209,7 @@ exports[`EuiTablePagination renders 1`] = `
aria-describedby="generated-id"
aria-live="off"
aria-modal="true"
- class="euiPanel euiPanel--plain euiPopover__panel emotion-euiPanel-grow-m-plain-euiPopover__panel-hasTransform"
+ class="euiPanel euiPanel--plain euiPopover__panel emotion-euiPanel-grow-m-plain-euiPopover__panel-light-hasTransform"
data-autofocus="true"
data-popover-panel="true"
role="dialog"
diff --git a/src/components/tour/__snapshots__/tour_step.test.tsx.snap b/src/components/tour/__snapshots__/tour_step.test.tsx.snap
index 05fce02e5ce..1de4a7cfa46 100644
--- a/src/components/tour/__snapshots__/tour_step.test.tsx.snap
+++ b/src/components/tour/__snapshots__/tour_step.test.tsx.snap
@@ -25,7 +25,7 @@ exports[`EuiTourStep accepts an array of buttons in the footerAction prop 1`] =
aria-labelledby="generated-id"
aria-live="assertive"
aria-modal="true"
- class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel euiTour testClass1 testClass2 emotion-euiPanel-grow-m-m-plain-euiPopover__panel-isOpen-hasTransform-left-euiTour-euiTestCss"
+ class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel euiTour testClass1 testClass2 emotion-euiPanel-grow-m-m-plain-euiPopover__panel-light-isOpen-hasTransform-left-euiTour-euiTestCss"
data-popover-open="true"
data-popover-panel="true"
role="dialog"
@@ -138,7 +138,7 @@ exports[`EuiTourStep can change the minWidth and maxWidth 1`] = `
aria-labelledby="generated-id"
aria-live="assertive"
aria-modal="true"
- class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel euiTour testClass1 testClass2 emotion-euiPanel-grow-m-m-plain-euiPopover__panel-isOpen-hasTransform-left-euiTour-euiTestCss"
+ class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel euiTour testClass1 testClass2 emotion-euiPanel-grow-m-m-plain-euiPopover__panel-light-isOpen-hasTransform-left-euiTour-euiTestCss"
data-popover-open="true"
data-popover-panel="true"
role="dialog"
@@ -236,7 +236,7 @@ exports[`EuiTourStep can have subtitle 1`] = `
aria-labelledby="generated-id"
aria-live="assertive"
aria-modal="true"
- class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel euiTour testClass1 testClass2 emotion-euiPanel-grow-m-m-plain-euiPopover__panel-isOpen-hasTransform-left-euiTour-euiTestCss"
+ class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel euiTour testClass1 testClass2 emotion-euiPanel-grow-m-m-plain-euiPopover__panel-light-isOpen-hasTransform-left-euiTour-euiTestCss"
data-popover-open="true"
data-popover-panel="true"
role="dialog"
@@ -339,7 +339,7 @@ exports[`EuiTourStep can override the footer action 1`] = `
aria-labelledby="generated-id"
aria-live="assertive"
aria-modal="true"
- class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel euiTour testClass1 testClass2 emotion-euiPanel-grow-m-m-plain-euiPopover__panel-isOpen-hasTransform-left-euiTour-euiTestCss"
+ class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel euiTour testClass1 testClass2 emotion-euiPanel-grow-m-m-plain-euiPopover__panel-light-isOpen-hasTransform-left-euiTour-euiTestCss"
data-popover-open="true"
data-popover-panel="true"
role="dialog"
@@ -426,7 +426,7 @@ exports[`EuiTourStep can turn off the beacon 1`] = `
aria-labelledby="generated-id"
aria-live="assertive"
aria-modal="true"
- class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel euiTour testClass1 testClass2 emotion-euiPanel-grow-m-m-plain-euiPopover__panel-isOpen-hasTransform-left-euiTour-euiTestCss"
+ class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel euiTour testClass1 testClass2 emotion-euiPanel-grow-m-m-plain-euiPopover__panel-light-isOpen-hasTransform-left-euiTour-euiTestCss"
data-popover-open="true"
data-popover-panel="true"
role="dialog"
@@ -519,7 +519,7 @@ exports[`EuiTourStep is rendered 1`] = `
aria-labelledby="generated-id"
aria-live="assertive"
aria-modal="true"
- class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel euiTour testClass1 testClass2 emotion-euiPanel-grow-m-m-plain-euiPopover__panel-isOpen-hasTransform-left-euiTour-euiTestCss"
+ class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel euiTour testClass1 testClass2 emotion-euiPanel-grow-m-m-plain-euiPopover__panel-light-isOpen-hasTransform-left-euiTour-euiTestCss"
data-popover-open="true"
data-popover-panel="true"
role="dialog"
diff --git a/upcoming_changelogs/7310.md b/upcoming_changelogs/7310.md
new file mode 100644
index 00000000000..832776a1d1f
--- /dev/null
+++ b/upcoming_changelogs/7310.md
@@ -0,0 +1 @@
+- Updated the background color of `EuiPopover`s in dark mode to increase visibility & contrast against other page/panel backgrounds