groundfloor-react-ui 1.0.19 → 1.0.20

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.
@@ -1,85 +1,116 @@
1
- import React from "react";
2
- import styled from "styled-components";
3
1
  import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import styled, { useTheme } from 'styled-components';
4
4
  import defaultStyles from '../constants/defaultStyle';
5
- import getDefaultStyles from '../constants/utils';
6
5
  import defaultThemeColor from '../constants/defaultThemeColor';
6
+ import getDefaultStyles from '../constants/utils';
7
7
 
8
8
  const CheckBoxWrapper = styled.div`
9
- ${({ theme, defaultCheckBoxWrapperStyle }) => {
10
- return getDefaultStyles(theme, defaultCheckBoxWrapperStyle);
9
+ ${({ inBuiltCss, defaultCheckBoxWrapperStyle }) => {
10
+ return getDefaultStyles(inBuiltCss, defaultCheckBoxWrapperStyle);
11
11
  }}
12
12
  `;
13
13
  const CheckBoxLabel = styled.label`
14
- //Set the styles from the default styles object
15
- ${({ theme, defaultCheckBoxLabelStyle }) => {
16
- return getDefaultStyles(theme, defaultCheckBoxLabelStyle);
14
+ //Set the styles from the default styles object
15
+ ${({ inBuiltCss, defaultCheckBoxLabelStyle }) => {
16
+ return getDefaultStyles(inBuiltCss, defaultCheckBoxLabelStyle);
17
17
  }}
18
- background-color: ${({ checked, backgroundColor, disabledColor }) => checked ?
19
- backgroundColor : disabledColor};
18
+ background-color: ${({ checked, backgroundColor, disabledColor, theme }) => {
19
+ if (checked && backgroundColor) return backgroundColor;
20
+ else if (checked && !backgroundColor) return theme.primary['primary-1'];
21
+ else if (!checked && disabledColor) return disabledColor;
22
+ else if (!checked && !disabledColor) return theme.neutral['neutral-2'];
23
+ }};
24
+ // custom styles
25
+ ${({ customToggleBoxStyle }) => customToggleBoxStyle}
26
+ &:before {
27
+ content: '';
28
+ display: block;
29
+ border-radius: 50%;
30
+ width: 16px;
31
+ height: 16px;
32
+ margin-top: 3px;
33
+ background: ${({ switchColor, theme }) =>
34
+ switchColor ? switchColor : theme.bgColor};
35
+ transition: 0.2s;
36
+ margin-left: ${({ checked }) => (checked ? '4px' : '25px')};
37
+
20
38
  // custom styles
21
- ${({ customToggleBoxStyle }) => customToggleBoxStyle}
22
- &:before {
23
- content: "";
24
- display: block;
25
- border-radius: 50%;
26
- width: 16px;
27
- height: 16px;
28
- margin-top: 3px;
29
- background: ${({ switchColor }) => switchColor};
30
- transition: 0.2s;
31
- margin-left: ${({ checked }) => checked ? '4px' : '25px'};
32
-
33
- // custom styles
34
- ${({ customSwitchStyle }) => customSwitchStyle}
35
- }
39
+ ${({ customSwitchStyle }) => customSwitchStyle}
40
+ }
36
41
  `;
37
42
 
38
-
39
-
40
- const CheckBox = styled.input.attrs({ type: "checkbox" })`
41
- opacity: 0;
42
- z-index: 1;
43
- border-radius: 31px;
44
- width: 45px;
45
- height: 22px;
46
- cursor: pointer;
43
+ const CheckBox = styled.input.attrs({ type: 'checkbox' })`
44
+ opacity: 0;
45
+ z-index: 1;
46
+ border-radius: 31px;
47
+ width: 45px;
48
+ height: 22px;
49
+ cursor: pointer;
47
50
  `;
48
51
 
49
52
  const OptionText = styled.span`
50
- //Set the styles from the default styles object
51
- ${({ theme, defaultOptionTextStyle }) => {
52
- return getDefaultStyles(theme, defaultOptionTextStyle);
53
+ //Set the styles from the default styles object
54
+ ${({ inBuiltCss, defaultOptionTextStyle }) => {
55
+ return getDefaultStyles(inBuiltCss, defaultOptionTextStyle);
53
56
  }}
54
-
55
- // custom styles
57
+
58
+ // custom styles
56
59
  ${({ optionStyle }) => optionStyle}
57
60
  `;
58
61
 
59
- export const ToggleSwitch = ({ checked, customSwitchStyle, customToggleBoxStyle, backgroundColor, disabledColor, switchColor, onClick, trueLabel, falseLabel, optionStyle, ...props }) => {
62
+ export const ToggleSwitch = ({
63
+ checked,
64
+ customSwitchStyle,
65
+ customToggleBoxStyle,
66
+ backgroundColor,
67
+ disabledColor,
68
+ switchColor,
69
+ onClick,
70
+ trueLabel,
71
+ falseLabel,
72
+ optionStyle,
73
+ ...props
74
+ }) => {
75
+ const activeTheme = useTheme() || defaultThemeColor;
76
+
60
77
  return (
61
- <CheckBoxWrapper theme={defaultStyles} defaultCheckBoxWrapperStyle={'toggle-switch-wrapper'} {...props} >
62
- <CheckBox {...props}
63
- id="checkbox"
64
- theme={defaultStyles}
78
+ <CheckBoxWrapper
79
+ inBuiltCss={defaultStyles}
80
+ defaultCheckBoxWrapperStyle={'toggle-switch-wrapper'}
81
+ {...props}
82
+ >
83
+ <CheckBox
84
+ {...props}
85
+ id='checkbox'
86
+ inBuiltCss={defaultStyles}
65
87
  defaultCheckBoxStyle={'toggle-switch-checkbox'}
66
- onClick={() => { onClick(!checked) }}
88
+ onClick={() => {
89
+ onClick(!checked);
90
+ }}
67
91
  isChecked={checked}
68
92
  />
69
- <CheckBoxLabel {...props}
70
- htmlFor="checkbox"
93
+ <CheckBoxLabel
94
+ {...props}
95
+ htmlFor='checkbox'
71
96
  customToggleBoxStyle={customToggleBoxStyle}
72
97
  customSwitchStyle={customSwitchStyle}
73
98
  disabledColor={disabledColor}
74
99
  backgroundColor={backgroundColor}
75
100
  switchColor={switchColor}
76
- theme={defaultStyles}
101
+ inBuiltCss={defaultStyles}
77
102
  defaultCheckBoxLabelStyle={'toggle-switch-checkbox-label'}
78
103
  checked={checked}
104
+ theme={activeTheme}
79
105
  />
80
- <OptionText optionStyle={optionStyle}
81
- theme={defaultStyles}
82
- defaultOptionTextStyle={'toggle-switch-option-text'} {...props} >{checked ? trueLabel : falseLabel}</OptionText>
106
+ <OptionText
107
+ optionStyle={optionStyle}
108
+ inBuiltCss={defaultStyles}
109
+ defaultOptionTextStyle={'toggle-switch-option-text'}
110
+ {...props}
111
+ >
112
+ {checked ? trueLabel : falseLabel}
113
+ </OptionText>
83
114
  </CheckBoxWrapper>
84
115
  );
85
116
  };
@@ -103,21 +134,18 @@ ToggleSwitch.propTypes = {
103
134
  checked: PropTypes.bool,
104
135
  /**
105
136
  * label when toggle state is checked
106
- * */
137
+ * */
107
138
  trueLabel: PropTypes.string,
108
139
  /**
109
140
  * label when toggle state is not checked
110
- * */
141
+ * */
111
142
  falseLabel: PropTypes.string,
112
- }
143
+ };
113
144
 
114
145
  ToggleSwitch.defaultProps = {
115
- backgroundColor: `${defaultThemeColor.primary['primary-1']}`,
116
- switchColor: `${defaultThemeColor.bgColor}`,
117
- disabledColor: `${defaultThemeColor.neutral['neutral-2']}`,
118
146
  checked: false,
119
147
  trueLabel: 'Yes',
120
148
  falseLabel: 'No',
121
149
  customSwitchStyle: {},
122
- customToggleBoxStyle: {}
123
- }
150
+ customToggleBoxStyle: {},
151
+ };
@@ -1,11 +1,11 @@
1
+ import PropTypes from 'prop-types';
1
2
  import React from 'react';
2
3
  import Modal from 'react-modal';
3
- import styled from 'styled-components';
4
+ import styled, { useTheme } from 'styled-components';
4
5
  import defaultStyles from '../constants/defaultStyle';
6
+ import defaultThemeColor from '../constants/defaultThemeColor';
5
7
  import getDefaultStyles from '../constants/utils';
6
- import PropTypes from 'prop-types';
7
8
  import { Icon } from '../Icon';
8
- import defaultThemeColor from '../constants/defaultThemeColor';
9
9
 
10
10
  const customStyles = {
11
11
  overlay: {
@@ -21,8 +21,9 @@ const customStyles = {
21
21
  marginRight: '-50%',
22
22
  padding: '0px',
23
23
  transform: 'translate(-50%, -50%)',
24
- maxHeight: '75vh',
25
24
  minWidth: '40vw',
25
+ maxHeight: '85vh',
26
+ overflow: 'hidden',
26
27
  },
27
28
  };
28
29
 
@@ -56,6 +57,7 @@ const ModalHeader = styled.div`
56
57
  ${({ customModalHeaderStyle }) => customModalHeaderStyle}
57
58
  `;
58
59
  const ModalBody = styled.div`
60
+
59
61
  //Set the styles from the default styles object
60
62
  ${({ theme, type }) => {
61
63
  return getDefaultStyles(theme, type);
@@ -64,6 +66,11 @@ const ModalBody = styled.div`
64
66
  ${({ customModalBodyStyle }) => customModalBodyStyle}
65
67
  `;
66
68
 
69
+ const ContentWrapper = styled.div`
70
+ max-height: 60vh;
71
+ overflow-y: scroll;
72
+ `
73
+
67
74
  const ModalFooter = styled.div`
68
75
  //Set the styles from the default styles object
69
76
  ${({ theme, type }) => {
@@ -74,9 +81,19 @@ const ModalFooter = styled.div`
74
81
  `;
75
82
 
76
83
  const CommonDiv = styled.div`
77
- padding: 2rem 3rem 0rem 3rem;
84
+ padding: .5rem 3rem 0rem 3rem;
78
85
  `;
79
86
 
87
+ const HeaderWrapper = styled.div`
88
+ position: sticky;
89
+ background-color: ${({ theme }) => theme.bgColor};
90
+ width: 100%;
91
+ top: 0px;
92
+ border-bottom: 1px solid ${({ theme }) => theme.border}
93
+
94
+ `
95
+
96
+
80
97
  try {
81
98
  Modal.setAppElement('#root')
82
99
 
@@ -84,6 +101,7 @@ try {
84
101
  Modal.setAppElement('#__next')
85
102
  }
86
103
 
104
+
87
105
  export const ModalComp = ({
88
106
  modalIsOpen,
89
107
  toggleModal,
@@ -97,6 +115,8 @@ export const ModalComp = ({
97
115
  customModalFooterStyle,
98
116
  ...props
99
117
  }) => {
118
+ const activeTheme = useTheme() || defaultThemeColor;
119
+
100
120
  return (
101
121
  <Modal
102
122
  isOpen={modalIsOpen}
@@ -105,38 +125,42 @@ export const ModalComp = ({
105
125
  contentLabel='Modal'
106
126
  {...props}
107
127
  >
108
- <ModalClose
109
- theme={defaultStyles}
110
- type={'modalComp-modal-close'}
111
- style={customModalCloseStyle}
112
- onClick={toggleModal}
113
- >
114
- <Icon
115
- icon='cross-icon'
116
- color={defaultThemeColor.neutral['neutral-2']}
117
- size={15}
118
- />
119
- </ModalClose>
120
-
121
- <ModalHeader style={customModalHeaderStyle}>
122
- <CommonDiv>{headerContent}</CommonDiv>
123
- </ModalHeader>
124
- <ModalBody
125
- theme={defaultStyles}
126
- type={'modalComp-modal-body'}
127
- style={customModalBodyStyle}
128
- >
129
- <CommonDiv> {bodyContent}
130
- </CommonDiv>
131
- </ModalBody>
132
-
133
- <ModalFooter
134
- theme={defaultStyles}
135
- type={'modalComp-modal-footer'}
136
- style={customModalFooterStyle}
137
- >
138
- {footerContent}
139
- </ModalFooter>
128
+ <HeaderWrapper theme={activeTheme}>
129
+ <ModalClose
130
+ theme={defaultStyles}
131
+ type={'modalComp-modal-close'}
132
+ style={customModalCloseStyle}
133
+ onClick={toggleModal}
134
+ >
135
+ <Icon
136
+ icon='cross-icon'
137
+ color={defaultThemeColor.neutral['neutral-2']}
138
+ size={15}
139
+ />
140
+ </ModalClose>
141
+
142
+ <ModalHeader style={customModalHeaderStyle}>
143
+ <CommonDiv>{headerContent}</CommonDiv>
144
+ </ModalHeader>
145
+ </HeaderWrapper>
146
+ <ContentWrapper>
147
+ <ModalBody
148
+ theme={defaultStyles}
149
+ type={'modalComp-modal-body'}
150
+ style={customModalBodyStyle}
151
+ >
152
+ <CommonDiv> {bodyContent}
153
+ </CommonDiv>
154
+ </ModalBody>
155
+
156
+ <ModalFooter
157
+ theme={defaultStyles}
158
+ type={'modalComp-modal-footer'}
159
+ style={customModalFooterStyle}
160
+ >
161
+ {footerContent}
162
+ </ModalFooter>
163
+ </ContentWrapper>
140
164
  </Modal>
141
165
  );
142
166
  };
@@ -1,83 +1,59 @@
1
- import React from 'react';
2
1
  import PropTypes from 'prop-types';
3
- import styled from 'styled-components';
2
+ import React from 'react';
3
+ import styled, { useTheme } from 'styled-components';
4
4
  import defaultThemeColor from '../constants/defaultThemeColor';
5
5
 
6
6
  const StyledPagination = styled.div`
7
- display: flex;
8
- align-items: center;
9
- color: ${({ theme }) => theme.variant['neutral-2']};
7
+ display: flex;
8
+ align-items: center;
9
+ color: ${({ theme }) => theme.variant['neutral-2']};
10
10
  `;
11
11
 
12
- StyledPagination.defaultProps = {
13
- theme: defaultThemeColor,
14
- }
15
-
16
12
  export const Pagination = ({ ...props }) => {
13
+ const activeTheme = useTheme() || defaultThemeColor;
17
14
 
18
15
  return (
19
- <StyledPagination>
20
- {props.children}
21
- </ StyledPagination>
16
+ <StyledPagination theme={activeTheme}>{props.children}</StyledPagination>
22
17
  );
23
18
  };
24
19
 
25
- Pagination.propTypes = {
26
- /**
27
- * Theme props
28
- */
29
- theme: PropTypes.object,
30
- }
31
-
32
- Pagination.defaultProps = {
33
- theme: defaultThemeColor,
34
- }
35
-
36
20
  const Item = styled.div`
37
- font-size: 14px;
38
- color: ${({ selected, theme }) => selected ? theme.variant['primary-1'] : null};
39
-
40
- svg {
41
- width: 14px;
42
- height: 14px;
43
- path {
44
- fill: ${({ selected, theme }) => selected ? theme.variant['primary-1'] : theme.variant['neutral-2']};
45
- }
21
+ font-size: 14px;
22
+ color: ${({ selected, theme }) =>
23
+ selected ? theme.variant['primary-1'] : null};
24
+
25
+ svg {
26
+ width: 14px;
27
+ height: 14px;
28
+ path {
29
+ fill: ${({ selected, theme }) =>
30
+ selected ? theme.variant['primary-1'] : theme.variant['neutral-2']};
46
31
  }
32
+ }
47
33
 
48
- cursor: pointer;
49
- &:not(:first-child):not(:last-child) {
50
- margin: 0 22px;
51
- }
34
+ cursor: pointer;
35
+ &:not(:first-child):not(:last-child) {
36
+ margin: 0 22px;
37
+ }
52
38
  `;
53
39
 
54
- Item.defaultProps = {
55
- theme: defaultThemeColor,
56
- }
57
-
58
40
  Pagination.PageItem = function PageItem({ selected, ...props }) {
41
+ const activeTheme = useTheme() || defaultThemeColor;
42
+
59
43
  return (
60
- <Item selected={selected} {...props}>
44
+ <Item selected={selected} theme={activeTheme} {...props}>
61
45
  {props.children}
62
46
  </Item>
63
- )
64
- }
47
+ );
48
+ };
65
49
 
66
50
  Pagination.PageItem.propTypes = {
67
- /**
68
- * Theme props
69
- */
70
- theme: PropTypes.object,
71
51
  /**
72
52
  * Is Page selected?
73
- */
53
+ */
74
54
  selected: PropTypes.bool,
75
- }
55
+ };
76
56
 
77
57
  Pagination.PageItem.defaultProps = {
78
- theme: defaultThemeColor,
79
58
  selected: false,
80
- }
81
-
82
-
83
-
59
+ };
@@ -1,47 +1,68 @@
1
- import React from "react";
2
1
  import PropTypes from 'prop-types';
3
- import styled from 'styled-components';
2
+ import React from 'react';
3
+ import styled, { useTheme } from 'styled-components';
4
4
  import defaultStyles from '../constants/defaultStyle';
5
5
  import defaultThemeColor from '../constants/defaultThemeColor';
6
- import getDefaultStyles from '../constants/utils';
6
+ import { hexToRGB } from '../constants/utils';
7
7
  import { Label } from '../Label';
8
- import { hexToRGB } from "../constants/utils";
9
8
 
10
9
  const WrapperDiv = styled.div`
11
- //Set the styles from the default styles object
12
- ${ ({ theme, type }) => {
13
- return getDefaultStyles(theme, type);
14
- }}
15
- background-color: ${({ color }) => color?
16
- hexToRGB(color, 0.5) :
17
- defaultThemeColor.primary['primary-1']};
10
+ height: 10px;
11
+ border-radius: 10px;
12
+ margin-top: 13px;
13
+ margin-left: 13px;
14
+ margin-right: 13px;
15
+ width: inherit;
16
+ background-color: ${({ color, theme }) =>
17
+ color ? hexToRGB(color, 0.5) : hexToRGB(theme.primary['primary-1'], 0.5)};
18
18
  `;
19
19
 
20
20
  const Container = styled.div`
21
- //Set the styles from the default styles object
22
- ${ ({ theme, type }) => {
23
- return getDefaultStyles(theme, type);
24
- }}
25
-
26
- // custom styles
27
- ${({ progressBarStyle }) => progressBarStyle}
28
- width: ${({now }) => now+'%'};
29
- background-color: ${({ color }) => color ?color :defaultThemeColor.primary['primary-1']};
21
+ height: inherit;
22
+ width: inherit;
23
+ transition: width 1s ease-in-out;
24
+ border-radius: inherit;
25
+ text-align: right;
26
+
27
+ // custom styles
28
+ ${({ progressBarStyle }) => progressBarStyle}
29
+ width: ${({ now }) => now + '%'};
30
+ background-color: ${({ color, theme }) =>
31
+ color ? color : theme.primary['primary-1']};
30
32
  `;
31
33
 
32
- export const ProgressBar = ({ labelStyle,progressBarStyle,label,now,color,...props}) => {
34
+ export const ProgressBar = ({
35
+ labelStyle,
36
+ progressBarStyle,
37
+ label,
38
+ now,
39
+ color,
40
+ ...props
41
+ }) => {
42
+ const activeTheme = useTheme() || defaultThemeColor;
43
+
33
44
  return (
34
45
  <div>
35
46
  <Label
36
- theme={defaultStyles}
47
+ inBuiltCss={defaultStyles}
37
48
  customStyles={labelStyle}
38
49
  type={'progressbarLabel'}
39
50
  text={label}
40
- {...props} />
41
- <WrapperDiv progressBarStyle={progressBarStyle} theme={defaultStyles}
42
- type={'progressWrapper'} color={color} {...props}>
43
- <Container progressBarStyle={progressBarStyle} now={now} theme={defaultStyles}
44
- type={'containerWrapper'} color={color} {...props}/>
51
+ {...props}
52
+ />
53
+ <WrapperDiv
54
+ progressBarStyle={progressBarStyle}
55
+ theme={activeTheme}
56
+ color={color}
57
+ {...props}
58
+ >
59
+ <Container
60
+ progressBarStyle={progressBarStyle}
61
+ now={now}
62
+ theme={activeTheme}
63
+ color={color}
64
+ {...props}
65
+ />
45
66
  </WrapperDiv>
46
67
  </div>
47
68
  );
@@ -49,19 +70,19 @@ export const ProgressBar = ({ labelStyle,progressBarStyle,label,now,color,...pro
49
70
 
50
71
  ProgressBar.propTypes = {
51
72
  /**
52
- * Custom style of the lable of the progressbar
73
+ * Custom style of the label of the progressBar
53
74
  */
54
75
  labelStyle: PropTypes.object,
55
76
  /**
56
- * Custom style of the progressbar
77
+ * Custom style of the progressBar
57
78
  */
58
79
  progressBarStyle: PropTypes.object,
59
-
80
+
60
81
  /**
61
- * Custom color(HEX format) of the progressbar
82
+ * Custom color(HEX format) of the progressBar
62
83
  */
63
84
  color: PropTypes.string,
64
-
85
+
65
86
  /**
66
87
  * label props
67
88
  */
@@ -73,12 +94,8 @@ ProgressBar.propTypes = {
73
94
  };
74
95
 
75
96
  ProgressBar.defaultProps = {
76
- labelStyle:{},
97
+ labelStyle: {},
77
98
  progressBarStyle: {},
78
- label:'',
79
- now:0,
80
- color: "#2E56F4"
81
- };
82
-
83
-
84
-
99
+ label: '',
100
+ now: 0,
101
+ };
@@ -1,8 +1,7 @@
1
- import React, { useEffect, useState } from 'react';
2
1
  import PropTypes from 'prop-types';
3
- import styled, { css } from 'styled-components';
4
- import defaultStyles from '../constants/defaultStyle';
5
- import getDefaultStyles from '../constants/utils';
2
+ import React, { useEffect, useState } from 'react';
3
+ import styled, { css, useTheme } from 'styled-components';
4
+ import defaultThemeColor from '../constants/defaultThemeColor';
6
5
 
7
6
  const StyledContainer = styled.div`
8
7
  box-sizing: border-box;
@@ -112,7 +111,6 @@ function getPercentage(value, maxRange) {
112
111
  }
113
112
 
114
113
  export const Rating = ({
115
- theme,
116
114
  type,
117
115
  customStylesContainer,
118
116
  customStylesStar,
@@ -127,6 +125,7 @@ export const Rating = ({
127
125
  toggleSet,
128
126
  identifier,
129
127
  ...props }) => {
128
+ const activeTheme = useTheme() || defaultThemeColor;
130
129
 
131
130
  const [starArr, setStarArr] = useState(undefined);
132
131
  const [starVal, setStarVal] = useState(undefined);
@@ -182,18 +181,15 @@ export const Rating = ({
182
181
  </>
183
182
 
184
183
  return (
185
- <StyledContainer theme={theme} customStyles={customStylesContainer} type={type} size={size} {...props} className={'container'} >
184
+ <StyledContainer customStyles={customStylesContainer} type={type} size={size} {...props} className={'container'} >
186
185
  {toggleStar ? stars :
187
- <StyledPercentage theme={theme} type={type} customStyles={customStylesPercentage}>{percentage}%</StyledPercentage>}
186
+ <StyledPercentage type={type} customStyles={customStylesPercentage}>{percentage}%</StyledPercentage>}
188
187
  </StyledContainer>
189
188
  )
190
189
  }
191
190
 
192
191
  Rating.propTypes = {
193
- /**
194
- * Theme props
195
- */
196
- theme: PropTypes.object,
192
+
197
193
  /**
198
194
  * Custom style object for container
199
195
  */
@@ -249,7 +245,6 @@ Rating.propTypes = {
249
245
  }
250
246
 
251
247
  Rating.defaultProps = {
252
- theme: defaultStyles,
253
248
  customStylesContainer: null,
254
249
  customStylesStar: null,
255
250
  customStylesPercentage: null,
@@ -260,5 +255,4 @@ Rating.defaultProps = {
260
255
  toggleStar: true,
261
256
  toggleSet: false,
262
257
  color: '#F7B001'
263
- }
264
-
258
+ }