groundfloor-react-ui 1.0.3 → 1.0.6

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.
@@ -3,134 +3,150 @@ import PropTypes from 'prop-types';
3
3
  import styled, { css, useTheme } from 'styled-components';
4
4
  import defaultThemeColor from '../constants/defaultThemeColor';
5
5
 
6
-
7
6
  const TextBox = styled.div`
8
- color: #A9B1B8;
9
- font-size: 21px;
10
- border: 1px solid ${({ theme, isValid }) => isValid ? defaultThemeColor.border : theme.variant['error']};
11
- border-radius: 4px;
12
- padding: 5px;
13
- display: inline-block;
14
- align-items: center;
15
-
16
- &:focus-within {
17
- border: 1px solid ${({ theme }) => theme.variant['primary-1']};
18
- outline: none;
19
- }
7
+ color: #a9b1b8;
8
+ font-size: 21px;
9
+ border: 1px solid
10
+ ${({ theme, isValid }) =>
11
+ isValid ? defaultThemeColor.border : theme.variant['error']};
12
+ border-radius: 4px;
13
+ padding: 5px;
14
+ display: inline-block;
15
+ align-items: center;
16
+ background-color: ${({ theme }) => theme.bgColor};
17
+ &:focus-within {
18
+ border: 1px solid ${({ theme }) => theme.variant['primary-1']};
19
+ outline: none;
20
+ }
20
21
  `;
21
22
 
22
23
  TextBox.defaultProps = {
23
24
  theme: defaultThemeColor,
24
- }
25
+ };
25
26
 
26
27
  const Input = styled.input`
27
- border: 0;
28
- outline: 0;
29
- color: ${({ theme }) => theme.variant['primary-2']};
30
- margin: 0 5px;
31
- padding: 0;
32
- font-size: 21px;
33
- width: 24px;
28
+ border: 0;
29
+ outline: 0;
30
+ color: ${({ theme }) => theme.variant['primary-2']};
31
+ margin: 0 5px;
32
+ padding: 0;
33
+ font-size: 21px;
34
+ width: 24px;
35
+ background-color: ${({ theme }) => theme.bgColor};
34
36
  `;
35
37
 
36
38
  Input.defaultProps = {
37
39
  theme: defaultThemeColor,
38
- }
40
+ };
39
41
 
40
42
  const requiredAsterisk = css`
41
- &:after {
42
- content:" *";
43
- color: ${({ theme }) => theme.variant['error']};
44
- }
45
- `
43
+ &:after {
44
+ content: ' *';
45
+ color: ${({ theme }) => theme.variant['error']};
46
+ }
47
+ `;
46
48
 
47
49
  const Label = styled.label`
48
- display: block;
49
- margin-bottom: ${({ labelInline, errMsg }) => (labelInline && errMsg) ? '18px' : '7px'};
50
- margin-right: ${({ labelInline }) => labelInline ? '7px' : ''};
51
- color: ${({ theme }) => theme.variant['neutral-2']};
52
- ${({ required }) => required ? requiredAsterisk : null}
50
+ display: block;
51
+ margin-bottom: ${({ labelInline, errMsg }) =>
52
+ labelInline && errMsg ? '18px' : '7px'};
53
+ margin-right: ${({ labelInline }) => (labelInline ? '7px' : '')};
54
+ color: ${({ theme }) => theme.variant['neutral-2']};
55
+ ${({ required }) => (required ? requiredAsterisk : null)}
56
+ padding-bottom: 0px;
53
57
  `;
54
58
 
55
59
  Label.defaultProps = {
56
60
  theme: defaultThemeColor,
57
- }
61
+ };
58
62
 
59
63
  const inline = css`
60
- display: flex;
61
- align-items: center;
62
- `
64
+ display: flex;
65
+ align-items: center;
66
+ `;
63
67
 
64
68
  const Form = styled.div`
65
- ${({ labelInline }) => labelInline ? inline : null}
66
- .err-text {
67
- color: ${({ theme }) => theme.variant['error']};
68
- margin-top: 5px;
69
- font-size: 10px;
70
- }
71
-
72
- > div {
73
- flex: 1 0 auto;
74
- }
75
- `
69
+ ${({ labelInline }) => (labelInline ? inline : null)}
70
+ .err-text {
71
+ color: ${({ theme }) => theme.variant['error']};
72
+ margin-top: 5px;
73
+ font-size: 10px;
74
+ }
75
+
76
+ > div {
77
+ flex: 1 0 auto;
78
+ }
79
+ `;
76
80
 
77
81
  Form.defaultProps = {
78
82
  theme: defaultThemeColor,
79
- }
83
+ };
80
84
 
81
85
  const Button = styled.button`
82
- border: none;
83
- outline: none;
84
- border-radius: 4px;
85
- background-color: #F2F4FE;
86
- color: #444;
87
- padding: 5px 6px;
88
- font-size: 18px;
89
- cursor: pointer;
86
+ border: none;
87
+ outline: none;
88
+ border-radius: 4px;
89
+ background-color: ${({ theme }) => theme.bgColor};
90
+ color: #444;
91
+ padding: 5px 6px;
92
+ font-size: 18px;
93
+ cursor: pointer;
90
94
  `;
91
95
 
92
96
  Button.defaultProps = {
93
97
  theme: defaultThemeColor,
94
- }
95
-
96
- export const TimeInput = ({ label, errMsg, hour, minute, period, onChange, ...props }) => {
98
+ };
99
+
100
+ export const TimeInput = ({
101
+ label,
102
+ errMsg,
103
+ hour,
104
+ minute,
105
+ period,
106
+ onChange,
107
+ ...props
108
+ }) => {
97
109
  const theme = useTheme() || defaultThemeColor;
98
110
 
99
111
  function hourChange(evt) {
100
- const num = evt.currentTarget.value > 12 ? 12 : parseFloat(evt.currentTarget.value) || 0;
112
+ const num =
113
+ evt.currentTarget.value > 12
114
+ ? 12
115
+ : parseFloat(evt.currentTarget.value) || 0;
101
116
  onChange({ hour: num, minute, period });
102
117
  }
103
118
 
104
119
  function minuteChange(evt) {
105
120
  console.log('minute change', evt.currentTarget.value);
106
- const num = evt.currentTarget.value > 59 ? 59 : parseFloat(evt.currentTarget.value) || 0;
121
+ const num =
122
+ evt.currentTarget.value > 59
123
+ ? 59
124
+ : parseFloat(evt.currentTarget.value) || 0;
107
125
  onChange({ hour, minute: num, period });
108
126
  }
109
127
 
110
128
  function periodChange(evt) {
111
- const p = period === 'AM' ? 'PM' : 'AM'
129
+ const p = period === 'AM' ? 'PM' : 'AM';
112
130
  onChange({ hour, minute, period: p });
113
131
  }
114
132
 
115
133
  return (
116
134
  <Form {...props}>
117
- <Label {...props} errMsg={errMsg} >
135
+ <Label {...props} errMsg={errMsg}>
118
136
  {label}
119
137
  </Label>
120
138
  <div>
121
- <TextBox
122
- {...props}
123
- >
139
+ <TextBox {...props}>
124
140
  <Input value={hour} onChange={hourChange} />
125
141
  :
126
142
  <Input value={minute} onChange={minuteChange} />
127
- <Button onClick={periodChange} >{period}</Button>
143
+ <Button onClick={periodChange}>{period}</Button>
128
144
  </TextBox>
129
145
  <div className='err-text'>{errMsg}</div>
130
146
  </div>
131
147
  </Form>
132
- )
133
- }
148
+ );
149
+ };
134
150
 
135
151
  TimeInput.propTypes = {
136
152
  /**
@@ -165,7 +181,7 @@ TimeInput.propTypes = {
165
181
  * Error Message
166
182
  */
167
183
  errMsg: PropTypes.string,
168
- }
184
+ };
169
185
 
170
186
  TimeInput.defaultProps = {
171
187
  label: '',
@@ -176,5 +192,4 @@ TimeInput.defaultProps = {
176
192
  labelInline: false,
177
193
  isValid: true,
178
194
  errMsg: '',
179
- }
180
-
195
+ };