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

Addon-a11y: Move stories into addon #19114

Merged
merged 13 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from 12 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
63 changes: 63 additions & 0 deletions code/addons/a11y/template/stories/parameters.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import globalThis from 'global';

export default {
component: globalThis.Components.Button,
args: {
children: 'Click Me!',
},
parameters: {
chromatic: { disable: true },
},
};

export const Basic = {};

export const Violation = {
args: {
// empty on purpose to get a button with no text
children: '',
},
};

export const Checks = {
parameters: {
a11y: {
config: {},
options: {
checks: {
'color-contrast': { options: { noScroll: true } },
},
restoreScroll: true,
},
},
},
};

export const Targetted = {
parameters: {
a11y: {
element: 'button',
},
},
};
Copy link
Member

Choose a reason for hiding this comment

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

Is it obvious this is doing something? Would it be better to do these kind of things in the HTML-based story file?


export const Blank = {
parameters: {
a11y: {
config: {
disableOtherRules: true,
// @ts-ignore
rules: [],
},
options: {},
},
},
};

export const Disabled = {
parameters: {
a11y: {
disable: true,
},
},
};
65 changes: 65 additions & 0 deletions code/addons/a11y/template/stories/tests.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import globalThis from 'global';

export default {
component: globalThis.Components.Html,
args: {
content: '',
},
parameters: {
chromatic: { disable: true },
},
};

export const Violations = {
args: {
content: `
<div>
<p>empty heading</p>
<h1></h1>
</div>
<div>
<p>empty button</p>
<button></button>
</div>
<div>
<p>low contrast</p>
<button style="color: rgb(255, 255, 255); background-color: rgb(76, 175, 80);">Click me!</button>
</div>
<div>
<p>missing label</p>
<label><input /></label>
</div>
<div>
<p>missing alt</p>
<img src="https://storybook.js.org/images/placeholders/350x150.png" />
</div>
`,
},
};

export const Passes = {
args: {
content: `
<div>
<p>heading</p>
<h1>heading 1</h1>
</div>
<div>
<p>button</p>
<button>Click me!</button>
</div>
<div>
<p>contrast</p>
<button style="color: rgb(255, 255, 255); background-color: rgb(0, 0, 0);">Click me!</button>
</div>
<div>
<p>label</p>
<label><span>label</span><input /></label>
</div>
<div>
<p>alt</p>
<img src="https://storybook.js.org/images/placeholders/350x150.png" alt="placeholder" />
</div>
`,
},
};
8 changes: 4 additions & 4 deletions code/cypress/integration/navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ describe('Routing', () => {
it('should navigate to story addons-a11y-basebutton--default', () => {
visit('official-storybook');

cy.get('#addons-a11y-basebutton--label').click({ force: true });
cy.url().should('include', 'path=/story/addons-a11y-basebutton--label');
cy.get('#addons-controls--basic').click({ force: true });
cy.url().should('include', 'path=/story/addons-controls--basic');
});

it('should directly visit a certain story and render correctly', () => {
visit('official-storybook/?path=/story/addons-a11y-basebutton--label');
visit('official-storybook/?path=/story/basics-actionbar--single-item');

cy.getStoryElement().should('contain.text', 'Testing the a11y addon');
cy.getStoryElement().should('contain.text', 'Clear');
});
});
17 changes: 0 additions & 17 deletions code/examples/ember-cli/stories/addon-a11y.stories.js

This file was deleted.

7 changes: 0 additions & 7 deletions code/examples/html-kitchen-sink/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
export const parameters = {
a11y: {
config: {},
options: {
checks: { 'color-contrast': { options: { noScroll: true } } },
restoreScroll: true,
},
},
docs: {
iframeHeight: '200px',
},
Expand Down

This file was deleted.

27 changes: 0 additions & 27 deletions code/examples/html-kitchen-sink/stories/addon-a11y.stories.js

This file was deleted.

7 changes: 0 additions & 7 deletions code/examples/official-storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,6 @@ export const decorators = [

export const parameters = {
exportedParameter: 'exportedParameter',
a11y: {
config: {},
options: {
checks: { 'color-contrast': { options: { noScroll: true } } },
restoreScroll: true,
},
},
actions: { argTypesRegex: '^on.*' },
options: {
storySort: (a, b) =>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading