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

48 lines
1.1 KiB
Plaintext

```ts
// Button.stories.ts
import Button from './Button.vue';
import type { Meta, StoryObj } from '@storybook/vue';
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, { argTypes }) => ({
components: { Button },
props: Object.keys(argTypes),
template: '<Button v-bind="$props" v-on="$props" />',
}),
args: {
primary: false,
label: 'Button',
},
};
// This is not
export const Inaccessible: Story = {
render: (args, { argTypes }) => ({
components: { Button },
props: Object.keys(argTypes),
template: '<Button v-bind="$props" v-on="$props" />',
}),
args: {
...Accessible.args,
backgroundColor: 'red',
},
};
```