From 42e03faf5ca0be0d30d59a0b50510d8312dd7e92 Mon Sep 17 00:00:00 2001 From: Amaranta Date: Mon, 9 Dec 2024 02:55:16 -0400 Subject: [PATCH 1/8] [EuiToolTip] implement memoization for styles in tool_tip_popover.tsx --- packages/eui/src/components/tool_tip/tool_tip_popover.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/eui/src/components/tool_tip/tool_tip_popover.tsx b/packages/eui/src/components/tool_tip/tool_tip_popover.tsx index a561b30b7c1..8770362b505 100644 --- a/packages/eui/src/components/tool_tip/tool_tip_popover.tsx +++ b/packages/eui/src/components/tool_tip/tool_tip_popover.tsx @@ -16,7 +16,7 @@ import React, { } from 'react'; import classNames from 'classnames'; import { CommonProps } from '../common'; -import { useEuiTheme } from '../../services'; +import { useEuiMemoizedStyles } from '../../services'; import { euiToolTipStyles } from './tool_tip.styles'; export type ToolTipPositions = 'top' | 'right' | 'bottom' | 'left'; @@ -41,8 +41,7 @@ export const EuiToolTipPopover: FunctionComponent = ({ }) => { const popover = useRef(); - const euiTheme = useEuiTheme(); - const styles = euiToolTipStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiToolTipStyles); const cssStyles = [ styles.euiToolTip, calculatedPosition && styles[calculatedPosition], From 94ebcf824bf1c089083c117dc431ae01afb30783 Mon Sep 17 00:00:00 2001 From: Amaranta Date: Mon, 9 Dec 2024 03:45:19 -0400 Subject: [PATCH 2/8] [EuiToolTip] implement memoization for styles in tool_tip_popover.tsx --- .../icon/__snapshots__/icon.test.tsx.snap | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/eui/src/components/icon/__snapshots__/icon.test.tsx.snap b/packages/eui/src/components/icon/__snapshots__/icon.test.tsx.snap index 692f493f252..ac1238916c6 100644 --- a/packages/eui/src/components/icon/__snapshots__/icon.test.tsx.snap +++ b/packages/eui/src/components/icon/__snapshots__/icon.test.tsx.snap @@ -166,6 +166,24 @@ exports[`EuiIcon props color inherit is rendered 1`] = ` `; +exports[`EuiIcon props color inherit is rendered 2`] = ` + +`; + exports[`EuiIcon props color primary is rendered 1`] = `
; From 05192a90f47abe662b13881a10bf4705914708b7 Mon Sep 17 00:00:00 2001 From: Amaranta Date: Mon, 9 Dec 2024 15:08:23 -0400 Subject: [PATCH 4/8] [EuiToolTip] implement memoization for styles in popover component files --- .../src/components/popover/popover_arrow/_popover_arrow.tsx | 5 ++--- packages/eui/src/components/popover/popover_footer.tsx | 5 ++--- packages/eui/src/components/popover/popover_title.tsx | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/eui/src/components/popover/popover_arrow/_popover_arrow.tsx b/packages/eui/src/components/popover/popover_arrow/_popover_arrow.tsx index 4238824ae23..db5726eb1ec 100644 --- a/packages/eui/src/components/popover/popover_arrow/_popover_arrow.tsx +++ b/packages/eui/src/components/popover/popover_arrow/_popover_arrow.tsx @@ -9,7 +9,7 @@ import React, { HTMLAttributes, FunctionComponent } from 'react'; import { CommonProps } from '../../common'; import { euiPopoverArrowStyles } from './_popover_arrow.styles'; -import { useEuiTheme } from '../../../services'; +import { useEuiMemoizedStyles } from '../../../services'; export const POSITIONS = ['top', 'left', 'right', 'bottom'] as const; export type EuiPopoverArrowPositions = (typeof POSITIONS)[number]; @@ -24,8 +24,7 @@ export const EuiPopoverArrow: FunctionComponent = ({ position, ...rest }) => { - const euiTheme = useEuiTheme(); - const styles = euiPopoverArrowStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiPopoverArrowStyles); const cssStyles = [styles.euiPopoverArrow, styles[position]]; return ( diff --git a/packages/eui/src/components/popover/popover_footer.tsx b/packages/eui/src/components/popover/popover_footer.tsx index 577ecc2b217..0dde7c55b7f 100644 --- a/packages/eui/src/components/popover/popover_footer.tsx +++ b/packages/eui/src/components/popover/popover_footer.tsx @@ -9,7 +9,7 @@ import React, { HTMLAttributes, FunctionComponent, useContext } from 'react'; import classNames from 'classnames'; import { EuiPaddingSize, useEuiPaddingCSS } from '../../global_styling'; -import { useEuiTheme } from '../../services'; +import { useEuiMemoizedStyles } from '../../services'; import { CommonProps } from '../common'; import { euiPopoverFooterStyles } from './popover_footer.styles'; import { EuiPopoverPanelContext } from './popover_panel/_popover_panel'; @@ -32,8 +32,7 @@ export const EuiPopoverFooter: EuiPopoverFooterProps = ({ ...rest }) => { const { paddingSize: panelPadding } = useContext(EuiPopoverPanelContext); - const euiTheme = useEuiTheme(); - const styles = euiPopoverFooterStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiPopoverFooterStyles); const paddingStyles = useEuiPaddingCSS(); const cssStyles = [ styles.euiPopoverFooter, diff --git a/packages/eui/src/components/popover/popover_title.tsx b/packages/eui/src/components/popover/popover_title.tsx index 4263f35998e..8575ed43141 100644 --- a/packages/eui/src/components/popover/popover_title.tsx +++ b/packages/eui/src/components/popover/popover_title.tsx @@ -9,7 +9,7 @@ import React, { HTMLAttributes, FunctionComponent, useContext } from 'react'; import classNames from 'classnames'; import { EuiPaddingSize, useEuiPaddingCSS } from '../../global_styling'; -import { useEuiTheme } from '../../services'; +import { useEuiMemoizedStyles } from '../../services'; import { CommonProps } from '../common'; import { euiPopoverTitleStyles } from './popover_title.styles'; import { EuiPopoverPanelContext } from './popover_panel/_popover_panel'; @@ -32,8 +32,7 @@ export const EuiPopoverTitle: EuiPopoverTitleProps = ({ ...rest }) => { const { paddingSize: panelPadding } = useContext(EuiPopoverPanelContext); - const euiTheme = useEuiTheme(); - const styles = euiPopoverTitleStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiPopoverTitleStyles); const paddingStyles = useEuiPaddingCSS(); const cssStyles = [ styles.euiPopoverTitle, From 008cfaf17344bac09ec9ded99116100267939f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Gonz=C3=A1lez?= Date: Mon, 9 Dec 2024 17:31:51 -0400 Subject: [PATCH 5/8] FIX: Delete snapshots to match unit tests --- .../icon/__snapshots__/icon.test.tsx.snap | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/packages/eui/src/components/icon/__snapshots__/icon.test.tsx.snap b/packages/eui/src/components/icon/__snapshots__/icon.test.tsx.snap index ac1238916c6..692f493f252 100644 --- a/packages/eui/src/components/icon/__snapshots__/icon.test.tsx.snap +++ b/packages/eui/src/components/icon/__snapshots__/icon.test.tsx.snap @@ -166,24 +166,6 @@ exports[`EuiIcon props color inherit is rendered 1`] = ` `; -exports[`EuiIcon props color inherit is rendered 2`] = ` - -`; - exports[`EuiIcon props color primary is rendered 1`] = `