Skip to content

Commit

Permalink
feat: enable i18n support for back button in header component [UFO-13…
Browse files Browse the repository at this point in the history
…00] (#2971)

* feat: enable i18n support for back button in header component

* chore: add changeset
  • Loading branch information
Lelith authored Jan 10, 2025
1 parent e7c8f65 commit efc27b7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-teachers-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@contentful/f36-header': patch
---

Enables a dynamic string for the aria-label on the BackButton in the Header Component.
14 changes: 10 additions & 4 deletions packages/components/header/src/BackButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@ import { ArrowBackwardIcon } from '@contentful/f36-icons';

export type BackButtonProps = Omit<
Partial<IconButtonProps>,
'aria-label' | 'children' | 'icon' | 'variant' | 'size'
>;
'children' | 'icon' | 'variant' | 'size'
> & {
'aria-label'?: string;
};

function _BackButton(
{ onClick, ...otherProps }: BackButtonProps,
{
onClick,
'aria-label': ariaLabel = 'Go back',
...otherProps
}: BackButtonProps,
ref: Ref<HTMLButtonElement>,
) {
return (
<IconButton
{...otherProps}
aria-label="Go back"
aria-label={ariaLabel}
icon={<ArrowBackwardIcon variant="muted" />}
onClick={onClick}
size="small"
Expand Down
5 changes: 4 additions & 1 deletion packages/components/header/stories/Header.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export const Default: Story<HeaderProps> = ({
<Box style={{ minWidth: '1000px' }}>
<Header
withBackButton={true}
backButtonProps={{ onClick: action('back button click') }}
backButtonProps={{
onClick: action('back button click'),
'aria-label': 'Custom go back aria-label',
}}
breadcrumbs={[
{
content: 'Content Types',
Expand Down

0 comments on commit efc27b7

Please sign in to comment.