Skip to content

Commit

Permalink
chore(ModalHeader): enable dynamic aria-label value (#2961)
Browse files Browse the repository at this point in the history
* chore(ModalHeader): enable dynamic  value

* refactor: adjust defaults

* chore: add changelog

---------

Co-authored-by: Kathrin Holzmann <Lelith@users.noreply.github.com>
  • Loading branch information
cf-remylenoir and Lelith authored Jan 9, 2025
1 parent 59a56df commit dcc3a32
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/chilled-lizards-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@contentful/f36-modal": patch
---

Enable dynamic `aria-label` value
8 changes: 7 additions & 1 deletion packages/components/modal/src/ModalHeader/ModalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ interface ModalHeaderInternalProps extends CommonProps {
subtitle?: string;
onClose?: Function;
children?: React.ReactNode;
aria?: {
closeIconLabel?: string;
};
}

export type ModalHeaderProps = PropsWithHTMLElement<
Expand All @@ -30,6 +33,9 @@ export const ModalHeader = ({
testId = 'cf-ui-modal-header',
className,
children,
aria = {
closeIconLabel: 'Close',
},
...otherProps
}: ModalHeaderProps): React.ReactElement => {
const styles = getModalHeaderStyles();
Expand All @@ -55,7 +61,7 @@ export const ModalHeader = ({
<Flex alignItems="center" className={styles.buttonContainer}>
<IconButton
variant="transparent"
aria-label="Close"
aria-label={aria.closeIconLabel}
size="small"
icon={<CloseIcon size="small" />}
onClick={() => {
Expand Down
3 changes: 3 additions & 0 deletions packages/components/modal/stories/Modal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export const Basic: Story<ModalProps> = (props) => {
{...props}
modalHeaderProps={{
className: 'additional-modal-header-class',
aria: {
closeIconLabel: 'Custom close modal aria label',
},
}}
modalContentProps={{
className: 'additional-modal-content-class',
Expand Down

0 comments on commit dcc3a32

Please sign in to comment.