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
@@ -0,0 +1 @@
|
|
1
|
+
export const options = { types: ['active', 'standby'] }
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import PropTypes from 'prop-types'
|
3
|
+
|
4
|
+
import Paragraph from '../../atoms/Paragraph'
|
5
|
+
import Divider from '../../atoms/Divider'
|
6
|
+
import Spacer from '../../layout/Spacer'
|
7
|
+
import Accordion from '../Accordion'
|
8
|
+
|
9
|
+
import styles from './TaskCounter.module.css'
|
10
|
+
import withStyles from '../../hocs/withStyles'
|
11
|
+
|
12
|
+
export const TaskCounter = ({
|
13
|
+
title,
|
14
|
+
children,
|
15
|
+
current,
|
16
|
+
total,
|
17
|
+
isToggleable,
|
18
|
+
onToggle,
|
19
|
+
getStyles,
|
20
|
+
defaultIsCollapsed,
|
21
|
+
}) => {
|
22
|
+
if (isToggleable) {
|
23
|
+
return (
|
24
|
+
<Accordion
|
25
|
+
title={title}
|
26
|
+
addons={{
|
27
|
+
append: (
|
28
|
+
<Paragraph weight="medium" isInline>
|
29
|
+
{total ? `${current}/${total}` : current}
|
30
|
+
</Paragraph>
|
31
|
+
),
|
32
|
+
}}
|
33
|
+
onToggle={onToggle}
|
34
|
+
defaultIsCollapsed={defaultIsCollapsed}
|
35
|
+
>
|
36
|
+
{children}
|
37
|
+
</Accordion>
|
38
|
+
)
|
39
|
+
}
|
40
|
+
|
41
|
+
return (
|
42
|
+
<div className={getStyles('task-counter')}>
|
43
|
+
<div className={getStyles('container')}>
|
44
|
+
<Paragraph weight="medium">{title}</Paragraph>
|
45
|
+
<Paragraph weight="medium" isInline>
|
46
|
+
{total ? `${current}/${total}` : current}
|
47
|
+
</Paragraph>
|
48
|
+
</div>
|
49
|
+
<Spacer.Vertical size="xs" />
|
50
|
+
<Divider />
|
51
|
+
{children}
|
52
|
+
</div>
|
53
|
+
)
|
54
|
+
}
|
55
|
+
|
56
|
+
TaskCounter.propTypes = {
|
57
|
+
title: PropTypes.string.isRequired,
|
58
|
+
getStyles: PropTypes.func.isRequired,
|
59
|
+
current: PropTypes.number.isRequired,
|
60
|
+
children: PropTypes.node,
|
61
|
+
onToggle: PropTypes.func,
|
62
|
+
isToggleable: PropTypes.bool,
|
63
|
+
total: PropTypes.number,
|
64
|
+
defaultIsCollapsed: PropTypes.bool,
|
65
|
+
}
|
66
|
+
|
67
|
+
TaskCounter.defaultProps = {
|
68
|
+
getStyles: () => {},
|
69
|
+
onToggle: () => {},
|
70
|
+
current: 0,
|
71
|
+
defaultIsCollapsed: true,
|
72
|
+
}
|
73
|
+
|
74
|
+
export default withStyles(styles)(TaskCounter)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { TaskCounter, styles } from '.'
|
2
|
+
|
3
|
+
import { getTemplate } from '../../helpers/storybook'
|
4
|
+
|
5
|
+
const Template = getTemplate(TaskCounter, styles)
|
6
|
+
|
7
|
+
export default {
|
8
|
+
title: 'Molecules/TaskCounter',
|
9
|
+
component: TaskCounter,
|
10
|
+
args: {
|
11
|
+
title: 'Em Sméagol body.',
|
12
|
+
current: 2,
|
13
|
+
children:
|
14
|
+
"Fells defeated veins this. There and Back Again. A Hobbit's Tale. Loved lucky Istari difficult lay? Dale fellow's rioting. Blanket Misty Mountain started rival wriggles flatten convinced succumbed closing? Slug town fond pipe-weed flatten recognizes Goblins! Innards pouf admirable freely nothingness sleepless exactly afternoon cruelty Bofur? Craftsmen tested fair Alfrid gets figure words winter's field offer healed squash? These galumphing Grima tread mustn't seen melt ideal picked recover employment. Nazgûl alas luckiest?",
|
15
|
+
},
|
16
|
+
}
|
17
|
+
|
18
|
+
export const Default = Template.bind({})
|
19
|
+
export const Total = Template.bind({})
|
20
|
+
Total.args = { total: 10 }
|
21
|
+
|
22
|
+
export const Toggleable = Template.bind({})
|
23
|
+
Toggleable.args = {
|
24
|
+
isToggleable: true,
|
25
|
+
total: 10,
|
26
|
+
}
|
@@ -0,0 +1,177 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`Storyshots Molecules/TaskCounter Default 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
|
+
<div
|
19
|
+
className="task-counter"
|
20
|
+
>
|
21
|
+
<div
|
22
|
+
className="container"
|
23
|
+
>
|
24
|
+
<p
|
25
|
+
className="paragraph color-base size-md weight-medium"
|
26
|
+
>
|
27
|
+
Em Sméagol body.
|
28
|
+
</p>
|
29
|
+
<p
|
30
|
+
className="paragraph color-base size-md weight-medium is-inline"
|
31
|
+
>
|
32
|
+
2
|
33
|
+
</p>
|
34
|
+
</div>
|
35
|
+
<div
|
36
|
+
className="spacer vertical"
|
37
|
+
style={
|
38
|
+
Object {
|
39
|
+
"height": 5,
|
40
|
+
}
|
41
|
+
}
|
42
|
+
/>
|
43
|
+
<div
|
44
|
+
className="divider"
|
45
|
+
/>
|
46
|
+
Fells defeated veins this. There and Back Again. A Hobbit's Tale. Loved lucky Istari difficult lay? Dale fellow's rioting. Blanket Misty Mountain started rival wriggles flatten convinced succumbed closing? Slug town fond pipe-weed flatten recognizes Goblins! Innards pouf admirable freely nothingness sleepless exactly afternoon cruelty Bofur? Craftsmen tested fair Alfrid gets figure words winter's field offer healed squash? These galumphing Grima tread mustn't seen melt ideal picked recover employment. Nazgûl alas luckiest?
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
`;
|
50
|
+
|
51
|
+
exports[`Storyshots Molecules/TaskCounter Toggleable 1`] = `
|
52
|
+
<div
|
53
|
+
style={
|
54
|
+
Object {
|
55
|
+
"alignContent": "flex-start",
|
56
|
+
"display": "flex",
|
57
|
+
"flexDirection": "column",
|
58
|
+
"flexWrap": "wrap",
|
59
|
+
"gap": "10px 30px",
|
60
|
+
"height": "100%",
|
61
|
+
"justifyContent": "flex-start",
|
62
|
+
"maxHeight": "auto",
|
63
|
+
}
|
64
|
+
}
|
65
|
+
>
|
66
|
+
<div
|
67
|
+
className="accordion"
|
68
|
+
>
|
69
|
+
<div
|
70
|
+
className="container"
|
71
|
+
onClick={[Function]}
|
72
|
+
>
|
73
|
+
<div
|
74
|
+
className="icon color-inverted size-sm background-muted"
|
75
|
+
style={
|
76
|
+
Object {
|
77
|
+
"height": 25,
|
78
|
+
"width": 25,
|
79
|
+
}
|
80
|
+
}
|
81
|
+
>
|
82
|
+
<svg
|
83
|
+
height={25}
|
84
|
+
viewBox="0 0 15 9"
|
85
|
+
width={25}
|
86
|
+
xmlns="http://www.w3.org/2000/svg"
|
87
|
+
>
|
88
|
+
<path
|
89
|
+
clipRule="evenodd"
|
90
|
+
d="M7.82633 8.70623L0.882568 1.54063L1.89405 0.496826L7.82633 6.61863L13.7586 0.496826L14.7701 1.54063L7.82633 8.70623Z"
|
91
|
+
fillRule="evenodd"
|
92
|
+
/>
|
93
|
+
</svg>
|
94
|
+
</div>
|
95
|
+
<div
|
96
|
+
className="spacer horizontal"
|
97
|
+
style={
|
98
|
+
Object {
|
99
|
+
"height": "100%",
|
100
|
+
"maxHeight": "auto",
|
101
|
+
"width": 15,
|
102
|
+
}
|
103
|
+
}
|
104
|
+
/>
|
105
|
+
<p
|
106
|
+
className="paragraph color-base size-md weight-medium"
|
107
|
+
>
|
108
|
+
Em Sméagol body.
|
109
|
+
</p>
|
110
|
+
<p
|
111
|
+
className="paragraph color-base size-md weight-medium is-inline"
|
112
|
+
>
|
113
|
+
2/10
|
114
|
+
</p>
|
115
|
+
</div>
|
116
|
+
<div
|
117
|
+
className="spacer vertical"
|
118
|
+
style={
|
119
|
+
Object {
|
120
|
+
"height": 5,
|
121
|
+
}
|
122
|
+
}
|
123
|
+
/>
|
124
|
+
<div
|
125
|
+
className="divider"
|
126
|
+
/>
|
127
|
+
</div>
|
128
|
+
</div>
|
129
|
+
`;
|
130
|
+
|
131
|
+
exports[`Storyshots Molecules/TaskCounter Total 1`] = `
|
132
|
+
<div
|
133
|
+
style={
|
134
|
+
Object {
|
135
|
+
"alignContent": "flex-start",
|
136
|
+
"display": "flex",
|
137
|
+
"flexDirection": "column",
|
138
|
+
"flexWrap": "wrap",
|
139
|
+
"gap": "10px 30px",
|
140
|
+
"height": "100%",
|
141
|
+
"justifyContent": "flex-start",
|
142
|
+
"maxHeight": "auto",
|
143
|
+
}
|
144
|
+
}
|
145
|
+
>
|
146
|
+
<div
|
147
|
+
className="task-counter"
|
148
|
+
>
|
149
|
+
<div
|
150
|
+
className="container"
|
151
|
+
>
|
152
|
+
<p
|
153
|
+
className="paragraph color-base size-md weight-medium"
|
154
|
+
>
|
155
|
+
Em Sméagol body.
|
156
|
+
</p>
|
157
|
+
<p
|
158
|
+
className="paragraph color-base size-md weight-medium is-inline"
|
159
|
+
>
|
160
|
+
2/10
|
161
|
+
</p>
|
162
|
+
</div>
|
163
|
+
<div
|
164
|
+
className="spacer vertical"
|
165
|
+
style={
|
166
|
+
Object {
|
167
|
+
"height": 5,
|
168
|
+
}
|
169
|
+
}
|
170
|
+
/>
|
171
|
+
<div
|
172
|
+
className="divider"
|
173
|
+
/>
|
174
|
+
Fells defeated veins this. There and Back Again. A Hobbit's Tale. Loved lucky Istari difficult lay? Dale fellow's rioting. Blanket Misty Mountain started rival wriggles flatten convinced succumbed closing? Slug town fond pipe-weed flatten recognizes Goblins! Innards pouf admirable freely nothingness sleepless exactly afternoon cruelty Bofur? Craftsmen tested fair Alfrid gets figure words winter's field offer healed squash? These galumphing Grima tread mustn't seen melt ideal picked recover employment. Nazgûl alas luckiest?
|
175
|
+
</div>
|
176
|
+
</div>
|
177
|
+
`;
|
package/package.json
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
{
|
2
|
+
"name": "imbric-theme",
|
3
|
+
"version": "0.1.1",
|
4
|
+
"description": "A components library to create apps from zero to production",
|
5
|
+
"private": false,
|
6
|
+
"main": "index.js",
|
7
|
+
"repository": {
|
8
|
+
"type": "git",
|
9
|
+
"url": "https://bitbucket.org/jorgemuriel/imbric-storybook/src/master/"
|
10
|
+
},
|
11
|
+
"engines": {
|
12
|
+
"node": ">=16.13.2",
|
13
|
+
"yarn": ">=1.22.17"
|
14
|
+
},
|
15
|
+
"scripts": {
|
16
|
+
"build:storybook": "build-storybook --no-dll",
|
17
|
+
"build:tokens": "node ./scripts/build-tokens",
|
18
|
+
"build": "run-s build:tokens build:storybook",
|
19
|
+
"build:docs": "yarn build:tokens && yarn build:storybook --docs --no-manager-cache",
|
20
|
+
"cc": "node ./scripts/create-component",
|
21
|
+
"commit": "cz",
|
22
|
+
"deploy:prod": "run-s build:docs deploy:vercel:prod",
|
23
|
+
"deploy:stag": "run-s build deploy:vercel:stag",
|
24
|
+
"deploy:vercel:prod": "vercel --prod",
|
25
|
+
"deploy:vercel:stag": "vercel",
|
26
|
+
"dev:storybook": "start-storybook -p 6006",
|
27
|
+
"dev:tokens": "watch 'yarn build:tokens' ./tokens",
|
28
|
+
"dev": "concurrently 'npm:dev:*'",
|
29
|
+
"lint:css:fix": "yarn lint:css:prettier:fix && yarn lint:css:stylelint:fix",
|
30
|
+
"lint:css:prettier:fix": "yarn lint:css:prettier --write",
|
31
|
+
"lint:css:prettier": "prettier '**/*.css' --list-different --ignore-path .gitignore",
|
32
|
+
"lint:css:stylelint:fix": "yarn lint:css:stylelint --fix",
|
33
|
+
"lint:css:stylelint": "stylelint '**/*.css' --ignore-path .gitignore",
|
34
|
+
"lint:css": "run-s lint:css:stylelint lint:css:prettier",
|
35
|
+
"lint:fix": "run-p lint:js:fix lint:json:fix lint:css:fix",
|
36
|
+
"lint:js:fix": "yarn lint:js --fix",
|
37
|
+
"lint:js": "eslint --cache --ignore-path .gitignore '**/*.js'",
|
38
|
+
"lint:json:fix": "yarn lint:json --write",
|
39
|
+
"lint:json": "prettier '**/*.json' --list-different --ignore-path .gitignore",
|
40
|
+
"lint": "run-p lint:js lint:json lint:css",
|
41
|
+
"test:coverage": "yarn test --coverage",
|
42
|
+
"test:coverage:html": "yarn test:coverage & open coverage/lcov-report/index.html",
|
43
|
+
"test:watch": "CONSOLE_LEVEL=debug yarn test --watch",
|
44
|
+
"test": "jest"
|
45
|
+
},
|
46
|
+
"keywords": [
|
47
|
+
"react",
|
48
|
+
"components"
|
49
|
+
],
|
50
|
+
"author": "imbric",
|
51
|
+
"license": "UNLICENSED",
|
52
|
+
"dependencies": {
|
53
|
+
"classnames": "2.3.1"
|
54
|
+
},
|
55
|
+
"devDependencies": {
|
56
|
+
"@babel/core": "7.11.6",
|
57
|
+
"@babel/preset-env": "7.11.5",
|
58
|
+
"@babel/preset-react": "7.10.4",
|
59
|
+
"@commitlint/cli": "11.0.0",
|
60
|
+
"@commitlint/config-conventional": "11.0.0",
|
61
|
+
"@semantic-release/changelog": "5.0.1",
|
62
|
+
"@semantic-release/git": "9.0.0",
|
63
|
+
"@storybook/addon-actions": "6.4.18",
|
64
|
+
"@storybook/addon-essentials": "6.4.18",
|
65
|
+
"@storybook/addon-links": "6.4.18",
|
66
|
+
"@storybook/addon-storyshots": "6.4.18",
|
67
|
+
"@storybook/react": "6.4.18",
|
68
|
+
"@svgr/webpack": "5.5.0",
|
69
|
+
"@testing-library/react": "12.0.0",
|
70
|
+
"babel-jest": "26.3.0",
|
71
|
+
"babel-loader": "8.1.0",
|
72
|
+
"chromatic": "5.2.0",
|
73
|
+
"commitizen": "4.2.2",
|
74
|
+
"concurrently": "5.3.0",
|
75
|
+
"enquirer": "2.3.6",
|
76
|
+
"eslint": "7.8.1",
|
77
|
+
"eslint-config-prettier": "6.11.0",
|
78
|
+
"eslint-plugin-prettier": "3.1.4",
|
79
|
+
"eslint-plugin-react": "7.20.6",
|
80
|
+
"eslint-plugin-storybook": "0.5.6",
|
81
|
+
"husky": "7.0.4",
|
82
|
+
"identity-obj-proxy": "3.0.0",
|
83
|
+
"jest": "26.4.2",
|
84
|
+
"lint-staged": "10.3.0",
|
85
|
+
"minireset.css": "0.0.6",
|
86
|
+
"npm-run-all": "4.1.5",
|
87
|
+
"prettier": "2.1.1",
|
88
|
+
"react": "16.13.1",
|
89
|
+
"react-dom": "16.13.1",
|
90
|
+
"react-is": "16.13.1",
|
91
|
+
"react-test-renderer": "16.13.1",
|
92
|
+
"semantic-release": "17.1.2",
|
93
|
+
"stylelint": "13.7.2",
|
94
|
+
"stylelint-config-idiomatic-order": "8.1.0",
|
95
|
+
"stylelint-config-recommended": "3.0.0",
|
96
|
+
"watch": "1.0.2"
|
97
|
+
},
|
98
|
+
"peerDependencies": {
|
99
|
+
"react": "16.13.1",
|
100
|
+
"react-dom": "16.13.1"
|
101
|
+
}
|
102
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
const { choices, decisions } = require('../tokens')
|
2
|
+
const toKebabCase = require('../utils/toKebabCase')
|
3
|
+
const fs = require('fs')
|
4
|
+
|
5
|
+
const cleanLines = (string = '') => string.trim().replace(/^\n\n/gm, '\n')
|
6
|
+
|
7
|
+
function transformTokens(parentKey, object) {
|
8
|
+
const objectKeys = Object.keys(object)
|
9
|
+
|
10
|
+
return objectKeys.reduce((transformedTokens, objectKey) => {
|
11
|
+
const value = object[objectKey]
|
12
|
+
const customProperty = parentKey
|
13
|
+
? toKebabCase(`${parentKey}-${objectKey}`)
|
14
|
+
: toKebabCase(`${objectKey}`)
|
15
|
+
|
16
|
+
if (Array.isArray(value)) {
|
17
|
+
return `${transformedTokens}\n --${customProperty}: ${value.join(', ')};`
|
18
|
+
} else if (typeof value === 'object') {
|
19
|
+
return `${transformedTokens}\n${transformTokens(customProperty, value)}`
|
20
|
+
}
|
21
|
+
|
22
|
+
const label = `--${parentKey}-${toKebabCase(objectKey)}`
|
23
|
+
return `${transformedTokens}\n ${label}: ${value};`
|
24
|
+
}, '')
|
25
|
+
}
|
26
|
+
|
27
|
+
function buildTokens() {
|
28
|
+
const transformedChoices = transformTokens(null, choices)
|
29
|
+
const transformedDecisions = transformTokens(null, decisions)
|
30
|
+
const customProperties = `${transformedChoices}${transformedDecisions}`
|
31
|
+
|
32
|
+
const data = `:root {\n ${cleanLines(customProperties)}\n}\n`
|
33
|
+
|
34
|
+
fs.writeFile('./styles/tokens.css', data, 'utf8', (error) => {
|
35
|
+
if (error) throw error
|
36
|
+
console.log('🎨 Custom properties created!')
|
37
|
+
})
|
38
|
+
}
|
39
|
+
|
40
|
+
buildTokens()
|
@@ -0,0 +1,127 @@
|
|
1
|
+
/* eslint-disable no-undef */
|
2
|
+
const fs = require('fs').promises
|
3
|
+
const path = require('path')
|
4
|
+
const enquirer = require('enquirer')
|
5
|
+
const toPascalCase = require('../utils/toPascalCase')
|
6
|
+
const toKebabCase = require('../utils/toKebabCase')
|
7
|
+
const toCapitalize = require('../utils/toCapitalize')
|
8
|
+
|
9
|
+
const ATOMIC_DESIGN_TYPES = {
|
10
|
+
atom: 'atoms',
|
11
|
+
molecule: 'molecules',
|
12
|
+
layout: 'layout',
|
13
|
+
}
|
14
|
+
const COMPONENT_TEMPLATE_PATH = 'templates/component'
|
15
|
+
|
16
|
+
function createComponentFolder(componentPath) {
|
17
|
+
return fs.mkdir(componentPath, { recursive: true })
|
18
|
+
}
|
19
|
+
|
20
|
+
function readComponentFile(componentTemplate) {
|
21
|
+
return fs.readFile(
|
22
|
+
path.join(__dirname, `../${COMPONENT_TEMPLATE_PATH}/${componentTemplate}`),
|
23
|
+
'utf8'
|
24
|
+
)
|
25
|
+
}
|
26
|
+
|
27
|
+
function replaceComponentFile(
|
28
|
+
componentIsStory,
|
29
|
+
componentFile,
|
30
|
+
componentName,
|
31
|
+
mappedType
|
32
|
+
) {
|
33
|
+
if (!componentIsStory) {
|
34
|
+
return componentFile
|
35
|
+
.replace(/component/g, toKebabCase(componentName))
|
36
|
+
.replace(/Component/g, componentName)
|
37
|
+
} else {
|
38
|
+
return componentFile
|
39
|
+
.replace(/Component/g, componentName)
|
40
|
+
.replace(/atomic/g, mappedType)
|
41
|
+
.replace(/Atomic/g, toCapitalize(mappedType))
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
function createComponentFile(componentPath, replacedComponentFile) {
|
46
|
+
return fs.writeFile(componentPath, replacedComponentFile, 'utf8')
|
47
|
+
}
|
48
|
+
|
49
|
+
async function createComponent(componentTemplates, type, componentName) {
|
50
|
+
const mappedType = ATOMIC_DESIGN_TYPES[type]
|
51
|
+
const atomicComponentPath = path.join(
|
52
|
+
__dirname,
|
53
|
+
`../${mappedType}/${componentName}`
|
54
|
+
)
|
55
|
+
|
56
|
+
try {
|
57
|
+
await createComponentFolder(atomicComponentPath)
|
58
|
+
console.log('🔧 component folder created!')
|
59
|
+
|
60
|
+
for (const componentTemplate of componentTemplates) {
|
61
|
+
const componentTemplateRenamed = componentTemplate.replace(
|
62
|
+
/Component/g,
|
63
|
+
toPascalCase(componentName)
|
64
|
+
)
|
65
|
+
const componentIsStory = componentTemplate.search('stories') !== -1
|
66
|
+
|
67
|
+
const componentFile = await readComponentFile(componentTemplate)
|
68
|
+
const replacedComponentFile = await replaceComponentFile(
|
69
|
+
componentIsStory,
|
70
|
+
componentFile,
|
71
|
+
componentName,
|
72
|
+
mappedType
|
73
|
+
)
|
74
|
+
await createComponentFile(
|
75
|
+
path.join(atomicComponentPath, componentTemplateRenamed),
|
76
|
+
replacedComponentFile
|
77
|
+
)
|
78
|
+
console.log(`🔧 component file ${componentTemplateRenamed} created!`)
|
79
|
+
}
|
80
|
+
} catch (error) {
|
81
|
+
console.log(error)
|
82
|
+
process.exit(1)
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
async function getPromptParams() {
|
87
|
+
let { type } = await enquirer.prompt({
|
88
|
+
type: 'select',
|
89
|
+
name: 'type',
|
90
|
+
message: 'What kind of component would you like to create?',
|
91
|
+
choices: ['atom', 'molecule', 'layout'],
|
92
|
+
initial: 'atom',
|
93
|
+
})
|
94
|
+
|
95
|
+
let { componentName } = await enquirer.prompt({
|
96
|
+
type: 'input',
|
97
|
+
name: 'componentName',
|
98
|
+
message: 'What is the name of the new component?',
|
99
|
+
validate(input) {
|
100
|
+
if (!this.skipped && input.trim().length === 0 && input.trim() !== ',') {
|
101
|
+
return 'Please, tell us what is the name of the new component. Try again!'
|
102
|
+
}
|
103
|
+
return true
|
104
|
+
},
|
105
|
+
})
|
106
|
+
|
107
|
+
try {
|
108
|
+
const componentTemplates = await fs.readdir(
|
109
|
+
path.join(__dirname, `../${COMPONENT_TEMPLATE_PATH}`)
|
110
|
+
)
|
111
|
+
|
112
|
+
if (componentTemplates.length !== 0) {
|
113
|
+
createComponent(componentTemplates, type, toPascalCase(componentName))
|
114
|
+
} else {
|
115
|
+
throw new Error(
|
116
|
+
`There are not template files to create the component: ${toPascalCase(
|
117
|
+
componentName
|
118
|
+
)}`
|
119
|
+
)
|
120
|
+
}
|
121
|
+
} catch (error) {
|
122
|
+
console.log(error)
|
123
|
+
process.exit(1)
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
getPromptParams()
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import initStoryshots, {
|
2
|
+
multiSnapshotWithOptions,
|
3
|
+
Stories2SnapsConverter,
|
4
|
+
} from '@storybook/addon-storyshots'
|
5
|
+
|
6
|
+
import './utils/testUtils/matchMediaMock'
|
7
|
+
|
8
|
+
initStoryshots({
|
9
|
+
test: multiSnapshotWithOptions(),
|
10
|
+
stories2snapsConverter: new Stories2SnapsConverter({
|
11
|
+
snapshotExtension: '.js.snap',
|
12
|
+
}),
|
13
|
+
})
|