button.stories.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import React from 'react';
  2. import styled from 'react-emotion';
  3. import {storiesOf} from '@storybook/react';
  4. import {withInfo} from '@storybook/addon-info';
  5. import {action} from '@storybook/addon-actions';
  6. import {boolean} from '@storybook/addon-knobs';
  7. import Button from 'app/components/button';
  8. import DropdownButton from 'app/components/dropdownButton';
  9. const Item = styled('span')`
  10. padding: 12px;
  11. `;
  12. const Section = styled('div')`
  13. margin-bottom: 32px;
  14. `;
  15. // eslint-disable-next-line
  16. storiesOf('UI|Buttons', module)
  17. .add(
  18. 'overview',
  19. withInfo({
  20. text: 'An overview of all the different buttons and states',
  21. propTablesExclude: [Item, Section],
  22. })(() => (
  23. <div>
  24. <Section>
  25. <h2>Priorities</h2>
  26. <Item>
  27. <Button to="/test" onClick={action('clicked default')}>
  28. Default Button
  29. </Button>
  30. </Item>
  31. <Item>
  32. <Button title="Tooltip" priority="primary" onClick={action('click primary')}>
  33. Primary Button
  34. </Button>
  35. </Item>
  36. <Item>
  37. <Button priority="success" onClick={action('click success')}>
  38. Success Button
  39. </Button>
  40. </Item>
  41. <Item>
  42. <Button priority="danger" onClick={action('click danger')}>
  43. Danger Button
  44. </Button>
  45. </Item>
  46. <Item>
  47. <Button to={''} disabled onClick={action('click disabled')}>
  48. Disabled Button
  49. </Button>
  50. </Item>
  51. </Section>
  52. <Section>
  53. <h2>Sizes</h2>
  54. <Item>
  55. <Button size="xsmall">Extra Small</Button>
  56. </Item>
  57. <Item>
  58. <Button size="small">Small</Button>
  59. </Item>
  60. <Item>
  61. <Button>Normal</Button>
  62. </Item>
  63. <Item>
  64. <Button size="large">Large</Button>
  65. </Item>
  66. </Section>
  67. <Section>
  68. <h2>Icons</h2>
  69. <div style={{display: 'flex', alignItems: 'center'}}>
  70. <Item>
  71. <Button icon="icon-github">View on GitHub</Button>
  72. </Item>
  73. <Item>
  74. <Button size="small" icon="icon-github">
  75. View on GitHub
  76. </Button>
  77. </Item>
  78. </div>
  79. </Section>
  80. <Section>
  81. <h2>States (busy/disabled)</h2>
  82. <div style={{display: 'flex', alignItems: 'center'}}>
  83. <Item>
  84. <Button
  85. busy={boolean('Extra Small Busy', true)}
  86. priority="primary"
  87. size="xsmall"
  88. >
  89. Extra Small
  90. </Button>
  91. </Item>
  92. <Item>
  93. <Button busy={boolean('Small Busy', true)} priority="primary" size="small">
  94. Small
  95. </Button>
  96. </Item>
  97. <Item>
  98. <Button busy={boolean('Normal Busy', true)} priority="primary">
  99. Normal
  100. </Button>
  101. </Item>
  102. <Item>
  103. <Button busy={boolean('Large Busy', true)} priority="primary" size="large">
  104. Large
  105. </Button>
  106. </Item>
  107. <Item>
  108. <Button priority="primary" disabled onClick={action('click disabled')}>
  109. Disabled Button
  110. </Button>
  111. </Item>
  112. </div>
  113. </Section>
  114. </div>
  115. ))
  116. )
  117. .add(
  118. 'DropdownButton',
  119. withInfo('A button meant to be used with some sort of dropdown')(() => (
  120. <React.Fragment>
  121. <Item>
  122. <DropdownButton isOpen={false}>Closed</DropdownButton>
  123. </Item>
  124. <Item>
  125. <DropdownButton isOpen={true}>Open</DropdownButton>
  126. </Item>
  127. </React.Fragment>
  128. ))
  129. );