imbric-theme 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
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,28 @@
1
+ import isObject from './isObject'
2
+
3
+ const NOT_EMPTIABLE_TYPES = [
4
+ 'number',
5
+ 'undefined',
6
+ 'symbol',
7
+ 'boolean',
8
+ 'bigint',
9
+ 'function',
10
+ ]
11
+
12
+ const isEmpty = (value) => {
13
+ if (value === null || NOT_EMPTIABLE_TYPES.includes(typeof value)) {
14
+ throw new Error('The value is not an object, an array or a string')
15
+ }
16
+
17
+ if (isObject(value)) {
18
+ return (
19
+ Object.keys(value).length === 0 &&
20
+ Object.keys(Object.getPrototypeOf(value)).length === 0
21
+ )
22
+ }
23
+
24
+ if (Array.isArray(value) || typeof value === 'string') {
25
+ return value.length === 0
26
+ }
27
+ }
28
+ export default isEmpty
@@ -0,0 +1,125 @@
1
+ import isEmpty from './isEmpty'
2
+
3
+ describe('[ utils / isEmpty ]', () => {
4
+ describe('when the `param` is an empty object', () => {
5
+ it('should return `true`', () => {
6
+ // Arrange
7
+ const param = {}
8
+
9
+ // Act
10
+ const result = isEmpty(param)
11
+ const expected = true
12
+
13
+ // Assert
14
+ expect(result).toBe(expected)
15
+ })
16
+ })
17
+
18
+ describe('when the `param` is `Object.create({})`', () => {
19
+ it('should return `true`', () => {
20
+ // Arrange
21
+ const param = Object.create({})
22
+
23
+ // Act
24
+ const result = isEmpty(param)
25
+ const expected = true
26
+
27
+ // Assert
28
+ expect(result).toBe(expected)
29
+ })
30
+ })
31
+
32
+ describe('when the `param` is an empty array', () => {
33
+ it('should return `true`', () => {
34
+ // Arrange
35
+ const param = []
36
+
37
+ // Act
38
+ const result = isEmpty(param)
39
+ const expected = true
40
+
41
+ // Assert
42
+ expect(result).toBe(expected)
43
+ })
44
+ })
45
+
46
+ describe('when the `param` is an empty string', () => {
47
+ it('should return `true`', () => {
48
+ // Arrange
49
+ const param = ''
50
+
51
+ // Act
52
+ const result = isEmpty(param)
53
+ const expected = true
54
+
55
+ // Assert
56
+ expect(result).toBe(expected)
57
+ })
58
+ })
59
+
60
+ describe('when the `param` is NOT an empty object', () => {
61
+ it('should return `false`', () => {
62
+ // Arrange
63
+ const param = { foo: 'bar' }
64
+
65
+ // Act
66
+ const result = isEmpty(param)
67
+ const expected = false
68
+
69
+ // Assert
70
+ expect(result).toBe(expected)
71
+ })
72
+ })
73
+
74
+ describe('when the `param` is NOT an empty array', () => {
75
+ it('should return `false`', () => {
76
+ // Arrange
77
+ const param = ['foo', 'bar']
78
+
79
+ // Act
80
+ const result = isEmpty(param)
81
+ const expected = false
82
+
83
+ // Assert
84
+ expect(result).toBe(expected)
85
+ })
86
+ })
87
+
88
+ describe('when the `param` is NOT an empty string', () => {
89
+ it('should return `false`', () => {
90
+ // Arrange
91
+ const param = 'foo'
92
+
93
+ // Act
94
+ const result = isEmpty(param)
95
+ const expected = false
96
+
97
+ // Assert
98
+ expect(result).toBe(expected)
99
+ })
100
+ })
101
+
102
+ const NOT_EMPTIABLE_VALUES = [
103
+ [42],
104
+ [null],
105
+ [undefined],
106
+ [Symbol()],
107
+ [true],
108
+ [10n],
109
+ [() => {}],
110
+ ]
111
+
112
+ describe('when the params are NOT emptiable', () => {
113
+ it.each(NOT_EMPTIABLE_VALUES)(
114
+ 'should trhow an error for param `%s`',
115
+ (param) => {
116
+ // Act
117
+ const result = () => isEmpty(param)
118
+ const expected = 'The value is not an object, an array or a string'
119
+
120
+ // Assert
121
+ expect(result).toThrow(expected)
122
+ }
123
+ )
124
+ })
125
+ })
@@ -0,0 +1,4 @@
1
+ const isObject = (obj) =>
2
+ Object.prototype.toString.call(obj) === '[object Object]'
3
+
4
+ export default isObject
@@ -0,0 +1,6 @@
1
+ const keyboardCodes = {
2
+ ENTER: 'Enter',
3
+ ESC: 'Escape',
4
+ }
5
+
6
+ export default keyboardCodes
@@ -0,0 +1,14 @@
1
+ // https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
2
+ Object.defineProperty(window, 'matchMedia', {
3
+ writable: true,
4
+ value: jest.fn().mockImplementation((query) => ({
5
+ matches: false,
6
+ media: query,
7
+ onchange: null,
8
+ addListener: jest.fn(), // deprecated
9
+ removeListener: jest.fn(), // deprecated
10
+ addEventListener: jest.fn(),
11
+ removeEventListener: jest.fn(),
12
+ dispatchEvent: jest.fn(),
13
+ })),
14
+ })
@@ -0,0 +1,2 @@
1
+ export default 'SvgrURL'
2
+ export const ReactComponent = 'div'
@@ -0,0 +1,4 @@
1
+ const toCapitalize = (string) =>
2
+ string.charAt(0).toUpperCase() + string.slice(1)
3
+
4
+ module.exports = toCapitalize
@@ -0,0 +1,8 @@
1
+ const toKebabCase = (string) =>
2
+ string
3
+ .replace(/([A-Z])([A-Z])/g, '$1-$2')
4
+ .replace(/([a-z])([A-Z])/g, '$1-$2')
5
+ .replace(/[\s_]+/g, '-')
6
+ .toLowerCase()
7
+
8
+ module.exports = toKebabCase
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Function to validate a string and capitalize it if necessary
3
+ * @param {str} str
4
+ */
5
+ function toPascalCase(str) {
6
+ const REG_EXP = /[A-Z]/
7
+
8
+ if (!REG_EXP.test(str)) {
9
+ return str
10
+ .replace(
11
+ /\w\S*/g,
12
+ (word) => word.charAt(0).toUpperCase() + word.substr(1).toLowerCase()
13
+ )
14
+ .replace(/ /g, '')
15
+ } else {
16
+ return str
17
+ }
18
+ }
19
+
20
+ module.exports = toPascalCase
@@ -0,0 +1,30 @@
1
+ // https://github.com/storybookjs/storybook/issues/6055#issuecomment-521046352
2
+ // yarn dev:storybook --debug-webpack
3
+
4
+ const cssModules = (config) => {
5
+ // We search the rule defined for `*.css` files
6
+ const cssRule = config.module.rules.find(
7
+ (rule) => rule.test && rule.test.test('.css')
8
+ )
9
+
10
+ // We exclude `*.module.css` files from the previous rule
11
+ cssRule.exclude = /\.module\.css$/
12
+
13
+ // We add a our custom rule for `*.module.css` files
14
+ config.module.rules.push({
15
+ test: /\.module\.css$/,
16
+ use: [
17
+ 'style-loader',
18
+ {
19
+ loader: 'css-loader',
20
+ options: {
21
+ modules: true,
22
+ },
23
+ },
24
+ ],
25
+ })
26
+
27
+ return config
28
+ }
29
+
30
+ module.exports = cssModules
@@ -0,0 +1,6 @@
1
+ const loadConfigs = (configs) => (storybookConfig) => {
2
+ configs.forEach((config) => config(storybookConfig))
3
+ return storybookConfig
4
+ }
5
+
6
+ module.exports = loadConfigs
@@ -0,0 +1,22 @@
1
+ // https://github.com/storybookjs/storybook/issues/9070#issuecomment-635895868
2
+ // yarn dev:storybook --debug-webpack
3
+
4
+ const reactInlineSvg = (config) => {
5
+ // We search the rule defined for `*.svg` files
6
+ const fileRule = config.module.rules.find(
7
+ (rule) => rule.test && rule.test.test('.svg')
8
+ )
9
+
10
+ // We exclude `*.svg` files from the previous rule
11
+ fileRule.exclude = /\.svg$/
12
+
13
+ // We add a our custom rule for `*.svg` files
14
+ config.module.rules.push({
15
+ test: /\.svg$/,
16
+ loader: ['@svgr/webpack'],
17
+ })
18
+
19
+ return config
20
+ }
21
+
22
+ module.exports = reactInlineSvg