dropdownControl.stories.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import React from 'react';
  2. import {withInfo} from '@storybook/addon-info';
  3. import {text, boolean} from '@storybook/addon-knobs';
  4. import DropdownControl, {DropdownItem} from 'app/components/dropdownControl';
  5. import MenuItem from 'app/components/menuItem';
  6. export default {
  7. title: 'UI/Dropdowns/DropdownControl',
  8. };
  9. export const BasicLabelKnobs = withInfo('Using a string value for the button label')(
  10. () => {
  11. const menuWidth = text('menuWidth', undefined);
  12. const alwaysRenderMenu = boolean('alwaysRenderMenu', true);
  13. const alignRight = boolean('alignRight', false);
  14. const blendWithActor = boolean('blendWithActor', false);
  15. return (
  16. <div className="clearfix">
  17. <DropdownControl
  18. label="Open Me"
  19. menuWidth={menuWidth}
  20. alwaysRenderMenu={alwaysRenderMenu}
  21. alignRight={alignRight}
  22. blendWithActor={blendWithActor}
  23. >
  24. <DropdownItem href="">Href Item</DropdownItem>
  25. <DropdownItem to="">Router Item</DropdownItem>
  26. <DropdownItem disabled>Disabled Item</DropdownItem>
  27. <DropdownItem divider />
  28. <DropdownItem isActive href="">
  29. Active Item
  30. </DropdownItem>
  31. </DropdownControl>
  32. </div>
  33. );
  34. }
  35. );
  36. BasicLabelKnobs.story = {
  37. name: 'basic label + knobs',
  38. };
  39. export const BasicMenuItem = withInfo('Element labels replace the button contents')(
  40. () => (
  41. <div className="clearfix">
  42. <DropdownControl label={<em>Slanty</em>}>
  43. <MenuItem href="">Item</MenuItem>
  44. <MenuItem href="">Item</MenuItem>
  45. </DropdownControl>
  46. </div>
  47. )
  48. );
  49. BasicMenuItem.story = {
  50. name: 'basic menu item',
  51. };
  52. export const ElementLabel = withInfo('Element labels replace the button contents')(() => (
  53. <div className="clearfix">
  54. <DropdownControl label={<em>Created Date</em>}>
  55. <MenuItem href="">Item</MenuItem>
  56. <MenuItem href="">Item</MenuItem>
  57. </DropdownControl>
  58. </div>
  59. ));
  60. ElementLabel.story = {
  61. name: 'element label',
  62. };
  63. export const PrefixedLabel = withInfo('Element labels replace the button contents')(
  64. () => (
  65. <div className="clearfix">
  66. <DropdownControl buttonProps={{prefix: 'Sort By'}} label={<em>Created At</em>}>
  67. <MenuItem href="">Item</MenuItem>
  68. <MenuItem href="">Item</MenuItem>
  69. </DropdownControl>
  70. </div>
  71. )
  72. );
  73. PrefixedLabel.story = {
  74. name: 'prefixed label',
  75. };
  76. export const CustomButton = withInfo('button prop lets you replace the entire button.')(
  77. () => (
  78. <div className="clearfix">
  79. <DropdownControl
  80. button={({getActorProps}) => <button {...getActorProps()}>click me</button>}
  81. >
  82. <MenuItem href="">Item</MenuItem>
  83. <MenuItem href="">Item</MenuItem>
  84. </DropdownControl>
  85. </div>
  86. )
  87. );
  88. CustomButton.story = {
  89. name: 'custom button',
  90. };