imbric-theme 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.babelrc.json +3 -0
- package/.commitlintrc.json +3 -0
- package/.editorconfig +13 -0
- package/.eslintcache +1 -0
- package/.eslintrc.json +36 -0
- package/.huskyrc.json +6 -0
- package/.lintstagedrc.json +5 -0
- package/.nvmrc +1 -0
- package/.prettierrc.json +4 -0
- package/.releaserc.json +13 -0
- package/.storybook/main.js +9 -0
- package/.storybook/preview-head.html +2 -0
- package/.storybook/preview.js +32 -0
- package/.stylelintrc.json +14 -0
- package/.vscode/launch.json +15 -0
- package/CHANGELOG.md +0 -0
- package/README.md +69 -0
- package/atoms/Avatar/Avatar.js +36 -0
- package/atoms/Avatar/Avatar.module.css +3 -0
- package/atoms/Avatar/Avatar.stories.js +29 -0
- package/atoms/Avatar/__snapshots__/Avatar.stories.js.snap +105 -0
- package/atoms/Avatar/constants.js +3 -0
- package/atoms/Avatar/helpers.js +7 -0
- package/atoms/Avatar/index.js +3 -0
- package/atoms/Button/Button.js +68 -0
- package/atoms/Button/Button.module.css +63 -0
- package/atoms/Button/Button.stories.js +47 -0
- package/atoms/Button/Button.test.js +60 -0
- package/atoms/Button/__snapshots__/Button.stories.js.snap +191 -0
- package/atoms/Button/constants.js +3 -0
- package/atoms/Button/index.js +3 -0
- package/atoms/Card/Card.js +48 -0
- package/atoms/Card/Card.module.css +52 -0
- package/atoms/Card/Card.stories.js +41 -0
- package/atoms/Card/__snapshots__/Card.stories.js.snap +136 -0
- package/atoms/Card/constants.js +4 -0
- package/atoms/Card/index.js +3 -0
- package/atoms/Check/Check.js +26 -0
- package/atoms/Check/Check.module.css +11 -0
- package/atoms/Check/Check.stories.js +15 -0
- package/atoms/Check/__snapshots__/Check.stories.js.snap +67 -0
- package/atoms/Check/index.js +2 -0
- package/atoms/Divider/Divider.js +19 -0
- package/atoms/Divider/Divider.module.css +5 -0
- package/atoms/Divider/Divider.stories.js +12 -0
- package/atoms/Divider/__snapshots__/Divider.stories.js.snap +22 -0
- package/atoms/Divider/index.js +2 -0
- package/atoms/Heading/Heading.js +37 -0
- package/atoms/Heading/Heading.module.css +66 -0
- package/atoms/Heading/Heading.stories.js +46 -0
- package/atoms/Heading/__snapshots__/Heading.stories.js.snap +189 -0
- package/atoms/Heading/constants.js +5 -0
- package/atoms/Heading/index.js +3 -0
- package/atoms/Icon/Icon.js +66 -0
- package/atoms/Icon/Icon.module.css +112 -0
- package/atoms/Icon/Icon.stories.js +48 -0
- package/atoms/Icon/__snapshots__/Icon.stories.js.snap +1311 -0
- package/atoms/Icon/constants.js +486 -0
- package/atoms/Icon/helpers.js +9 -0
- package/atoms/Icon/index.js +3 -0
- package/atoms/Input/Input.js +49 -0
- package/atoms/Input/Input.module.css +27 -0
- package/atoms/Input/Input.stories.js +32 -0
- package/atoms/Input/__snapshots__/Input.stories.js.snap +101 -0
- package/atoms/Input/constants.js +3 -0
- package/atoms/Input/index.js +3 -0
- package/atoms/Link/Link.js +33 -0
- package/atoms/Link/Link.module.css +14 -0
- package/atoms/Link/Link.stories.js +30 -0
- package/atoms/Link/__snapshots__/Link.stories.js.snap +118 -0
- package/atoms/Link/constants.js +5 -0
- package/atoms/Link/index.js +3 -0
- package/atoms/Loading/Loading.js +30 -0
- package/atoms/Loading/Loading.module.css +51 -0
- package/atoms/Loading/Loading.stories.js +17 -0
- package/atoms/Loading/__snapshots__/Loading.stories.js.snap +26 -0
- package/atoms/Loading/index.js +2 -0
- package/atoms/Modal/Modal.js +98 -0
- package/atoms/Modal/Modal.module.css +85 -0
- package/atoms/Modal/Modal.stories.js +43 -0
- package/atoms/Modal/__snapshots__/Modal.stories.js.snap +239 -0
- package/atoms/Modal/constants.js +1 -0
- package/atoms/Modal/index.js +3 -0
- package/atoms/Paragraph/Paragraph.js +56 -0
- package/atoms/Paragraph/Paragraph.module.css +68 -0
- package/atoms/Paragraph/Paragraph.stories.js +52 -0
- package/atoms/Paragraph/__snapshots__/Paragraph.stories.js.snap +230 -0
- package/atoms/Paragraph/constants.js +5 -0
- package/atoms/Paragraph/index.js +3 -0
- package/atoms/Picture/Picture.js +40 -0
- package/atoms/Picture/Picture.module.css +16 -0
- package/atoms/Picture/Picture.stories.js +32 -0
- package/atoms/Picture/__snapshots__/Picture.stories.js.snap +156 -0
- package/atoms/Picture/index.js +2 -0
- package/atoms/Textarea/Textarea.js +46 -0
- package/atoms/Textarea/Textarea.module.css +25 -0
- package/atoms/Textarea/Textarea.stories.js +16 -0
- package/atoms/Textarea/__snapshots__/Textarea.stories.js.snap +25 -0
- package/atoms/Textarea/index.js +2 -0
- package/codecov.yml +2 -0
- package/helpers/storybook.js +29 -0
- package/helpers/storybook.test.js +40 -0
- package/helpers/styles.js +37 -0
- package/helpers/styles.test.js +222 -0
- package/hocs/withStyles.js +17 -0
- package/hook/useMedia.js +22 -0
- package/index.js +31 -0
- package/jest.config.js +23 -0
- package/jest.setup.js +13 -0
- package/layout/CenteredContent/CenteredContent.js +30 -0
- package/layout/CenteredContent/CenteredContent.module.css +12 -0
- package/layout/CenteredContent/CenteredContent.stories.js +22 -0
- package/layout/CenteredContent/__snapshots__/CenteredContent.stories.js.snap +27 -0
- package/layout/CenteredContent/index.js +2 -0
- package/layout/Container/Container.js +29 -0
- package/layout/Container/Container.module.css +14 -0
- package/layout/Container/Container.stories.js +22 -0
- package/layout/Container/__snapshots__/Container.stories.js.snap +27 -0
- package/layout/Container/index.js +2 -0
- package/layout/FullHeightContent/FullHeightContent.js +40 -0
- package/layout/FullHeightContent/FullHeightContent.module.css +21 -0
- package/layout/FullHeightContent/FullHeightContent.stories.js +22 -0
- package/layout/FullHeightContent/__snapshots__/FullHeightContent.stories.js.snap +41 -0
- package/layout/FullHeightContent/index.js +2 -0
- package/layout/Spacer/Spacer.js +40 -0
- package/layout/Spacer/Spacer.module.css +12 -0
- package/layout/Spacer/Spacer.stories.js +25 -0
- package/layout/Spacer/__snapshots__/Spacer.stories.js.snap +97 -0
- package/layout/Spacer/components/Horizontal/Horizontal.js +43 -0
- package/layout/Spacer/components/Horizontal/Horizontal.stories.js +32 -0
- package/layout/Spacer/components/Horizontal/__snapshots__/Horizontal.stories.js.snap +97 -0
- package/layout/Spacer/components/Horizontal/index.js +1 -0
- package/layout/Spacer/components/Vertical/Vertical.js +31 -0
- package/layout/Spacer/components/Vertical/Vertical.stories.js +25 -0
- package/layout/Spacer/components/Vertical/__snapshots__/Vertical.stories.js.snap +85 -0
- package/layout/Spacer/components/Vertical/index.js +1 -0
- package/layout/Spacer/components/index.js +2 -0
- package/layout/Spacer/constants.js +5 -0
- package/layout/Spacer/helpers.js +3 -0
- package/layout/Spacer/index.js +3 -0
- package/molecules/Accordion/Accordion.js +70 -0
- package/molecules/Accordion/Accordion.module.css +12 -0
- package/molecules/Accordion/Accordion.stories.js +31 -0
- package/molecules/Accordion/__snapshots__/Accordion.stories.js.snap +228 -0
- package/molecules/Accordion/index.js +2 -0
- package/molecules/AddButton/AddButton.js +137 -0
- package/molecules/AddButton/AddButton.module.css +128 -0
- package/molecules/AddButton/AddButton.stories.js +47 -0
- package/molecules/AddButton/__snapshots__/AddButton.stories.js.snap +326 -0
- package/molecules/AddButton/constants.js +6 -0
- package/molecules/AddButton/handlers.js +58 -0
- package/molecules/AddButton/handlers.test.js +19 -0
- package/molecules/AddButton/helpers.js +6 -0
- package/molecules/AddButton/helpers.test.js +41 -0
- package/molecules/AddButton/hooks.js +14 -0
- package/molecules/AddButton/index.js +3 -0
- package/molecules/ButtonIcon/ButtonIcon.js +41 -0
- package/molecules/ButtonIcon/ButtonIcon.stories.js +27 -0
- package/molecules/ButtonIcon/__snapshots__/ButtonIcon.stories.js.snap +178 -0
- package/molecules/ButtonIcon/constants.js +6 -0
- package/molecules/ButtonIcon/index.js +2 -0
- package/molecules/Dropdown/Dropdown.js +59 -0
- package/molecules/Dropdown/Dropdown.module.css +34 -0
- package/molecules/Dropdown/Dropdown.stories.js +41 -0
- package/molecules/Dropdown/__snapshots__/Dropdown.stories.js.snap +181 -0
- package/molecules/Dropdown/index.js +2 -0
- package/molecules/Error/Error.js +35 -0
- package/molecules/Error/Error.module.css +11 -0
- package/molecules/Error/Error.stories.js +18 -0
- package/molecules/Error/__snapshots__/Error.stories.js.snap +134 -0
- package/molecules/Error/index.js +2 -0
- package/molecules/IconLabel/IconLabel.js +83 -0
- package/molecules/IconLabel/IconLabel.module.css +16 -0
- package/molecules/IconLabel/IconLabel.stories.js +25 -0
- package/molecules/IconLabel/__snapshots__/IconLabel.stories.js.snap +211 -0
- package/molecules/IconLabel/constants.js +6 -0
- package/molecules/IconLabel/index.js +3 -0
- package/molecules/LoadingError/LoadingError.js +31 -0
- package/molecules/LoadingError/LoadingError.stories.js +24 -0
- package/molecules/LoadingError/__snapshots__/LoadingError.stories.js.snap +109 -0
- package/molecules/LoadingError/index.js +1 -0
- package/molecules/Score/Score.js +61 -0
- package/molecules/Score/Score.module.css +11 -0
- package/molecules/Score/Score.stories.js +13 -0
- package/molecules/Score/__snapshots__/Score.stories.js.snap +100 -0
- package/molecules/Score/faces/happy.svg +7 -0
- package/molecules/Score/faces/normal.svg +6 -0
- package/molecules/Score/faces/sad.svg +6 -0
- package/molecules/Score/index.js +2 -0
- package/molecules/Task/Task.js +114 -0
- package/molecules/Task/Task.module.css +47 -0
- package/molecules/Task/Task.stories.js +47 -0
- package/molecules/Task/__snapshots__/Task.stories.js.snap +953 -0
- package/molecules/Task/constants.js +1 -0
- package/molecules/Task/index.js +3 -0
- package/molecules/TaskCounter/TaskCounter.js +74 -0
- package/molecules/TaskCounter/TaskCounter.module.css +11 -0
- package/molecules/TaskCounter/TaskCounter.stories.js +26 -0
- package/molecules/TaskCounter/__snapshots__/TaskCounter.stories.js.snap +177 -0
- package/molecules/TaskCounter/index.js +2 -0
- package/package.json +102 -0
- package/scripts/build-tokens.js +40 -0
- package/scripts/create-component.js +127 -0
- package/storybook.test.js +13 -0
- package/styles/globals.css +10 -0
- package/styles/tokens.css +390 -0
- package/templates/component/Component.js +22 -0
- package/templates/component/Component.module.css +3 -0
- package/templates/component/Component.stories.js +23 -0
- package/templates/component/constants.js +1 -0
- package/templates/component/index.js +3 -0
- package/tokens/Token/Helper.js +30 -0
- package/tokens/Token/Token.js +13 -0
- package/tokens/Token/Token.module.css +64 -0
- package/tokens/Token/components/Color.js +21 -0
- package/tokens/Token/components/Color.stories.js +126 -0
- package/tokens/Token/components/FontFamily.js +24 -0
- package/tokens/Token/components/FontFamily.stories.js +32 -0
- package/tokens/Token/components/FontSize.js +24 -0
- package/tokens/Token/components/FontSize.stories.js +31 -0
- package/tokens/Token/components/FontWeight.js +24 -0
- package/tokens/Token/components/FontWeight.stories.js +31 -0
- package/tokens/Token/components/Spacing.js +24 -0
- package/tokens/Token/components/Spacing.stories.js +29 -0
- package/tokens/Token/components/__snapshots__/Color.stories.js.snap +7169 -0
- package/tokens/Token/components/__snapshots__/FontFamily.stories.js.snap +133 -0
- package/tokens/Token/components/__snapshots__/FontSize.stories.js.snap +261 -0
- package/tokens/Token/components/__snapshots__/FontWeight.stories.js.snap +317 -0
- package/tokens/Token/components/__snapshots__/Spacing.stories.js.snap +229 -0
- package/tokens/Token/components/index.js +5 -0
- package/tokens/Token/helpers.js +17 -0
- package/tokens/Token/index.js +1 -0
- package/tokens/index.js +471 -0
- package/utils/isEmpty.js +28 -0
- package/utils/isEmpty.test.js +125 -0
- package/utils/isObject.js +4 -0
- package/utils/keyboardCodes.js +6 -0
- package/utils/testUtils/matchMediaMock.js +14 -0
- package/utils/testUtils/svgrMock.js +2 -0
- package/utils/toCapitalize.js +4 -0
- package/utils/toKebabCase.js +8 -0
- package/utils/toPascalCase.js +20 -0
- package/webpack/cssModules.js +30 -0
- package/webpack/loadConfigs.js +6 -0
- package/webpack/reactInlineSvg.js +22 -0
package/utils/isEmpty.js
ADDED
@@ -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,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,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,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
|