@spothero/ui 14.4.0 → 14.5.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,30 @@
1
+ # 14.5.1 - 05/05/2022
2
+ ## Miscellaneous Updates
3
+ * [[87e838a](https://github.com/spothero/fe-ui/commit/87e838a)] - `feature:` FED 321 secondary button updates, add tertiary and destructive buttons ([#284](https://github.com/spothero/fe-ui/pull/284)) (Mick Johnson)
4
+
5
+ # 14.5.0 - 05/03/2022
6
+
7
+ ## New Features
8
+ * [[173526f](https://github.com/spothero/fe-ui/commit/173526f)] - FED-354 feat: adds Input component ([#283](https://github.com/spothero/fe-ui/pull/283)) (annaliarosed)
9
+ * `feat:` Set up TextInput component
10
+ * `refactor:` Rename component and set up styles
11
+ * `feat:` Unlabeled, placeholder styles added
12
+ * `feat:` Unlabeled, value styles added
13
+ * `feat:` Unlabeled, focus styles added
14
+ * `feat:` Unlabeled, error and disabled styles added
15
+ * `feat:` Add label prop and styles
16
+ * `feat:` Add helperText prop and styles
17
+ * `feat:` Add errorMessage prop and styles
18
+ * `feat:` Add isReadOnly prop to stories
19
+ * `fix:` Clean up
20
+ * `fix:` Change value color when isInvalid
21
+ * `fix:` Add missing ref
22
+ * `refactor:` Extract FormControl
23
+ * `fix:` Remove imported interfaces
24
+ * `fix:` Pass only isInvalid prop to FormControl
25
+ * `fix:` Pass only isDisabled and isRequired prop to FormControl
26
+ * `fix:` Pass forgotten propsCo-authored-by: Annalia Destefano <annalia.destefano@spothero.com>
27
+
1
28
  # 14.4.0 - 04/21/2022
2
29
 
3
30
  ## Dependency Updates
package/CHANGELOG.tmp CHANGED
@@ -1,5 +1,4 @@
1
- # 14.4.0 - 04/21/2022
2
-
3
- ## Dependency Updates
4
- * [[d04c143](https://github.com/spothero/fe-ui/commit/d04c143)] - Upgrade to React 17 ([#282](https://github.com/spothero/fe-ui/pull/282)) (Gru Singh)
1
+ # 14.5.1 - 05/05/2022
2
+ ## Miscellaneous Updates
3
+ * [[87e838a](https://github.com/spothero/fe-ui/commit/87e838a)] - `feature:` FED 321 secondary button updates, add tertiary and destructive buttons ([#284](https://github.com/spothero/fe-ui/pull/284)) (Mick Johnson)
5
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spothero/ui",
3
- "version": "14.4.0",
3
+ "version": "14.5.1",
4
4
  "description": "SpotHero's React component UI library.",
5
5
  "main": "v2/index-bundled.cjs.js",
6
6
  "module": "v2/index.js",
@@ -15,6 +15,7 @@ const anchorProps = (isExternal = false) => ({
15
15
  const Button = forwardRef(({asAnchor, isExternal, ...props}, ref) => (
16
16
  <ChakraButton
17
17
  iconSpacing={2}
18
+ sx={{'text-underline-offset': '1px'}}
18
19
  {...props}
19
20
  {...((asAnchor || props.as === 'a') && anchorProps(isExternal))}
20
21
  ref={ref}
@@ -32,6 +32,17 @@ const disabledButtonHoverStyle = {
32
32
  },
33
33
  };
34
34
 
35
+ const destructiveButtonStyles = {
36
+ bg: 'white',
37
+ borderColor: 'red.default',
38
+ color: 'red.default',
39
+ _hover: {
40
+ borderColor: 'red.800',
41
+ color: 'red.800',
42
+ ...disabledButtonHoverStyle,
43
+ },
44
+ };
45
+
35
46
  export const variants = {
36
47
  primary: {
37
48
  bg: 'primary.default',
@@ -63,7 +74,7 @@ export const variants = {
63
74
  borderColor: 'gray.medium',
64
75
  color: 'primary.default',
65
76
  _hover: {
66
- borderColor: 'primary.default',
77
+ borderColor: 'primary.600',
67
78
  color: 'primary.600',
68
79
  ...disabledButtonHoverStyle,
69
80
  },
@@ -125,6 +136,57 @@ export const variants = {
125
136
  },
126
137
  },
127
138
  },
139
+ tertiary: {
140
+ bg: 'none',
141
+ borderWidth: 'none',
142
+ borderRadius: 'unset',
143
+ color: 'primary.default',
144
+ textDecoration: 'underline',
145
+ h: 'unset',
146
+ m: 'unset',
147
+ minW: 'unset',
148
+ p: 'unset',
149
+ lineHeight: 1,
150
+ _disabled: {
151
+ bg: 'none',
152
+ color: 'gray.dark',
153
+ },
154
+ _hover: {
155
+ color: 'primary.600',
156
+ _disabled: {
157
+ color: 'gray.dark',
158
+ },
159
+ },
160
+ },
161
+ tertiaryOnDark: {
162
+ bg: 'none',
163
+ borderRadius: 'unset',
164
+ borderWidth: 'none',
165
+ color: 'white',
166
+ textDecoration: 'underline',
167
+ h: 'unset',
168
+ m: 'unset',
169
+ minW: 'unset',
170
+ p: 'unset',
171
+ _disabled: {
172
+ bg: 'none',
173
+ color: 'white',
174
+ opacity: '.7',
175
+ },
176
+ _hover: {
177
+ color: 'white',
178
+ opacity: '.8',
179
+ _disabled: {
180
+ opacity: '.7',
181
+ },
182
+ },
183
+ },
184
+ destructive: {
185
+ ...destructiveButtonStyles,
186
+ },
187
+ destructiveOnDark: {
188
+ ...destructiveButtonStyles,
189
+ },
128
190
  };
129
191
 
130
192
  const defaultProps = {
@@ -58,8 +58,23 @@ Tertiary.argTypes = {
58
58
  onClick: {action: 'clicked'},
59
59
  };
60
60
  Tertiary.args = {
61
- children: 'textButton',
62
- variant: 'textButton',
61
+ children: 'tertiary',
62
+ variant: 'tertiary',
63
+ isDisabled: false,
64
+ isLoading: false,
65
+ loadingText: 'Loading',
66
+ isFullWidth: false,
67
+ };
68
+
69
+ export const Destructive = ButtonTemplate.bind({});
70
+ Destructive.argTypes = {
71
+ ...createSelectControl('type', ['button', 'reset', 'submit']),
72
+ ...disableArgs('variant'),
73
+ onClick: {action: 'clicked'},
74
+ };
75
+ Destructive.args = {
76
+ children: 'destructive',
77
+ variant: 'destructive',
63
78
  isDisabled: false,
64
79
  isLoading: false,
65
80
  loadingText: 'Loading',
@@ -0,0 +1,43 @@
1
+ import React, {forwardRef} from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import {
4
+ FormControl as ChakraFormControl,
5
+ FormHelperText,
6
+ FormLabel,
7
+ FormErrorMessage,
8
+ } from '@chakra-ui/react';
9
+
10
+ const FormControl = forwardRef(
11
+ ({children, label, helperText, errorMessage, ...props}, ref) => (
12
+ <ChakraFormControl {...props} ref={ref}>
13
+ {label && (
14
+ <FormLabel
15
+ color="gray.600"
16
+ fontWeight="semibold"
17
+ mb={2}
18
+ fontSize="sm"
19
+ >
20
+ {label}
21
+ </FormLabel>
22
+ )}
23
+ {children}
24
+ {helperText && (
25
+ <FormHelperText color="gray.600" mt={1} fontSize="xs">
26
+ {helperText}
27
+ </FormHelperText>
28
+ )}
29
+ <FormErrorMessage color="error" mt={1} fontSize="xs">
30
+ {errorMessage}
31
+ </FormErrorMessage>
32
+ </ChakraFormControl>
33
+ )
34
+ );
35
+
36
+ FormControl.propTypes = {
37
+ label: PropTypes.string,
38
+ helperText: PropTypes.string,
39
+ errorMessage: PropTypes.string,
40
+ children: PropTypes.node,
41
+ };
42
+
43
+ export default FormControl;
@@ -0,0 +1,41 @@
1
+ import React, {forwardRef} from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import {Input as ChakraInput} from '@chakra-ui/react';
4
+ import FormControl from '../FormControl/FormControl';
5
+
6
+ const Input = forwardRef(
7
+ (
8
+ {
9
+ label,
10
+ helperText,
11
+ errorMessage,
12
+ isInvalid,
13
+ isDisabled,
14
+ isRequired,
15
+ ...props
16
+ },
17
+ ref
18
+ ) => (
19
+ <FormControl
20
+ isInvalid={isInvalid}
21
+ isDisabled={isDisabled}
22
+ isRequired={isRequired}
23
+ errorMessage={errorMessage}
24
+ helperText={helperText}
25
+ label={label}
26
+ >
27
+ <ChakraInput ref={ref} {...props} />
28
+ </FormControl>
29
+ )
30
+ );
31
+
32
+ Input.propTypes = {
33
+ label: PropTypes.string,
34
+ helperText: PropTypes.string,
35
+ errorMessage: PropTypes.string,
36
+ isInvalid: PropTypes.bool,
37
+ isDisabled: PropTypes.bool,
38
+ isRequired: PropTypes.bool,
39
+ };
40
+
41
+ export default Input;
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ import Component from './Input';
5
+
6
+ export default {
7
+ title: 'v2/Input',
8
+ component: Component,
9
+ parameters: {
10
+ removeBaseHtmlClass: true,
11
+ },
12
+ };
13
+
14
+ const InputTemplate = props => (
15
+ <Component variant="outline" maxWidth="200px" {...props} />
16
+ );
17
+
18
+ InputTemplate.propTypes = {
19
+ placeholder: PropTypes.string,
20
+ label: PropTypes.string,
21
+ helperText: PropTypes.string,
22
+ errorMessage: PropTypes.string,
23
+ isInvalid: PropTypes.bool,
24
+ isDisabled: PropTypes.bool,
25
+ isReadOnly: PropTypes.bool,
26
+ };
27
+
28
+ export const Input = InputTemplate.bind({});
29
+
30
+ Input.argTypes = {
31
+ placeholder: {
32
+ control: {type: 'text'},
33
+ },
34
+ label: {
35
+ control: {type: 'text'},
36
+ },
37
+ helperText: {
38
+ control: {type: 'text'},
39
+ },
40
+ errorMessage: {
41
+ control: {type: 'text'},
42
+ },
43
+ };
44
+
45
+ Input.args = {
46
+ placeholder: 'Placeholder text',
47
+ label: 'Label',
48
+ helperText: 'Helper text',
49
+ errorMessage: 'Error message',
50
+ isInvalid: false,
51
+ isDisabled: false,
52
+ isReadOnly: false,
53
+ };
@@ -0,0 +1 @@
1
+ export {default} from './Input';
@@ -0,0 +1,35 @@
1
+ import merge from 'lodash/merge';
2
+ import chakraDefaultTheme from '@chakra-ui/theme';
3
+
4
+ const variants = {
5
+ outline: {
6
+ field: {
7
+ border: '1px solid',
8
+ borderColor: 'gray.200',
9
+ fontSize: 'base',
10
+ paddingLeft: 3,
11
+ paddingRight: 3,
12
+ bg: 'inherit',
13
+ fontWeight: 'semibold',
14
+ boxShadow: 'none !important',
15
+ _placeholder: {color: 'gray.600', fontWeight: 'normal'},
16
+ _focus: {
17
+ borderColor: 'brandBlue',
18
+ },
19
+ _hover: {borderColor: 'gray.300'},
20
+ _readOnly: {boxShadow: 'none !important', userSelect: 'all'},
21
+ _disabled: {
22
+ backgroundColor: 'gray.50',
23
+ opacity: 0.4,
24
+ cursor: 'not-allowed',
25
+ },
26
+ _invalid: {
27
+ borderColor: 'error',
28
+ },
29
+ },
30
+ },
31
+ };
32
+
33
+ export default merge(chakraDefaultTheme.components.Input, {
34
+ variants,
35
+ });
@@ -22,6 +22,7 @@ export {default as Icon} from './Icon/Icon';
22
22
  export {default as Image} from './Image/Image';
23
23
  export {default as Loader} from './Loader/Loader';
24
24
  export {default as Checkbox} from './Checkbox';
25
+ export {default as Input} from './Input';
25
26
  export {Popover, PopoverTrigger, PopoverContent} from './Popover';
26
27
 
27
28
  // generic chakra reexports
@@ -11,3 +11,4 @@ export {default as Tabs} from './Tabs/styles';
11
11
  export {default as Select} from './Select/styles';
12
12
  export {default as Checkbox} from './Checkbox/styles';
13
13
  export {default as Popover} from './Popover/styles';
14
+ export {default as Input} from './Input/styles';