imbric-theme 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/.babelrc.json +3 -0
  2. package/.commitlintrc.json +3 -0
  3. package/.editorconfig +13 -0
  4. package/.eslintcache +1 -0
  5. package/.eslintrc.json +36 -0
  6. package/.huskyrc.json +6 -0
  7. package/.lintstagedrc.json +5 -0
  8. package/.nvmrc +1 -0
  9. package/.prettierrc.json +4 -0
  10. package/.releaserc.json +13 -0
  11. package/.storybook/main.js +9 -0
  12. package/.storybook/preview-head.html +2 -0
  13. package/.storybook/preview.js +32 -0
  14. package/.stylelintrc.json +14 -0
  15. package/.vscode/launch.json +15 -0
  16. package/CHANGELOG.md +0 -0
  17. package/README.md +69 -0
  18. package/atoms/Avatar/Avatar.js +36 -0
  19. package/atoms/Avatar/Avatar.module.css +3 -0
  20. package/atoms/Avatar/Avatar.stories.js +29 -0
  21. package/atoms/Avatar/__snapshots__/Avatar.stories.js.snap +105 -0
  22. package/atoms/Avatar/constants.js +3 -0
  23. package/atoms/Avatar/helpers.js +7 -0
  24. package/atoms/Avatar/index.js +3 -0
  25. package/atoms/Button/Button.js +68 -0
  26. package/atoms/Button/Button.module.css +63 -0
  27. package/atoms/Button/Button.stories.js +47 -0
  28. package/atoms/Button/Button.test.js +60 -0
  29. package/atoms/Button/__snapshots__/Button.stories.js.snap +191 -0
  30. package/atoms/Button/constants.js +3 -0
  31. package/atoms/Button/index.js +3 -0
  32. package/atoms/Card/Card.js +48 -0
  33. package/atoms/Card/Card.module.css +52 -0
  34. package/atoms/Card/Card.stories.js +41 -0
  35. package/atoms/Card/__snapshots__/Card.stories.js.snap +136 -0
  36. package/atoms/Card/constants.js +4 -0
  37. package/atoms/Card/index.js +3 -0
  38. package/atoms/Check/Check.js +26 -0
  39. package/atoms/Check/Check.module.css +11 -0
  40. package/atoms/Check/Check.stories.js +15 -0
  41. package/atoms/Check/__snapshots__/Check.stories.js.snap +67 -0
  42. package/atoms/Check/index.js +2 -0
  43. package/atoms/Divider/Divider.js +19 -0
  44. package/atoms/Divider/Divider.module.css +5 -0
  45. package/atoms/Divider/Divider.stories.js +12 -0
  46. package/atoms/Divider/__snapshots__/Divider.stories.js.snap +22 -0
  47. package/atoms/Divider/index.js +2 -0
  48. package/atoms/Heading/Heading.js +37 -0
  49. package/atoms/Heading/Heading.module.css +66 -0
  50. package/atoms/Heading/Heading.stories.js +46 -0
  51. package/atoms/Heading/__snapshots__/Heading.stories.js.snap +189 -0
  52. package/atoms/Heading/constants.js +5 -0
  53. package/atoms/Heading/index.js +3 -0
  54. package/atoms/Icon/Icon.js +66 -0
  55. package/atoms/Icon/Icon.module.css +112 -0
  56. package/atoms/Icon/Icon.stories.js +48 -0
  57. package/atoms/Icon/__snapshots__/Icon.stories.js.snap +1311 -0
  58. package/atoms/Icon/constants.js +486 -0
  59. package/atoms/Icon/helpers.js +9 -0
  60. package/atoms/Icon/index.js +3 -0
  61. package/atoms/Input/Input.js +49 -0
  62. package/atoms/Input/Input.module.css +27 -0
  63. package/atoms/Input/Input.stories.js +32 -0
  64. package/atoms/Input/__snapshots__/Input.stories.js.snap +101 -0
  65. package/atoms/Input/constants.js +3 -0
  66. package/atoms/Input/index.js +3 -0
  67. package/atoms/Link/Link.js +33 -0
  68. package/atoms/Link/Link.module.css +14 -0
  69. package/atoms/Link/Link.stories.js +30 -0
  70. package/atoms/Link/__snapshots__/Link.stories.js.snap +118 -0
  71. package/atoms/Link/constants.js +5 -0
  72. package/atoms/Link/index.js +3 -0
  73. package/atoms/Loading/Loading.js +30 -0
  74. package/atoms/Loading/Loading.module.css +51 -0
  75. package/atoms/Loading/Loading.stories.js +17 -0
  76. package/atoms/Loading/__snapshots__/Loading.stories.js.snap +26 -0
  77. package/atoms/Loading/index.js +2 -0
  78. package/atoms/Modal/Modal.js +98 -0
  79. package/atoms/Modal/Modal.module.css +85 -0
  80. package/atoms/Modal/Modal.stories.js +43 -0
  81. package/atoms/Modal/__snapshots__/Modal.stories.js.snap +239 -0
  82. package/atoms/Modal/constants.js +1 -0
  83. package/atoms/Modal/index.js +3 -0
  84. package/atoms/Paragraph/Paragraph.js +56 -0
  85. package/atoms/Paragraph/Paragraph.module.css +68 -0
  86. package/atoms/Paragraph/Paragraph.stories.js +52 -0
  87. package/atoms/Paragraph/__snapshots__/Paragraph.stories.js.snap +230 -0
  88. package/atoms/Paragraph/constants.js +5 -0
  89. package/atoms/Paragraph/index.js +3 -0
  90. package/atoms/Picture/Picture.js +40 -0
  91. package/atoms/Picture/Picture.module.css +16 -0
  92. package/atoms/Picture/Picture.stories.js +32 -0
  93. package/atoms/Picture/__snapshots__/Picture.stories.js.snap +156 -0
  94. package/atoms/Picture/index.js +2 -0
  95. package/atoms/Textarea/Textarea.js +46 -0
  96. package/atoms/Textarea/Textarea.module.css +25 -0
  97. package/atoms/Textarea/Textarea.stories.js +16 -0
  98. package/atoms/Textarea/__snapshots__/Textarea.stories.js.snap +25 -0
  99. package/atoms/Textarea/index.js +2 -0
  100. package/codecov.yml +2 -0
  101. package/helpers/storybook.js +29 -0
  102. package/helpers/storybook.test.js +40 -0
  103. package/helpers/styles.js +37 -0
  104. package/helpers/styles.test.js +222 -0
  105. package/hocs/withStyles.js +17 -0
  106. package/hook/useMedia.js +22 -0
  107. package/index.js +31 -0
  108. package/jest.config.js +23 -0
  109. package/jest.setup.js +13 -0
  110. package/layout/CenteredContent/CenteredContent.js +30 -0
  111. package/layout/CenteredContent/CenteredContent.module.css +12 -0
  112. package/layout/CenteredContent/CenteredContent.stories.js +22 -0
  113. package/layout/CenteredContent/__snapshots__/CenteredContent.stories.js.snap +27 -0
  114. package/layout/CenteredContent/index.js +2 -0
  115. package/layout/Container/Container.js +29 -0
  116. package/layout/Container/Container.module.css +14 -0
  117. package/layout/Container/Container.stories.js +22 -0
  118. package/layout/Container/__snapshots__/Container.stories.js.snap +27 -0
  119. package/layout/Container/index.js +2 -0
  120. package/layout/FullHeightContent/FullHeightContent.js +40 -0
  121. package/layout/FullHeightContent/FullHeightContent.module.css +21 -0
  122. package/layout/FullHeightContent/FullHeightContent.stories.js +22 -0
  123. package/layout/FullHeightContent/__snapshots__/FullHeightContent.stories.js.snap +41 -0
  124. package/layout/FullHeightContent/index.js +2 -0
  125. package/layout/Spacer/Spacer.js +40 -0
  126. package/layout/Spacer/Spacer.module.css +12 -0
  127. package/layout/Spacer/Spacer.stories.js +25 -0
  128. package/layout/Spacer/__snapshots__/Spacer.stories.js.snap +97 -0
  129. package/layout/Spacer/components/Horizontal/Horizontal.js +43 -0
  130. package/layout/Spacer/components/Horizontal/Horizontal.stories.js +32 -0
  131. package/layout/Spacer/components/Horizontal/__snapshots__/Horizontal.stories.js.snap +97 -0
  132. package/layout/Spacer/components/Horizontal/index.js +1 -0
  133. package/layout/Spacer/components/Vertical/Vertical.js +31 -0
  134. package/layout/Spacer/components/Vertical/Vertical.stories.js +25 -0
  135. package/layout/Spacer/components/Vertical/__snapshots__/Vertical.stories.js.snap +85 -0
  136. package/layout/Spacer/components/Vertical/index.js +1 -0
  137. package/layout/Spacer/components/index.js +2 -0
  138. package/layout/Spacer/constants.js +5 -0
  139. package/layout/Spacer/helpers.js +3 -0
  140. package/layout/Spacer/index.js +3 -0
  141. package/molecules/Accordion/Accordion.js +70 -0
  142. package/molecules/Accordion/Accordion.module.css +12 -0
  143. package/molecules/Accordion/Accordion.stories.js +31 -0
  144. package/molecules/Accordion/__snapshots__/Accordion.stories.js.snap +228 -0
  145. package/molecules/Accordion/index.js +2 -0
  146. package/molecules/AddButton/AddButton.js +137 -0
  147. package/molecules/AddButton/AddButton.module.css +128 -0
  148. package/molecules/AddButton/AddButton.stories.js +47 -0
  149. package/molecules/AddButton/__snapshots__/AddButton.stories.js.snap +326 -0
  150. package/molecules/AddButton/constants.js +6 -0
  151. package/molecules/AddButton/handlers.js +58 -0
  152. package/molecules/AddButton/handlers.test.js +19 -0
  153. package/molecules/AddButton/helpers.js +6 -0
  154. package/molecules/AddButton/helpers.test.js +41 -0
  155. package/molecules/AddButton/hooks.js +14 -0
  156. package/molecules/AddButton/index.js +3 -0
  157. package/molecules/ButtonIcon/ButtonIcon.js +41 -0
  158. package/molecules/ButtonIcon/ButtonIcon.stories.js +27 -0
  159. package/molecules/ButtonIcon/__snapshots__/ButtonIcon.stories.js.snap +178 -0
  160. package/molecules/ButtonIcon/constants.js +6 -0
  161. package/molecules/ButtonIcon/index.js +2 -0
  162. package/molecules/Dropdown/Dropdown.js +59 -0
  163. package/molecules/Dropdown/Dropdown.module.css +34 -0
  164. package/molecules/Dropdown/Dropdown.stories.js +41 -0
  165. package/molecules/Dropdown/__snapshots__/Dropdown.stories.js.snap +181 -0
  166. package/molecules/Dropdown/index.js +2 -0
  167. package/molecules/Error/Error.js +35 -0
  168. package/molecules/Error/Error.module.css +11 -0
  169. package/molecules/Error/Error.stories.js +18 -0
  170. package/molecules/Error/__snapshots__/Error.stories.js.snap +134 -0
  171. package/molecules/Error/index.js +2 -0
  172. package/molecules/IconLabel/IconLabel.js +83 -0
  173. package/molecules/IconLabel/IconLabel.module.css +16 -0
  174. package/molecules/IconLabel/IconLabel.stories.js +25 -0
  175. package/molecules/IconLabel/__snapshots__/IconLabel.stories.js.snap +211 -0
  176. package/molecules/IconLabel/constants.js +6 -0
  177. package/molecules/IconLabel/index.js +3 -0
  178. package/molecules/LoadingError/LoadingError.js +31 -0
  179. package/molecules/LoadingError/LoadingError.stories.js +24 -0
  180. package/molecules/LoadingError/__snapshots__/LoadingError.stories.js.snap +109 -0
  181. package/molecules/LoadingError/index.js +1 -0
  182. package/molecules/Score/Score.js +61 -0
  183. package/molecules/Score/Score.module.css +11 -0
  184. package/molecules/Score/Score.stories.js +13 -0
  185. package/molecules/Score/__snapshots__/Score.stories.js.snap +100 -0
  186. package/molecules/Score/faces/happy.svg +7 -0
  187. package/molecules/Score/faces/normal.svg +6 -0
  188. package/molecules/Score/faces/sad.svg +6 -0
  189. package/molecules/Score/index.js +2 -0
  190. package/molecules/Task/Task.js +114 -0
  191. package/molecules/Task/Task.module.css +47 -0
  192. package/molecules/Task/Task.stories.js +47 -0
  193. package/molecules/Task/__snapshots__/Task.stories.js.snap +953 -0
  194. package/molecules/Task/constants.js +1 -0
  195. package/molecules/Task/index.js +3 -0
  196. package/molecules/TaskCounter/TaskCounter.js +74 -0
  197. package/molecules/TaskCounter/TaskCounter.module.css +11 -0
  198. package/molecules/TaskCounter/TaskCounter.stories.js +26 -0
  199. package/molecules/TaskCounter/__snapshots__/TaskCounter.stories.js.snap +177 -0
  200. package/molecules/TaskCounter/index.js +2 -0
  201. package/package.json +102 -0
  202. package/scripts/build-tokens.js +40 -0
  203. package/scripts/create-component.js +127 -0
  204. package/storybook.test.js +13 -0
  205. package/styles/globals.css +10 -0
  206. package/styles/tokens.css +390 -0
  207. package/templates/component/Component.js +22 -0
  208. package/templates/component/Component.module.css +3 -0
  209. package/templates/component/Component.stories.js +23 -0
  210. package/templates/component/constants.js +1 -0
  211. package/templates/component/index.js +3 -0
  212. package/tokens/Token/Helper.js +30 -0
  213. package/tokens/Token/Token.js +13 -0
  214. package/tokens/Token/Token.module.css +64 -0
  215. package/tokens/Token/components/Color.js +21 -0
  216. package/tokens/Token/components/Color.stories.js +126 -0
  217. package/tokens/Token/components/FontFamily.js +24 -0
  218. package/tokens/Token/components/FontFamily.stories.js +32 -0
  219. package/tokens/Token/components/FontSize.js +24 -0
  220. package/tokens/Token/components/FontSize.stories.js +31 -0
  221. package/tokens/Token/components/FontWeight.js +24 -0
  222. package/tokens/Token/components/FontWeight.stories.js +31 -0
  223. package/tokens/Token/components/Spacing.js +24 -0
  224. package/tokens/Token/components/Spacing.stories.js +29 -0
  225. package/tokens/Token/components/__snapshots__/Color.stories.js.snap +7169 -0
  226. package/tokens/Token/components/__snapshots__/FontFamily.stories.js.snap +133 -0
  227. package/tokens/Token/components/__snapshots__/FontSize.stories.js.snap +261 -0
  228. package/tokens/Token/components/__snapshots__/FontWeight.stories.js.snap +317 -0
  229. package/tokens/Token/components/__snapshots__/Spacing.stories.js.snap +229 -0
  230. package/tokens/Token/components/index.js +5 -0
  231. package/tokens/Token/helpers.js +17 -0
  232. package/tokens/Token/index.js +1 -0
  233. package/tokens/index.js +471 -0
  234. package/utils/isEmpty.js +28 -0
  235. package/utils/isEmpty.test.js +125 -0
  236. package/utils/isObject.js +4 -0
  237. package/utils/keyboardCodes.js +6 -0
  238. package/utils/testUtils/matchMediaMock.js +14 -0
  239. package/utils/testUtils/svgrMock.js +2 -0
  240. package/utils/toCapitalize.js +4 -0
  241. package/utils/toKebabCase.js +8 -0
  242. package/utils/toPascalCase.js +20 -0
  243. package/webpack/cssModules.js +30 -0
  244. package/webpack/loadConfigs.js +6 -0
  245. package/webpack/reactInlineSvg.js +22 -0
@@ -0,0 +1,105 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Storyshots Atoms/Avatar Default 1`] = `
4
+ <div
5
+ style={
6
+ Object {
7
+ "alignContent": "flex-start",
8
+ "display": "flex",
9
+ "flexDirection": "row",
10
+ "flexWrap": "wrap",
11
+ "gap": "10px 30px",
12
+ "height": "100%",
13
+ "justifyContent": "flex-start",
14
+ "maxHeight": "auto",
15
+ }
16
+ }
17
+ >
18
+ <div
19
+ className="avatar"
20
+ >
21
+ <picture
22
+ className="picture is-rounded with-border"
23
+ >
24
+ <img
25
+ src="https://picsum.photos/id/1027/200/200"
26
+ style={
27
+ Object {
28
+ "height": 44,
29
+ "maxWidth": 44,
30
+ }
31
+ }
32
+ />
33
+ </picture>
34
+ </div>
35
+ </div>
36
+ `;
37
+
38
+ exports[`Storyshots Atoms/Avatar Sizes 1`] = `
39
+ <div
40
+ style={
41
+ Object {
42
+ "alignContent": "flex-start",
43
+ "display": "flex",
44
+ "flexDirection": "row",
45
+ "flexWrap": "wrap",
46
+ "gap": "10px 30px",
47
+ "height": "100%",
48
+ "justifyContent": "flex-start",
49
+ "maxHeight": "auto",
50
+ }
51
+ }
52
+ >
53
+ <div
54
+ className="avatar"
55
+ >
56
+ <picture
57
+ className="picture is-rounded with-border"
58
+ >
59
+ <img
60
+ src="https://picsum.photos/id/1027/200/200"
61
+ style={
62
+ Object {
63
+ "height": 22,
64
+ "maxWidth": 22,
65
+ }
66
+ }
67
+ />
68
+ </picture>
69
+ </div>
70
+ <div
71
+ className="avatar"
72
+ >
73
+ <picture
74
+ className="picture is-rounded with-border"
75
+ >
76
+ <img
77
+ src="https://picsum.photos/id/1027/200/200"
78
+ style={
79
+ Object {
80
+ "height": 44,
81
+ "maxWidth": 44,
82
+ }
83
+ }
84
+ />
85
+ </picture>
86
+ </div>
87
+ <div
88
+ className="avatar"
89
+ >
90
+ <picture
91
+ className="picture is-rounded with-border"
92
+ >
93
+ <img
94
+ src="https://picsum.photos/id/1027/200/200"
95
+ style={
96
+ Object {
97
+ "height": 66,
98
+ "maxWidth": 66,
99
+ }
100
+ }
101
+ />
102
+ </picture>
103
+ </div>
104
+ </div>
105
+ `;
@@ -0,0 +1,3 @@
1
+ export const options = {
2
+ sizes: ['sm', 'md', 'lg'],
3
+ }
@@ -0,0 +1,7 @@
1
+ const avatarSize = {
2
+ sm: 22,
3
+ md: 44,
4
+ lg: 66,
5
+ }
6
+
7
+ export const mapSize = (size) => avatarSize[size]
@@ -0,0 +1,3 @@
1
+ export { default, Avatar } from './Avatar'
2
+ export { options } from './constants'
3
+ export { default as styles } from './Avatar.module.css'
@@ -0,0 +1,68 @@
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+
4
+ import Heading from '../Heading'
5
+
6
+ import styles from './Button.module.css'
7
+ import { options } from './constants'
8
+ import withStyles from '../../hocs/withStyles'
9
+
10
+ import isEmpty from '../../utils/isEmpty'
11
+ import isObject from '../../utils/isObject'
12
+
13
+ export const handleClick = ({ onClick }) => (event) => {
14
+ onClick(event)
15
+ }
16
+
17
+ export const Button = ({
18
+ type,
19
+ children,
20
+ addons,
21
+ isMuted,
22
+ isInline,
23
+ onClick,
24
+ getStyles,
25
+ }) => (
26
+ <button
27
+ className={getStyles('button', ['type'], {
28
+ 'is-inline': isInline || type === 'tertiary',
29
+ 'is-muted': isMuted && type === 'primary',
30
+ })}
31
+ onClick={onClick && handleClick({ onClick })}
32
+ >
33
+ {addons && addons.prepend}
34
+
35
+ <Heading
36
+ color={type === 'primary' ? 'inverted' : 'primary'}
37
+ isCentered
38
+ isInline={isObject(addons) && !isEmpty(addons)}
39
+ weight={'light'}
40
+ >
41
+ {children}
42
+ </Heading>
43
+
44
+ {addons && addons.append}
45
+ </button>
46
+ )
47
+
48
+ Button.propTypes = {
49
+ children: PropTypes.string.isRequired,
50
+ getStyles: PropTypes.func.isRequired,
51
+ type: PropTypes.oneOf(options.types),
52
+ addons: PropTypes.shape({
53
+ prepend: PropTypes.node,
54
+ append: PropTypes.node,
55
+ }),
56
+ onClick: PropTypes.func,
57
+ isInline: PropTypes.bool,
58
+ isMuted: PropTypes.bool,
59
+ }
60
+
61
+ Button.defaultProps = {
62
+ type: 'primary',
63
+ getStyles: () => {},
64
+ onClick: () => {},
65
+ isInline: false,
66
+ }
67
+
68
+ export default withStyles(styles)(Button)
@@ -0,0 +1,63 @@
1
+ .button {
2
+ display: inline-flex;
3
+ width: 100%;
4
+ min-width: max-content;
5
+ height: 45px;
6
+ align-items: center;
7
+ justify-content: center;
8
+ padding: 20px 30px;
9
+ border: var(--border-width-thin) solid var(--color-base-transparent);
10
+ border-radius: var(--button-border-radius-none);
11
+ box-shadow: var(--box-shadow-sm);
12
+ cursor: pointer;
13
+ transition: filter 0.5s ease, box-shadow 0.2s ease-in;
14
+ }
15
+
16
+ .button:focus {
17
+ box-shadow: 0 0 0 1px var(--color-primary), 0 0 10px 0 var(--color-primary);
18
+ outline: none;
19
+ }
20
+
21
+ .button:hover {
22
+ filter: brightness(1.1);
23
+ }
24
+
25
+ .button:active {
26
+ box-shadow: var(--box-shadow-xs);
27
+ filter: brightness(0.9);
28
+ }
29
+
30
+ .type-primary {
31
+ background: var(--color-primary);
32
+ }
33
+
34
+ .type-primary:focus {
35
+ box-shadow: 0 0 0 1px var(--color-primary-inverted),
36
+ 0 0 10px 0 var(--color-primary);
37
+ }
38
+
39
+ .type-secondary {
40
+ border: var(--border-width-thin) solid var(--color-primary);
41
+ background: var(--color-base-transparent);
42
+ }
43
+
44
+ .type-tertiary {
45
+ height: 25px;
46
+ padding: 0;
47
+ border-bottom: 1px solid var(--color-primary);
48
+ background: var(--color-base-transparent);
49
+ border-radius: var(--border-radius-none);
50
+ box-shadow: var(--shadows-none);
51
+ }
52
+
53
+ .type-tertiary:focus {
54
+ box-shadow: 0 10px 10px -8px var(--color-primary);
55
+ }
56
+
57
+ .button.is-inline {
58
+ max-width: max-content;
59
+ }
60
+
61
+ .is-muted {
62
+ background: var(--color-primary-muted);
63
+ }
@@ -0,0 +1,47 @@
1
+ import { Button, options, styles } from '.'
2
+ import {
3
+ getTemplate,
4
+ getListTemplate,
5
+ getOptionsArgTypes,
6
+ } from '../../helpers/storybook'
7
+
8
+ const Template = getTemplate(Button, styles)
9
+ const ListTemplate = getListTemplate(Button, styles)
10
+
11
+ export default {
12
+ title: 'Atoms/Button',
13
+ component: Button,
14
+ args: {
15
+ children: 'You Shall Not Pass!',
16
+ },
17
+ argTypes: {
18
+ type: getOptionsArgTypes(options.types),
19
+ children: { control: 'text' },
20
+ isMuted: { description: 'It requires `type` to be "primary"' },
21
+ },
22
+ }
23
+
24
+ export const Default = Template.bind({})
25
+
26
+ export const Types = ListTemplate.bind({})
27
+ Types.args = { items: options.types.map((type) => ({ type })) }
28
+
29
+ export const Inline = Template.bind({})
30
+ Inline.args = { isInline: true }
31
+
32
+ export const Muted = Template.bind({})
33
+ Muted.args = { type: 'primary', isMuted: true }
34
+
35
+ export const AddonPrepend = Template.bind({})
36
+ AddonPrepend.args = {
37
+ addons: {
38
+ prepend: 'Dare Erebor forgive most.',
39
+ },
40
+ }
41
+
42
+ export const AddonAppend = Template.bind({})
43
+ AddonAppend.args = {
44
+ addons: {
45
+ append: 'But ill-tempered Thengel.',
46
+ },
47
+ }
@@ -0,0 +1,60 @@
1
+ import React from 'react'
2
+ import { render, fireEvent, screen } from '@testing-library/react'
3
+
4
+ import Button, { handleClick } from './Button'
5
+
6
+ describe('[ atoms / Button ]', () => {
7
+ describe('#Button', () => {
8
+ describe('when `Button`is clicked', () => {
9
+ it('should call `onClick`', () => {
10
+ // Arrange
11
+ const onClickMock = jest.fn()
12
+ const props = {
13
+ onClick: onClickMock,
14
+ }
15
+
16
+ // Act
17
+ render(<Button {...props}>Button</Button>)
18
+ fireEvent.click(screen.getByText('Button'))
19
+
20
+ // Assert
21
+ expect(onClickMock).toHaveBeenCalled()
22
+ })
23
+ })
24
+ })
25
+
26
+ describe('#handleClick', () => {
27
+ // Given, When, Then
28
+ describe('when `handleClick` is called', () => {
29
+ it('should return a function', () => {
30
+ // Arrange
31
+ const params = {}
32
+
33
+ // Act
34
+ const result = typeof handleClick(params)
35
+ const expected = 'function'
36
+
37
+ // Assert
38
+ expect(result).toBe(expected)
39
+ })
40
+ })
41
+
42
+ describe('when `handleClick` returned function is called', () => {
43
+ it('should call `onClick` with the `event`', () => {
44
+ // Arrange
45
+ const onClickMock = jest.fn()
46
+ const params = {
47
+ onClick: onClickMock,
48
+ }
49
+
50
+ const event = 'event'
51
+
52
+ // Act
53
+ handleClick(params)(event)
54
+
55
+ // Assert
56
+ expect(onClickMock).toHaveBeenCalledWith(event)
57
+ })
58
+ })
59
+ })
60
+ })
@@ -0,0 +1,191 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Storyshots Atoms/Button Addon Append 1`] = `
4
+ <div
5
+ style={
6
+ Object {
7
+ "alignContent": "flex-start",
8
+ "display": "flex",
9
+ "flexDirection": "column",
10
+ "flexWrap": "wrap",
11
+ "gap": "10px 30px",
12
+ "height": "100%",
13
+ "justifyContent": "flex-start",
14
+ "maxHeight": "auto",
15
+ }
16
+ }
17
+ >
18
+ <button
19
+ className="button type-primary"
20
+ onClick={[Function]}
21
+ >
22
+ <h1
23
+ className="heading color-inverted size-md weight-light is-centered is-inline"
24
+ >
25
+ You Shall Not Pass!
26
+ </h1>
27
+ But ill-tempered Thengel.
28
+ </button>
29
+ </div>
30
+ `;
31
+
32
+ exports[`Storyshots Atoms/Button Addon Prepend 1`] = `
33
+ <div
34
+ style={
35
+ Object {
36
+ "alignContent": "flex-start",
37
+ "display": "flex",
38
+ "flexDirection": "column",
39
+ "flexWrap": "wrap",
40
+ "gap": "10px 30px",
41
+ "height": "100%",
42
+ "justifyContent": "flex-start",
43
+ "maxHeight": "auto",
44
+ }
45
+ }
46
+ >
47
+ <button
48
+ className="button type-primary"
49
+ onClick={[Function]}
50
+ >
51
+ Dare Erebor forgive most.
52
+ <h1
53
+ className="heading color-inverted size-md weight-light is-centered is-inline"
54
+ >
55
+ You Shall Not Pass!
56
+ </h1>
57
+ </button>
58
+ </div>
59
+ `;
60
+
61
+ exports[`Storyshots Atoms/Button Default 1`] = `
62
+ <div
63
+ style={
64
+ Object {
65
+ "alignContent": "flex-start",
66
+ "display": "flex",
67
+ "flexDirection": "column",
68
+ "flexWrap": "wrap",
69
+ "gap": "10px 30px",
70
+ "height": "100%",
71
+ "justifyContent": "flex-start",
72
+ "maxHeight": "auto",
73
+ }
74
+ }
75
+ >
76
+ <button
77
+ className="button type-primary"
78
+ onClick={[Function]}
79
+ >
80
+ <h1
81
+ className="heading color-inverted size-md weight-light is-centered"
82
+ >
83
+ You Shall Not Pass!
84
+ </h1>
85
+ </button>
86
+ </div>
87
+ `;
88
+
89
+ exports[`Storyshots Atoms/Button Inline 1`] = `
90
+ <div
91
+ style={
92
+ Object {
93
+ "alignContent": "flex-start",
94
+ "display": "flex",
95
+ "flexDirection": "column",
96
+ "flexWrap": "wrap",
97
+ "gap": "10px 30px",
98
+ "height": "100%",
99
+ "justifyContent": "flex-start",
100
+ "maxHeight": "auto",
101
+ }
102
+ }
103
+ >
104
+ <button
105
+ className="button type-primary is-inline"
106
+ onClick={[Function]}
107
+ >
108
+ <h1
109
+ className="heading color-inverted size-md weight-light is-centered"
110
+ >
111
+ You Shall Not Pass!
112
+ </h1>
113
+ </button>
114
+ </div>
115
+ `;
116
+
117
+ exports[`Storyshots Atoms/Button Muted 1`] = `
118
+ <div
119
+ style={
120
+ Object {
121
+ "alignContent": "flex-start",
122
+ "display": "flex",
123
+ "flexDirection": "column",
124
+ "flexWrap": "wrap",
125
+ "gap": "10px 30px",
126
+ "height": "100%",
127
+ "justifyContent": "flex-start",
128
+ "maxHeight": "auto",
129
+ }
130
+ }
131
+ >
132
+ <button
133
+ className="button type-primary is-muted"
134
+ onClick={[Function]}
135
+ >
136
+ <h1
137
+ className="heading color-inverted size-md weight-light is-centered"
138
+ >
139
+ You Shall Not Pass!
140
+ </h1>
141
+ </button>
142
+ </div>
143
+ `;
144
+
145
+ exports[`Storyshots Atoms/Button Types 1`] = `
146
+ <div
147
+ style={
148
+ Object {
149
+ "alignContent": "flex-start",
150
+ "display": "flex",
151
+ "flexDirection": "column",
152
+ "flexWrap": "wrap",
153
+ "gap": "10px 30px",
154
+ "height": "100%",
155
+ "justifyContent": "flex-start",
156
+ "maxHeight": "auto",
157
+ }
158
+ }
159
+ >
160
+ <button
161
+ className="button type-primary"
162
+ onClick={[Function]}
163
+ >
164
+ <h1
165
+ className="heading color-inverted size-md weight-light is-centered"
166
+ >
167
+ You Shall Not Pass!
168
+ </h1>
169
+ </button>
170
+ <button
171
+ className="button type-secondary"
172
+ onClick={[Function]}
173
+ >
174
+ <h1
175
+ className="heading color-primary size-md weight-light is-centered"
176
+ >
177
+ You Shall Not Pass!
178
+ </h1>
179
+ </button>
180
+ <button
181
+ className="button type-tertiary is-inline"
182
+ onClick={[Function]}
183
+ >
184
+ <h1
185
+ className="heading color-primary size-md weight-light is-centered"
186
+ >
187
+ You Shall Not Pass!
188
+ </h1>
189
+ </button>
190
+ </div>
191
+ `;
@@ -0,0 +1,3 @@
1
+ export const options = {
2
+ types: ['primary', 'secondary', 'tertiary'],
3
+ }
@@ -0,0 +1,3 @@
1
+ export { default, Button } from './Button'
2
+ export { options } from './constants'
3
+ export { default as styles } from './Button.module.css'
@@ -0,0 +1,48 @@
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+
4
+ import styles from './Card.module.css'
5
+ import { options } from './constants'
6
+ import withStyles from '../../hocs/withStyles'
7
+
8
+ export const handleClick = ({ onClick }) => (event) => {
9
+ onClick(event)
10
+ }
11
+
12
+ export const Card = ({
13
+ getStyles,
14
+ onClick,
15
+ isClickable,
16
+ isDraggable,
17
+ children,
18
+ }) => {
19
+ return (
20
+ <div
21
+ onClick={onClick && handleClick({ onClick })}
22
+ className={getStyles('card', ['color', 'size'], {
23
+ 'is-clickable': isClickable,
24
+ 'is-draggable': isDraggable,
25
+ })}
26
+ >
27
+ {children}
28
+ </div>
29
+ )
30
+ }
31
+
32
+ Card.propTypes = {
33
+ children: PropTypes.node.isRequired,
34
+ getStyles: PropTypes.func.isRequired,
35
+ onClick: PropTypes.func,
36
+ color: PropTypes.oneOf(options.colors),
37
+ size: PropTypes.oneOf(options.sizes),
38
+ isClickable: PropTypes.bool,
39
+ isDraggable: PropTypes.bool,
40
+ }
41
+
42
+ Card.defaultProps = {
43
+ color: 'base',
44
+ size: 'sm',
45
+ getStyles: () => {},
46
+ }
47
+
48
+ export default withStyles(styles)(Card)
@@ -0,0 +1,52 @@
1
+ .card {
2
+ display: flex;
3
+ width: 100%;
4
+ align-items: center;
5
+ padding: 12px 10px;
6
+ border: var(--border-width-thin) solid var(--color-base-transparent);
7
+ border-radius: var(--card-border-radius);
8
+ box-shadow: var(--box-shadow-sm);
9
+ color: var(--color-font-base);
10
+ transition: box-shadow 0.2s ease-in;
11
+ }
12
+
13
+ .size-sm {
14
+ min-height: 45px;
15
+ }
16
+
17
+ .size-md {
18
+ min-height: 80px;
19
+ }
20
+
21
+ .size-lg {
22
+ min-height: 115px;
23
+ }
24
+
25
+ .color-primary {
26
+ background: var(--color-primary);
27
+ color: var(--color-primary-inverted);
28
+ }
29
+
30
+ .color-secondary {
31
+ background: var(--color-secondary);
32
+ color: var(--color-secondary-inverted);
33
+ }
34
+
35
+ .color-base {
36
+ border: var(--border-width-thin) solid var(--color-gray-400);
37
+ background: var(--background-color-primary-highlight);
38
+ }
39
+
40
+ .is-clickable {
41
+ cursor: pointer;
42
+ }
43
+
44
+ .is-draggable {
45
+ cursor: grab;
46
+ user-select: none;
47
+ }
48
+
49
+ .card.is-clickable:active,
50
+ .card.is-draggable:active {
51
+ box-shadow: var(--box-shadow-xs);
52
+ }
@@ -0,0 +1,41 @@
1
+ import { Card, options, styles } from '.'
2
+ import {
3
+ getTemplate,
4
+ getListTemplate,
5
+ getOptionsArgTypes,
6
+ } from '../../helpers/storybook'
7
+
8
+ const Template = getTemplate(Card, styles)
9
+ const ListTemplate = getListTemplate(Card, styles)
10
+
11
+ export default {
12
+ title: 'Atoms/Card',
13
+ component: Card,
14
+ args: {
15
+ children:
16
+ 'Lacerations coaster sort comings windlance happily EIf-witch handful unbefitting? Decide rising startled Aragorn invitations midnight deserves fortunes innards. You cannot hide. I see you. There is no life in the void. Only death. Mirror Emyn dreamed!',
17
+ },
18
+ argTypes: {
19
+ color: getOptionsArgTypes(options.colors),
20
+ size: getOptionsArgTypes(options.sizes),
21
+ children: { control: 'text' },
22
+ },
23
+ }
24
+
25
+ export const Default = Template.bind({})
26
+
27
+ export const Clickable = Template.bind({})
28
+ Clickable.args = {
29
+ isClickable: true,
30
+ }
31
+
32
+ export const Dragabble = Template.bind({})
33
+ Dragabble.args = {
34
+ isDraggable: true,
35
+ }
36
+
37
+ export const Colors = ListTemplate.bind({})
38
+ Colors.args = { items: options.colors.map((color) => ({ color })) }
39
+
40
+ export const Sizes = ListTemplate.bind({})
41
+ Sizes.args = { items: options.sizes.map((size) => ({ size })) }