button.stories.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 {IconDelete} from 'app/icons/iconDelete';
  11. const Item = styled('span')`
  12. padding: 12px;
  13. `;
  14. const WideButton = styled(Button)`
  15. width: 200px;
  16. `;
  17. // eslint-disable-next-line
  18. storiesOf('UI|Buttons', module)
  19. .add(
  20. 'overview',
  21. withInfo({
  22. text: 'An overview of all the different buttons and states',
  23. propTablesExclude: [Item],
  24. })(() => (
  25. <div>
  26. <div className="section">
  27. <h2>Priorities</h2>
  28. <Item>
  29. <Button to="/test" onClick={action('clicked default')}>
  30. Default Button
  31. </Button>
  32. </Item>
  33. <Item>
  34. <Button title="Tooltip" priority="primary" onClick={action('click primary')}>
  35. Primary Button
  36. </Button>
  37. </Item>
  38. <Item>
  39. <Button priority="success" onClick={action('click success')}>
  40. Success Button
  41. </Button>
  42. </Item>
  43. <Item>
  44. <Button priority="danger" onClick={action('click danger')}>
  45. Danger Button
  46. </Button>
  47. </Item>
  48. <Item>
  49. <Button priority="link" onClick={action('click link')}>
  50. Link Button
  51. </Button>
  52. </Item>
  53. <Item>
  54. <Button to="" disabled onClick={action('click disabled')}>
  55. Disabled Button
  56. </Button>
  57. </Item>
  58. </div>
  59. <div className="section">
  60. <h2>Sizes</h2>
  61. <Item>
  62. <Button size="zero" borderless>
  63. Zero
  64. </Button>
  65. </Item>
  66. <Item>
  67. <Button size="xsmall">X Small</Button>
  68. </Item>
  69. <Item>
  70. <Button size="small">Small</Button>
  71. </Item>
  72. <Item>
  73. <Button>Default</Button>
  74. </Item>
  75. </div>
  76. <div className="section">
  77. <h2>Icons</h2>
  78. <div style={{display: 'flex', alignItems: 'center'}}>
  79. <Item>
  80. <Button size="zero" borderless icon={<IconDelete size="xs" />} />
  81. </Item>
  82. <Item>
  83. <Button size="xsmall" icon={<IconDelete size="xs" />}>
  84. X Small
  85. </Button>
  86. </Item>
  87. <Item>
  88. <Button size="small" icon={<IconDelete size="xs" />}>
  89. Small
  90. </Button>
  91. </Item>
  92. <Item>
  93. <Button icon={<IconDelete />}>Default</Button>
  94. </Item>
  95. </div>
  96. </div>
  97. <div className="section">
  98. <h2>Alignment</h2>
  99. <Item>
  100. <WideButton align="left">Aligned left</WideButton>
  101. </Item>
  102. <Item>
  103. <WideButton align="right">Aligned right</WideButton>
  104. </Item>
  105. </div>
  106. <div className="section">
  107. <h2>States (busy/disabled)</h2>
  108. <div style={{display: 'flex', alignItems: 'center'}}>
  109. <Item>
  110. <Button
  111. busy={boolean('Extra Small Busy', true)}
  112. priority="primary"
  113. size="xsmall"
  114. >
  115. Extra Small
  116. </Button>
  117. </Item>
  118. <Item>
  119. <Button busy={boolean('Small Busy', true)} priority="primary" size="small">
  120. Small
  121. </Button>
  122. </Item>
  123. <Item>
  124. <Button busy={boolean('Normal Busy', true)} priority="primary">
  125. Normal
  126. </Button>
  127. </Item>
  128. <Item>
  129. <Button priority="primary" disabled onClick={action('click disabled')}>
  130. Disabled Button
  131. </Button>
  132. </Item>
  133. </div>
  134. </div>
  135. </div>
  136. ))
  137. )
  138. .add(
  139. 'DropdownButton',
  140. withInfo('A button meant to be used with some sort of dropdown')(() => (
  141. <React.Fragment>
  142. <Item>
  143. <DropdownButton isOpen={false}>Closed</DropdownButton>
  144. </Item>
  145. <Item>
  146. <DropdownButton isOpen>Open</DropdownButton>
  147. </Item>
  148. </React.Fragment>
  149. ))
  150. )
  151. .add(
  152. 'ButtonBar',
  153. withInfo('Buttons in a Bar container')(() => (
  154. <div>
  155. <div className="section">
  156. <h3>With a Gap</h3>
  157. <ButtonBar gap={number('button gap', 1)}>
  158. <Button>First Button</Button>
  159. <Button>Second Button</Button>
  160. <Button>Third Button</Button>
  161. </ButtonBar>
  162. </div>
  163. <div className="section">
  164. <h3>Merged Buttons with "active" button</h3>
  165. <ButtonBar active="left" merged>
  166. <Button barId="left">Left Button</Button>
  167. <Button barId="right">Right Button</Button>
  168. </ButtonBar>
  169. </div>
  170. <div className="section">
  171. <h3>Multiple Merged Buttons with "active" button</h3>
  172. <ButtonBar active="2" merged>
  173. <Button barId="1">First Button</Button>
  174. <Button barId="2">Second Button</Button>
  175. <Button barId="3">Third Button</Button>
  176. <Button barId="4">Fourth Button</Button>
  177. </ButtonBar>
  178. </div>
  179. </div>
  180. ))
  181. );