From ff192553ecaa74513ad9fa6167e90a30e7fe56dc Mon Sep 17 00:00:00 2001 From: Cee Chen <549407+cee-chen@users.noreply.github.com> Date: Fri, 2 Feb 2024 09:16:39 -0800 Subject: [PATCH] [EuiTourStep] `className` consistency with EuiPopover + performance/cleanups (#7497) --- changelogs/upcoming/7497.md | 4 + .../beacon/__snapshots__/beacon.test.tsx.snap | 16 +- src/components/beacon/beacon.tsx | 20 +- .../__snapshots__/tour_step.test.tsx.snap | 592 ++---------------- src/components/tour/_tour_footer.styles.ts | 28 + src/components/tour/_tour_footer.tsx | 125 ++++ src/components/tour/_tour_header.styles.ts | 29 + src/components/tour/_tour_header.tsx | 47 ++ src/components/tour/tour.styles.ts | 50 +- src/components/tour/tour_step.test.tsx | 96 ++- src/components/tour/tour_step.tsx | 237 ++----- 11 files changed, 456 insertions(+), 788 deletions(-) create mode 100644 changelogs/upcoming/7497.md create mode 100644 src/components/tour/_tour_footer.styles.ts create mode 100644 src/components/tour/_tour_footer.tsx create mode 100644 src/components/tour/_tour_header.styles.ts create mode 100644 src/components/tour/_tour_header.tsx diff --git a/changelogs/upcoming/7497.md b/changelogs/upcoming/7497.md new file mode 100644 index 00000000000..89b9fccebcd --- /dev/null +++ b/changelogs/upcoming/7497.md @@ -0,0 +1,4 @@ +**Breaking changes** + +- `EuiTourStep`'s `className` and `style` props now apply to the anchoring element instead of to the popover panel, to match `EuiPopover` behavior. + - Convert your existing usages to `panelClassName` and `panelStyle` respectively instead. diff --git a/src/components/beacon/__snapshots__/beacon.test.tsx.snap b/src/components/beacon/__snapshots__/beacon.test.tsx.snap index 55c5dfc918b..bfc036891eb 100644 --- a/src/components/beacon/__snapshots__/beacon.test.tsx.snap +++ b/src/components/beacon/__snapshots__/beacon.test.tsx.snap @@ -5,7 +5,7 @@ exports[`EuiBeacon is rendered 1`] = ` aria-label="aria-label" class="euiBeacon testClass1 testClass2 emotion-euiBeacon-success-euiTestCss" data-test-subj="test subject string" - style="height: 12px; width: 12px;" + style="block-size: 12px; inline-size: 12px;" /> `; @@ -14,7 +14,7 @@ exports[`EuiBeacon props color accent is rendered 1`] = ` aria-label="aria-label" class="euiBeacon testClass1 testClass2 emotion-euiBeacon-accent-euiTestCss" data-test-subj="test subject string" - style="height: 12px; width: 12px;" + style="block-size: 12px; inline-size: 12px;" /> `; @@ -23,7 +23,7 @@ exports[`EuiBeacon props color danger is rendered 1`] = ` aria-label="aria-label" class="euiBeacon testClass1 testClass2 emotion-euiBeacon-danger-euiTestCss" data-test-subj="test subject string" - style="height: 12px; width: 12px;" + style="block-size: 12px; inline-size: 12px;" /> `; @@ -32,7 +32,7 @@ exports[`EuiBeacon props color primary is rendered 1`] = ` aria-label="aria-label" class="euiBeacon testClass1 testClass2 emotion-euiBeacon-primary-euiTestCss" data-test-subj="test subject string" - style="height: 12px; width: 12px;" + style="block-size: 12px; inline-size: 12px;" /> `; @@ -41,7 +41,7 @@ exports[`EuiBeacon props color subdued is rendered 1`] = ` aria-label="aria-label" class="euiBeacon testClass1 testClass2 emotion-euiBeacon-subdued-euiTestCss" data-test-subj="test subject string" - style="height: 12px; width: 12px;" + style="block-size: 12px; inline-size: 12px;" /> `; @@ -50,7 +50,7 @@ exports[`EuiBeacon props color success is rendered 1`] = ` aria-label="aria-label" class="euiBeacon testClass1 testClass2 emotion-euiBeacon-success-euiTestCss" data-test-subj="test subject string" - style="height: 12px; width: 12px;" + style="block-size: 12px; inline-size: 12px;" /> `; @@ -59,7 +59,7 @@ exports[`EuiBeacon props color warning is rendered 1`] = ` aria-label="aria-label" class="euiBeacon testClass1 testClass2 emotion-euiBeacon-warning-euiTestCss" data-test-subj="test subject string" - style="height: 12px; width: 12px;" + style="block-size: 12px; inline-size: 12px;" /> `; @@ -68,6 +68,6 @@ exports[`EuiBeacon props size accepts size 1`] = ` aria-label="aria-label" class="euiBeacon testClass1 testClass2 emotion-euiBeacon-success-euiTestCss" data-test-subj="test subject string" - style="height: 14px; width: 14px;" + style="block-size: 14px; inline-size: 14px;" /> `; diff --git a/src/components/beacon/beacon.tsx b/src/components/beacon/beacon.tsx index b0070e00217..acea33586f2 100644 --- a/src/components/beacon/beacon.tsx +++ b/src/components/beacon/beacon.tsx @@ -6,13 +6,15 @@ * Side Public License, v 1. */ -import React, { FunctionComponent, HTMLAttributes } from 'react'; +import React, { FunctionComponent, HTMLAttributes, useMemo } from 'react'; import { CommonProps } from '../common'; import classNames from 'classnames'; -import { euiBeaconStyles } from './beacon.styles'; +import { logicalStyles } from '../../global_styling'; import { useEuiTheme } from '../../services'; +import { euiBeaconStyles } from './beacon.styles'; + export const COLORS = [ 'subdued', 'primary', @@ -51,11 +53,15 @@ export const EuiBeacon: FunctionComponent = ({ const styles = euiBeaconStyles(euiTheme); const cssStyles = [styles.euiBeacon, styles[color]]; - const beaconStyle = { - ...style, - height: size, - width: size, - }; + const beaconStyle = useMemo( + () => + logicalStyles({ + ...style, + height: size, + width: size, + }), + [style, size] + ); return (
diff --git a/src/components/tour/__snapshots__/tour_step.test.tsx.snap b/src/components/tour/__snapshots__/tour_step.test.tsx.snap index 4ba2a0953aa..0aa353e4849 100644 --- a/src/components/tour/__snapshots__/tour_step.test.tsx.snap +++ b/src/components/tour/__snapshots__/tour_step.test.tsx.snap @@ -1,565 +1,99 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`EuiTourStep accepts an array of buttons in the footerAction prop 1`] = ` -
- - Test - -
-
+exports[`EuiTourStep renders 1`] = ` + +
-
-
-`; - -exports[`EuiTourStep can be closed 1`] = ` -
- - Test - -
-`; - -exports[`EuiTourStep can change the minWidth and maxWidth 1`] = ` -
- - Test - -
-
- -
-
-`; - -exports[`EuiTourStep can have subtitle 1`] = ` -
- - Test - -
-
-