Skip to content

Commit 79c6ce6

Browse files
authored
feat(AnalyticalCardHeader): allow customizing the aria-level of titleText (#7260)
1 parent 5be7e83 commit 79c6ce6

File tree

1 file changed

+11
-2
lines changed
  • packages/main/src/components/AnalyticalCardHeader

1 file changed

+11
-2
lines changed

packages/main/src/components/AnalyticalCardHeader/index.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import iconDown from '@ui5/webcomponents-icons/dist/down.js';
44
import iconUp from '@ui5/webcomponents-icons/dist/up.js';
55
import { useI18nBundle, useStylesheet } from '@ui5/webcomponents-react-base';
66
import { clsx } from 'clsx';
7-
import type { MouseEventHandler, ReactElement, ReactNode } from 'react';
7+
import type { HTMLAttributes, MouseEventHandler, ReactElement, ReactNode } from 'react';
88
import { cloneElement, forwardRef, useId } from 'react';
99
import { DeviationIndicator, ValueColor } from '../../enums/index.js';
1010
import {
@@ -27,6 +27,14 @@ export interface AnalyticalCardHeaderPropTypes extends CommonProps {
2727
* The title of the card
2828
*/
2929
titleText?: string;
30+
/**
31+
* Determines the ARIA level of the `titleText`.
32+
*
33+
* __Note:__ Defining a `titleTextLevel` will apply the `aria-level` attribute with a value from 1 to 6.
34+
*
35+
* @default 3
36+
*/
37+
titleTextLevel?: HTMLAttributes<HTMLSpanElement>['aria-level'];
3038
/**
3139
* The subtitle of the card
3240
*/
@@ -98,6 +106,7 @@ const deviationMap = new Map<AnalyticalCardHeaderPropTypes['trend'], any>([
98106
export const AnalyticalCardHeader = forwardRef<HTMLDivElement, AnalyticalCardHeaderPropTypes>((props, ref) => {
99107
const {
100108
titleText,
109+
titleTextLevel = 3,
101110
subtitleText,
102111
value,
103112
scale,
@@ -182,7 +191,7 @@ export const AnalyticalCardHeader = forwardRef<HTMLDivElement, AnalyticalCardHea
182191
<div>
183192
<div className={classNames.headerTitles}>
184193
<div className={classNames.headerFirstLine}>
185-
<span role="heading" aria-level={3} className={classNames.headerText} id={`${headerId}-title`}>
194+
<span role="heading" aria-level={titleTextLevel} className={classNames.headerText} id={`${headerId}-title`}>
186195
{titleText}
187196
</span>
188197
{status && <span className={classNames.status}>{status}</span>}

0 commit comments

Comments
 (0)