@spothero/ui 15.7.0 → 15.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -6
- package/styles/v2/components/Card/Card.jsx +1 -1
- package/styles/v2/components/Divider/Divider.jsx +29 -0
- package/styles/v2/components/Divider/Divider.stories.js +42 -0
- package/styles/v2/components/Divider/Divider.styles.js +15 -0
- package/styles/v2/components/FormControl/FormControl.jsx +18 -4
- package/styles/v2/components/Input/Input.jsx +3 -0
- package/styles/v2/components/Input/Input.stories.js +6 -0
- package/styles/v2/components/Input/styles/index.js +13 -2
- package/styles/v2/components/Select/Select.jsx +3 -0
- package/styles/v2/components/Select/Select.stories.js +1 -0
- package/styles/v2/components/index.js +1 -0
- package/styles/v2/components/styles.js +1 -0
- package/v2/index.js +1 -1
- package/v2/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spothero/ui",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.8.0",
|
|
4
4
|
"description": "SpotHero's React component UI library.",
|
|
5
5
|
"main": "v2/index.js",
|
|
6
6
|
"repository": "https://github.com/spothero/fe-monorepo",
|
|
@@ -88,10 +88,10 @@
|
|
|
88
88
|
"@spothero/npm-publisher": "*",
|
|
89
89
|
"@spothero/prettier-config": "*",
|
|
90
90
|
"@spothero/stylelint-config": "*",
|
|
91
|
-
"@storybook/addon-actions": "6.
|
|
92
|
-
"@storybook/addon-essentials": "6.
|
|
93
|
-
"@storybook/addon-links": "6.
|
|
94
|
-
"@storybook/react": "6.
|
|
91
|
+
"@storybook/addon-actions": "6.5.10",
|
|
92
|
+
"@storybook/addon-essentials": "6.5.10",
|
|
93
|
+
"@storybook/addon-links": "6.5.10",
|
|
94
|
+
"@storybook/react": "6.5.10",
|
|
95
95
|
"@testing-library/jest-dom": "5.11.9",
|
|
96
96
|
"@testing-library/react": "11.2.5",
|
|
97
97
|
"@testing-library/user-event": "12.8.1",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"@emotion/react": "11.1.5",
|
|
133
133
|
"@emotion/styled": "11.1.5",
|
|
134
134
|
"@spothero/utils": "*",
|
|
135
|
-
"@storybook/addon-a11y": "6.
|
|
135
|
+
"@storybook/addon-a11y": "6.5.10",
|
|
136
136
|
"axe-core": "4.1.3",
|
|
137
137
|
"chartist": "0.11.4",
|
|
138
138
|
"chartist-plugin-legend": "0.6.2",
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, {forwardRef} from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import {Divider as ChakraDivider} from '@chakra-ui/react';
|
|
4
|
+
import {baseStyles, colorScheme} from './Divider.styles';
|
|
5
|
+
|
|
6
|
+
const Divider = forwardRef(({variant, colorScheme: borderColor, ...props}, ref) => {
|
|
7
|
+
return (
|
|
8
|
+
<ChakraDivider
|
|
9
|
+
{...baseStyles}
|
|
10
|
+
{...colorScheme[borderColor]}
|
|
11
|
+
variant={variant}
|
|
12
|
+
{...props}
|
|
13
|
+
ref={ref}
|
|
14
|
+
/>
|
|
15
|
+
)});
|
|
16
|
+
|
|
17
|
+
Divider.propTypes = {
|
|
18
|
+
/** Color scheme used */
|
|
19
|
+
colorScheme: PropTypes.oneOf(['low', 'medium']),
|
|
20
|
+
/** The styling that will be applied to the HR tag */
|
|
21
|
+
variant: PropTypes.oneOf(['solid', 'dashed']),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
Divider.defaultProps = {
|
|
25
|
+
variant: 'solid',
|
|
26
|
+
colorScheme: 'medium',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default Divider;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {colorScheme} from './Divider.styles';
|
|
4
|
+
|
|
5
|
+
import Component from './Divider';
|
|
6
|
+
|
|
7
|
+
import {Box, Text} from '@chakra-ui/react';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
title: 'v2/Divider',
|
|
11
|
+
component: Component,
|
|
12
|
+
argTypes: {
|
|
13
|
+
colorScheme: {
|
|
14
|
+
control: {
|
|
15
|
+
type: 'select',
|
|
16
|
+
options: Object.keys(colorScheme),
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
variant: {
|
|
20
|
+
control: {
|
|
21
|
+
type: 'select',
|
|
22
|
+
options: ['solid', 'dashed'],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const Template = props => (
|
|
30
|
+
<Box>
|
|
31
|
+
<Text>Over HowdyHowdyHowdy</Text>
|
|
32
|
+
<Component {...props}/>
|
|
33
|
+
<Text>Under HowdyHowdyHowdy</Text>
|
|
34
|
+
</Box>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export const Divider = Template.bind({});
|
|
38
|
+
|
|
39
|
+
Divider.args = {
|
|
40
|
+
variant: 'solid',
|
|
41
|
+
colorScheme: 'medium',
|
|
42
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import merge from 'lodash/merge';
|
|
2
|
+
import chakraDefaultTheme from '@chakra-ui/theme';
|
|
3
|
+
|
|
4
|
+
export const colorScheme = {
|
|
5
|
+
low: {
|
|
6
|
+
borderColor: 'gray.100'
|
|
7
|
+
},
|
|
8
|
+
medium: {
|
|
9
|
+
borderColor: 'gray.200'
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default merge(chakraDefaultTheme.components.Divider, {
|
|
14
|
+
colorScheme,
|
|
15
|
+
});
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
FormHelperText,
|
|
6
6
|
FormLabel,
|
|
7
7
|
FormErrorMessage,
|
|
8
|
+
Text,
|
|
8
9
|
} from '@chakra-ui/react';
|
|
9
10
|
|
|
10
11
|
const FormControl = forwardRef(
|
|
@@ -30,21 +31,34 @@ const FormControl = forwardRef(
|
|
|
30
31
|
<FormLabel
|
|
31
32
|
color="gray.600"
|
|
32
33
|
fontWeight="semibold"
|
|
33
|
-
|
|
34
|
+
marginBottom={helperText ? 0 : 1}
|
|
34
35
|
fontSize="sm"
|
|
35
36
|
htmlFor={inputId}
|
|
36
37
|
as={isFieldset ? 'legend' : 'label'}
|
|
38
|
+
requiredIndicator=""
|
|
39
|
+
optionalIndicator={
|
|
40
|
+
props?.isOptional && !props?.isRequired ? (
|
|
41
|
+
<Text
|
|
42
|
+
marginLeft={1}
|
|
43
|
+
as="span"
|
|
44
|
+
variant="caption"
|
|
45
|
+
color="text.secondary.light"
|
|
46
|
+
>
|
|
47
|
+
Optional
|
|
48
|
+
</Text>
|
|
49
|
+
) : null
|
|
50
|
+
}
|
|
37
51
|
>
|
|
38
52
|
{label}
|
|
39
53
|
</FormLabel>
|
|
40
54
|
)}
|
|
41
|
-
{children}
|
|
42
55
|
{helperText && (
|
|
43
|
-
<FormHelperText color="gray.600"
|
|
56
|
+
<FormHelperText color="gray.600" marginBottom={1} fontSize="xs">
|
|
44
57
|
{helperText}
|
|
45
58
|
</FormHelperText>
|
|
46
59
|
)}
|
|
47
|
-
|
|
60
|
+
{children}
|
|
61
|
+
<FormErrorMessage color="error" mt={1} fontSize="xs">
|
|
48
62
|
{errorMessage}
|
|
49
63
|
</FormErrorMessage>
|
|
50
64
|
</ChakraFormControl>
|
|
@@ -13,6 +13,7 @@ const Input = forwardRef(
|
|
|
13
13
|
isInvalid,
|
|
14
14
|
isDisabled,
|
|
15
15
|
isRequired,
|
|
16
|
+
isOptional,
|
|
16
17
|
...props
|
|
17
18
|
},
|
|
18
19
|
ref
|
|
@@ -24,6 +25,7 @@ const Input = forwardRef(
|
|
|
24
25
|
isInvalid={isInvalid}
|
|
25
26
|
isDisabled={isDisabled}
|
|
26
27
|
isRequired={isRequired}
|
|
28
|
+
isOptional={isOptional}
|
|
27
29
|
errorMessage={errorMessage}
|
|
28
30
|
helperText={helperText}
|
|
29
31
|
label={label}
|
|
@@ -43,6 +45,7 @@ Input.propTypes = {
|
|
|
43
45
|
isInvalid: PropTypes.bool,
|
|
44
46
|
isDisabled: PropTypes.bool,
|
|
45
47
|
isRequired: PropTypes.bool,
|
|
48
|
+
isOptional: PropTypes.bool,
|
|
46
49
|
};
|
|
47
50
|
|
|
48
51
|
export default Input;
|
|
@@ -2,12 +2,15 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
4
|
import Component from './Input';
|
|
5
|
+
import {useTheme} from '@chakra-ui/react';
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
title: 'v2/Input',
|
|
8
9
|
component: Component,
|
|
9
10
|
parameters: {
|
|
11
|
+
importBy: 'Input',
|
|
10
12
|
removeBaseHtmlClass: true,
|
|
13
|
+
chakraLink: 'https://chakra-ui.com/docs/components/input',
|
|
11
14
|
},
|
|
12
15
|
};
|
|
13
16
|
|
|
@@ -23,6 +26,7 @@ InputTemplate.propTypes = {
|
|
|
23
26
|
isInvalid: PropTypes.bool,
|
|
24
27
|
isDisabled: PropTypes.bool,
|
|
25
28
|
isReadOnly: PropTypes.bool,
|
|
29
|
+
isOptional: PropTypes.bool,
|
|
26
30
|
};
|
|
27
31
|
|
|
28
32
|
export const Input = InputTemplate.bind({});
|
|
@@ -43,6 +47,7 @@ Input.argTypes = {
|
|
|
43
47
|
};
|
|
44
48
|
|
|
45
49
|
Input.args = {
|
|
50
|
+
id: 'input_id',
|
|
46
51
|
placeholder: 'Placeholder text',
|
|
47
52
|
label: 'Label',
|
|
48
53
|
helperText: 'Helper text',
|
|
@@ -51,4 +56,5 @@ Input.args = {
|
|
|
51
56
|
isDisabled: false,
|
|
52
57
|
isReadOnly: false,
|
|
53
58
|
isRequired: false,
|
|
59
|
+
isOptional: false,
|
|
54
60
|
};
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import merge from 'lodash/merge';
|
|
2
2
|
import chakraDefaultTheme from '@chakra-ui/theme';
|
|
3
3
|
|
|
4
|
+
const baseStyle = {
|
|
5
|
+
field: {
|
|
6
|
+
_placeholder: {
|
|
7
|
+
color: 'text.secondary.light',
|
|
8
|
+
fontWeight: 'normal',
|
|
9
|
+
_disabled: {color: 'text.secondary.light', opacity: 1},
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
4
14
|
const variants = {
|
|
5
15
|
outline: {
|
|
6
16
|
field: {
|
|
@@ -12,7 +22,7 @@ const variants = {
|
|
|
12
22
|
bg: 'inherit',
|
|
13
23
|
fontWeight: 'normal',
|
|
14
24
|
boxShadow: 'none !important',
|
|
15
|
-
_placeholder: {color: '
|
|
25
|
+
_placeholder: {color: 'text.secondary.light', fontWeight: 'normal'},
|
|
16
26
|
_focus: {
|
|
17
27
|
borderColor: 'brandBlue',
|
|
18
28
|
},
|
|
@@ -20,7 +30,7 @@ const variants = {
|
|
|
20
30
|
_readOnly: {boxShadow: 'none !important', userSelect: 'all'},
|
|
21
31
|
_disabled: {
|
|
22
32
|
backgroundColor: 'gray.50',
|
|
23
|
-
opacity:
|
|
33
|
+
opacity: 1,
|
|
24
34
|
cursor: 'not-allowed',
|
|
25
35
|
},
|
|
26
36
|
_invalid: {
|
|
@@ -34,5 +44,6 @@ const variants = {
|
|
|
34
44
|
};
|
|
35
45
|
|
|
36
46
|
export default merge(chakraDefaultTheme.components.Input, {
|
|
47
|
+
baseStyle,
|
|
37
48
|
variants,
|
|
38
49
|
});
|
|
@@ -16,6 +16,7 @@ const Select = forwardRef(
|
|
|
16
16
|
isInvalid,
|
|
17
17
|
isDisabled,
|
|
18
18
|
isRequired,
|
|
19
|
+
isOptional,
|
|
19
20
|
...props
|
|
20
21
|
},
|
|
21
22
|
ref
|
|
@@ -28,6 +29,7 @@ const Select = forwardRef(
|
|
|
28
29
|
isDisabled={isDisabled}
|
|
29
30
|
isRequired={isRequired}
|
|
30
31
|
errorMessage={errorMessage}
|
|
32
|
+
isOptional={isOptional}
|
|
31
33
|
helperText={helperText}
|
|
32
34
|
label={label}
|
|
33
35
|
inputId={props.id}
|
|
@@ -54,6 +56,7 @@ Select.propTypes = {
|
|
|
54
56
|
isInvalid: PropTypes.bool,
|
|
55
57
|
isDisabled: PropTypes.bool,
|
|
56
58
|
isRequired: PropTypes.bool,
|
|
59
|
+
isOptional: PropTypes.bool,
|
|
57
60
|
};
|
|
58
61
|
|
|
59
62
|
export default Select;
|
|
@@ -24,6 +24,7 @@ export {default as Image} from './Image/Image';
|
|
|
24
24
|
export {default as Loader} from './Loader/Loader';
|
|
25
25
|
export {default as Checkbox} from './Checkbox';
|
|
26
26
|
export {default as Input} from './Input';
|
|
27
|
+
export {default as Divider} from './Divider/Divider';
|
|
27
28
|
export {
|
|
28
29
|
Popover,
|
|
29
30
|
PopoverAnchor,
|
|
@@ -7,6 +7,7 @@ export {default as Button} from './Button/Button.styles';
|
|
|
7
7
|
export {default as GridItem} from './Grid/GridItem.styles';
|
|
8
8
|
export {default as Spinner} from './Spinner/Spinner.styles';
|
|
9
9
|
export {default as Heading} from './Heading/Heading.styles';
|
|
10
|
+
export {default as Divider} from './Divider/Divider.styles';
|
|
10
11
|
export {default as Tabs} from './Tabs/styles';
|
|
11
12
|
export {default as Select} from './Select/styles';
|
|
12
13
|
export {default as Checkbox} from './Checkbox/styles';
|