fbredius/storybook

View on GitHub
docs/snippets/angular/component-story-with-accessibility.ts.mdx

Summary

Maintainability
Test Coverage
```ts
// Button.stories.ts

import { Meta, Story } from '@storybook/angular';

import { Button } from './Button.component';

export default {
  /* 👇 The title prop is optional.
  * See https://storybook.js.org/docs/angular/configure/overview#configure-story-loading to learn how to generate automatic titles
  */
  title: 'Accessibility testing',
  component: Button,
  argTypes: {
    backgroundColor: { control: 'color' },
  },
} as Meta;

const Template: Story = (args) => ({
  props: args,
});

export const Accessible: Story = Template.bind({});
Accessible.args = {
  primary: false,
  label: 'Button',
};

export const Inaccessible: Story = Template.bind({});
Inaccessible.args = {
  ...Accessible.args,
  backgroundColor: 'red',
};
```