button.stories.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. import React from 'react';
  2. import styled from '@emotion/styled';
  3. import {storiesOf} from '@storybook/react';
  4. import {withInfo} from '@storybook/addon-info';
  5. import {action} from '@storybook/addon-actions';
  6. import {boolean, number} from '@storybook/addon-knobs';
  7. import Button from 'app/components/button';
  8. import ButtonBar from 'app/components/buttonBar';
  9. import DropdownButton from 'app/components/dropdownButton';
  10. import InlineSvg from 'app/components/inlineSvg';
  11. import space from 'app/styles/space';
  12. const Item = styled('span')`
  13. padding: 12px;
  14. `;
  15. const Section = styled('div')`
  16. margin-bottom: 32px;
  17. `;
  18. const WideButton = styled(Button)`
  19. width: 200px;
  20. `;
  21. // eslint-disable-next-line
  22. storiesOf('UI|Buttons', module)
  23. .add(
  24. 'overview',
  25. withInfo({
  26. text: 'An overview of all the different buttons and states',
  27. propTablesExclude: [Item, Section],
  28. })(() => (
  29. <div>
  30. <Section>
  31. <h2>Priorities</h2>
  32. <Item>
  33. <Button to="/test" onClick={action('clicked default')}>
  34. Default Button
  35. </Button>
  36. </Item>
  37. <Item>
  38. <Button title="Tooltip" priority="primary" onClick={action('click primary')}>
  39. Primary Button
  40. </Button>
  41. </Item>
  42. <Item>
  43. <Button priority="success" onClick={action('click success')}>
  44. Success Button
  45. </Button>
  46. </Item>
  47. <Item>
  48. <Button priority="danger" onClick={action('click danger')}>
  49. Danger Button
  50. </Button>
  51. </Item>
  52. <Item>
  53. <Button to="" disabled onClick={action('click disabled')}>
  54. Disabled Button
  55. </Button>
  56. </Item>
  57. </Section>
  58. <Section>
  59. <h2>Sizes</h2>
  60. <Item>
  61. <Button size="micro">Micro</Button>
  62. </Item>
  63. <Item>
  64. <Button size="zero">Zero</Button>
  65. </Item>
  66. <Item>
  67. <Button size="xxsmall">Extra Extra Small</Button>
  68. </Item>
  69. <Item>
  70. <Button size="xsmall">Extra Small</Button>
  71. </Item>
  72. <Item>
  73. <Button size="small">Small</Button>
  74. </Item>
  75. <Item>
  76. <Button>Normal</Button>
  77. </Item>
  78. <Item>
  79. <Button size="large">Large</Button>
  80. </Item>
  81. </Section>
  82. <Section>
  83. <h2>Alignment</h2>
  84. <Item>
  85. <WideButton align="left">Aligned left</WideButton>
  86. </Item>
  87. <Item>
  88. <WideButton align="right">Aligned right</WideButton>
  89. </Item>
  90. </Section>
  91. <Section>
  92. <h2>Icons</h2>
  93. <div style={{display: 'flex', alignItems: 'center'}}>
  94. <Item>
  95. <Button>
  96. <InlineSvg
  97. src="icon-github"
  98. size="14"
  99. style={{marginRight: space(0.5)}}
  100. />
  101. Not-icon-props Button
  102. </Button>
  103. </Item>
  104. <Item>
  105. <Button icon="icon-github">Icon Button</Button>
  106. </Item>
  107. <Item>
  108. <Button size="small" icon="icon-github">
  109. View on GitHub
  110. </Button>
  111. </Item>
  112. <Item>
  113. <Button size="micro" icon="icon-trash" />
  114. </Item>
  115. <Item>
  116. <Button size="zero" icon="icon-trash" />
  117. </Item>
  118. <Item>
  119. <Button size="xxsmall" icon="icon-trash" />
  120. </Item>
  121. <Item>
  122. <Button size="xsmall" icon="icon-trash" />
  123. </Item>
  124. <Item>
  125. <Button size="small" icon="icon-trash" />
  126. </Item>
  127. <Item>
  128. <Button icon="icon-trash" />
  129. </Item>
  130. <Item>
  131. <Button size="large" icon="icon-trash" />
  132. </Item>
  133. </div>
  134. </Section>
  135. <Section>
  136. <h2>States (busy/disabled)</h2>
  137. <div style={{display: 'flex', alignItems: 'center'}}>
  138. <Item>
  139. <Button
  140. busy={boolean('Extra Small Busy', true)}
  141. priority="primary"
  142. size="xsmall"
  143. >
  144. Extra Small
  145. </Button>
  146. </Item>
  147. <Item>
  148. <Button busy={boolean('Small Busy', true)} priority="primary" size="small">
  149. Small
  150. </Button>
  151. </Item>
  152. <Item>
  153. <Button busy={boolean('Normal Busy', true)} priority="primary">
  154. Normal
  155. </Button>
  156. </Item>
  157. <Item>
  158. <Button busy={boolean('Large Busy', true)} priority="primary" size="large">
  159. Large
  160. </Button>
  161. </Item>
  162. <Item>
  163. <Button priority="primary" disabled onClick={action('click disabled')}>
  164. Disabled Button
  165. </Button>
  166. </Item>
  167. </div>
  168. </Section>
  169. </div>
  170. ))
  171. )
  172. .add(
  173. 'DropdownButton',
  174. withInfo('A button meant to be used with some sort of dropdown')(() => (
  175. <React.Fragment>
  176. <Item>
  177. <DropdownButton isOpen={false}>Closed</DropdownButton>
  178. </Item>
  179. <Item>
  180. <DropdownButton isOpen>Open</DropdownButton>
  181. </Item>
  182. </React.Fragment>
  183. ))
  184. )
  185. .add(
  186. 'ButtonBar',
  187. withInfo('Buttons in a Bar container')(() => (
  188. <div>
  189. <Section>
  190. <h3>With a Gap</h3>
  191. <ButtonBar gap={number('button gap', 1)}>
  192. <Button>First Button</Button>
  193. <Button>Second Button</Button>
  194. <Button>Third Button</Button>
  195. </ButtonBar>
  196. </Section>
  197. <Section>
  198. <h3>Merged Buttons</h3>
  199. <ButtonBar merged>
  200. <Button>Left Button</Button>
  201. <Button priority="primary">Right Button</Button>
  202. </ButtonBar>
  203. </Section>
  204. <Section>
  205. <h3>Multiple Merged Buttons</h3>
  206. <ButtonBar merged>
  207. <Button>First Button</Button>
  208. <Button>Second Button</Button>
  209. <Button>Third Button</Button>
  210. <Button>Fourth Button</Button>
  211. </ButtonBar>
  212. </Section>
  213. </div>
  214. ))
  215. );