index.stories.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import React, { useMemo } from 'react';
  2. import { storiesOf } from '@storybook/react';
  3. import { Button, InputNumber, Form, Dropdown, Tag } from '../../index';
  4. const stories = storiesOf('All', module);
  5. stories.add('simple', () => {
  6. function Demo() {
  7. const subDropdown = useMemo(
  8. () => (
  9. <Dropdown.Menu>
  10. <Dropdown.Item>Menu Item 1</Dropdown.Item>
  11. <Dropdown.Item>Menu Item 2</Dropdown.Item>
  12. <Dropdown.Item>Menu Item 3</Dropdown.Item>
  13. </Dropdown.Menu>
  14. ),
  15. []
  16. );
  17. return (
  18. <>
  19. <div style={{ width: 500 }}>
  20. <Button icon={'edit'} theme={'solid'} />
  21. <InputNumber max={100} min={10} defaultValue={5} />
  22. <Form layout="horizontal">
  23. <Form.Select field="Role" label="角色" style={{ width: 120 }}>
  24. <Form.Select.Option value="admin">管理员</Form.Select.Option>
  25. <Form.Select.Option value="user">普通用户</Form.Select.Option>
  26. <Form.Select.Option value="guest">访客</Form.Select.Option>
  27. </Form.Select>
  28. <Form.Input field="UserName" label="用户名" />
  29. <Form.Input field="Password" label="密码" />
  30. <Form.DatePicker type={'dateRange'} field={'dateRange'} label={'date range'} />
  31. </Form>
  32. <Dropdown
  33. render={
  34. <Dropdown.Menu>
  35. <Dropdown position={'rightTop'} render={subDropdown}>
  36. <Dropdown.Item>Menu Item 1</Dropdown.Item>
  37. </Dropdown>
  38. <Dropdown position={'leftTop'} render={subDropdown}>
  39. <Dropdown.Item>Menu Item 2</Dropdown.Item>
  40. </Dropdown>
  41. <Dropdown.Item>Menu Item 3</Dropdown.Item>
  42. </Dropdown.Menu>
  43. }
  44. >
  45. <Tag>Hover Me</Tag>
  46. </Dropdown>
  47. </div>
  48. </>
  49. );
  50. }
  51. return <Demo />;
  52. });