groundfloor-react-ui 1.0.20 → 1.0.21

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,73 +1,72 @@
1
- import React, { useState } from "react";
2
1
  import PropTypes from 'prop-types';
3
- import styled, { css } from 'styled-components';
2
+ import React, { useState } from 'react';
3
+ import styled, { css, useTheme } from 'styled-components';
4
4
  import defaultStyles from '../constants/defaultStyle';
5
- import { Image } from '../Images'
5
+ import defaultThemeColor from '../constants/defaultThemeColor';
6
+ import { Image } from '../Images';
6
7
 
7
8
  /**
8
9
  * Primary UI component for user interaction
9
10
  */
10
11
  const StyledContainer = styled.span`
11
- ${({ theme, type, customStyles }) => {
12
- if (theme) {
12
+ ${({ inBuiltCss, type, customStyles }) => {
13
+ if (inBuiltCss) {
13
14
  let tempObj = {};
14
- if (theme[type]) {
15
- for (const property in theme['common']) {
16
- tempObj[property] = theme['common'][property]
15
+ if (inBuiltCss[type]) {
16
+ for (const property in inBuiltCss['common']) {
17
+ tempObj[property] = inBuiltCss['common'][property];
17
18
  }
18
- for (const property in theme[type]) {
19
- tempObj[property] = theme[type][property]
20
- delete theme.common[property]
19
+ for (const property in inBuiltCss[type]) {
20
+ tempObj[property] = inBuiltCss[type][property];
21
+ delete inBuiltCss.common[property];
21
22
  }
22
23
  }
23
24
  return { ...tempObj, ...customStyles };
24
25
  }
25
26
  }}
26
- width: auto;
27
+ width: auto;
27
28
  `;
28
29
 
29
30
  const StyledCircle = styled.div`
30
- ${({ theme, type, size, customStyles }) => {
31
- if (theme) {
31
+ background-color: ${({ theme }) => theme.primary['primary-1']};
32
+ color: ${({ theme }) => theme.bgColor};
33
+
34
+ ${({ inBuiltCss, type, size, customStyles }) => {
35
+ if (inBuiltCss) {
32
36
  let tempObj = {};
33
- if (theme[type]) {
34
- for (const property in theme['common']) {
35
- tempObj[property] = theme['common'][property]
37
+ if (inBuiltCss[type]) {
38
+ for (const property in inBuiltCss['common']) {
39
+ tempObj[property] = inBuiltCss['common'][property];
36
40
  }
37
- for (const property in theme[type]) {
38
- tempObj[property] = theme[type][property]
39
- delete theme.common[property]
41
+ for (const property in inBuiltCss[type]) {
42
+ tempObj[property] = inBuiltCss[type][property];
43
+ delete inBuiltCss.common[property];
40
44
  }
41
- for (const property in theme[`${type}${size}`]) {
42
- tempObj[property] = theme[`${type}${size}`][property]
43
- delete theme.common[property]
45
+ for (const property in inBuiltCss[`${type}${size}`]) {
46
+ tempObj[property] = inBuiltCss[`${type}${size}`][property];
47
+ delete inBuiltCss.common[property];
44
48
  }
45
49
  }
46
50
  return { ...tempObj, ...customStyles };
47
51
  }
48
52
  }}
49
- ${({ isSelected }) => {
50
-
53
+ ${({ isSelected, selectedStyle, notSelectedStyle }) => {
51
54
  if (isSelected) {
52
55
  return css`
53
- border: 2px solid rgba(255, 255, 255, 0.3);
54
- background-color: #1D36AD;
55
- min-width: 42px;
56
- min-height: 42px;
57
- `
56
+ ${selectedStyle}
57
+
58
+ min-width: 42px;
59
+ min-height: 42px;
60
+ `;
58
61
  } else {
59
62
  return css`
60
- border: 2px solid #2240CB;
61
- background-color: #2240CB;
62
- // width: 38px;
63
- // height: 38px;
64
- `
63
+ ${notSelectedStyle}
64
+ `;
65
65
  }
66
66
  }}
67
67
  font-weight: 600;
68
68
  `;
69
69
 
70
-
71
70
  //Create the style for the Avatar
72
71
 
73
72
  // let customStylesCircle = {}
@@ -81,52 +80,52 @@ const StyledCircle = styled.div`
81
80
  // console.log("customStylesCircle" + i + ": ", customStylesCircle)
82
81
 
83
82
  const StyledName = styled.span`
84
- ${({ theme, type, size, customStyles }) => {
85
- if (theme) {
83
+ color: ${({ theme }) => theme.textColor};
84
+
85
+ ${({ inBuiltCss, type, size, customStyles }) => {
86
+ if (inBuiltCss) {
86
87
  let tempObj = {};
87
- if (theme[type]) {
88
- for (const property in theme['common']) {
89
- tempObj[property] = theme['common'][property]
88
+ if (inBuiltCss[type]) {
89
+ for (const property in inBuiltCss['common']) {
90
+ tempObj[property] = inBuiltCss['common'][property];
90
91
  }
91
- for (const property in theme[type]) {
92
- delete theme.common[property]
93
- tempObj[property] = theme[type][property]
92
+ for (const property in inBuiltCss[type]) {
93
+ delete inBuiltCss.common[property];
94
+ tempObj[property] = inBuiltCss[type][property];
94
95
  }
95
- for (const property in theme[`${type}${size}`]) {
96
- tempObj[property] = theme[`${type}${size}`][property]
97
- delete theme.common[property]
96
+ for (const property in inBuiltCss[`${type}${size}`]) {
97
+ tempObj[property] = inBuiltCss[`${type}${size}`][property];
98
+ delete inBuiltCss.common[property];
98
99
  }
99
100
  }
100
101
  return { ...tempObj, ...customStyles };
101
102
  }
102
103
  }}
103
104
 
104
- &:hover{
105
- ${({ theme, type, size, customStylesHover }) => {
106
- if (theme) {
105
+ &:hover {
106
+ ${({ inBuiltCss, type, size, customStylesHover }) => {
107
+ if (inBuiltCss) {
107
108
  let tempObj = {};
108
- // if (theme[type]) {
109
- // for (const property in theme['common']) {
110
- // tempObj[property] = theme['common'][property]
109
+ // if (inBuiltCss[type]) {
110
+ // for (const property in inBuiltCss['common']) {
111
+ // tempObj[property] = inBuiltCss['common'][property]
111
112
  // }
112
- // for (const property in theme[type]) {
113
- // delete theme.common[property]
114
- // tempObj[property] = theme[type][property]
113
+ // for (const property in inBuiltCss[type]) {
114
+ // delete inBuiltCss.common[property]
115
+ // tempObj[property] = inBuiltCss[type][property]
115
116
  // }
116
- // for (const property in theme[`${type}${size}`]) {
117
- // tempObj[property] = theme[`${type}${size}`][property]
118
- // delete theme.common[property]
117
+ // for (const property in inBuiltCss[`${type}${size}`]) {
118
+ // tempObj[property] = inBuiltCss[`${type}${size}`][property]
119
+ // delete inBuiltCss.common[property]
119
120
  // }
120
121
  // }
121
122
  return { ...tempObj, ...customStylesHover };
122
123
  }
123
124
  }}
124
- }
125
-
125
+ }
126
126
  `;
127
127
 
128
128
  export const AvatarSBfooter = ({
129
- theme,
130
129
  customStylesContainer,
131
130
  customStylesImage,
132
131
  customStylesCircle,
@@ -136,43 +135,71 @@ export const AvatarSBfooter = ({
136
135
  toggleName,
137
136
  user,
138
137
  border,
138
+ selectedStyle,
139
+ notSelectedStyle,
139
140
  isSelected,
140
141
  value,
141
142
  ...props
142
143
  }) => {
143
-
144
- const [avatarStatus, setAvatarStatus] = useState("loading");
144
+ const [avatarStatus, setAvatarStatus] = useState('loading');
145
+ const activeTheme = useTheme() || defaultThemeColor;
145
146
 
146
147
  const handleImageStatus = (imageStatus) => {
147
148
  setAvatarStatus(imageStatus);
148
- }
149
+ };
149
150
  // console.log('user', user)
150
151
  return (
151
- <StyledContainer border={border} theme={theme} customStyles={customStylesContainer} type={'avatarContainer'} {...props}>
152
- {user?.url && <Image
153
- {...props}
154
- theme={theme}
155
- customStyles={customStylesImage}
156
- type={'imageAvatar'}
157
- size={size}
158
- alt="user-picture"
159
- src={user.url}
160
- handleImageStatus={handleImageStatus}
161
- style={{ visibility: avatarStatus !== "loaded" ? 'hidden' : 'visible' }}
162
- />}
152
+ <StyledContainer
153
+ border={border}
154
+ theme={activeTheme}
155
+ inBuiltCss={defaultStyles}
156
+ customStyles={customStylesContainer}
157
+ type={'avatarContainer'}
158
+ {...props}
159
+ >
160
+ {user?.url && (
161
+ <Image
162
+ {...props}
163
+ inBuiltCss={defaultStyles}
164
+ customStyles={customStylesImage}
165
+ type={'imageAvatar'}
166
+ size={size}
167
+ alt='user-picture'
168
+ src={user.url}
169
+ handleImageStatus={handleImageStatus}
170
+ style={{
171
+ visibility: avatarStatus !== 'loaded' ? 'hidden' : 'visible',
172
+ }}
173
+ />
174
+ )}
163
175
 
164
- <StyledCircle {...props}
165
- theme={theme}
176
+ <StyledCircle
177
+ {...props}
178
+ theme={activeTheme}
179
+ inBuiltCss={defaultStyles}
166
180
  type={'avatarCircle'}
167
- customStyles={customStylesCircle} size={size}
168
- style={{ visibility: avatarStatus !== "loaded" ? 'visible' : 'hidden' }}
181
+ customStyles={customStylesCircle}
182
+ size={size}
183
+ style={{ visibility: avatarStatus !== 'loaded' ? 'visible' : 'hidden' }}
169
184
  isSelected={isSelected}
185
+ selectedStyle={selectedStyle}
186
+ notSelectedStyle={notSelectedStyle}
170
187
  >
171
- {
172
- value
173
- }
188
+ {value}
174
189
  </StyledCircle>
175
- {toggleName && <StyledName {...props} theme={theme} type={'avatarName'} customStyles={customStylesName} customStylesHover={customStylesNameHover} size={size}>{user.userName} </StyledName>}
190
+ {toggleName && (
191
+ <StyledName
192
+ theme={activeTheme}
193
+ {...props}
194
+ inBuiltCss={defaultStyles}
195
+ type={'avatarName'}
196
+ customStyles={customStylesName}
197
+ customStylesHover={customStylesNameHover}
198
+ size={size}
199
+ >
200
+ {user.userName}{' '}
201
+ </StyledName>
202
+ )}
176
203
  </StyledContainer>
177
204
  );
178
205
  };
@@ -206,14 +233,9 @@ AvatarSBfooter.propTypes = {
206
233
  * Object with user information. To display the user's picture need a key "url". To display the name need a key "userName"
207
234
  */
208
235
  user: PropTypes.object,
209
- /**
210
- * Theme object
211
- */
212
- theme: PropTypes.object,
213
236
  };
214
237
 
215
238
  AvatarSBfooter.defaultProps = {
216
- theme: defaultStyles,
217
239
  block: false,
218
240
  size: 'MD',
219
241
  toggleName: false,
@@ -222,5 +244,4 @@ AvatarSBfooter.defaultProps = {
222
244
  customStylesImage: null,
223
245
  customStylesCircle: null,
224
246
  customStylesName: null,
225
- };
226
-
247
+ };
@@ -1,46 +1,54 @@
1
- import React from "react";
2
- import PropTypes from "prop-types";
3
- import styled from 'styled-components';
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import styled, { useTheme } from 'styled-components';
4
4
  import defaultThemeColor from '../constants/defaultThemeColor';
5
5
 
6
6
  const BannerWrapper = styled.div`
7
- color: ${({ theme }) => theme.textColor};
8
- display: flex;
9
- background-color: ${({ backgroundColor }) => backgroundColor };
10
- border-left: 5px solid ${({ borderColor }) => borderColor };;
11
- padding-left:28px;
12
- padding-top: 22px;
13
- padding-bottom:22px;
14
- width: inherit;
15
- `
16
-
17
- BannerWrapper.defaultProps = {
18
- theme: defaultThemeColor,
19
- }
7
+ color: ${({ theme }) => theme.textColor};
8
+ display: flex;
9
+ background-color: ${({ backgroundColor, theme }) =>
10
+ backgroundColor ? backgroundColor : theme.variant['insight-purple']};
11
+ border-left: 5px solid
12
+ ${({ borderColor, theme }) =>
13
+ borderColor ? borderColor : theme.variant['graph-3']};
14
+ padding-left: 28px;
15
+ padding-top: 22px;
16
+ padding-bottom: 22px;
17
+ width: inherit;
18
+ `;
20
19
 
21
20
  const BannerContent = styled.div`
22
- color: ${({ theme }) => theme.textColor};
23
- display: flex;
24
- font-size: 16px;
25
- text-align: left;
26
- word-wrap: break-word;
27
- `
21
+ color: ${({ theme }) => theme.textColor};
22
+ display: flex;
23
+ font-size: 16px;
24
+ text-align: left;
25
+ word-wrap: break-word;
26
+ `;
28
27
 
29
- BannerContent.defaultProps = {
30
- theme: defaultThemeColor,
31
- }
28
+ export const Banner = ({
29
+ backgroundColor,
30
+ borderColor,
31
+ variant,
32
+ children,
33
+ ...props
34
+ }) => {
35
+ const activeTheme = useTheme() || defaultThemeColor;
32
36
 
33
- export const Banner = ({ backgroundColor, borderColor,variant, children,...props}) =>{
34
37
  return (
35
38
  <>
36
- <BannerWrapper backgroundColor={backgroundColor} borderColor={borderColor} {...props}>
37
- <BannerContent {...props}>
39
+ <BannerWrapper
40
+ theme={activeTheme}
41
+ backgroundColor={backgroundColor}
42
+ borderColor={borderColor}
43
+ {...props}
44
+ >
45
+ <BannerContent theme={activeTheme} {...props}>
38
46
  {children}
39
47
  </BannerContent>
40
48
  </BannerWrapper>
41
49
  </>
42
50
  );
43
- }
51
+ };
44
52
 
45
53
  Banner.propTypes = {
46
54
  /**
@@ -54,12 +62,9 @@ Banner.propTypes = {
54
62
  /**
55
63
  * What will be rendered inside the bannaer
56
64
  */
57
- children: PropTypes.any
58
- }
65
+ children: PropTypes.any,
66
+ };
59
67
 
60
68
  Banner.defaultProps = {
61
69
  children: '',
62
- backgroundColor:'#f7f2ff',
63
- borderColor:'#8b2dff',
64
- }
65
-
70
+ };