dropdownControl.stories.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import React from 'react';
  2. import {storiesOf} from '@storybook/react';
  3. import {withInfo} from '@storybook/addon-info';
  4. import {text, boolean} from '@storybook/addon-knobs';
  5. import DropdownControl from 'app/components/dropdownControl';
  6. import MenuItem from 'app/components/menuItem';
  7. storiesOf('UI|Dropdowns/DropdownControl', module)
  8. .add(
  9. 'basic label + knobs',
  10. withInfo('Using a string value for the button label')(() => {
  11. const menuWidth = text('menuWidth', undefined);
  12. const menuOffset = text('menuOffset', undefined);
  13. const alwaysRenderMenu = boolean('alwaysRenderMenu', true);
  14. return (
  15. <div className="clearfix">
  16. <DropdownControl
  17. label="Open Me"
  18. menuWidth={menuWidth}
  19. menuOffset={menuOffset}
  20. alwaysRenderMenu={alwaysRenderMenu}
  21. >
  22. <MenuItem href="">Item</MenuItem>
  23. <MenuItem href="">Item</MenuItem>
  24. </DropdownControl>
  25. </div>
  26. );
  27. })
  28. )
  29. .add(
  30. 'element label',
  31. withInfo('Element labels replace the button contents')(() => (
  32. <div className="clearfix">
  33. <DropdownControl label={<em>Slanty</em>}>
  34. <MenuItem href="">Item</MenuItem>
  35. <MenuItem href="">Item</MenuItem>
  36. </DropdownControl>
  37. </div>
  38. ))
  39. )
  40. .add(
  41. 'custom button',
  42. withInfo('button prop lets you replace the entire button.')(() => (
  43. <div className="clearfix">
  44. <DropdownControl
  45. button={({isOpen, getActorProps}) => (
  46. <button {...getActorProps()}>click me</button>
  47. )}
  48. >
  49. <MenuItem href="">Item</MenuItem>
  50. <MenuItem href="">Item</MenuItem>
  51. </DropdownControl>
  52. </div>
  53. ))
  54. );