diff --git a/src/components/call_out/call_out.styles.ts b/src/components/call_out/call_out.styles.ts index a6164f8d9511..59e4cd4cc049 100644 --- a/src/components/call_out/call_out.styles.ts +++ b/src/components/call_out/call_out.styles.ts @@ -45,15 +45,10 @@ export const euiCallOutStyles = ({ euiTheme }: UseEuiTheme) => { ${logicalCSS('right', euiTheme.size.s)} `, }, - euiCallOut__icon: css` - position: relative; - ${logicalCSS('top', '-1px')} - ${logicalCSS('margin-right', euiTheme.size.s)} - `, }; }; -export const euiCallOutHeadingStyles = ({ euiTheme }: UseEuiTheme) => { +export const euiCallOutHeaderStyles = ({ euiTheme }: UseEuiTheme) => { return { euiCallOutHeader: css` font-weight: ${euiTheme.font.weight.medium}; @@ -75,5 +70,10 @@ export const euiCallOutHeadingStyles = ({ euiTheme }: UseEuiTheme) => { danger: css` color: ${euiTheme.colors.dangerText}; `, + euiCallOut__icon: css` + position: relative; + ${logicalCSS('top', '-1px')} + ${logicalCSS('margin-right', euiTheme.size.s)} + `, }; }; diff --git a/src/components/call_out/call_out.tsx b/src/components/call_out/call_out.tsx index 728848b099f2..4abcacb253d9 100644 --- a/src/components/call_out/call_out.tsx +++ b/src/components/call_out/call_out.tsx @@ -6,22 +6,21 @@ * Side Public License, v 1. */ -import React, { forwardRef, HTMLAttributes, ReactNode } from 'react'; +import React, { forwardRef, HTMLAttributes, ReactNode, useMemo } from 'react'; import classNames from 'classnames'; +import { useEuiMemoizedStyles } from '../../services'; import { CommonProps } from '../common'; import { IconType, EuiIcon } from '../icon'; - import { EuiButtonIcon } from '../button'; import { EuiText } from '../text'; -import { useEuiTheme } from '../../services'; import { EuiPanel } from '../panel'; import { EuiSpacer } from '../spacer'; import { EuiTitle } from '../title'; import { EuiI18n } from '../i18n'; -import { euiCallOutStyles, euiCallOutHeadingStyles } from './call_out.styles'; +import { euiCallOutStyles, euiCallOutHeaderStyles } from './call_out.styles'; export const COLORS = ['primary', 'success', 'warning', 'danger'] as const; export type Color = (typeof COLORS)[number]; @@ -63,22 +62,12 @@ export const EuiCallOut = forwardRef( }, ref ) => { - const theme = useEuiTheme(); - const styles = euiCallOutStyles(theme); + const styles = useEuiMemoizedStyles(euiCallOutStyles); const cssStyles = [ styles.euiCallOut, onDismiss && styles.hasDismissButton.hasDimissButton, onDismiss && styles.hasDismissButton[size], ]; - const cssDismissButtonStyles = [ - styles.dismissButton.euiCallOut__dismissButton, - styles.dismissButton[size], - ]; - const headerStyles = euiCallOutHeadingStyles(theme); - const cssHeaderStyles = [ - headerStyles.euiCallOutHeader, - headerStyles[color], - ]; const classes = classNames( 'euiCallOut', @@ -88,42 +77,57 @@ export const EuiCallOut = forwardRef( className ); - const dismissButton = onDismiss && ( - - {(dismissAriaLabel: string) => ( - - )} - - ); - - const headerIcon = iconType && ( -