Skip to content
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

refactor: Removing aria attributes from Banner component #2318

Merged
14 changes: 0 additions & 14 deletions cypress/integration/Banner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,6 @@ describe('Banner', () => {
it('should have an element with a role of "button"', () => {
cy.findByRole('button').should('be.visible');
});

it('should have an "aria-labelledby" that matches the action', () => {
cy.findByRole('button').then($button => {
const id = $button.attr('aria-labelledby');
cy.findByText('View All').should('have.attr', 'id', id);
});
});

it('should have an "aria-describedby" that matches the label', () => {
cy.findByRole('button').then($button => {
const id = $button.attr('aria-describedby');
cy.findByText('3 Errors').should('have.attr', 'id', id);
});
});
});
});
});
3 changes: 1 addition & 2 deletions modules/react/banner/lib/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@workday/canvas-kit-react/common';
import {Flex} from '@workday/canvas-kit-react/layout';

import {useBanner, useBannerModel, useThemedPalette} from './hooks';
import {useBannerModel, useThemedPalette} from './hooks';

import {BannerIcon} from './BannerIcon';
import {BannerLabel} from './BannerLabel';
Expand Down Expand Up @@ -70,7 +70,6 @@ const styles: CSSProperties = {
export const Banner = createContainer('button')({
displayName: 'Banner',
modelHook: useBannerModel,
elemPropsHook: useBanner,
subComponents: {
/**
* `Banner.Icon` is a styled {@link SystemIcon}. The icon defaults to exclamationTriangleIcon or
Expand Down
7 changes: 7 additions & 0 deletions modules/react/banner/stories/Banner.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Banner} from '@workday/canvas-kit-react/banner';
import {ActionText} from './examples/ActionText';
import {Basic} from './examples/Basic';
import {Error} from './examples/Error';
import {IconBanner} from './examples/IconBanner';
import {Sticky} from './examples/Sticky';
import {ThemedAlert} from './examples/ThemedAlert';
import {ThemedError} from './examples/ThemedError';
Expand Down Expand Up @@ -49,6 +50,12 @@ banner. This will change the defualt icon to `exclamationCircleIcon`.

<ExampleCodeBlock code={Error} />

### Icon Banner

When not using any text in the `Banner`, use our `Tooltip` component to both show a visible text alternative, and assign an `aria-label` string to the child `Banner`.
mannycarrera4 marked this conversation as resolved.
Show resolved Hide resolved

<ExampleCodeBlock code={IconBanner} />

### Sticky

Set the `isSticky` prop of the `Banner` to display it along the right edge of the page. When true,
Expand Down
17 changes: 17 additions & 0 deletions modules/react/banner/stories/examples/IconBanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';

import {Banner} from '@workday/canvas-kit-react/banner';
import {Tooltip} from '@workday/canvas-kit-react/tooltip';
import {styled} from '@workday/canvas-kit-react/common';

export const IconBanner = () => {
const StyledBanner = styled(Banner)({width: '4em'});
mannycarrera4 marked this conversation as resolved.
Show resolved Hide resolved

return (
<Tooltip title="Warning">
<StyledBanner>
mannycarrera4 marked this conversation as resolved.
Show resolved Hide resolved
<Banner.Icon />
</StyledBanner>
mannycarrera4 marked this conversation as resolved.
Show resolved Hide resolved
</Tooltip>
);
};
Loading