= ({
isDisabled && styles.isDisabled,
];
- checkValidInitials(initials);
-
- const avatarStyle = { ...style };
-
- let iconCustomColor = iconColor;
-
- const isNamedColor =
- color === 'plain' || color === 'subdued' || color === null;
-
- if (!isNamedColor) {
- checkValidColor(color);
-
- const assignedColor =
- color || visColors[Math.floor(name.length % visColors.length)];
- const textColor = isColorDark(...hexToRgb(assignedColor))
- ? '#FFFFFF'
- : '#000000';
-
- avatarStyle.backgroundColor = assignedColor;
- avatarStyle.color = textColor;
-
- // Allow consumers to let the icons keep their default color (like app icons)
- // when passing `iconColor = null`, otherwise continue to pass on `iconColor` or adjust with textColor
- iconCustomColor = iconColor || iconColor === null ? iconColor : textColor;
- }
-
- if (imageUrl) {
- avatarStyle.backgroundImage = `url(${imageUrl})`;
- }
+ const avatarStyle = useMemo(() => {
+ if (imageUrl) {
+ return {
+ backgroundImage: `url(${imageUrl})`,
+ };
+ }
+ if (!isNamedColor) {
+ checkValidColor(color);
+
+ const assignedColor =
+ color || visColors[Math.floor(name.length % visColors.length)];
+ const textColor = isColorDark(...hexToRgb(assignedColor))
+ ? '#FFFFFF'
+ : '#000000';
+
+ return {
+ backgroundColor: assignedColor,
+ color: textColor,
+ };
+ }
+ }, [imageUrl, color, isNamedColor, name.length]);
- let content;
- if (!imageUrl && !iconType) {
- // Create the initials
- const calculatedInitials = toInitials(name, initialsLength, initials);
- content = {calculatedInitials};
- } else if (iconType) {
- content = (
-
- );
- }
+ const iconCustomColor = useMemo(() => {
+ // `null` allows icons to keep their default color (e.g. app icons)
+ if (iconColor === null) return undefined;
+ // Otherwise continue to pass on `iconColor`
+ if (iconColor) return iconColor;
+ // Fall back to the adjusted text color if it exists
+ return avatarStyle?.color;
+ }, [iconColor, avatarStyle?.color]);
return (
- {content}
+ {!imageUrl &&
+ (iconType ? (
+
+ ) : (
+
+ {toInitials(name, initialsLength, initials)}
+
+ ))}
);
};
diff --git a/src/components/bottom_bar/__snapshots__/bottom_bar.test.tsx.snap b/src/components/bottom_bar/__snapshots__/bottom_bar.test.tsx.snap
index d890fdb1121..532be79cfda 100644
--- a/src/components/bottom_bar/__snapshots__/bottom_bar.test.tsx.snap
+++ b/src/components/bottom_bar/__snapshots__/bottom_bar.test.tsx.snap
@@ -11,7 +11,7 @@ exports[`EuiBottomBar is rendered 1`] = `
>
@@ -43,7 +43,7 @@ exports[`EuiBottomBar props affordForDisplacement can be false 1`] = `
>
{
${euiTheme.animation.resistance};
}
`,
- static: css``,
+ static: css``, // Default
fixed: css`
+ position: fixed;
z-index: ${Number(euiTheme.levels.header) - 2};
`,
sticky: css`
+ position: sticky;
z-index: ${Number(euiTheme.levels.header) - 2};
`,
// Padding
diff --git a/src/components/bottom_bar/bottom_bar.test.tsx b/src/components/bottom_bar/bottom_bar.test.tsx
index f9569417ce7..4b2264e4e0f 100644
--- a/src/components/bottom_bar/bottom_bar.test.tsx
+++ b/src/components/bottom_bar/bottom_bar.test.tsx
@@ -9,13 +9,8 @@
import React from 'react';
import { render } from '../../test/rtl';
import { requiredProps } from '../../test';
-import { keysOf } from '../common';
-import {
- EuiBottomBar,
- paddingSizeToClassNameMap,
- POSITIONS,
-} from './bottom_bar';
+import { EuiBottomBar, PADDING_SIZES, POSITIONS } from './bottom_bar';
describe('EuiBottomBar', () => {
test('is rendered', () => {
@@ -28,7 +23,7 @@ describe('EuiBottomBar', () => {
describe('props', () => {
describe('paddingSize', () => {
- keysOf(paddingSizeToClassNameMap).forEach((paddingSize) => {
+ PADDING_SIZES.forEach((paddingSize) => {
test(`${paddingSize} is rendered`, () => {
const { baseElement } = render(
diff --git a/src/components/bottom_bar/bottom_bar.tsx b/src/components/bottom_bar/bottom_bar.tsx
index b30d07ba55b..806d3742950 100644
--- a/src/components/bottom_bar/bottom_bar.tsx
+++ b/src/components/bottom_bar/bottom_bar.tsx
@@ -14,26 +14,22 @@ import React, {
useEffect,
useState,
} from 'react';
-import { useCombinedRefs, useEuiTheme } from '../../services';
+
+import {
+ useCombinedRefs,
+ useEuiMemoizedStyles,
+ EuiThemeProvider,
+} from '../../services';
import { EuiScreenReaderOnly } from '../accessibility';
import { CommonProps, ExclusiveUnion } from '../common';
import { EuiI18n } from '../i18n';
import { useResizeObserver } from '../observer/resize_observer';
import { EuiPortal, EuiPortalProps } from '../portal';
-import { euiBottomBarStyles } from './bottom_bar.styles';
-import { EuiThemeProvider } from '../../services/theme/provider';
-type BottomBarPaddingSize = 'none' | 's' | 'm' | 'l';
+import { euiBottomBarStyles } from './bottom_bar.styles';
-// Exported for testing
-export const paddingSizeToClassNameMap: {
- [value in BottomBarPaddingSize]: string | null;
-} = {
- none: null,
- s: 'euiBottomBar--paddingSmall',
- m: 'euiBottomBar--paddingMedium',
- l: 'euiBottomBar--paddingLarge',
-};
+export const PADDING_SIZES = ['none', 's', 'm', 'l'] as const;
+type BottomBarPaddingSize = (typeof PADDING_SIZES)[number];
export const POSITIONS = ['static', 'fixed', 'sticky'] as const;
export type _BottomBarPosition = (typeof POSITIONS)[number];
@@ -123,8 +119,7 @@ const _EuiBottomBar = forwardRef<
},
ref
) => {
- const euiTheme = useEuiTheme();
- const styles = euiBottomBarStyles(euiTheme);
+ const styles = useEuiMemoizedStyles(euiBottomBarStyles);
// Force some props if `fixed` position, but not if the user has supplied these
affordForDisplacement =
@@ -159,7 +154,6 @@ const _EuiBottomBar = forwardRef<
const classes = classNames(
'euiBottomBar',
`euiBottomBar--${position}`,
- paddingSizeToClassNameMap[paddingSize],
className
);
@@ -167,7 +161,6 @@ const _EuiBottomBar = forwardRef<
styles.euiBottomBar,
styles[position],
styles[paddingSize],
- { position },
];
const newStyle = {
@@ -240,10 +233,7 @@ export const EuiBottomBar = forwardRef(
(props, ref) => {
const BottomBar = _EuiBottomBar;
return (
-
+
);
diff --git a/src/components/code/code_block_annotations.style.ts b/src/components/code/code_block_annotations.style.ts
index 33821cdf4f4..b9faf685fc1 100644
--- a/src/components/code/code_block_annotations.style.ts
+++ b/src/components/code/code_block_annotations.style.ts
@@ -14,9 +14,7 @@ import {
} from '../../global_styling';
import { UseEuiTheme } from '../../services';
-export const euiCodeBlockAnnotationsStyles = (
- euiTheme: UseEuiTheme['euiTheme']
-) => {
+export const euiCodeBlockAnnotationsStyles = ({ euiTheme }: UseEuiTheme) => {
const buttonIconSize = mathWithUnits(euiTheme.size.base, (x) => x - 1.5);
return {
diff --git a/src/components/code/code_block_annotations.tsx b/src/components/code/code_block_annotations.tsx
index 7c20a7d6fea..b789454a667 100644
--- a/src/components/code/code_block_annotations.tsx
+++ b/src/components/code/code_block_annotations.tsx
@@ -13,12 +13,12 @@ import React, {
useState,
} from 'react';
-import { useEuiTheme } from '../../services';
+import { useEuiTheme, useEuiMemoizedStyles } from '../../services';
+import { useEuiButtonFocusCSS } from '../../themes/amsterdam/global_styling/mixins/button';
import { CommonProps } from '../common';
import { useEuiI18n } from '../i18n';
import { EuiPopover } from '../popover';
import { EuiIcon } from '../icon';
-import { useEuiButtonFocusCSS } from '../../themes/amsterdam/global_styling/mixins/button';
import { euiCodeBlockAnnotationsStyles } from './code_block_annotations.style';
@@ -40,15 +40,16 @@ export const EuiCodeBlockAnnotation: FunctionComponent<
{ lineNumber }
);
- const { euiTheme, colorMode } = useEuiTheme();
- const styles = euiCodeBlockAnnotationsStyles(euiTheme);
+ const styles = useEuiMemoizedStyles(euiCodeBlockAnnotationsStyles);
const buttonIconFocusStyle = useEuiButtonFocusCSS();
const cssButtonIconStyles = [
styles.euiCodeBlockAnnotation__buttonIcon,
buttonIconFocusStyle,
];
+ const { euiTheme, colorMode } = useEuiTheme();
const isDarkMode = colorMode === 'DARK';
+ const iconColor = isDarkMode ? euiTheme.colors.ink : 'ghost';
return (
-
+
}
zIndex={Number(euiTheme.levels.mask) + 1} // Ensure fullscreen annotation popovers sit above the mask
diff --git a/src/components/collapsible_nav/collapsible_nav.tsx b/src/components/collapsible_nav/collapsible_nav.tsx
index 82bb1f1a612..d2216ab948a 100644
--- a/src/components/collapsible_nav/collapsible_nav.tsx
+++ b/src/components/collapsible_nav/collapsible_nav.tsx
@@ -15,7 +15,7 @@ import React, {
} from 'react';
import classNames from 'classnames';
import {
- useEuiTheme,
+ useEuiMemoizedStyles,
useGeneratedHtmlId,
useIsWithinMinBreakpoint,
useCombinedRefs,
@@ -90,8 +90,7 @@ export const EuiCollapsibleNav: FunctionComponent = ({
const flyoutType = navIsDocked ? 'push' : 'overlay';
const classes = classNames('euiCollapsibleNav', className);
- const euiTheme = useEuiTheme();
- const styles = euiCollapsibleNavStyles(euiTheme);
+ const styles = useEuiMemoizedStyles(euiCollapsibleNavStyles);
const cssStyles = [styles.euiCollapsibleNav, styles[flyoutType]];
// Show a trigger button if one was passed but
diff --git a/src/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.tsx b/src/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.tsx
index b65c1d44aa7..23726f1d450 100644
--- a/src/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.tsx
+++ b/src/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.tsx
@@ -11,7 +11,7 @@ import classNames from 'classnames';
import { CommonProps, ExclusiveUnion } from '../../common';
import {
EuiThemeProvider,
- useEuiTheme,
+ useEuiMemoizedStyles,
useGeneratedHtmlId,
} from '../../../services';
@@ -115,8 +115,7 @@ export const EuiCollapsibleNavGroup: FunctionComponent<
const groupID = useGeneratedHtmlId({ conditionalId: id });
const titleID = `${groupID}__title`;
- const euiTheme = useEuiTheme();
- const styles = euiCollapsibleNavGroupStyles(euiTheme);
+ const styles = useEuiMemoizedStyles(euiCollapsibleNavGroupStyles);
const cssStyles = [
styles.euiCollapsibleNavGroup,
isCollapsible ? styles.isCollapsible : styles.notCollapsible,
diff --git a/src/components/collapsible_nav_beta/collapsible_nav_beta.tsx b/src/components/collapsible_nav_beta/collapsible_nav_beta.tsx
index c84c7bc114c..bda361fa4c4 100644
--- a/src/components/collapsible_nav_beta/collapsible_nav_beta.tsx
+++ b/src/components/collapsible_nav_beta/collapsible_nav_beta.tsx
@@ -19,7 +19,7 @@ import React, {
import classNames from 'classnames';
import {
- useEuiTheme,
+ useEuiMemoizedStyles,
useEuiThemeCSSVariables,
useGeneratedHtmlId,
throttle,
@@ -94,8 +94,7 @@ const _EuiCollapsibleNavBeta: FunctionComponent = ({
...rest
}) => {
const { setGlobalCSSVariables } = useEuiThemeCSSVariables();
- const euiTheme = useEuiTheme();
- const headerHeight = euiHeaderVariables(euiTheme).height;
+ const { height: headerHeight } = useEuiMemoizedStyles(euiHeaderVariables);
/**
* Collapsed state
@@ -179,7 +178,7 @@ const _EuiCollapsibleNavBeta: FunctionComponent = ({
'euiCollapsibleNavBeta',
className
);
- const styles = euiCollapsibleNavBetaStyles(euiTheme);
+ const styles = useEuiMemoizedStyles(euiCollapsibleNavBetaStyles);
const cssStyles = [
styles.euiCollapsibleNavBeta,
styles[side],
diff --git a/src/components/collapsible_nav_beta/collapsible_nav_body_footer.tsx b/src/components/collapsible_nav_beta/collapsible_nav_body_footer.tsx
index 5eb3756dbec..c4acbdcd8e0 100644
--- a/src/components/collapsible_nav_beta/collapsible_nav_body_footer.tsx
+++ b/src/components/collapsible_nav_beta/collapsible_nav_body_footer.tsx
@@ -9,7 +9,7 @@
import React, { useContext } from 'react';
import classNames from 'classnames';
-import { useEuiTheme } from '../../services';
+import { useEuiMemoizedStyles } from '../../services';
import {
EuiFlyoutBody,
EuiFlyoutBodyProps,
@@ -63,8 +63,7 @@ export const EuiCollapsibleNavFooter: EuiFlyoutFooterProps = ({
const classes = classNames('euiCollapsibleNav__footer', className);
const { isCollapsed, isPush } = useContext(EuiCollapsibleNavContext);
- const euiTheme = useEuiTheme();
- const styles = euiCollapsibleNavFooterStyles(euiTheme);
+ const styles = useEuiMemoizedStyles(euiCollapsibleNavFooterStyles);
const cssStyles = styles.euiCollapsibleNav__footer;
const overflowWrapperStyles = [
styles.euiFlyoutFooter__overflow,
diff --git a/src/components/collapsible_nav_beta/collapsible_nav_button/collapsible_nav_button.tsx b/src/components/collapsible_nav_beta/collapsible_nav_button/collapsible_nav_button.tsx
index a543037fcc4..765d8732f63 100644
--- a/src/components/collapsible_nav_beta/collapsible_nav_button/collapsible_nav_button.tsx
+++ b/src/components/collapsible_nav_beta/collapsible_nav_button/collapsible_nav_button.tsx
@@ -8,7 +8,7 @@
import React, { forwardRef, useContext } from 'react';
-import { useEuiTheme } from '../../../services';
+import { useEuiMemoizedStyles } from '../../../services';
import { CommonProps } from '../../common';
import { EuiButtonIcon, EuiButtonIconPropsForButton } from '../../button';
import { useEuiI18n } from '../../i18n';
@@ -28,8 +28,7 @@ export const EuiCollapsibleNavButton = forwardRef<
EuiCollapsibleNavContext
);
- const euiTheme = useEuiTheme();
- const styles = euiCollapsibleNavButtonWrapperStyles(euiTheme);
+ const styles = useEuiMemoizedStyles(euiCollapsibleNavButtonWrapperStyles);
const cssStyles = [styles.euiCollapsibleNavButtonWrapper, styles[side]];
const buttonStyles = [styles.euiCollapsibleNavButton, css];
diff --git a/src/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.tsx b/src/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.tsx
index bbb7eaf3f5b..0483895d6f3 100644
--- a/src/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.tsx
+++ b/src/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.tsx
@@ -9,7 +9,7 @@
import React, { FunctionComponent, HTMLAttributes, useContext } from 'react';
import classNames from 'classnames';
-import { useEuiTheme, useGeneratedHtmlId } from '../../../services';
+import { useEuiMemoizedStyles, useGeneratedHtmlId } from '../../../services';
import { CommonProps } from '../../common';
import { EuiCollapsibleNavContext } from '../context';
@@ -50,8 +50,7 @@ export const EuiCollapsibleNavGroup: FunctionComponent<
wrapperProps?.className
);
- const euiTheme = useEuiTheme();
- const styles = euiCollapsibleNavGroupStyles(euiTheme);
+ const styles = useEuiMemoizedStyles(euiCollapsibleNavGroupStyles);
const cssStyles = [
styles.euiCollapsibleNavGroup,
isPush && isCollapsed
diff --git a/src/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.tsx b/src/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.tsx
index 92919174cce..2a7de2b32ad 100644
--- a/src/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.tsx
+++ b/src/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.tsx
@@ -9,7 +9,7 @@
import React, { FunctionComponent, useContext } from 'react';
import classNames from 'classnames';
-import { useEuiTheme } from '../../../../services';
+import { useEuiMemoizedStyles } from '../../../../services';
import {
EuiButtonIcon,
EuiButtonIconPropsForAnchor,
@@ -43,10 +43,9 @@ export const EuiCollapsedNavButton: FunctionComponent<
titleElement, // Extracted to avoid spreading to ...rest
...rest
}) => {
- const euiTheme = useEuiTheme();
const { side } = useContext(EuiCollapsibleNavContext);
- const buttonStyles = euiCollapsedNavButtonStyles(euiTheme);
+ const buttonStyles = useEuiMemoizedStyles(euiCollapsedNavButtonStyles);
const buttonCssStyles = [
buttonStyles.euiCollapsedNavButton,
isSelected && buttonStyles.isSelected,
@@ -57,7 +56,7 @@ export const EuiCollapsedNavButton: FunctionComponent<
linkProps?.className
);
- const tooltipStyles = euiCollapsedNavItemTooltipStyles(euiTheme);
+ const tooltipStyles = useEuiMemoizedStyles(euiCollapsedNavItemTooltipStyles);
const tooltipCssStyles = [
tooltipStyles.euiCollapsedNavItemTooltip,
tooltipStyles[side],
diff --git a/src/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_popover.tsx b/src/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_popover.tsx
index f1f07a03d06..bbd10cafa95 100644
--- a/src/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_popover.tsx
+++ b/src/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_popover.tsx
@@ -8,7 +8,7 @@
import React, { FunctionComponent, useState, useCallback } from 'react';
-import { useEuiTheme } from '../../../../services';
+import { useEuiMemoizedStyles } from '../../../../services';
import { EuiPopover, EuiPopoverTitle } from '../../../popover';
@@ -34,8 +34,7 @@ export const EuiCollapsedNavPopover: FunctionComponent<
isSelected,
...rest
}) => {
- const euiTheme = useEuiTheme();
- const styles = euiCollapsedNavPopoverStyles(euiTheme);
+ const styles = useEuiMemoizedStyles(euiCollapsedNavPopoverStyles);
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const togglePopover = useCallback(
diff --git a/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.tsx b/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.tsx
index 6aeb62ba4bf..8715d81d0e1 100644
--- a/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.tsx
+++ b/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.tsx
@@ -9,7 +9,7 @@
import React, { FunctionComponent, ReactNode } from 'react';
import classNames from 'classnames';
-import { useEuiTheme, useGeneratedHtmlId } from '../../../services';
+import { useEuiMemoizedStyles, useGeneratedHtmlId } from '../../../services';
import { EuiAccordion } from '../../accordion';
import {
@@ -51,8 +51,7 @@ export const EuiCollapsibleNavAccordion: FunctionComponent<
const classes = classNames('euiCollapsibleNavAccordion', className);
const groupID = useGeneratedHtmlId({ conditionalId: id });
- const euiTheme = useEuiTheme();
- const styles = euiCollapsibleNavAccordionStyles(euiTheme);
+ const styles = useEuiMemoizedStyles(euiCollapsibleNavAccordionStyles);
const cssStyles = [
styles.euiCollapsibleNavAccordion,
isSubItem ? styles.isSubItem : styles.isTopItem,
diff --git a/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_group.tsx b/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_group.tsx
index 0cafca8f208..73aad3be6fa 100644
--- a/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_group.tsx
+++ b/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_group.tsx
@@ -9,7 +9,7 @@
import React, { FunctionComponent, ReactNode } from 'react';
import classNames from 'classnames';
-import { useEuiTheme, useGeneratedHtmlId } from '../../../services';
+import { useEuiMemoizedStyles, useGeneratedHtmlId } from '../../../services';
import {
type _SharedEuiCollapsibleNavItemProps,
@@ -47,8 +47,7 @@ export const EuiCollapsibleNavGroup: FunctionComponent<
}) => {
const classes = classNames('euiCollapsibleNavGroup', className);
- const euiTheme = useEuiTheme();
- const sharedStyles = euiCollapsibleNavItemVariables(euiTheme);
+ const sharedStyles = useEuiMemoizedStyles(euiCollapsibleNavItemVariables);
const cssStyles = !isSubItem
? {
css: {
diff --git a/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.tsx b/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.tsx
index b887835c01f..dbb46a61d84 100644
--- a/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.tsx
+++ b/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.tsx
@@ -15,7 +15,7 @@ import React, {
} from 'react';
import classNames from 'classnames';
-import { useEuiTheme } from '../../../services';
+import { useEuiMemoizedStyles } from '../../../services';
import { CommonProps, ExclusiveUnion } from '../../common';
import { EuiIcon, IconType, EuiIconProps } from '../../icon';
@@ -247,8 +247,7 @@ export const EuiCollapsibleNavSubItems: FunctionComponent<
> = ({ items, isSubItem, isGroup, className, ...rest }) => {
const classes = classNames('euiCollapsibleNavItem__items', className);
- const euiTheme = useEuiTheme();
- const styles = euiCollapsibleNavSubItemsStyles(euiTheme);
+ const styles = useEuiMemoizedStyles(euiCollapsibleNavSubItemsStyles);
const cssStyles = [
styles.euiCollapsibleNavItem__items,
isGroup ? styles.isGroup : isSubItem ? styles.isSubItem : styles.isTopItem,
diff --git a/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_link.tsx b/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_link.tsx
index 6a8d406e2e8..eba54251b86 100644
--- a/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_link.tsx
+++ b/src/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_link.tsx
@@ -9,7 +9,7 @@
import React, { FunctionComponent, ReactNode } from 'react';
import classNames from 'classnames';
-import { useEuiTheme } from '../../../services';
+import { useEuiMemoizedStyles } from '../../../services';
import { EuiLink, EuiLinkProps } from '../../link';
import type {
@@ -58,8 +58,7 @@ export const EuiCollapsibleNavLink: FunctionComponent<
className,
isInteractive && linkProps?.className
);
- const euiTheme = useEuiTheme();
- const styles = euiCollapsibleNavLinkStyles(euiTheme);
+ const styles = useEuiMemoizedStyles(euiCollapsibleNavLinkStyles);
const cssStyles = [
styles.euiCollapsibleNavLink,
isSelected && styles.isSelected,
diff --git a/src/components/comment_list/comment_event.tsx b/src/components/comment_list/comment_event.tsx
index 7e1a56af706..f0e1d464deb 100644
--- a/src/components/comment_list/comment_event.tsx
+++ b/src/components/comment_list/comment_event.tsx
@@ -9,7 +9,7 @@
import React, { FunctionComponent, ReactNode, useMemo } from 'react';
import classNames from 'classnames';
-import { useEuiTheme } from '../../services';
+import { useEuiMemoizedStyles } from '../../services';
import { useEuiBorderColorCSS } from '../../global_styling';
import { CommonProps } from '../common';
import { IconType } from '../icon';
@@ -118,24 +118,23 @@ export const EuiCommentEvent: FunctionComponent = ({
/**
* Styles
*/
- const euiTheme = useEuiTheme();
const borderStyles = useEuiBorderColorCSS();
- const styles = euiCommentEventStyles(euiTheme);
+ const styles = useEuiMemoizedStyles(euiCommentEventStyles);
const cssStyles = [
styles.euiCommentEvent,
showEventBorders && styles.border,
showEventBorders && borderStyles[eventColor!],
];
- const headerStyles = euiCommentEventHeaderStyles(euiTheme);
+ const headerStyles = useEuiMemoizedStyles(euiCommentEventHeaderStyles);
const cssHeaderStyles = [
headerStyles.euiCommentEvent__header,
showEventBorders && headerStyles.border,
showEventBorders && borderStyles[eventColor!],
];
- const bodyStyles = euiCommentEventBodyStyles(euiTheme);
+ const bodyStyles = useEuiMemoizedStyles(euiCommentEventBodyStyles);
const cssBodyStyles = [bodyStyles.euiCommentEvent__body, bodyStyles[type]];
return (
diff --git a/src/components/context_menu/context_menu_item.tsx b/src/components/context_menu/context_menu_item.tsx
index c87c3f75f6f..e2088d0311c 100644
--- a/src/components/context_menu/context_menu_item.tsx
+++ b/src/components/context_menu/context_menu_item.tsx
@@ -19,7 +19,7 @@ import React, {
import classNames from 'classnames';
import {
- useEuiTheme,
+ useEuiMemoizedStyles,
getSecureRelForTarget,
cloneElementWithCss,
} from '../../services';
@@ -104,8 +104,7 @@ export const EuiContextMenuItem: FunctionComponent = ({
const classes = classNames('euiContextMenuItem', className);
- const euiTheme = useEuiTheme();
- const styles = euiContextMenuItemStyles(euiTheme);
+ const styles = useEuiMemoizedStyles(euiContextMenuItemStyles);
const cssStyles = [
styles.euiContextMenuItem,
styles.sizes[size],
diff --git a/src/components/resizable_container/__snapshots__/resizable_container.test.tsx.snap b/src/components/resizable_container/__snapshots__/resizable_container.test.tsx.snap
index ad3e6f48762..65820a3e682 100644
--- a/src/components/resizable_container/__snapshots__/resizable_container.test.tsx.snap
+++ b/src/components/resizable_container/__snapshots__/resizable_container.test.tsx.snap
@@ -233,7 +233,7 @@ exports[`EuiResizableContainer can have toggleable panels 1`] = `
>