groundfloor-react-ui 1.2.8 → 1.2.10

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 (186) hide show
  1. package/dist/index.es.js +461 -430
  2. package/dist/index.js +469 -438
  3. package/package.json +15 -43
  4. package/rollup.config.js +6 -6
  5. package/assets/fonts/Averta/Averta-Black.woff2 +0 -0
  6. package/assets/fonts/Averta/Averta-BlackItalic.woff2 +0 -0
  7. package/assets/fonts/Averta/Averta-Bold.woff2 +0 -0
  8. package/assets/fonts/Averta/Averta-BoldItalic.woff2 +0 -0
  9. package/assets/fonts/Averta/Averta-ExtraBold.woff2 +0 -0
  10. package/assets/fonts/Averta/Averta-ExtraBoldItalic.woff2 +0 -0
  11. package/assets/fonts/Averta/Averta-ExtraThin.woff2 +0 -0
  12. package/assets/fonts/Averta/Averta-ExtraThinItalic.woff2 +0 -0
  13. package/assets/fonts/Averta/Averta-Light.woff2 +0 -0
  14. package/assets/fonts/Averta/Averta-LightItalic.woff2 +0 -0
  15. package/assets/fonts/Averta/Averta-Regular.woff2 +0 -0
  16. package/assets/fonts/Averta/Averta-RegularItalic.woff2 +0 -0
  17. package/assets/fonts/Averta/Averta-SemiBold.woff2 +0 -0
  18. package/assets/fonts/Averta/Averta-SemiBoldItalic.woff2 +0 -0
  19. package/assets/fonts/Averta/Averta-Thin.woff2 +0 -0
  20. package/assets/fonts/Averta/Averta-ThinItalic.woff2 +0 -0
  21. package/assets/fonts/Beauty/BeautyDemo.woff +0 -0
  22. package/assets/icons/app-logo.svg +0 -3
  23. package/assets/icons/arrow-down.svg +0 -3
  24. package/assets/icons/arrow-rotate.svg +0 -1
  25. package/assets/icons/arrow-up.svg +0 -3
  26. package/assets/icons/bell.svg +0 -3
  27. package/assets/icons/check.svg +0 -3
  28. package/assets/icons/checkmark.svg +0 -3
  29. package/assets/icons/chevron-down.svg +0 -3
  30. package/assets/icons/chevron-left.svg +0 -3
  31. package/assets/icons/chevron-right.svg +0 -3
  32. package/assets/icons/cloud-icon.svg +0 -3
  33. package/assets/icons/connection.svg +0 -3
  34. package/assets/icons/cross-icon.svg +0 -3
  35. package/assets/icons/default.svg +0 -1
  36. package/assets/icons/door-internal-active.svg +0 -1
  37. package/assets/icons/edit-icon.svg +0 -3
  38. package/assets/icons/ellipses-horizontal.svg +0 -3
  39. package/assets/icons/ellipses.svg +0 -3
  40. package/assets/icons/email.svg +0 -3
  41. package/assets/icons/eye-hide-view.svg +0 -1
  42. package/assets/icons/eye-hide.svg +0 -1
  43. package/assets/icons/file-attach-white.svg +0 -3
  44. package/assets/icons/file-attach.svg +0 -3
  45. package/assets/icons/file-icon.svg +0 -1
  46. package/assets/icons/file-upload.svg +0 -3
  47. package/assets/icons/functional-equation-regular.svg +0 -147
  48. package/assets/icons/hamburger-menu.svg +0 -3
  49. package/assets/icons/heart.svg +0 -18
  50. package/assets/icons/image.svg +0 -3
  51. package/assets/icons/info.svg +0 -3
  52. package/assets/icons/jpg-icon.svg +0 -3
  53. package/assets/icons/magnifier.svg +0 -3
  54. package/assets/icons/menu-ellipse-two.svg +0 -1
  55. package/assets/icons/menu-ellipse.svg +0 -53
  56. package/assets/icons/pause-all.svg +0 -1
  57. package/assets/icons/pdf-icon.svg +0 -3
  58. package/assets/icons/pen-icon.svg +0 -3
  59. package/assets/icons/plus-outlined.svg +0 -3
  60. package/assets/icons/resume.svg +0 -1
  61. package/assets/icons/sign-icon.svg +0 -3
  62. package/assets/icons/star.svg +0 -3
  63. package/assets/icons/trash-icon.svg +0 -59
  64. package/assets/icons/triangle-down.svg +0 -3
  65. package/assets/icons/users.svg +0 -11
  66. package/assets/icons/view.svg +0 -3
  67. package/assets/icons/watcher.svg +0 -3
  68. package/assets/icons/zoom-in-white.svg +0 -1
  69. package/assets/styles/global.css +0 -0
  70. package/assets/styles/global.scss +0 -0
  71. package/components/Accordion/Accordion.js +0 -167
  72. package/components/Accordion/AccordionSB.js +0 -170
  73. package/components/Accordion/AccordionSBfooter.js +0 -171
  74. package/components/Accordion/index.js +0 -4
  75. package/components/ArrowBar/ArrowBar.js +0 -276
  76. package/components/ArrowBar/index.js +0 -2
  77. package/components/Avatar/Avatar.js +0 -171
  78. package/components/Avatar/AvatarSB.js +0 -255
  79. package/components/Avatar/AvatarSBfooter.js +0 -279
  80. package/components/Avatar/index.js +0 -4
  81. package/components/Banner/Banner.js +0 -70
  82. package/components/Banner/index.js +0 -2
  83. package/components/Breadcrumb/Breadcrumb.js +0 -225
  84. package/components/Breadcrumb/index.js +0 -2
  85. package/components/Button/PrimaryButton.js +0 -167
  86. package/components/Button/SecondaryButton.js +0 -156
  87. package/components/Button/TinyButton.js +0 -101
  88. package/components/Button/index.js +0 -6
  89. package/components/Cards/Card.js +0 -43
  90. package/components/Cards/CardRef.js +0 -71
  91. package/components/Cards/DocumentCard.js +0 -215
  92. package/components/Cards/index.js +0 -5
  93. package/components/Content/Content.js +0 -50
  94. package/components/Content/index.js +0 -1
  95. package/components/DesignComponent/StyledComponent/StyledComponent.js +0 -326
  96. package/components/DesignComponent/StyledComponent/index.js +0 -1
  97. package/components/DesignComponent/index.js +0 -1
  98. package/components/Divider/Divider.js +0 -56
  99. package/components/Divider/index.js +0 -2
  100. package/components/Drawer/Drawer.js +0 -84
  101. package/components/Drawer/index.js +0 -2
  102. package/components/ErrorBoundary/ErrorBoundary.js +0 -44
  103. package/components/ErrorBoundary/index.js +0 -1
  104. package/components/FilterChip/FilterChip.js +0 -70
  105. package/components/FilterChip/index.js +0 -1
  106. package/components/Footer/Footer.js +0 -57
  107. package/components/Footer/FooterContent.js +0 -98
  108. package/components/Footer/index.js +0 -3
  109. package/components/Form/FormComponent.js +0 -244
  110. package/components/Form/HeaderComponent.js +0 -64
  111. package/components/Form/SubmitComponent.js +0 -63
  112. package/components/Form/index.js +0 -5
  113. package/components/GroupAvatars/GroupAvatars.js +0 -139
  114. package/components/GroupAvatars/index.js +0 -1
  115. package/components/GroupButtons/ButtonPopup.js +0 -191
  116. package/components/GroupButtons/GroupButtons.js +0 -150
  117. package/components/GroupButtons/GroupButtonsPopup.js +0 -163
  118. package/components/GroupButtons/index.js +0 -3
  119. package/components/GroupStatusCircle/GroupStatusCircle.js +0 -135
  120. package/components/GroupStatusCircle/index.js +0 -1
  121. package/components/Header/Header.js +0 -58
  122. package/components/Header/index.js +0 -1
  123. package/components/HyperLink/HyperLink.js +0 -114
  124. package/components/HyperLink/index.js +0 -1
  125. package/components/Icon/Icon.js +0 -176
  126. package/components/Icon/index.js +0 -1
  127. package/components/Images/Image.js +0 -107
  128. package/components/Images/index.js +0 -2
  129. package/components/Inputs/CheckBoxInput.js +0 -339
  130. package/components/Inputs/ColorInput.js +0 -145
  131. package/components/Inputs/DateSelect.js +0 -461
  132. package/components/Inputs/DropdownSelect.js +0 -690
  133. package/components/Inputs/DropzoneInput.js +0 -450
  134. package/components/Inputs/NumericInput.js +0 -166
  135. package/components/Inputs/PasswordInput.js +0 -242
  136. package/components/Inputs/RadioInput.js +0 -292
  137. package/components/Inputs/SearchInput.js +0 -19
  138. package/components/Inputs/Signature.js +0 -369
  139. package/components/Inputs/TextArea.js +0 -214
  140. package/components/Inputs/TextInput.js +0 -235
  141. package/components/Inputs/TimeInput.js +0 -186
  142. package/components/Inputs/ToggleSwitch.js +0 -157
  143. package/components/Inputs/index.js +0 -15
  144. package/components/Label/Label.js +0 -48
  145. package/components/Label/index.js +0 -1
  146. package/components/Loaders/Loader.js +0 -179
  147. package/components/Loaders/index.js +0 -2
  148. package/components/Modal/ModalComp.js +0 -216
  149. package/components/Modal/index.js +0 -1
  150. package/components/Overlay/Overlay.js +0 -158
  151. package/components/Overlay/index.js +0 -1
  152. package/components/Pagination/Pagination.js +0 -59
  153. package/components/Pagination/index.js +0 -1
  154. package/components/ProgressBar/ProgressBar.js +0 -101
  155. package/components/ProgressBar/index.js +0 -1
  156. package/components/ProgressSteps/ProgressSteps.js +0 -121
  157. package/components/ProgressSteps/index.js +0 -1
  158. package/components/Rating/Rating.js +0 -258
  159. package/components/Rating/index.js +0 -1
  160. package/components/SecondaryLink/DarkSecondaryLink.js +0 -97
  161. package/components/SecondaryLink/LightSecondaryLink.js +0 -93
  162. package/components/SecondaryLink/index.js +0 -3
  163. package/components/Sidebar/Navbar.js +0 -306
  164. package/components/Sidebar/Sidebar.js +0 -207
  165. package/components/Sidebar/index.js +0 -3
  166. package/components/StatusChip/PrimaryStatusChip.js +0 -78
  167. package/components/StatusChip/SecondaryStatusChip.js +0 -78
  168. package/components/StatusChip/SlimPrimaryStatusChip.js +0 -92
  169. package/components/StatusChip/SlimSecondaryStatusChip.js +0 -93
  170. package/components/StatusChip/index.js +0 -6
  171. package/components/StatusCircle/StatusCircle.js +0 -64
  172. package/components/StatusCircle/index.js +0 -1
  173. package/components/Tables/Table.js +0 -178
  174. package/components/Tables/index.js +0 -1
  175. package/components/Tooltip/Tooltip.js +0 -581
  176. package/components/Tooltip/index.js +0 -1
  177. package/components/Typography/Typography.js +0 -77
  178. package/components/Typography/index.js +0 -2
  179. package/components/constants/colors.js +0 -33
  180. package/components/constants/defaultStyle.js +0 -801
  181. package/components/constants/defaultThemeColor.js +0 -16
  182. package/components/constants/index.js +0 -7
  183. package/components/constants/utils.js +0 -31
  184. package/components/global/FontStyle.js +0 -131
  185. package/components/global/index.js +0 -1
  186. package/index.js +0 -41
@@ -1,276 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React, { useEffect, useRef, useState } from 'react';
3
- import styled, { css, useTheme } from 'styled-components';
4
- import defaultThemeColor from '../constants/defaultThemeColor';
5
-
6
- const StyledArrowBar = styled.div`
7
- color: ${({ theme, variant }) => variant ? theme.variant[variant] : 'white'};
8
- ${({ scroll }) => {
9
- if (scroll) {
10
- return css`
11
- display: flex;
12
- overflow-x: auto;
13
- `
14
- } else {
15
- return css`
16
- display: grid;
17
- grid-template-columns: ${({ arrowNumber }) => `repeat(${arrowNumber}, 1fr)`};
18
- `
19
- }
20
- }}
21
- `;
22
-
23
- const StyledArrow = styled.div`
24
- min-height: 40px;
25
- max-height: 40px;
26
- background-color: ${({ color }) => color};
27
- align-items: center;
28
- display: flex;
29
- cursor: ${({ clickable }) => clickable ? 'pointer' : 'default'};
30
-
31
- ${({ index, dataLength }) => {
32
- if (index === 0) {
33
- return css`
34
- clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%);
35
- border-top-left-radius: 20px;
36
- border-bottom-left-radius: 20px;
37
- `
38
- } else if (index === dataLength - 1) {
39
- return css`
40
- clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, calc(0% + 9px) 50%);
41
- margin-left: -5px;
42
- `
43
- } else {
44
- return css`
45
- clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%, calc(0% + 9px) 50%);
46
- margin-left: -5px;
47
- `
48
- }
49
- }}
50
-
51
- ${({ scroll }) => {
52
- if (scroll) {
53
- return css`
54
- width:100%;
55
- `
56
- } else {
57
- return css`
58
- flex-shrink: 1;
59
- min-width: 15px;
60
- flex-grow: 1;
61
- flex-basis: auto;
62
-
63
- &:hover {
64
- width: -webkit-fill-available;
65
- }
66
- `
67
- }
68
- }}
69
- `;
70
-
71
- const StyledArrowContent = styled.div`
72
- padding: 0 15px;
73
- display: flex;
74
- align-items: center;
75
- justify-content: space-around;
76
- width: 100%;
77
- white-space: nowrap;
78
- overflow: hidden;
79
- text-overflow: ellipsis;
80
-
81
- & span{
82
- font-size: 22px;
83
- font-weight: 400;
84
- padding-right: 5px;
85
-
86
- ${({ scroll }) => {
87
- if (!scroll) {
88
- return css`
89
- display: ${({ styleArrowContentSpan }) => styleArrowContentSpan.display};
90
- white-space: nowrap;
91
- overflow: hidden;
92
- text-overflow: ellipsis;
93
- `
94
- }
95
- }}
96
- }
97
-
98
- & p{
99
- margin: 0;
100
- font-weight: 600;
101
-
102
- ${({ scroll }) => {
103
- if (scroll) {
104
- return css`
105
- font-size: 14px;
106
- `
107
- } else {
108
- return css`
109
- font-size: ${({ styleArrowContentP }) => styleArrowContentP.fontSize};
110
- display: ${({ styleArrowContentP }) => styleArrowContentP.display};
111
- white-space: nowrap;
112
- overflow: hidden;
113
- text-overflow: ellipsis;
114
- `
115
- }
116
- }}
117
- }
118
-
119
- ${({ scroll }) => {
120
- if (!scroll) {
121
- return css`
122
- ${StyledArrow}:hover & {
123
- ${({ styleArrowContentSpan, styleArrowContentP }) => {
124
- if (styleArrowContentP?.display === 'none' && styleArrowContentSpan?.display === 'none') {
125
- return css`
126
- span {
127
- display: block;
128
- }
129
- p {
130
- display: block;
131
- }
132
- `
133
- } else if (styleArrowContentP?.display === 'none') {
134
- return css`
135
- p {
136
- display: block;
137
- }
138
- `
139
- }
140
- }}
141
- };
142
- `
143
- }
144
- }}
145
- `;
146
-
147
- export const ArrowBar = ({ variant, data, scroll, onClick, clickable, ...props }) => {
148
- const activeTheme = useTheme() || defaultThemeColor;
149
-
150
- const arrowBarRef = useRef(null)
151
- const arrowRef = useRef(null)
152
-
153
- const [widthArrow, setWidthArrow] = useState(undefined);
154
- const [widthArrowBar, setWidthArrowBar] = useState(undefined);
155
-
156
- let styleArrowContentP = {
157
- fontSize: '',
158
- display: '',
159
- }
160
-
161
- let styleArrowContentSpan = {
162
- fontSize: '',
163
- display: '',
164
- }
165
-
166
- const handleWindowResize = () => {
167
- arrowBarRef && setWidthArrowBar(arrowBarRef?.current?.offsetWidth)
168
- }
169
-
170
- useEffect(() => {
171
- handleWindowResize();
172
- }, [data, widthArrowBar])
173
-
174
- //On component mount add event listener
175
- useEffect(() => {
176
- if (!scroll) {
177
- // Monitor the width of the viewPort to adjust the text of the arrow accordingly
178
- window.addEventListener("resize", handleWindowResize);
179
- return () => (window.removeEventListener("resize", handleWindowResize))
180
- }
181
- }, [])
182
-
183
- useEffect(() => {
184
- if (!scroll) {
185
- setWidthArrow(arrowRef?.current.offsetWidth);
186
- }
187
- }, [data, widthArrowBar, widthArrow]);
188
-
189
- //Get index of the longest value + label
190
- const longest = data.reduce(
191
- function (a, b) {
192
- return (a.label.length * 9) + (a.value.toString().length * 13) > (b.label.length * 9) + (b.value.toString().length * 13) ? a : b;
193
- }
194
- );
195
-
196
- // Calculate threshould base on lenght of value and label string
197
- // 15px padding left + (13px x ch VALUE) + 5px padding + (9px x ch LABEL) + 15px padding right
198
- function setThreshould(longest) {
199
- return {
200
- step1: 15 + (longest.value.toString().length * 13) + 5 + (longest.label.length * 9) + 15, //reduce font of LABEL
201
- step2: 15 + (longest.value.toString().length * 13) + 5 + (longest.label.length * 7) + 15, //hide LABEL
202
- step3: 15 + (longest.value.toString().length * 13) + 5 + 15, //hide VALUE
203
- }
204
- }
205
-
206
- //Each time the component re-render check the width of the Arrow with the longest content and set font dimentions
207
- if (!scroll) {
208
- const threshould = setThreshould(longest)
209
-
210
- if (widthArrow < threshould.step3) {
211
- styleArrowContentSpan.display = "none";
212
- styleArrowContentP.display = "none";
213
- } else if (widthArrow < threshould.step2) {
214
- styleArrowContentP.display = "none";
215
- } else if (widthArrow < threshould.step1) {
216
- styleArrowContentP.fontSize = "12px";
217
- } else {
218
- styleArrowContentP.fontSize = "14px";
219
- }
220
- }
221
-
222
- const ArrowContent = (value, label) => {
223
- return (
224
- <StyledArrowContent styleArrowContentP={styleArrowContentP} styleArrowContentSpan={styleArrowContentSpan} scroll={scroll}>
225
- <span >{value}</span><p>{label}</p>
226
- </StyledArrowContent>
227
- )
228
- };
229
-
230
- return (
231
- <StyledArrowBar theme={activeTheme} variant={variant} ref={scroll ? null : arrowBarRef} arrowNumber={data.length} scroll={scroll} >
232
- {data.map((singleData, index) => {
233
- return (
234
- // Add the ref to the Arrow with the longest text label + value
235
- <StyledArrow id={singleData.id} theme={activeTheme} onClick={clickable ? (e) => onClick(e, singleData) : null} clickable={clickable} scroll={scroll} ref={scroll ? null : singleData.label === longest.label ? arrowRef : null} key={'fa' + index + '-' + singleData.label} index={index} dataLength={data.length} color={singleData.color}>
236
- {ArrowContent(singleData.value, singleData.label)}
237
- </StyledArrow>
238
- )
239
- })}
240
- </StyledArrowBar>
241
- )
242
- }
243
-
244
- ArrowBar.propTypes = {
245
- /**
246
- * Color of the arrows text. primary-1, 2, error, etc.
247
- */
248
- variant: PropTypes.string,
249
-
250
- /**
251
- * Array of data. Each element of the array is an object in this format:
252
- * { value: 16, label: "Complete", color: '#34cc73' },
253
- */
254
- data: PropTypes.array,
255
- /**
256
- * True the bar will not shrink but will be scrollable
257
- * False the bar will shrink and hide its content base on the width
258
- */
259
- scroll: PropTypes.bool,
260
- /**
261
- * Click handler
262
- */
263
- onClick: PropTypes.func,
264
- /**
265
- * If true the cursor is a pointer and click handler active
266
- */
267
- clickable: PropTypes.bool,
268
- }
269
-
270
- ArrowBar.defaultProps = {
271
- variant: null,
272
- data: [],
273
- scroll: true,
274
- onClick: undefined,
275
- clickable: false
276
- }
@@ -1,2 +0,0 @@
1
- export * from './ArrowBar';
2
-
@@ -1,171 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React, { useState } from "react";
3
- import styled, { useTheme } from 'styled-components';
4
- import defaultStyles from '../constants/defaultStyle';
5
- import defaultThemeColor from "../constants/defaultThemeColor";
6
- import { Image } from '../Images';
7
-
8
- /**
9
- * Primary UI component for user interaction
10
- */
11
- const StyledContainer = styled.span`
12
- ${({ inBuiltCss, type, customStyles }) => {
13
- if (inBuiltCss) {
14
- let tempObj = {};
15
- if (inBuiltCss[type]) {
16
- for (const property in inBuiltCss['common']) {
17
- tempObj[property] = inBuiltCss['common'][property]
18
- }
19
- for (const property in inBuiltCss[type]) {
20
- tempObj[property] = inBuiltCss[type][property]
21
- delete inBuiltCss.common[property]
22
- }
23
- }
24
- return { ...tempObj, ...customStyles };
25
- }
26
- }}
27
- `;
28
-
29
- const StyledCircle = styled.div`
30
-
31
- background-color:${({ theme }) => theme.primary['primary-1']};
32
- color: ${({ theme }) => theme.bgColor};
33
- ${({ inBuiltCss, type, size, customStyles }) => {
34
- if (inBuiltCss) {
35
- let tempObj = {};
36
- if (inBuiltCss[type]) {
37
- for (const property in inBuiltCss['common']) {
38
- tempObj[property] = inBuiltCss['common'][property]
39
- }
40
- for (const property in inBuiltCss[type]) {
41
- tempObj[property] = inBuiltCss[type][property]
42
- delete inBuiltCss.common[property]
43
- }
44
- for (const property in inBuiltCss[`${type}${size}`]) {
45
- tempObj[property] = inBuiltCss[`${type}${size}`][property]
46
- delete inBuiltCss.common[property]
47
- }
48
- }
49
- return { ...tempObj, ...customStyles };
50
- }
51
- }}
52
- `;
53
-
54
- const StyledName = styled.span`
55
-
56
- color:${({ theme }) => theme.textColor};
57
-
58
- ${({ inBuiltCss, type, size, customStyles }) => {
59
- if (inBuiltCss) {
60
- let tempObj = {};
61
- if (inBuiltCss[type]) {
62
- for (const property in inBuiltCss['common']) {
63
- tempObj[property] = inBuiltCss['common'][property]
64
- }
65
- for (const property in inBuiltCss[type]) {
66
- delete inBuiltCss.common[property]
67
- tempObj[property] = inBuiltCss[type][property]
68
- }
69
- for (const property in inBuiltCss[`${type}${size}`]) {
70
- tempObj[property] = inBuiltCss[`${type}${size}`][property]
71
- delete inBuiltCss.common[property]
72
- }
73
- }
74
- return { ...tempObj, ...customStyles };
75
- }
76
- }}
77
- `;
78
-
79
- export const Avatar = ({
80
- customStylesContainer,
81
- customStylesImage,
82
- customStylesCircle,
83
- customStylesName,
84
- size,
85
- toggleName,
86
- user,
87
- border,
88
- ...props
89
- }) => {
90
-
91
- const [avatarStatus, setAvatarStatus] = useState("loading");
92
-
93
- const handleImageStatus = (imageStatus) => {
94
- setAvatarStatus(imageStatus);
95
- }
96
- const activeTheme = useTheme() || defaultThemeColor
97
-
98
-
99
-
100
- return (
101
- <StyledContainer inBuiltCss={defaultStyles} border={border} theme={activeTheme} customStyles={customStylesContainer} type={'avatarContainer'} {...props}>
102
- {user?.url && <Image
103
- {...props}
104
- customStyles={customStylesImage}
105
- type={'imageAvatar'}
106
- size={size}
107
- alt="user-picture"
108
- src={user.url}
109
- handleImageStatus={handleImageStatus}
110
- style={{ visibility: avatarStatus !== "loaded" ? 'hidden' : 'visible' }}
111
- />}
112
-
113
- <StyledCircle {...props}
114
- theme={activeTheme}
115
- inBuiltCss={defaultStyles}
116
- type={'avatarCircle'}
117
- customStyles={customStylesCircle} size={size}
118
- style={{ visibility: avatarStatus !== "loaded" ? 'visible' : 'hidden' }}
119
- >
120
- {
121
- user?.userName && user?.userName.split(" ").length >= 2 ? user?.userName.split(" ")[0].charAt(0).toUpperCase() + user?.userName.split(" ")[1].charAt(0).toUpperCase()
122
- : user?.userName && user?.userName.split(" ").length === 1 && user?.userName.split(" ")[0].charAt(0).toUpperCase()
123
- }
124
- </StyledCircle>
125
- {toggleName && <StyledName inBuiltCss={defaultStyles} {...props} theme={activeTheme} type={'avatarName'} customStyles={customStylesName} size={size}>{user.userName} </StyledName>}
126
- </StyledContainer>
127
- );
128
- };
129
-
130
- Avatar.propTypes = {
131
- /**
132
- * Custom style for circle
133
- */
134
- customStylesCircle: PropTypes.object,
135
- /**
136
- * Custom style for name
137
- */
138
- customStylesName: PropTypes.object,
139
- /**
140
- * Optional Custom color of the circle
141
- */
142
- customStylesContainer: PropTypes.object,
143
- /**
144
- * Optional Custom color of the border circle (if missing no border displayed)
145
- */
146
- customStylesImage: PropTypes.object,
147
- /**
148
- * Toggle name visibility
149
- */
150
- toggleName: PropTypes.bool,
151
- /**
152
- * How large should the Avatar be?
153
- */
154
- size: PropTypes.oneOf(['SM', 'MD', 'LG']),
155
- /**
156
- * Object with user information. To display the user's picture need a key "url". To display the name need a key "userName"
157
- */
158
- user: PropTypes.object,
159
-
160
- };
161
-
162
- Avatar.defaultProps = {
163
- block: false,
164
- size: 'MD',
165
- toggleName: false,
166
- user: null,
167
- customStylesContainer: null,
168
- customStylesImage: null,
169
- customStylesCircle: null,
170
- customStylesName: null,
171
- };
@@ -1,255 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React, { useState } from 'react';
3
- import styled, { css, useTheme } from 'styled-components';
4
- import defaultStyles from '../constants/defaultStyle';
5
- import defaultThemeColor from '../constants/defaultThemeColor';
6
- import { Image } from '../Images';
7
-
8
- /**
9
- * Primary UI component for user interaction
10
- */
11
- const StyledContainer = styled.span`
12
- ${({ inBuiltCss, type, customStyles }) => {
13
- if (inBuiltCss) {
14
- let tempObj = {};
15
- if (inBuiltCss[type]) {
16
- for (const property in inBuiltCss['common']) {
17
- tempObj[property] = inBuiltCss['common'][property];
18
- }
19
- for (const property in inBuiltCss[type]) {
20
- tempObj[property] = inBuiltCss[type][property];
21
- delete inBuiltCss.common[property];
22
- }
23
- }
24
- return { ...tempObj, ...customStyles };
25
- }
26
- }}
27
- width: auto;
28
- `;
29
-
30
- const StyledCircle = styled.div`
31
- background-color: ${({ theme }) => theme.primary['primary-1']};
32
- color: ${({ theme }) => theme.bgColor} !important;
33
- ${({ inBuiltCss, type, size, customStyles }) => {
34
- if (inBuiltCss) {
35
- let tempObj = {};
36
- if (inBuiltCss[type]) {
37
- for (const property in inBuiltCss['common']) {
38
- tempObj[property] = inBuiltCss['common'][property];
39
- }
40
- for (const property in inBuiltCss[type]) {
41
- tempObj[property] = inBuiltCss[type][property];
42
- delete inBuiltCss.common[property];
43
- }
44
- for (const property in inBuiltCss[`${type}${size}`]) {
45
- tempObj[property] = inBuiltCss[`${type}${size}`][property];
46
- delete inBuiltCss.common[property];
47
- }
48
- }
49
- return { ...tempObj, ...customStyles };
50
- }
51
- }}
52
- ${({ isSelected, selectedStyle, notSelectedStyle }) => {
53
- if (isSelected) {
54
- return css`
55
- min-width: 42px;
56
- min-height: 42px;
57
- ${selectedStyle}
58
- `;
59
- } else {
60
- return css`
61
- ${notSelectedStyle}
62
- `;
63
- }
64
- }}
65
- font-weight: 600;
66
- `;
67
-
68
- //Create the style for the Avatar
69
-
70
- // let customStylesCircle = {}
71
- // let customStylesContainer = {}
72
- // customStylesCircle.border = app.userName === selectedApp.lev1 ? `2px solid rgba(255, 255, 255, 0.3)` : `2px solid #2240CB`
73
- // customStylesCircle.backgroundColor = app.userName === selectedApp.lev1 ? '#1D36AD' : '#2240CB'
74
- // customStylesCircle.width = app.userName === selectedApp.lev1 ? '42px' : '38px'
75
- // customStylesCircle.height = app.userName === selectedApp.lev1 ? '42px' : '38px'
76
- // customStylesCircle.fontWeight = '600'
77
- // customStylesContainer.width = 'auto'
78
- // console.log("customStylesCircle" + i + ": ", customStylesCircle)
79
-
80
- const StyledName = styled.span`
81
- color: ${({ theme }) => theme.textColor};
82
- background-color: transparent !important;
83
-
84
- ${({ inBuiltCss, type, size, customStyles }) => {
85
- if (inBuiltCss) {
86
- let tempObj = {};
87
- if (inBuiltCss[type]) {
88
- for (const property in inBuiltCss['common']) {
89
- tempObj[property] = inBuiltCss['common'][property];
90
- }
91
- for (const property in inBuiltCss[type]) {
92
- delete inBuiltCss.common[property];
93
- tempObj[property] = inBuiltCss[type][property];
94
- }
95
- for (const property in inBuiltCss[`${type}${size}`]) {
96
- tempObj[property] = inBuiltCss[`${type}${size}`][property];
97
- delete inBuiltCss.common[property];
98
- }
99
- }
100
- return { ...tempObj, ...customStyles };
101
- }
102
- }}
103
-
104
- &:hover {
105
- ${({ inBuiltCss, type, size, customStylesHover }) => {
106
- if (inBuiltCss) {
107
- let tempObj = {};
108
- // if (inBuiltCss[type]) {
109
- // for (const property in inBuiltCss['common']) {
110
- // tempObj[property] = inBuiltCss['common'][property]
111
- // }
112
- // for (const property in inBuiltCss[type]) {
113
- // delete inBuiltCss.common[property]
114
- // tempObj[property] = inBuiltCss[type][property]
115
- // }
116
- // for (const property in inBuiltCss[`${type}${size}`]) {
117
- // tempObj[property] = inBuiltCss[`${type}${size}`][property]
118
- // delete inBuiltCss.common[property]
119
- // }
120
- // }
121
- return { ...tempObj, ...customStylesHover };
122
- }
123
- }}
124
- }
125
- `;
126
-
127
- export const AvatarSB = ({
128
- customStylesContainer,
129
- customStylesImage,
130
- customStylesCircle,
131
- customStylesName,
132
- customStylesNameHover,
133
- size,
134
- toggleName,
135
- user,
136
- border,
137
- isSelected,
138
- selectedStyle,
139
- notSelectedStyle,
140
- ...props
141
- }) => {
142
- const activeTheme = useTheme() || defaultThemeColor;
143
-
144
- const [avatarStatus, setAvatarStatus] = useState('loading');
145
-
146
- const handleImageStatus = (imageStatus) => {
147
- setAvatarStatus(imageStatus);
148
- };
149
- return (
150
- <StyledContainer
151
- border={border}
152
- inBuiltCss={defaultStyles}
153
- customStyles={customStylesContainer}
154
- type={'avatarContainer'}
155
- {...props}
156
- >
157
- {user?.url && (
158
- <Image
159
- {...props}
160
- inBuiltCss={defaultStyles}
161
- customStyles={customStylesImage}
162
- type={'imageAvatar'}
163
- size={size}
164
- alt='user-picture'
165
- src={user.url}
166
- handleImageStatus={handleImageStatus}
167
- style={{
168
- visibility: avatarStatus !== 'loaded' ? 'hidden' : 'visible',
169
- }}
170
- />
171
- )}
172
-
173
- <StyledCircle
174
- {...props}
175
- theme={activeTheme}
176
- selectedStyle={selectedStyle}
177
- notSelectedStyle={notSelectedStyle}
178
- inBuiltCss={defaultStyles}
179
- type={'avatarCircle'}
180
- customStyles={customStylesCircle}
181
- size={size}
182
- style={{ visibility: avatarStatus !== 'loaded' ? 'visible' : 'hidden' }}
183
- isSelected={isSelected}
184
- >
185
- {user?.userName && user?.userName.split(' ').length >= 2
186
- ? user?.userName.split(' ')[0].charAt(0).toUpperCase() +
187
- user?.userName.split(' ')[1].charAt(0).toUpperCase()
188
- : user?.userName &&
189
- user?.userName.split(' ').length === 1 &&
190
- user?.userName.split(' ')[0].charAt(0).toUpperCase()}
191
- </StyledCircle>
192
- {toggleName && (
193
- <StyledName
194
- theme={activeTheme}
195
- {...props}
196
- inBuiltCss={defaultStyles}
197
- type={'avatarName'}
198
- customStyles={customStylesName}
199
- customStylesHover={customStylesNameHover}
200
- size={size}
201
- >
202
- {user.userName}{' '}
203
- </StyledName>
204
- )}
205
- </StyledContainer>
206
- );
207
- };
208
-
209
- AvatarSB.propTypes = {
210
- /**
211
- * Custom style for circle
212
- */
213
- customStylesCircle: PropTypes.object,
214
- /**
215
- * Custom style for name
216
- */
217
- customStylesName: PropTypes.object,
218
- /**
219
- * Optional Custom color of the circle
220
- */
221
- customStylesContainer: PropTypes.object,
222
- /**
223
- * Optional Custom color of the border circle (if missing no border displayed)
224
- */
225
- customStylesImage: PropTypes.object,
226
- /**
227
- * Toggle name visibility
228
- */
229
- toggleName: PropTypes.bool,
230
- /**
231
- * How large should the Avatar be?
232
- */
233
- size: PropTypes.oneOf(['SM', 'MD', 'LG']),
234
- /**
235
- * Object with user information. To display the user's picture need a key "url". To display the name need a key "userName"
236
- */
237
- user: PropTypes.object,
238
- customStylesNameHover: PropTypes.object,
239
-
240
- // border,
241
- // isSelected,
242
- // selectedStyle,
243
- // notSelectedStyle,
244
- };
245
-
246
- AvatarSB.defaultProps = {
247
- block: false,
248
- size: 'MD',
249
- toggleName: false,
250
- user: null,
251
- customStylesContainer: null,
252
- customStylesImage: null,
253
- customStylesCircle: null,
254
- customStylesName: null,
255
- };