Skip to content

Commit

Permalink
docs(Form): add storybook story
Browse files Browse the repository at this point in the history
  • Loading branch information
eugpoloz committed Apr 7, 2023
1 parent e72fa37 commit b349469
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions packages/vkui/src/components/Form/Form.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import { Meta, Story } from '@storybook/react';
import { withSinglePanel, withVKUILayout } from '../../storybook/VKUIDecorators';
import { CanvasFullLayout, DisableCartesianParam } from '../../storybook/constants';
import { Button } from '../Button/Button';
import { FormItem } from '../FormItem/FormItem';
import { Group } from '../Group/Group';
import { Input } from '../Input/Input';
import { Form, FormProps } from './Form';

const story: Meta<FormProps> = {
title: 'Forms/Form',
component: Form,
parameters: { ...CanvasFullLayout, ...DisableCartesianParam },
};

export default story;

const Template: Story<FormProps> = (props) => (
<Form {...props}>
<FormItem top="Пароль">
<Input type="password" placeholder="Введите пароль" />
</FormItem>
<FormItem>
<Button type="submit" size="l">
Сохранить
</Button>
</FormItem>
</Form>
);

export const Playground = Template.bind({});
Playground.args = {
preventDefault: true,
onSubmit: () => {
console.log('Форма сохранена!');
},
};
Playground.decorators = [
(Component, context) => (
<Group>
<Component {...context.args} />
</Group>
),
withSinglePanel,
withVKUILayout,
];

0 comments on commit b349469

Please sign in to comment.