popover.stories.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import React, { useState } from 'react';
  2. import { storiesOf } from '@storybook/react';
  3. import Popover from '../index';
  4. import Button from '../../button';
  5. const stories = storiesOf('popover', module);
  6. const POSITION_SET:string[] = [
  7. 'top',
  8. 'topLeft',
  9. 'topRight',
  10. 'left',
  11. 'leftTop',
  12. 'leftBottom',
  13. 'right',
  14. 'rightTop',
  15. 'rightBottom',
  16. 'bottom',
  17. 'bottomLeft',
  18. 'bottomRight',
  19. 'leftTopOver',
  20. 'rightTopOver',
  21. ]
  22. stories.add('positions', () => (
  23. <div
  24. style={{
  25. width: 480,
  26. height: 360,
  27. boxSizing: 'content-box',
  28. padding: '150px 250px',
  29. display: 'flex',
  30. flexWrap: 'wrap',
  31. justifyContent: 'space-evenly',
  32. }}
  33. >
  34. {POSITION_SET.map((pos:any) => (
  35. <Popover
  36. key={pos}
  37. content={
  38. <div style={{ padding: 20 }}>
  39. <p>Hi Bytedancer!</p>
  40. </div>
  41. }
  42. trigger="click"
  43. position={pos}
  44. >
  45. <Button key={pos}>{pos}</Button>
  46. </Popover>
  47. ))}
  48. </div>
  49. ));