Skip to content

Commit

Permalink
TabHeader component accessibility improvements (#2654)
Browse files Browse the repository at this point in the history
* refactor:  component accessibility improvements

* style: active, focus & hover state font color

* style: use explicitly h4 selector for hover, focus and active link styles
  • Loading branch information
kark authored Jun 27, 2022
1 parent 8769e72 commit f3cc395
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-planes-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-frontend/application-components': patch
---

Accessibility improvements of the `TabHeader` component.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ const warnIfMissingContent = (props: TTabHeaderProps) => {
);
};

const getDisabledTabHeaderAriaAttributes = (
isDisabled: TTabHeaderProps['isDisabled']
) => (isDisabled ? { 'aria-disabled': true } : {});

const getDisabledLinkAtributes = (isDisabled: TTabHeaderProps['isDisabled']) =>
isDisabled ? { tabIndex: -1, 'aria-disabled': true } : {};

Expand Down Expand Up @@ -84,20 +80,16 @@ export const TabHeader = (props: TTabHeaderProps) => {

return (
<Link
role="tab"
aria-selected={isActive}
to={props.to}
css={getLinkStyles(isActive, isDisabled)}
{...getDisabledLinkAtributes(isDisabled)}
{...dataAttributeProps}
>
<div
role="tab"
aria-selected={isActive}
{...getDisabledTabHeaderAriaAttributes(isDisabled)}
>
<Text.Subheadline as="h4" truncate={true}>
{label}
</Text.Subheadline>
</div>
<Text.Subheadline as="h4" truncate={true}>
{label}
</Text.Subheadline>
</Link>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const getLinkStyles = (
isActive &&
css`
${getBottomBorderStyles(customProperties.colorPrimary)}
> * > * {
& h4 {
color: ${customProperties.colorPrimary} !important;
}
`,
Expand All @@ -63,7 +63,7 @@ export const getLinkStyles = (
:hover,
:focus,
:active {
> * > * {
& h4 {
color: ${customProperties.colorPrimary} !important;
}
}
Expand Down

1 comment on commit f3cc395

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for merchant-center-application-kit ready!

✅ Preview
https://merchant-center-application-eo7u3vk43-commercetools.vercel.app

Built with commit f3cc395.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.