@pareto-engineering/design-system 2.0.0-alpha.14 → 2.0.0-alpha.18

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.
Files changed (40) hide show
  1. package/dist/cjs/b/Button/styles.scss +27 -2
  2. package/dist/cjs/c/ContentSlides/common/Navigator/Navigator.js +4 -3
  3. package/dist/cjs/f/common/Debugger/Debugger.js +1 -1
  4. package/dist/cjs/f/common/Label/Label.js +1 -1
  5. package/dist/cjs/f/fields/ChoicesInput/ChoicesInput.js +1 -1
  6. package/dist/cjs/f/fields/SelectInput/SelectInput.js +25 -6
  7. package/dist/cjs/f/fields/SelectInput/styles.scss +4 -4
  8. package/dist/cjs/f/fields/TaskRecommendationInput/TaskRecommendationInput.js +1 -1
  9. package/dist/cjs/f/fields/TextInput/TextInput.js +19 -5
  10. package/dist/cjs/f/fields/TextInput/styles.scss +3 -7
  11. package/dist/cjs/f/fields/TextareaInput/TextareaInput.js +13 -6
  12. package/dist/es/b/Button/styles.scss +27 -2
  13. package/dist/es/c/ContentSlides/common/Navigator/Navigator.js +4 -3
  14. package/dist/es/f/common/Debugger/Debugger.js +1 -1
  15. package/dist/es/f/common/Label/Label.js +1 -1
  16. package/dist/es/f/fields/ChoicesInput/ChoicesInput.js +1 -1
  17. package/dist/es/f/fields/SelectInput/SelectInput.js +25 -6
  18. package/dist/es/f/fields/SelectInput/styles.scss +4 -4
  19. package/dist/es/f/fields/TaskRecommendationInput/TaskRecommendationInput.js +1 -1
  20. package/dist/es/f/fields/TextInput/TextInput.js +19 -5
  21. package/dist/es/f/fields/TextInput/styles.scss +3 -7
  22. package/dist/es/f/fields/TextareaInput/TextareaInput.js +13 -6
  23. package/package.json +1 -1
  24. package/src/__snapshots__/Storyshots.test.js.snap +284 -79
  25. package/src/stories/b/Button.stories.jsx +5 -4
  26. package/src/stories/f/SelectInput.stories.jsx +29 -0
  27. package/src/stories/f/TextInput.stories.jsx +10 -0
  28. package/src/stories/f/TextareaInput.stories.jsx +40 -4
  29. package/src/ui/b/Button/Button.jsx +2 -1
  30. package/src/ui/b/Button/styles.scss +27 -2
  31. package/src/ui/c/ContentSlides/common/Navigator/Navigator.jsx +3 -2
  32. package/src/ui/f/common/Debugger/Debugger.jsx +1 -1
  33. package/src/ui/f/common/Label/Label.jsx +1 -1
  34. package/src/ui/f/fields/ChoicesInput/ChoicesInput.jsx +1 -1
  35. package/src/ui/f/fields/SelectInput/SelectInput.jsx +35 -5
  36. package/src/ui/f/fields/SelectInput/styles.scss +4 -4
  37. package/src/ui/f/fields/TaskRecommendationInput/TaskRecommendationInput.jsx +1 -1
  38. package/src/ui/f/fields/TextInput/TextInput.jsx +15 -2
  39. package/src/ui/f/fields/TextInput/styles.scss +3 -7
  40. package/src/ui/f/fields/TextareaInput/TextareaInput.jsx +21 -10
@@ -14,10 +14,11 @@ export default {
14
14
  // storyfn => <div className="">{ storyfn() }</div>,
15
15
  ],
16
16
  argTypes:{
17
- color :{ control: { type: 'select', options: ALL_COLORS } },
18
- disabled:{ control: { type: 'boolean' } },
19
- isGhost :{ control: { type: 'boolean' } },
20
- isSimple:{ control: { type: 'boolean' } },
17
+ color :{ control: { type: 'select', options: ALL_COLORS } },
18
+ disabled :{ control: { type: 'boolean' } },
19
+ isGhost :{ control: { type: 'boolean' } },
20
+ isSimple :{ control: { type: 'boolean' } },
21
+ isAnimated:{ control: { type: 'boolean' } },
21
22
  },
22
23
  }
23
24
 
@@ -38,6 +38,35 @@ export const Base = () => (
38
38
  </>
39
39
  )
40
40
 
41
+ export const RequiredSelect = () => {
42
+ const requiredInput = (inputValue) => {
43
+ let error = ''
44
+
45
+ if (!inputValue || !inputValue?.length === 0) {
46
+ error = 'This information is required'
47
+ }
48
+ return error
49
+ }
50
+
51
+ return (
52
+ <>
53
+ <SelectInput
54
+ validate={requiredInput}
55
+ name="activity"
56
+ label="Activity Type"
57
+ options={[
58
+ {
59
+ value:'', label:'Select activity type', disabled:true,
60
+ },
61
+ { value: 'review', label: 'Review' },
62
+ { value: 'Approve', label: 'Approve' },
63
+ ]}
64
+ />
65
+ <FormDebugger />
66
+ </>
67
+ )
68
+ }
69
+
41
70
  export const Objects = () => (
42
71
  <>
43
72
  <SelectInput
@@ -52,6 +52,16 @@ export const Base = () => {
52
52
  )
53
53
  }
54
54
 
55
+ export const TextInputWithPlaceHolder = () => (
56
+ <div className="y-background1 b-dark-y u2 pb-u">
57
+ <TextInput
58
+ name="firstName"
59
+ label="What's your first name ?"
60
+ placeholder="First Name"
61
+ />
62
+ </div>
63
+ )
64
+
55
65
  export const DisabledTextInput = () => (
56
66
  <div className="y-background1 b-dark-y u2 pb-u">
57
67
  <TextInput
@@ -14,7 +14,7 @@ export default {
14
14
  decorators:[
15
15
  (storyfn) => (
16
16
  <Formik
17
- initialValues={{ feedBack: '' }}
17
+ initialValues={{ feedback: '' }}
18
18
  >
19
19
  <Form>
20
20
 
@@ -31,16 +31,52 @@ export default {
31
31
  export const Base = () => (
32
32
  <div className="y-background1 b-dark-y">
33
33
  <TextareaInput
34
- name="feedBack"
34
+ name="feedback"
35
35
  label="What can we improve on?"
36
36
  />
37
37
  <FormDebugger />
38
38
  </div>
39
39
  )
40
- export const DisabledTextareaInput = () => (
40
+
41
+ export const Placeholder = () => (
42
+ <div className="y-background1 b-dark-y">
43
+ <TextareaInput
44
+ name="feedback"
45
+ label="What can we improve on?"
46
+ placeholder="Type your feedback here..."
47
+ />
48
+ <FormDebugger />
49
+ </div>
50
+ )
51
+
52
+ export const Validation = () => {
53
+ const validate = (value) => {
54
+ let errorMessage = ''
55
+ const isValid = value.length > 3
56
+
57
+ if (!isValid) {
58
+ errorMessage = 'Value should be greater than 3 characters'
59
+ }
60
+ return errorMessage
61
+ }
62
+
63
+ return (
64
+ <div className="y-background1 b-dark-y">
65
+ <TextareaInput
66
+ name="feedback"
67
+ label="What can we improve on?"
68
+ placeholder="Type your feedback here..."
69
+ validate={validate}
70
+ />
71
+ <FormDebugger />
72
+ </div>
73
+ )
74
+ }
75
+
76
+ export const Disabled = () => (
41
77
  <div className="y-background1 b-dark-y">
42
78
  <TextareaInput
43
- name="feedBack"
79
+ name="feedback"
44
80
  label="What can we improve on?"
45
81
  disabled
46
82
  />
@@ -100,7 +100,8 @@ Button.propTypes = {
100
100
  /**
101
101
  * The button color
102
102
  */
103
- color :PropTypes.string,
103
+ color:PropTypes.string,
104
+
104
105
  /**
105
106
  * Button loading state
106
107
  */
@@ -7,6 +7,7 @@ $compact-padding: .6em .6em .48em;
7
7
  $default-color:primary;
8
8
  $font-weight:bold;
9
9
  $default-margin:.5em;
10
+ $default-animation-time: .3s;
10
11
 
11
12
  .#{bem.$base}.button {
12
13
  background: var(--x, var(--#{$default-color}));
@@ -14,8 +15,8 @@ $default-margin:.5em;
14
15
  border-radius: var(--theme-border-radius);
15
16
  color: var(--on-x, var(--on-#{$default-color}));
16
17
  display: inline-flex;
17
- font-weight: 600;
18
18
  font-family: var(--theme-default-paragraph);
19
+ font-weight: 600;
19
20
  justify-content: space-between;
20
21
  padding: $default-padding;
21
22
  transition: all .25s;
@@ -24,6 +25,14 @@ $default-margin:.5em;
24
25
  &::after {
25
26
  content: "-->";
26
27
  margin-left: $default-margin;
28
+ vertical-align: middle;
29
+ }
30
+
31
+ &:hover {
32
+ &::after {
33
+ --final-position: 50%;
34
+ animation: animateArrow $default-animation-time forwards;
35
+ }
27
36
  }
28
37
  }
29
38
 
@@ -31,6 +40,14 @@ $default-margin:.5em;
31
40
  &::before {
32
41
  content: "<--";
33
42
  margin-right: $default-margin;
43
+ vertical-align: middle;
44
+ }
45
+
46
+ &:hover {
47
+ &::before {
48
+ --final-position: -50%;
49
+ animation: animateArrow $default-animation-time forwards;
50
+ }
34
51
  }
35
52
  }
36
53
 
@@ -46,7 +63,6 @@ $default-margin:.5em;
46
63
  }
47
64
  }
48
65
 
49
-
50
66
  &.#{bem.$modifier-compact} {
51
67
  padding: $compact-padding;
52
68
  }
@@ -114,3 +130,12 @@ $default-margin:.5em;
114
130
  }
115
131
 
116
132
 
133
+ @keyframes animateArrow {
134
+ from {
135
+ transform: translateX(0);
136
+ }
137
+
138
+ to {
139
+ transform: translateX(var(--final-position));
140
+ }
141
+ }
@@ -77,6 +77,7 @@ const Navigator = ({
77
77
  setNextStepIndex(stepsForward)
78
78
  }
79
79
  }}
80
+ isCompact
80
81
  >
81
82
  Next
82
83
  </Button>
@@ -140,8 +141,8 @@ Navigator.propTypes = {
140
141
 
141
142
  Navigator.defaultProps = {
142
143
  canMoveForward:true,
143
- previousColor :'main1',
144
- nextColor :'main1',
144
+ previousColor :'main2',
145
+ nextColor :'main2',
145
146
  stepsForward :1,
146
147
  stepsBackwards:1,
147
148
  }
@@ -41,7 +41,7 @@ const Debugger = ({
41
41
  .join(' ')}
42
42
  style={style}
43
43
  >
44
- <Button onClick={toggleDebugger} color="main1">
44
+ <Button onClick={toggleDebugger} color="main2">
45
45
  { isOpen
46
46
  ? 'Close FormDebugger'
47
47
  : 'Open FormDebugger'}
@@ -90,7 +90,7 @@ Label.propTypes = {
90
90
  Label.defaultProps = {
91
91
  // someProp:false
92
92
  as :'label',
93
- color:'main1',
93
+ color:'main2',
94
94
  }
95
95
 
96
96
  export default Label
@@ -148,7 +148,7 @@ ChoicesInput.defaultProps = {
148
148
  gridColumnsMobile :2,
149
149
  gridColumnsDesktop:3,
150
150
  color :'background2',
151
- colorChecked :'main1',
151
+ colorChecked :'main2',
152
152
  disabled :false,
153
153
  }
154
154
 
@@ -27,6 +27,8 @@ const SelectInput = ({
27
27
  name,
28
28
  label,
29
29
  options,
30
+ validate,
31
+ description,
30
32
  disabled,
31
33
  // ...otherProps
32
34
  }) => {
@@ -34,7 +36,7 @@ const SelectInput = ({
34
36
  import('./styles.scss')
35
37
  }, [])
36
38
 
37
- const [field, meta] = useField(name)
39
+ const [field, meta] = useField({ name, validate })
38
40
 
39
41
  return (
40
42
  <div
@@ -52,18 +54,30 @@ const SelectInput = ({
52
54
  // {...otherProps}
53
55
  >
54
56
  <FormLabel className="input-label" name={name}>{label}</FormLabel>
55
- <select className="input v25 pv-v" {...field} id={name} disabled={disabled}>
57
+ <select className="input v25 pv-v" {...field} value={field.value || ''} id={name} disabled={disabled}>
56
58
  {
57
59
  options.map((option) => {
58
60
  // i.e if option is a string like "blah", return { value: "blah", label: "blah" }
59
61
  const newOption = typeof option === 'string' ? { value: option, label: option } : option
62
+
60
63
  return (
61
- <option key={newOption.value} value={newOption.value}>{newOption.label}</option>
64
+ <option
65
+ key={newOption.value}
66
+ value={newOption.value}
67
+ disabled={newOption?.disabled || false}
68
+ >
69
+ {newOption.label}
70
+ </option>
62
71
  )
63
72
  })
64
73
  }
65
74
  </select>
66
- {meta.error && meta.touched && <FormDescription error>{meta.error}</FormDescription>}
75
+ {(description || (meta.touched && meta.error))
76
+ && (
77
+ <FormDescription isError={!!meta.error} className="v50 mt-v s-1">
78
+ { meta.error || description }
79
+ </FormDescription>
80
+ )}
67
81
  </div>
68
82
  )
69
83
  }
@@ -93,12 +107,28 @@ SelectInput.propTypes = {
93
107
  */
94
108
  label:PropTypes.string,
95
109
 
110
+ /**
111
+ * The input field validator function
112
+ */
113
+ validate:PropTypes.func,
114
+
115
+ /**
116
+ * The select input description
117
+ */
118
+ description:PropTypes.string,
119
+
96
120
  /**
97
121
  * The options of the select input
98
122
  */
99
123
  options:PropTypes.arrayOf(
100
124
  PropTypes.oneOfType(
101
- [PropTypes.string, PropTypes.shape({ value: PropTypes.string, label: PropTypes.string })],
125
+ [
126
+ PropTypes.string,
127
+ PropTypes.shape({
128
+ value :PropTypes.string,
129
+ label :PropTypes.string,
130
+ disabled:PropTypes.bool,
131
+ })],
102
132
  ),
103
133
  ),
104
134
  /**
@@ -14,16 +14,16 @@ $default-padding: 0.75em 0.75em 0.55em;
14
14
 
15
15
 
16
16
  .input-label {
17
- color: var(--main1);
17
+ color: var(--main2);
18
18
  }
19
19
 
20
20
  .input {
21
- background: var(--light-background1);
22
- color: var(--on-background1);
21
+ background: var(--light-background2);
22
+ color: var(--on-background2);
23
23
  padding: $default-padding;
24
24
 
25
25
  &:focus {
26
- background: var(--dark-background1);
26
+ background: var(--dark-background2);
27
27
  }
28
28
  }
29
29
  }
@@ -124,7 +124,7 @@ TaskRecommendationInput.propTypes = {
124
124
  }
125
125
 
126
126
  TaskRecommendationInput.defaultProps = {
127
- color:'main1',
127
+ color:'main2',
128
128
  }
129
129
 
130
130
  export default memo(TaskRecommendationInput)
@@ -27,10 +27,12 @@ const TextInput = ({
27
27
  type,
28
28
  name,
29
29
  label,
30
+ labelColor,
30
31
  validate,
31
32
  oneInputLabel,
32
33
  description,
33
34
  disabled,
35
+ placeholder,
34
36
  // ...otherProps
35
37
  }) => {
36
38
  useLayoutEffect(() => {
@@ -53,11 +55,11 @@ const TextInput = ({
53
55
  // {...otherProps}
54
56
  >
55
57
  <FormLabel
56
- className={[
57
- 'input-label', oneInputLabel ? 'md-s2 s0 v1 mb-v' : 'v50 mb-v']
58
+ className={[oneInputLabel ? 'md-s2 s0 v1 mb-v' : 'v50 mb-v']
58
59
  .filter((e) => e)
59
60
  .join(' ')}
60
61
  name={name}
62
+ color={labelColor}
61
63
  >
62
64
  { label }
63
65
  </FormLabel>
@@ -66,6 +68,7 @@ const TextInput = ({
66
68
  className={`input ${meta.touched && meta.error ? 'input-border-error' : 'input-border'}`}
67
69
  type={type}
68
70
  disabled={disabled}
71
+ placeholder={placeholder}
69
72
  {...field}
70
73
  />
71
74
  {(description || (meta.touched && meta.error))
@@ -104,6 +107,11 @@ TextInput.propTypes = {
104
107
  */
105
108
  label:PropTypes.string.isRequired,
106
109
 
110
+ /**
111
+ * The input label color
112
+ */
113
+ labelColor:PropTypes.string,
114
+
107
115
  /**
108
116
  * The type of the input (html)
109
117
  */
@@ -136,6 +144,11 @@ TextInput.propTypes = {
136
144
  * Whether the text input should be disabled
137
145
  */
138
146
  disabled :PropTypes.bool,
147
+
148
+ /**
149
+ * The placeholder text for the input
150
+ */
151
+ placeholder:PropTypes.string,
139
152
  }
140
153
 
141
154
  TextInput.defaultProps = {
@@ -9,17 +9,13 @@ $default-padding: 0.75em 0.75em 0.55em;
9
9
  display: flex;
10
10
  flex-direction: column;
11
11
 
12
- .input-label {
13
- color: var(--main1);
14
- }
15
-
16
12
  .input {
17
- background: var(--light-background1);
18
- color: var(--on-background1);
13
+ background: var(--light-background2);
14
+ color: var(--on-background2);
19
15
  padding: $default-padding;
20
16
 
21
17
  &:focus {
22
- background: var(--dark-background1);
18
+ background: var(--dark-background2);
23
19
  }
24
20
  }
25
21
  }
@@ -34,6 +34,7 @@ const TextareaInput = ({
34
34
  labelColor,
35
35
  description,
36
36
  disabled,
37
+ placeholder,
37
38
  // ...otherProps
38
39
  }) => {
39
40
  useLayoutEffect(() => {
@@ -52,7 +53,6 @@ const TextareaInput = ({
52
53
  componentClassName,
53
54
  userClassName,
54
55
  `x-${textAreaColor}`,
55
- `y-${labelColor}`,
56
56
  ]
57
57
  .filter((e) => e)
58
58
  .join(' ')}
@@ -60,11 +60,11 @@ const TextareaInput = ({
60
60
  // {...otherProps}
61
61
  >
62
62
  <FormLabel
63
- className={[
64
- 'c-y', labelAsDescription ? 'md-s2 s0 v1 mb-v' : 'v50 mb-v']
63
+ className={[labelAsDescription ? 'md-s2 s0 v1 mb-v' : 'v50 mb-v']
65
64
  .filter((e) => e)
66
65
  .join(' ')}
67
66
  name={name}
67
+ color={labelColor}
68
68
  >
69
69
  { label }
70
70
  </FormLabel>
@@ -72,6 +72,7 @@ const TextareaInput = ({
72
72
  id={textAreaId}
73
73
  className={`textarea v50 pv-v ${meta.touched && meta.error ? 'input-border-error' : 'input-border'}`}
74
74
  {...field}
75
+ placeholder={placeholder}
75
76
  rows={rows}
76
77
  disabled={disabled}
77
78
  >
@@ -123,36 +124,46 @@ TextareaInput.propTypes = {
123
124
  * If the text area depends on it's label's text as the default description
124
125
  */
125
126
  labelAsDescription:PropTypes.bool,
127
+
126
128
  /**
127
129
  * The textarea id
128
130
  */
129
- textAreaId :PropTypes.string,
131
+ textAreaId:PropTypes.string,
132
+
130
133
  /**
131
134
  * The number of rows int the text area
132
135
  */
133
- rows :PropTypes.number,
136
+ rows:PropTypes.number,
137
+
134
138
  /**
135
139
  * Text area base color
136
140
  */
137
- textAreaColor :PropTypes.string,
141
+ textAreaColor:PropTypes.string,
142
+
138
143
  /**
139
144
  * Label base color
140
145
  */
141
- labelColor :PropTypes.string,
146
+ labelColor:PropTypes.string,
147
+
142
148
  /**
143
149
  * Text area description
144
150
  */
145
- description :PropTypes.string,
151
+ description:PropTypes.string,
152
+
146
153
  /**
147
154
  * Whether the text area should be disabled
148
155
  */
149
- disabled :PropTypes.bool,
156
+ disabled:PropTypes.bool,
157
+
158
+ /**
159
+ * The textarea placeholder text
160
+ */
161
+ placeholder:PropTypes.string,
150
162
  }
151
163
 
152
164
  TextareaInput.defaultProps = {
153
165
  rows :3,
154
166
  textAreaColor:'background1',
155
- labelColor :'main1',
156
167
  disabled :false,
157
168
  }
158
169