storybook/docs/snippets/vue/component-story-with-accessibility.ts-3.ts.mdx
2023-01-16 12:58:08 +00:00

52 lines
1.0 KiB
Plaintext

```ts
// Button.stories.ts
import Button from './Button.vue';
import type { Meta, StoryObj } from '@storybook/vue3';
const meta: Meta<typeof Button> = {
/* 👇 The title prop is optional.
* See https://storybook.js.org/docs/7.0/vue/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Accessibility testing',
component: Button,
argTypes: {
backgroundColor: { control: 'color' },
},
};
export default meta;
type Story = StoryObj<typeof Button>;
// This is an accessible story
export const Accessible: Story = {
render: (args) => ({
components: { Button },
setup() {
return { args };
},
template: '<Button v-bind="args" />',
}),
args: {
primary: false,
label: 'Button',
},
};
// This is not
export const Inaccessible: Story = {
render: (args) => ({
components: { Button },
setup() {
return { args };
},
template: '<Button v-bind="args" />',
}),
args: {
...Accessible.args,
backgroundColor: 'red',
},
};
```