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,19 @@
|
|
1
|
+
import { handleClick } from './handlers'
|
2
|
+
|
3
|
+
describe('[ Molecules / AddButton / Handlers ]', () => {
|
4
|
+
describe('#handleClick', () => {
|
5
|
+
describe('when the handler is call', () => {
|
6
|
+
it('should return a function', () => {
|
7
|
+
// Arrange
|
8
|
+
const params = {}
|
9
|
+
|
10
|
+
// Act
|
11
|
+
const result = typeof handleClick(params)
|
12
|
+
const expected = 'function'
|
13
|
+
|
14
|
+
// Assert
|
15
|
+
expect(result).toBe(expected)
|
16
|
+
})
|
17
|
+
})
|
18
|
+
})
|
19
|
+
})
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { shouldShowHelpText } from './helpers'
|
2
|
+
|
3
|
+
describe('[ Molecules / AddButton / Helpers ]', () => {
|
4
|
+
describe('#shouldShowHelpText', () => {
|
5
|
+
describe('when `isEditable`, `inputValue`, and `focusHelpText` exist', () => {
|
6
|
+
it('should return `true`', () => {
|
7
|
+
// Arrange
|
8
|
+
const params = {
|
9
|
+
isEditable: true,
|
10
|
+
inputValue: true,
|
11
|
+
focusHelpText: true,
|
12
|
+
}
|
13
|
+
|
14
|
+
// Act
|
15
|
+
const result = shouldShowHelpText(params)
|
16
|
+
const expected = true
|
17
|
+
|
18
|
+
// Assert
|
19
|
+
expect(result).toBe(expected)
|
20
|
+
})
|
21
|
+
})
|
22
|
+
|
23
|
+
describe('when `isEditable`, `inputValue`, and `blurHelpText` exist', () => {
|
24
|
+
it('should return `true`', () => {
|
25
|
+
// Arrange
|
26
|
+
const params = {
|
27
|
+
isEditable: true,
|
28
|
+
inputValue: true,
|
29
|
+
blurHelpText: true,
|
30
|
+
}
|
31
|
+
|
32
|
+
// Act
|
33
|
+
const result = shouldShowHelpText(params)
|
34
|
+
const expected = true
|
35
|
+
|
36
|
+
// Assert
|
37
|
+
expect(result).toBe(expected)
|
38
|
+
})
|
39
|
+
})
|
40
|
+
})
|
41
|
+
})
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { useEffect } from 'react'
|
2
|
+
import keyboardCodes from '../../utils/keyboardCodes'
|
3
|
+
|
4
|
+
const createKeydownEvent = (callback) => (event) => {
|
5
|
+
event.key === keyboardCodes.ENTER && callback()
|
6
|
+
}
|
7
|
+
|
8
|
+
export const useKeydownEnterKey = (callback) => {
|
9
|
+
useEffect(() => {
|
10
|
+
window.addEventListener('keydown', createKeydownEvent(callback))
|
11
|
+
return () =>
|
12
|
+
window.removeEventListener('keydown', createKeydownEvent(callback))
|
13
|
+
}, [])
|
14
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import PropTypes from 'prop-types'
|
3
|
+
|
4
|
+
import Spacer from '../../layout/Spacer'
|
5
|
+
import Button from '../../atoms/Button'
|
6
|
+
import Icon from '../../atoms/Icon'
|
7
|
+
|
8
|
+
import { options } from './constants'
|
9
|
+
|
10
|
+
export const ButtonIcon = ({ children, type, icon }) => (
|
11
|
+
<Button
|
12
|
+
type={type}
|
13
|
+
isInline={true}
|
14
|
+
addons={{
|
15
|
+
append: (
|
16
|
+
<>
|
17
|
+
<Spacer.Horizontal size="xs"></Spacer.Horizontal>
|
18
|
+
<Icon
|
19
|
+
name={icon}
|
20
|
+
color={type === 'primary' ? 'inverted' : 'primary'}
|
21
|
+
/>
|
22
|
+
</>
|
23
|
+
),
|
24
|
+
}}
|
25
|
+
>
|
26
|
+
{children}
|
27
|
+
</Button>
|
28
|
+
)
|
29
|
+
|
30
|
+
ButtonIcon.propTypes = {
|
31
|
+
children: PropTypes.node.isRequired,
|
32
|
+
icon: PropTypes.oneOf(options.icons),
|
33
|
+
type: PropTypes.oneOf(options.types),
|
34
|
+
}
|
35
|
+
|
36
|
+
ButtonIcon.defaultProps = {
|
37
|
+
type: 'secondary',
|
38
|
+
icon: 'arrowRight',
|
39
|
+
}
|
40
|
+
|
41
|
+
export default ButtonIcon
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { ButtonIcon, options } from '.'
|
2
|
+
import {
|
3
|
+
getTemplate,
|
4
|
+
getListTemplate,
|
5
|
+
getOptionsArgTypes,
|
6
|
+
} from '../../helpers/storybook'
|
7
|
+
|
8
|
+
const Template = getTemplate(ButtonIcon)
|
9
|
+
const ListTemplate = getListTemplate(ButtonIcon)
|
10
|
+
|
11
|
+
export default {
|
12
|
+
title: 'Molecules/ButtonIcon',
|
13
|
+
component: ButtonIcon,
|
14
|
+
args: {
|
15
|
+
children: 'Cowards Agreed',
|
16
|
+
},
|
17
|
+
argTypes: {
|
18
|
+
type: getOptionsArgTypes(options.types),
|
19
|
+
icon: getOptionsArgTypes(options.icons),
|
20
|
+
children: { control: 'text' },
|
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 })) }
|
@@ -0,0 +1,178 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`Storyshots Molecules/ButtonIcon 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
|
+
<button
|
19
|
+
className="button type-secondary is-inline"
|
20
|
+
onClick={[Function]}
|
21
|
+
>
|
22
|
+
<h1
|
23
|
+
className="heading color-primary size-md weight-light is-centered is-inline"
|
24
|
+
>
|
25
|
+
Cowards Agreed
|
26
|
+
</h1>
|
27
|
+
<div
|
28
|
+
className="spacer horizontal"
|
29
|
+
style={
|
30
|
+
Object {
|
31
|
+
"height": "100%",
|
32
|
+
"maxHeight": "auto",
|
33
|
+
"width": 5,
|
34
|
+
}
|
35
|
+
}
|
36
|
+
/>
|
37
|
+
<div
|
38
|
+
className="icon color-primary size-md background-transparent"
|
39
|
+
style={
|
40
|
+
Object {
|
41
|
+
"height": 35,
|
42
|
+
"width": 35,
|
43
|
+
}
|
44
|
+
}
|
45
|
+
>
|
46
|
+
<svg
|
47
|
+
height={35}
|
48
|
+
viewBox="0 0 19 20"
|
49
|
+
width={35}
|
50
|
+
xmlns="http://www.w3.org/2000/svg"
|
51
|
+
>
|
52
|
+
<path
|
53
|
+
clipRule="evenodd"
|
54
|
+
d="M8.65792 19.316L7.34192 18L15.6849 9.658L7.34192 1.316L8.65792 0L18.3149 9.658L8.65792 19.316Z"
|
55
|
+
fillRule="evenodd"
|
56
|
+
/>
|
57
|
+
<path
|
58
|
+
clipRule="evenodd"
|
59
|
+
d="M0 8.65796H17V10.658H0V8.65796Z"
|
60
|
+
fillRule="evenodd"
|
61
|
+
/>
|
62
|
+
</svg>
|
63
|
+
</div>
|
64
|
+
</button>
|
65
|
+
</div>
|
66
|
+
`;
|
67
|
+
|
68
|
+
exports[`Storyshots Molecules/ButtonIcon Types 1`] = `
|
69
|
+
<div
|
70
|
+
style={
|
71
|
+
Object {
|
72
|
+
"alignContent": "flex-start",
|
73
|
+
"display": "flex",
|
74
|
+
"flexDirection": "column",
|
75
|
+
"flexWrap": "wrap",
|
76
|
+
"gap": "10px 30px",
|
77
|
+
"height": "100%",
|
78
|
+
"justifyContent": "flex-start",
|
79
|
+
"maxHeight": "auto",
|
80
|
+
}
|
81
|
+
}
|
82
|
+
>
|
83
|
+
<button
|
84
|
+
className="button type-primary is-inline"
|
85
|
+
onClick={[Function]}
|
86
|
+
>
|
87
|
+
<h1
|
88
|
+
className="heading color-inverted size-md weight-light is-centered is-inline"
|
89
|
+
>
|
90
|
+
Cowards Agreed
|
91
|
+
</h1>
|
92
|
+
<div
|
93
|
+
className="spacer horizontal"
|
94
|
+
style={
|
95
|
+
Object {
|
96
|
+
"height": "100%",
|
97
|
+
"maxHeight": "auto",
|
98
|
+
"width": 5,
|
99
|
+
}
|
100
|
+
}
|
101
|
+
/>
|
102
|
+
<div
|
103
|
+
className="icon color-inverted size-md background-transparent"
|
104
|
+
style={
|
105
|
+
Object {
|
106
|
+
"height": 35,
|
107
|
+
"width": 35,
|
108
|
+
}
|
109
|
+
}
|
110
|
+
>
|
111
|
+
<svg
|
112
|
+
height={35}
|
113
|
+
viewBox="0 0 19 20"
|
114
|
+
width={35}
|
115
|
+
xmlns="http://www.w3.org/2000/svg"
|
116
|
+
>
|
117
|
+
<path
|
118
|
+
clipRule="evenodd"
|
119
|
+
d="M8.65792 19.316L7.34192 18L15.6849 9.658L7.34192 1.316L8.65792 0L18.3149 9.658L8.65792 19.316Z"
|
120
|
+
fillRule="evenodd"
|
121
|
+
/>
|
122
|
+
<path
|
123
|
+
clipRule="evenodd"
|
124
|
+
d="M0 8.65796H17V10.658H0V8.65796Z"
|
125
|
+
fillRule="evenodd"
|
126
|
+
/>
|
127
|
+
</svg>
|
128
|
+
</div>
|
129
|
+
</button>
|
130
|
+
<button
|
131
|
+
className="button type-secondary is-inline"
|
132
|
+
onClick={[Function]}
|
133
|
+
>
|
134
|
+
<h1
|
135
|
+
className="heading color-primary size-md weight-light is-centered is-inline"
|
136
|
+
>
|
137
|
+
Cowards Agreed
|
138
|
+
</h1>
|
139
|
+
<div
|
140
|
+
className="spacer horizontal"
|
141
|
+
style={
|
142
|
+
Object {
|
143
|
+
"height": "100%",
|
144
|
+
"maxHeight": "auto",
|
145
|
+
"width": 5,
|
146
|
+
}
|
147
|
+
}
|
148
|
+
/>
|
149
|
+
<div
|
150
|
+
className="icon color-primary size-md background-transparent"
|
151
|
+
style={
|
152
|
+
Object {
|
153
|
+
"height": 35,
|
154
|
+
"width": 35,
|
155
|
+
}
|
156
|
+
}
|
157
|
+
>
|
158
|
+
<svg
|
159
|
+
height={35}
|
160
|
+
viewBox="0 0 19 20"
|
161
|
+
width={35}
|
162
|
+
xmlns="http://www.w3.org/2000/svg"
|
163
|
+
>
|
164
|
+
<path
|
165
|
+
clipRule="evenodd"
|
166
|
+
d="M8.65792 19.316L7.34192 18L15.6849 9.658L7.34192 1.316L8.65792 0L18.3149 9.658L8.65792 19.316Z"
|
167
|
+
fillRule="evenodd"
|
168
|
+
/>
|
169
|
+
<path
|
170
|
+
clipRule="evenodd"
|
171
|
+
d="M0 8.65796H17V10.658H0V8.65796Z"
|
172
|
+
fillRule="evenodd"
|
173
|
+
/>
|
174
|
+
</svg>
|
175
|
+
</div>
|
176
|
+
</button>
|
177
|
+
</div>
|
178
|
+
`;
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import PropTypes from 'prop-types'
|
3
|
+
|
4
|
+
import Icon from '../../atoms/Icon'
|
5
|
+
|
6
|
+
import styles from './Dropdown.module.css'
|
7
|
+
import withStyles from '../../hocs/withStyles'
|
8
|
+
|
9
|
+
export const Dropdown = ({
|
10
|
+
getStyles,
|
11
|
+
id,
|
12
|
+
options,
|
13
|
+
value,
|
14
|
+
isInline,
|
15
|
+
onChange,
|
16
|
+
}) => (
|
17
|
+
<div
|
18
|
+
id={id}
|
19
|
+
className={getStyles('dropdown', {
|
20
|
+
'is-inline': isInline,
|
21
|
+
})}
|
22
|
+
>
|
23
|
+
<Icon className="dropdown-icon" name="angleDown" background="highlight" />
|
24
|
+
<select
|
25
|
+
className={getStyles('dropdown-select')}
|
26
|
+
onChange={(event) => onChange(event?.currentTarget?.value)}
|
27
|
+
value={value}
|
28
|
+
>
|
29
|
+
{options.map(({ text, value }) => (
|
30
|
+
<option key={value} value={value}>
|
31
|
+
{text}
|
32
|
+
</option>
|
33
|
+
))}
|
34
|
+
</select>
|
35
|
+
</div>
|
36
|
+
)
|
37
|
+
|
38
|
+
Dropdown.propTypes = {
|
39
|
+
onChange: PropTypes.func.isRequired,
|
40
|
+
getStyles: PropTypes.func.isRequired,
|
41
|
+
options: PropTypes.arrayOf(
|
42
|
+
PropTypes.shape({
|
43
|
+
text: PropTypes.string,
|
44
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
45
|
+
})
|
46
|
+
).isRequired,
|
47
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
48
|
+
id: PropTypes.string,
|
49
|
+
isInline: PropTypes.bool,
|
50
|
+
}
|
51
|
+
|
52
|
+
Dropdown.defaultProps = {
|
53
|
+
value: '',
|
54
|
+
isInline: false,
|
55
|
+
onChange: () => {},
|
56
|
+
getStyles: () => {},
|
57
|
+
}
|
58
|
+
|
59
|
+
export default withStyles(styles)(Dropdown)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
.dropdown {
|
2
|
+
position: relative;
|
3
|
+
display: inline-block;
|
4
|
+
width: 100%;
|
5
|
+
cursor: pointer;
|
6
|
+
}
|
7
|
+
|
8
|
+
.dropdown :global(.dropdown-icon) {
|
9
|
+
position: absolute;
|
10
|
+
top: 50%;
|
11
|
+
right: 1px;
|
12
|
+
pointer-events: none;
|
13
|
+
transform: translateY(-50%);
|
14
|
+
}
|
15
|
+
|
16
|
+
.dropdown-select {
|
17
|
+
width: 100%;
|
18
|
+
height: var(--input-height);
|
19
|
+
padding: 10px 30px 10px 20px;
|
20
|
+
border: var(--border-width-thin) solid var(--color-primary);
|
21
|
+
background: var(--input-background);
|
22
|
+
border-radius: var(--input-border-radius);
|
23
|
+
color: var(--color-font-base);
|
24
|
+
transition: box-shadow 0.2s ease;
|
25
|
+
}
|
26
|
+
|
27
|
+
.dropdown-select:focus {
|
28
|
+
box-shadow: 0 0 0 1px var(--color-primary), 0 0 10px 0 var(--color-primary);
|
29
|
+
outline: none;
|
30
|
+
}
|
31
|
+
|
32
|
+
.is-inline {
|
33
|
+
max-width: max-content;
|
34
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { Dropdown, styles } from '.'
|
2
|
+
|
3
|
+
import { getTemplate } from '../../helpers/storybook'
|
4
|
+
|
5
|
+
const Template = getTemplate(Dropdown, styles)
|
6
|
+
|
7
|
+
export default {
|
8
|
+
title: 'Molecules/Dropdown',
|
9
|
+
component: Dropdown,
|
10
|
+
args: {
|
11
|
+
options: [
|
12
|
+
{
|
13
|
+
text: '8:00 AM',
|
14
|
+
value: 800,
|
15
|
+
},
|
16
|
+
{
|
17
|
+
text: '1:00 PM',
|
18
|
+
value: 1300,
|
19
|
+
},
|
20
|
+
],
|
21
|
+
},
|
22
|
+
argTypes: {
|
23
|
+
options: {
|
24
|
+
description: '**array of shaped objects:**',
|
25
|
+
table: {
|
26
|
+
type: {
|
27
|
+
summary: 'object',
|
28
|
+
detail: "{ text: 'string', value: 'string|number'}",
|
29
|
+
},
|
30
|
+
},
|
31
|
+
},
|
32
|
+
},
|
33
|
+
}
|
34
|
+
|
35
|
+
export const Default = Template.bind({})
|
36
|
+
|
37
|
+
export const Value = Template.bind({})
|
38
|
+
Value.args = { value: 1300 }
|
39
|
+
|
40
|
+
export const Inline = Template.bind({})
|
41
|
+
Inline.args = { isInline: true }
|
@@ -0,0 +1,181 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`Storyshots Molecules/Dropdown 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="dropdown"
|
20
|
+
>
|
21
|
+
<div
|
22
|
+
className="dropdown-icon icon color-base size-md background-highlight"
|
23
|
+
style={
|
24
|
+
Object {
|
25
|
+
"height": 35,
|
26
|
+
"width": 35,
|
27
|
+
}
|
28
|
+
}
|
29
|
+
>
|
30
|
+
<svg
|
31
|
+
height={35}
|
32
|
+
viewBox="0 0 15 9"
|
33
|
+
width={35}
|
34
|
+
xmlns="http://www.w3.org/2000/svg"
|
35
|
+
>
|
36
|
+
<path
|
37
|
+
clipRule="evenodd"
|
38
|
+
d="M7.82633 8.70623L0.882568 1.54063L1.89405 0.496826L7.82633 6.61863L13.7586 0.496826L14.7701 1.54063L7.82633 8.70623Z"
|
39
|
+
fillRule="evenodd"
|
40
|
+
/>
|
41
|
+
</svg>
|
42
|
+
</div>
|
43
|
+
<select
|
44
|
+
className="dropdown-select"
|
45
|
+
onChange={[Function]}
|
46
|
+
value=""
|
47
|
+
>
|
48
|
+
<option
|
49
|
+
value={800}
|
50
|
+
>
|
51
|
+
8:00 AM
|
52
|
+
</option>
|
53
|
+
<option
|
54
|
+
value={1300}
|
55
|
+
>
|
56
|
+
1:00 PM
|
57
|
+
</option>
|
58
|
+
</select>
|
59
|
+
</div>
|
60
|
+
</div>
|
61
|
+
`;
|
62
|
+
|
63
|
+
exports[`Storyshots Molecules/Dropdown Inline 1`] = `
|
64
|
+
<div
|
65
|
+
style={
|
66
|
+
Object {
|
67
|
+
"alignContent": "flex-start",
|
68
|
+
"display": "flex",
|
69
|
+
"flexDirection": "column",
|
70
|
+
"flexWrap": "wrap",
|
71
|
+
"gap": "10px 30px",
|
72
|
+
"height": "100%",
|
73
|
+
"justifyContent": "flex-start",
|
74
|
+
"maxHeight": "auto",
|
75
|
+
}
|
76
|
+
}
|
77
|
+
>
|
78
|
+
<div
|
79
|
+
className="dropdown is-inline"
|
80
|
+
>
|
81
|
+
<div
|
82
|
+
className="dropdown-icon icon color-base size-md background-highlight"
|
83
|
+
style={
|
84
|
+
Object {
|
85
|
+
"height": 35,
|
86
|
+
"width": 35,
|
87
|
+
}
|
88
|
+
}
|
89
|
+
>
|
90
|
+
<svg
|
91
|
+
height={35}
|
92
|
+
viewBox="0 0 15 9"
|
93
|
+
width={35}
|
94
|
+
xmlns="http://www.w3.org/2000/svg"
|
95
|
+
>
|
96
|
+
<path
|
97
|
+
clipRule="evenodd"
|
98
|
+
d="M7.82633 8.70623L0.882568 1.54063L1.89405 0.496826L7.82633 6.61863L13.7586 0.496826L14.7701 1.54063L7.82633 8.70623Z"
|
99
|
+
fillRule="evenodd"
|
100
|
+
/>
|
101
|
+
</svg>
|
102
|
+
</div>
|
103
|
+
<select
|
104
|
+
className="dropdown-select"
|
105
|
+
onChange={[Function]}
|
106
|
+
value=""
|
107
|
+
>
|
108
|
+
<option
|
109
|
+
value={800}
|
110
|
+
>
|
111
|
+
8:00 AM
|
112
|
+
</option>
|
113
|
+
<option
|
114
|
+
value={1300}
|
115
|
+
>
|
116
|
+
1:00 PM
|
117
|
+
</option>
|
118
|
+
</select>
|
119
|
+
</div>
|
120
|
+
</div>
|
121
|
+
`;
|
122
|
+
|
123
|
+
exports[`Storyshots Molecules/Dropdown Value 1`] = `
|
124
|
+
<div
|
125
|
+
style={
|
126
|
+
Object {
|
127
|
+
"alignContent": "flex-start",
|
128
|
+
"display": "flex",
|
129
|
+
"flexDirection": "column",
|
130
|
+
"flexWrap": "wrap",
|
131
|
+
"gap": "10px 30px",
|
132
|
+
"height": "100%",
|
133
|
+
"justifyContent": "flex-start",
|
134
|
+
"maxHeight": "auto",
|
135
|
+
}
|
136
|
+
}
|
137
|
+
>
|
138
|
+
<div
|
139
|
+
className="dropdown"
|
140
|
+
>
|
141
|
+
<div
|
142
|
+
className="dropdown-icon icon color-base size-md background-highlight"
|
143
|
+
style={
|
144
|
+
Object {
|
145
|
+
"height": 35,
|
146
|
+
"width": 35,
|
147
|
+
}
|
148
|
+
}
|
149
|
+
>
|
150
|
+
<svg
|
151
|
+
height={35}
|
152
|
+
viewBox="0 0 15 9"
|
153
|
+
width={35}
|
154
|
+
xmlns="http://www.w3.org/2000/svg"
|
155
|
+
>
|
156
|
+
<path
|
157
|
+
clipRule="evenodd"
|
158
|
+
d="M7.82633 8.70623L0.882568 1.54063L1.89405 0.496826L7.82633 6.61863L13.7586 0.496826L14.7701 1.54063L7.82633 8.70623Z"
|
159
|
+
fillRule="evenodd"
|
160
|
+
/>
|
161
|
+
</svg>
|
162
|
+
</div>
|
163
|
+
<select
|
164
|
+
className="dropdown-select"
|
165
|
+
onChange={[Function]}
|
166
|
+
value={1300}
|
167
|
+
>
|
168
|
+
<option
|
169
|
+
value={800}
|
170
|
+
>
|
171
|
+
8:00 AM
|
172
|
+
</option>
|
173
|
+
<option
|
174
|
+
value={1300}
|
175
|
+
>
|
176
|
+
1:00 PM
|
177
|
+
</option>
|
178
|
+
</select>
|
179
|
+
</div>
|
180
|
+
</div>
|
181
|
+
`;
|