From ff8623edcfd1b49db0eefe04b8f37ffeba82bf0d Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Mon, 1 Jul 2024 15:40:58 +0300 Subject: [PATCH] update PR --- .../stat/__snapshots__/stat.test.tsx.snap | 96 +------------------ packages/eui/src/components/stat/stat.tsx | 35 +++---- 2 files changed, 14 insertions(+), 117 deletions(-) diff --git a/packages/eui/src/components/stat/__snapshots__/stat.test.tsx.snap b/packages/eui/src/components/stat/__snapshots__/stat.test.tsx.snap index 649546d70d0..64247baf02e 100644 --- a/packages/eui/src/components/stat/__snapshots__/stat.test.tsx.snap +++ b/packages/eui/src/components/stat/__snapshots__/stat.test.tsx.snap @@ -18,11 +18,6 @@ exports[`EuiStat is rendered 1`] = ` > title

-

- description title -

`; @@ -42,11 +37,6 @@ exports[`EuiStat props accent is rendered 1`] = ` > title

-

- description title -

`; @@ -66,11 +56,6 @@ exports[`EuiStat props center is rendered 1`] = ` > title

-

- description title -

`; @@ -90,11 +75,6 @@ exports[`EuiStat props danger is rendered 1`] = ` > title

-

- description title -

`; @@ -114,11 +94,6 @@ exports[`EuiStat props default is rendered 1`] = ` > title

-

- description title -

`; @@ -139,11 +114,6 @@ exports[`EuiStat props hexcode colors are rendered 1`] = ` > title

-

- description title -

`; @@ -163,11 +133,6 @@ exports[`EuiStat props l is rendered 1`] = ` > title

-

- description title -

`; @@ -187,11 +152,6 @@ exports[`EuiStat props left is rendered 1`] = ` > title

-

- description title -

`; @@ -209,15 +169,11 @@ exports[`EuiStat props loading is rendered 1`] = `

--

-

- Statistic is loading -

`; @@ -237,11 +193,6 @@ exports[`EuiStat props m is rendered 1`] = ` > title

-

- description title -

`; @@ -261,11 +212,6 @@ exports[`EuiStat props primary is rendered 1`] = ` > title

-

- description title -

`; @@ -328,11 +274,6 @@ exports[`EuiStat props right is rendered 1`] = ` > title

-

- description title -

`; @@ -352,11 +293,6 @@ exports[`EuiStat props s is rendered 1`] = ` > title

-

- description title -

`; @@ -376,11 +312,6 @@ exports[`EuiStat props subdued is rendered 1`] = ` > title

-

- description title -

`; @@ -400,11 +331,6 @@ exports[`EuiStat props success is rendered 1`] = ` > title

-

- description title -

`; @@ -424,11 +350,6 @@ exports[`EuiStat props title and description are reversed 1`] = ` description

-

- title description -

`; @@ -448,11 +369,6 @@ exports[`EuiStat props xs is rendered 1`] = ` > title

-

- description title -

`; @@ -472,11 +388,6 @@ exports[`EuiStat props xxs is rendered 1`] = ` > title

-

- description title -

`; @@ -496,10 +407,5 @@ exports[`EuiStat props xxxs is rendered 1`] = ` > title

-

- description title -

`; diff --git a/packages/eui/src/components/stat/stat.tsx b/packages/eui/src/components/stat/stat.tsx index d8bdf8690d5..1d46c32904f 100644 --- a/packages/eui/src/components/stat/stat.tsx +++ b/packages/eui/src/components/stat/stat.tsx @@ -18,8 +18,7 @@ import classNames from 'classnames'; import { EuiText } from '../text'; import { EuiTitle, EuiTitleSize } from '../title/title'; -import { EuiScreenReaderOnly } from '../accessibility'; -import { EuiI18n } from '../i18n'; +import { useEuiI18n } from '../i18n'; import { useEuiTheme } from '../../services'; import { euiStatStyles, euiStatTitleStyles } from './stat.styles'; @@ -93,6 +92,11 @@ export const EuiStat: FunctionComponent< const cssStyles = [styles.euiStat, styles[textAlign]]; const classes = classNames('euiStat', className); + const loadingStatsAriaLabel = useEuiI18n( + 'euiStat.loadingText', + 'Statistic is loading' + ); + const descriptionDisplay = ( {createElement(descriptionElement, {}, description)} @@ -106,40 +110,27 @@ export const EuiStat: FunctionComponent< isNamedTitleColor && titleStyles[titleColor as TitleColor], isLoading && titleStyles.isLoading, ]; - const titleChildren = isLoading ? '--' : title; const titleDisplay = ( - + {createElement( titleElement, isNamedTitleColor ? {} : { style: { color: titleColor } }, - titleChildren + isLoading ? '--' : title )} ); - const screenReader = ( - -

- {isLoading ? ( - - ) : ( - - {reverse ? `${title} ${description}` : `${description} ${title}`} - - )} -

-
- ); - const statDisplay = ( {!reverse && descriptionDisplay} {titleDisplay} {reverse && descriptionDisplay} - {typeof title === 'string' && - typeof description === 'string' && - screenReader} );