dropdownControl.stories.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import DropdownControl, {DropdownItem} from 'sentry/components/dropdownControl';
  2. import MenuItem from 'sentry/components/menuItem';
  3. export default {
  4. title: 'Components/Buttons/Dropdowns/Dropdown Control',
  5. };
  6. export const BasicLabelKnobs = ({
  7. menuWidth,
  8. alwaysRenderMenu,
  9. alignRight,
  10. blendWithActor,
  11. }) => {
  12. return (
  13. <div className="clearfix">
  14. <DropdownControl
  15. label="Open Me"
  16. menuWidth={menuWidth}
  17. alwaysRenderMenu={alwaysRenderMenu}
  18. alignRight={alignRight}
  19. blendWithActor={blendWithActor}
  20. >
  21. <DropdownItem href="">Href Item</DropdownItem>
  22. <DropdownItem to="">Router Item</DropdownItem>
  23. <DropdownItem disabled>Disabled Item</DropdownItem>
  24. <DropdownItem divider />
  25. <DropdownItem isActive href="">
  26. Active Item
  27. </DropdownItem>
  28. </DropdownControl>
  29. </div>
  30. );
  31. };
  32. BasicLabelKnobs.storyName = 'Basic Label + Knobs';
  33. BasicLabelKnobs.args = {
  34. menuWidth: '',
  35. alwaysRenderMenu: true,
  36. alignRight: false,
  37. blendWithActor: false,
  38. };
  39. BasicLabelKnobs.parameters = {
  40. docs: {
  41. description: {
  42. story: 'Using a string value for the button label',
  43. },
  44. },
  45. };
  46. export const BasicMenuItem = () => (
  47. <div className="clearfix">
  48. <DropdownControl label={<em>Slanty</em>}>
  49. <MenuItem href="">Item</MenuItem>
  50. <MenuItem href="">Item</MenuItem>
  51. </DropdownControl>
  52. </div>
  53. );
  54. BasicMenuItem.storyName = 'Basic Menu Item';
  55. BasicMenuItem.parameters = {
  56. docs: {
  57. description: {
  58. story: 'Element labels replace the button contents',
  59. },
  60. },
  61. };
  62. export const ElementLabel = () => (
  63. <div className="clearfix">
  64. <DropdownControl label="Created Date">
  65. <MenuItem href="">Item</MenuItem>
  66. <MenuItem href="">Item</MenuItem>
  67. </DropdownControl>
  68. </div>
  69. );
  70. ElementLabel.storyName = 'Element Label';
  71. ElementLabel.parameters = {
  72. docs: {
  73. description: {
  74. story: 'Element labels replace the button contents',
  75. },
  76. },
  77. };
  78. export const PrefixedLabel = () => (
  79. <div className="clearfix">
  80. <DropdownControl buttonProps={{prefix: 'Sort By'}} label="Created Date">
  81. <MenuItem href="">Item</MenuItem>
  82. <MenuItem href="">Item</MenuItem>
  83. </DropdownControl>
  84. </div>
  85. );
  86. PrefixedLabel.storyName = 'Prefixed Label';
  87. PrefixedLabel.parameters = {
  88. docs: {
  89. description: {
  90. story: 'Element labels replace the button contents',
  91. },
  92. },
  93. };
  94. export const CustomButton = () => (
  95. <div className="clearfix">
  96. <DropdownControl
  97. button={({getActorProps}) => <button {...getActorProps()}>click me</button>}
  98. >
  99. <MenuItem href="">Item</MenuItem>
  100. <MenuItem href="">Item</MenuItem>
  101. </DropdownControl>
  102. </div>
  103. );
  104. CustomButton.storyName = 'Custom Button';
  105. CustomButton.parameters = {
  106. docs: {
  107. description: {
  108. story: 'button prop lets you replace the entire button.',
  109. },
  110. },
  111. };