Skip to content

feat(AnalyticalCardHeader): allow customizing the aria-level of titleText #7260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/main/src/components/AnalyticalCardHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import iconDown from '@ui5/webcomponents-icons/dist/down.js';
import iconUp from '@ui5/webcomponents-icons/dist/up.js';
import { useI18nBundle, useStylesheet } from '@ui5/webcomponents-react-base';
import { clsx } from 'clsx';
import type { MouseEventHandler, ReactElement, ReactNode } from 'react';
import type { HTMLAttributes, MouseEventHandler, ReactElement, ReactNode } from 'react';
import { cloneElement, forwardRef, useId } from 'react';
import { DeviationIndicator, ValueColor } from '../../enums/index.js';
import {
Expand All @@ -27,6 +27,14 @@ export interface AnalyticalCardHeaderPropTypes extends CommonProps {
* The title of the card
*/
titleText?: string;
/**
* Determines the ARIA level of the `titleText`.
*
* __Note:__ Defining a `titleTextLevel` will apply the `aria-level` attribute with a value from 1 to 6.
*
* @default 3
*/
titleTextLevel?: HTMLAttributes<HTMLSpanElement>['aria-level'];
/**
* The subtitle of the card
*/
Expand Down Expand Up @@ -98,6 +106,7 @@ const deviationMap = new Map<AnalyticalCardHeaderPropTypes['trend'], any>([
export const AnalyticalCardHeader = forwardRef<HTMLDivElement, AnalyticalCardHeaderPropTypes>((props, ref) => {
const {
titleText,
titleTextLevel = 3,
subtitleText,
value,
scale,
Expand Down Expand Up @@ -182,7 +191,7 @@ export const AnalyticalCardHeader = forwardRef<HTMLDivElement, AnalyticalCardHea
<div>
<div className={classNames.headerTitles}>
<div className={classNames.headerFirstLine}>
<span role="heading" aria-level={3} className={classNames.headerText} id={`${headerId}-title`}>
<span role="heading" aria-level={titleTextLevel} className={classNames.headerText} id={`${headerId}-title`}>
{titleText}
</span>
{status && <span className={classNames.status}>{status}</span>}
Expand Down
Loading