groundfloor-react-ui 1.0.0
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.
- package/README.md +20 -0
- package/assets/fonts/Averta/Averta-Black.woff2 +0 -0
- package/assets/fonts/Averta/Averta-BlackItalic.woff2 +0 -0
- package/assets/fonts/Averta/Averta-Bold.woff2 +0 -0
- package/assets/fonts/Averta/Averta-BoldItalic.woff2 +0 -0
- package/assets/fonts/Averta/Averta-ExtraBold.woff2 +0 -0
- package/assets/fonts/Averta/Averta-ExtraBoldItalic.woff2 +0 -0
- package/assets/fonts/Averta/Averta-ExtraThin.woff2 +0 -0
- package/assets/fonts/Averta/Averta-ExtraThinItalic.woff2 +0 -0
- package/assets/fonts/Averta/Averta-Light.woff2 +0 -0
- package/assets/fonts/Averta/Averta-LightItalic.woff2 +0 -0
- package/assets/fonts/Averta/Averta-Regular.woff2 +0 -0
- package/assets/fonts/Averta/Averta-RegularItalic.woff2 +0 -0
- package/assets/fonts/Averta/Averta-SemiBold.woff2 +0 -0
- package/assets/fonts/Averta/Averta-SemiBoldItalic.woff2 +0 -0
- package/assets/fonts/Averta/Averta-Thin.woff2 +0 -0
- package/assets/fonts/Averta/Averta-ThinItalic.woff2 +0 -0
- package/assets/fonts/Beauty/BeautyDemo.woff +0 -0
- package/assets/icons/app-logo.svg +3 -0
- package/assets/icons/arrow-down.svg +3 -0
- package/assets/icons/arrow-rotate.svg +1 -0
- package/assets/icons/arrow-up.svg +3 -0
- package/assets/icons/bell.svg +3 -0
- package/assets/icons/check.svg +3 -0
- package/assets/icons/checkmark.svg +3 -0
- package/assets/icons/chevron-down.svg +3 -0
- package/assets/icons/chevron-left.svg +3 -0
- package/assets/icons/chevron-right.svg +3 -0
- package/assets/icons/cloud-icon.svg +3 -0
- package/assets/icons/connection.svg +3 -0
- package/assets/icons/cross-icon.svg +3 -0
- package/assets/icons/door-internal-active.svg +1 -0
- package/assets/icons/edit-icon.svg +3 -0
- package/assets/icons/ellipses-horizontal.svg +3 -0
- package/assets/icons/ellipses.svg +3 -0
- package/assets/icons/email.svg +3 -0
- package/assets/icons/eye-hide-view.svg +1 -0
- package/assets/icons/eye-hide.svg +1 -0
- package/assets/icons/file-attach-white.svg +3 -0
- package/assets/icons/file-attach.svg +3 -0
- package/assets/icons/functional-equation-regular.svg +147 -0
- package/assets/icons/hamburger-menu.svg +3 -0
- package/assets/icons/heart.svg +18 -0
- package/assets/icons/image.svg +3 -0
- package/assets/icons/info.svg +3 -0
- package/assets/icons/jpg-icon.svg +3 -0
- package/assets/icons/magnifier.svg +3 -0
- package/assets/icons/menu-ellipse-two.svg +1 -0
- package/assets/icons/menu-ellipse.svg +53 -0
- package/assets/icons/pause-all.svg +1 -0
- package/assets/icons/pdf-icon.svg +3 -0
- package/assets/icons/pen-icon.svg +3 -0
- package/assets/icons/plus-outlined.svg +3 -0
- package/assets/icons/resume.svg +1 -0
- package/assets/icons/sign-icon.svg +3 -0
- package/assets/icons/star.svg +3 -0
- package/assets/icons/trash-icon.svg +59 -0
- package/assets/icons/triangle-down.svg +3 -0
- package/assets/icons/users.svg +11 -0
- package/assets/icons/view.svg +3 -0
- package/assets/icons/watcher.svg +3 -0
- package/assets/icons/zoom-in-white.svg +1 -0
- package/assets/styles/global.css +0 -0
- package/assets/styles/global.scss +0 -0
- package/components/Accordion/Accordion.js +114 -0
- package/components/Accordion/AccordionSB.js +168 -0
- package/components/Accordion/AccordionSBfooter.js +171 -0
- package/components/Accordion/index.js +4 -0
- package/components/ArrowBar/ArrowBar.js +293 -0
- package/components/ArrowBar/index.js +2 -0
- package/components/Avatar/Avatar.js +167 -0
- package/components/Avatar/AvatarSB.js +226 -0
- package/components/Avatar/AvatarSBfooter.js +226 -0
- package/components/Avatar/index.js +4 -0
- package/components/Banner/Banner.js +65 -0
- package/components/Banner/index.js +2 -0
- package/components/Breadcrumb/Breadcrumb.js +192 -0
- package/components/Breadcrumb/index.js +2 -0
- package/components/Button/PrimaryButton.js +125 -0
- package/components/Button/SecondaryButton.js +114 -0
- package/components/Button/TinyButton.js +94 -0
- package/components/Button/index.js +6 -0
- package/components/Cards/Card.js +48 -0
- package/components/Cards/CardRef.js +64 -0
- package/components/Cards/DocumentCard.js +221 -0
- package/components/Cards/index.js +5 -0
- package/components/Content/Content.js +51 -0
- package/components/Content/index.js +1 -0
- package/components/Divider/Divider.js +63 -0
- package/components/Divider/index.js +2 -0
- package/components/Drawer/Drawer.js +93 -0
- package/components/Drawer/index.js +2 -0
- package/components/ErrorBoundary/ErrorBoundary.js +44 -0
- package/components/ErrorBoundary/index.js +1 -0
- package/components/FilterChip/FilterChip.js +68 -0
- package/components/FilterChip/index.js +1 -0
- package/components/Footer/Footer.js +58 -0
- package/components/Footer/FooterContentLev3.js +96 -0
- package/components/Footer/index.js +2 -0
- package/components/Form/FormComponent.js +273 -0
- package/components/Form/HeaderComponent.js +39 -0
- package/components/Form/StyledComponent.js +323 -0
- package/components/Form/SubmitComponent.js +63 -0
- package/components/Form/index.js +4 -0
- package/components/GroupAvatars/GroupAvatars.js +143 -0
- package/components/GroupAvatars/index.js +1 -0
- package/components/GroupButtons/ButtonPopup.js +192 -0
- package/components/GroupButtons/GroupButtons.js +150 -0
- package/components/GroupButtons/GroupButtonsPopup.js +169 -0
- package/components/GroupButtons/index.js +3 -0
- package/components/GroupStatusCircle/GroupStatusCircle.js +135 -0
- package/components/GroupStatusCircle/index.js +1 -0
- package/components/Header/Header.js +58 -0
- package/components/Header/index.js +1 -0
- package/components/HyperLink/HyperLink.js +114 -0
- package/components/HyperLink/index.js +1 -0
- package/components/Icon/Icon.js +161 -0
- package/components/Icon/index.js +1 -0
- package/components/Images/Image.js +112 -0
- package/components/Images/index.js +2 -0
- package/components/Inputs/CheckBoxEditableInput.js +352 -0
- package/components/Inputs/CheckBoxInput.js +195 -0
- package/components/Inputs/CheckBoxInputMS.js +160 -0
- package/components/Inputs/DateSelect.js +411 -0
- package/components/Inputs/DropdownSelect.js +466 -0
- package/components/Inputs/DropzoneInput.js +335 -0
- package/components/Inputs/NumericInput.js +155 -0
- package/components/Inputs/RadioInput.js +205 -0
- package/components/Inputs/SearchInput.js +18 -0
- package/components/Inputs/Signature.js +278 -0
- package/components/Inputs/TextArea.js +196 -0
- package/components/Inputs/TextInput.js +182 -0
- package/components/Inputs/TextInputClicable.js +198 -0
- package/components/Inputs/TextInputClicableMS.js +255 -0
- package/components/Inputs/TimeInput.js +181 -0
- package/components/Inputs/ToggleSwitch.js +123 -0
- package/components/Inputs/index.js +13 -0
- package/components/Label/Label.js +48 -0
- package/components/Label/index.js +1 -0
- package/components/Loaders/Loader.js +179 -0
- package/components/Loaders/index.js +2 -0
- package/components/Modal/Modal.js +116 -0
- package/components/Modal/ModalComp.js +158 -0
- package/components/Modal/index.js +2 -0
- package/components/Overlay/Overlay.js +159 -0
- package/components/Overlay/index.js +1 -0
- package/components/Pagination/Pagination.js +83 -0
- package/components/Pagination/index.js +1 -0
- package/components/ProgressBar/ProgressBar.js +84 -0
- package/components/ProgressBar/index.js +1 -0
- package/components/ProgressSteps/ProgressSteps.js +121 -0
- package/components/ProgressSteps/index.js +1 -0
- package/components/Rating/Rating.js +264 -0
- package/components/Rating/index.js +1 -0
- package/components/SecondaryLink/DarkSecondaryLink.js +97 -0
- package/components/SecondaryLink/LightSecondaryLink.js +93 -0
- package/components/SecondaryLink/index.js +3 -0
- package/components/Sidebar/Navbar.js +328 -0
- package/components/Sidebar/Sidebar.js +180 -0
- package/components/Sidebar/index.js +3 -0
- package/components/StatusChip/PrimaryStatusChip.js +78 -0
- package/components/StatusChip/SecondaryStatusChip.js +78 -0
- package/components/StatusChip/SlimPrimaryStatusChip.js +92 -0
- package/components/StatusChip/SlimSecondaryStatusChip.js +93 -0
- package/components/StatusChip/index.js +6 -0
- package/components/StatusCircle/StatusCircle.js +64 -0
- package/components/StatusCircle/index.js +1 -0
- package/components/Tables/Table.js +156 -0
- package/components/Tables/index.js +1 -0
- package/components/Tooltip/Tooltip.js +479 -0
- package/components/Tooltip/index.js +1 -0
- package/components/Typography/Typography.js +78 -0
- package/components/Typography/index.js +2 -0
- package/components/constants/colors.js +33 -0
- package/components/constants/defaultStyle.js +781 -0
- package/components/constants/defaultThemeColor.js +15 -0
- package/components/constants/index.js +7 -0
- package/components/constants/utils.js +31 -0
- package/components/global/FontStyle.js +131 -0
- package/components/global/index.js +1 -0
- package/dist/index.es.js +2302 -0
- package/dist/index.js +2302 -0
- package/index.js +40 -0
- package/package.json +67 -0
- package/rollup.config.js +53 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
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 theme = 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 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 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
|
+
* Theme object
|
|
251
|
+
*/
|
|
252
|
+
theme: PropTypes.object,
|
|
253
|
+
/**
|
|
254
|
+
* Array of data. Each element of the array is an object in this format:
|
|
255
|
+
* { value: 16, label: "Complete", color: '#34cc73' },
|
|
256
|
+
*/
|
|
257
|
+
data: PropTypes.array,
|
|
258
|
+
/**
|
|
259
|
+
* True the bar will not shrink but will be scrollable
|
|
260
|
+
* False the bar will shrink and hide its content base on the width
|
|
261
|
+
*/
|
|
262
|
+
scroll: PropTypes.bool,
|
|
263
|
+
/**
|
|
264
|
+
* Click handler
|
|
265
|
+
*/
|
|
266
|
+
onClick: PropTypes.func,
|
|
267
|
+
/**
|
|
268
|
+
* If true the cursor is a pointer and click handler active
|
|
269
|
+
*/
|
|
270
|
+
clickable: PropTypes.bool,
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
StyledArrowBar.defaultProps = {
|
|
274
|
+
theme: defaultThemeColor,
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
StyledArrow.defaultProps = {
|
|
278
|
+
theme: defaultThemeColor,
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
StyledArrowContent.defaultProps = {
|
|
282
|
+
theme: defaultThemeColor,
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
ArrowBar.defaultProps = {
|
|
286
|
+
theme: defaultThemeColor,
|
|
287
|
+
variant: null,
|
|
288
|
+
data: [],
|
|
289
|
+
scroll: true,
|
|
290
|
+
onClick: undefined,
|
|
291
|
+
clickable: false
|
|
292
|
+
}
|
|
293
|
+
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import defaultStyles from '../constants/defaultStyle';
|
|
5
|
+
import { Image } from '../Images'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Primary UI component for user interaction
|
|
9
|
+
*/
|
|
10
|
+
const StyledContainer = styled.span`
|
|
11
|
+
${({ theme, type, customStyles }) => {
|
|
12
|
+
if (theme) {
|
|
13
|
+
let tempObj = {};
|
|
14
|
+
if (theme[type]) {
|
|
15
|
+
for (const property in theme['common']) {
|
|
16
|
+
tempObj[property] = theme['common'][property]
|
|
17
|
+
}
|
|
18
|
+
for (const property in theme[type]) {
|
|
19
|
+
tempObj[property] = theme[type][property]
|
|
20
|
+
delete theme.common[property]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return { ...tempObj, ...customStyles };
|
|
24
|
+
}
|
|
25
|
+
}}
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
const StyledCircle = styled.div`
|
|
29
|
+
${({ theme, type, size, customStyles }) => {
|
|
30
|
+
if (theme) {
|
|
31
|
+
let tempObj = {};
|
|
32
|
+
if (theme[type]) {
|
|
33
|
+
for (const property in theme['common']) {
|
|
34
|
+
tempObj[property] = theme['common'][property]
|
|
35
|
+
}
|
|
36
|
+
for (const property in theme[type]) {
|
|
37
|
+
tempObj[property] = theme[type][property]
|
|
38
|
+
delete theme.common[property]
|
|
39
|
+
}
|
|
40
|
+
for (const property in theme[`${type}${size}`]) {
|
|
41
|
+
tempObj[property] = theme[`${type}${size}`][property]
|
|
42
|
+
delete theme.common[property]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { ...tempObj, ...customStyles };
|
|
46
|
+
}
|
|
47
|
+
}}
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
const StyledName = styled.span`
|
|
51
|
+
${({ theme, type, size, customStyles }) => {
|
|
52
|
+
if (theme) {
|
|
53
|
+
let tempObj = {};
|
|
54
|
+
if (theme[type]) {
|
|
55
|
+
for (const property in theme['common']) {
|
|
56
|
+
tempObj[property] = theme['common'][property]
|
|
57
|
+
}
|
|
58
|
+
for (const property in theme[type]) {
|
|
59
|
+
delete theme.common[property]
|
|
60
|
+
tempObj[property] = theme[type][property]
|
|
61
|
+
}
|
|
62
|
+
for (const property in theme[`${type}${size}`]) {
|
|
63
|
+
tempObj[property] = theme[`${type}${size}`][property]
|
|
64
|
+
delete theme.common[property]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return { ...tempObj, ...customStyles };
|
|
68
|
+
}
|
|
69
|
+
}}
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
export const Avatar = ({
|
|
73
|
+
theme,
|
|
74
|
+
customStylesContainer,
|
|
75
|
+
customStylesImage,
|
|
76
|
+
customStylesCircle,
|
|
77
|
+
customStylesName,
|
|
78
|
+
size,
|
|
79
|
+
toggleName,
|
|
80
|
+
user,
|
|
81
|
+
border,
|
|
82
|
+
...props
|
|
83
|
+
}) => {
|
|
84
|
+
|
|
85
|
+
const [avatarStatus, setAvatarStatus] = useState("loading");
|
|
86
|
+
|
|
87
|
+
const handleImageStatus = (imageStatus) => {
|
|
88
|
+
setAvatarStatus(imageStatus);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<StyledContainer border={border} theme={theme} customStyles={customStylesContainer} type={'avatarContainer'} {...props}>
|
|
93
|
+
{user?.url && <Image
|
|
94
|
+
{...props}
|
|
95
|
+
theme={theme}
|
|
96
|
+
customStyles={customStylesImage}
|
|
97
|
+
type={'imageAvatar'}
|
|
98
|
+
size={size}
|
|
99
|
+
alt="user-picture"
|
|
100
|
+
src={user.url}
|
|
101
|
+
handleImageStatus={handleImageStatus}
|
|
102
|
+
style={{ visibility: avatarStatus !== "loaded" ? 'hidden' : 'visible' }}
|
|
103
|
+
/>}
|
|
104
|
+
|
|
105
|
+
<StyledCircle {...props}
|
|
106
|
+
theme={theme}
|
|
107
|
+
type={'avatarCircle'}
|
|
108
|
+
customStyles={customStylesCircle} size={size}
|
|
109
|
+
style={{ visibility: avatarStatus !== "loaded" ? 'visible' : 'hidden' }}
|
|
110
|
+
>
|
|
111
|
+
{
|
|
112
|
+
user?.userName && user?.userName.split(" ").length >= 2 ? user?.userName.split(" ")[0].charAt(0).toUpperCase() + user?.userName.split(" ")[1].charAt(0).toUpperCase()
|
|
113
|
+
: user?.userName && user?.userName.split(" ").length === 1 && user?.userName.split(" ")[0].charAt(0).toUpperCase()
|
|
114
|
+
}
|
|
115
|
+
</StyledCircle>
|
|
116
|
+
{toggleName && <StyledName {...props} theme={theme} type={'avatarName'} customStyles={customStylesName} size={size}>{user.userName} </StyledName>}
|
|
117
|
+
</StyledContainer>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
Avatar.propTypes = {
|
|
122
|
+
/**
|
|
123
|
+
* Custom style for circle
|
|
124
|
+
*/
|
|
125
|
+
customStylesCircle: PropTypes.object,
|
|
126
|
+
/**
|
|
127
|
+
* Custom style for name
|
|
128
|
+
*/
|
|
129
|
+
customStylesName: PropTypes.object,
|
|
130
|
+
/**
|
|
131
|
+
* Optional Custom color of the circle
|
|
132
|
+
*/
|
|
133
|
+
customStylesContainer: PropTypes.object,
|
|
134
|
+
/**
|
|
135
|
+
* Optional Custom color of the border circle (if missing no border displayed)
|
|
136
|
+
*/
|
|
137
|
+
customStylesImage: PropTypes.object,
|
|
138
|
+
/**
|
|
139
|
+
* Toggle name visibility
|
|
140
|
+
*/
|
|
141
|
+
toggleName: PropTypes.bool,
|
|
142
|
+
/**
|
|
143
|
+
* How large should the Avatar be?
|
|
144
|
+
*/
|
|
145
|
+
size: PropTypes.oneOf(['SM', 'MD', 'LG']),
|
|
146
|
+
/**
|
|
147
|
+
* Object with user information. To display the user's picture need a key "url". To display the name need a key "userName"
|
|
148
|
+
*/
|
|
149
|
+
user: PropTypes.object,
|
|
150
|
+
/**
|
|
151
|
+
* Theme object
|
|
152
|
+
*/
|
|
153
|
+
theme: PropTypes.object,
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
Avatar.defaultProps = {
|
|
157
|
+
theme: defaultStyles,
|
|
158
|
+
block: false,
|
|
159
|
+
size: 'MD',
|
|
160
|
+
toggleName: false,
|
|
161
|
+
user: null,
|
|
162
|
+
customStylesContainer: null,
|
|
163
|
+
customStylesImage: null,
|
|
164
|
+
customStylesCircle: null,
|
|
165
|
+
customStylesName: null,
|
|
166
|
+
};
|
|
167
|
+
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import defaultStyles from '../constants/defaultStyle';
|
|
5
|
+
import { Image } from '../Images'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Primary UI component for user interaction
|
|
9
|
+
*/
|
|
10
|
+
const StyledContainer = styled.span`
|
|
11
|
+
${({ theme, type, customStyles }) => {
|
|
12
|
+
if (theme) {
|
|
13
|
+
let tempObj = {};
|
|
14
|
+
if (theme[type]) {
|
|
15
|
+
for (const property in theme['common']) {
|
|
16
|
+
tempObj[property] = theme['common'][property]
|
|
17
|
+
}
|
|
18
|
+
for (const property in theme[type]) {
|
|
19
|
+
tempObj[property] = theme[type][property]
|
|
20
|
+
delete theme.common[property]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return { ...tempObj, ...customStyles };
|
|
24
|
+
}
|
|
25
|
+
}}
|
|
26
|
+
width: auto;
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
const StyledCircle = styled.div`
|
|
30
|
+
${({ theme, type, size, customStyles }) => {
|
|
31
|
+
if (theme) {
|
|
32
|
+
let tempObj = {};
|
|
33
|
+
if (theme[type]) {
|
|
34
|
+
for (const property in theme['common']) {
|
|
35
|
+
tempObj[property] = theme['common'][property]
|
|
36
|
+
}
|
|
37
|
+
for (const property in theme[type]) {
|
|
38
|
+
tempObj[property] = theme[type][property]
|
|
39
|
+
delete theme.common[property]
|
|
40
|
+
}
|
|
41
|
+
for (const property in theme[`${type}${size}`]) {
|
|
42
|
+
tempObj[property] = theme[`${type}${size}`][property]
|
|
43
|
+
delete theme.common[property]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return { ...tempObj, ...customStyles };
|
|
47
|
+
}
|
|
48
|
+
}}
|
|
49
|
+
${({ isSelected }) => {
|
|
50
|
+
|
|
51
|
+
if (isSelected) {
|
|
52
|
+
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
|
+
`
|
|
58
|
+
} else {
|
|
59
|
+
return css`
|
|
60
|
+
border: 2px solid #2240CB;
|
|
61
|
+
background-color: #2240CB;
|
|
62
|
+
// width: 38px;
|
|
63
|
+
// height: 38px;
|
|
64
|
+
`
|
|
65
|
+
}
|
|
66
|
+
}}
|
|
67
|
+
font-weight: 600;
|
|
68
|
+
`;
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
//Create the style for the Avatar
|
|
72
|
+
|
|
73
|
+
// let customStylesCircle = {}
|
|
74
|
+
// let customStylesContainer = {}
|
|
75
|
+
// customStylesCircle.border = app.userName === selectedApp.lev1 ? `2px solid rgba(255, 255, 255, 0.3)` : `2px solid #2240CB`
|
|
76
|
+
// customStylesCircle.backgroundColor = app.userName === selectedApp.lev1 ? '#1D36AD' : '#2240CB'
|
|
77
|
+
// customStylesCircle.width = app.userName === selectedApp.lev1 ? '42px' : '38px'
|
|
78
|
+
// customStylesCircle.height = app.userName === selectedApp.lev1 ? '42px' : '38px'
|
|
79
|
+
// customStylesCircle.fontWeight = '600'
|
|
80
|
+
// customStylesContainer.width = 'auto'
|
|
81
|
+
// console.log("customStylesCircle" + i + ": ", customStylesCircle)
|
|
82
|
+
|
|
83
|
+
const StyledName = styled.span`
|
|
84
|
+
${({ theme, type, size, customStyles }) => {
|
|
85
|
+
if (theme) {
|
|
86
|
+
let tempObj = {};
|
|
87
|
+
if (theme[type]) {
|
|
88
|
+
for (const property in theme['common']) {
|
|
89
|
+
tempObj[property] = theme['common'][property]
|
|
90
|
+
}
|
|
91
|
+
for (const property in theme[type]) {
|
|
92
|
+
delete theme.common[property]
|
|
93
|
+
tempObj[property] = theme[type][property]
|
|
94
|
+
}
|
|
95
|
+
for (const property in theme[`${type}${size}`]) {
|
|
96
|
+
tempObj[property] = theme[`${type}${size}`][property]
|
|
97
|
+
delete theme.common[property]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return { ...tempObj, ...customStyles };
|
|
101
|
+
}
|
|
102
|
+
}}
|
|
103
|
+
|
|
104
|
+
&:hover{
|
|
105
|
+
${({ theme, type, size, customStylesHover }) => {
|
|
106
|
+
if (theme) {
|
|
107
|
+
let tempObj = {};
|
|
108
|
+
// if (theme[type]) {
|
|
109
|
+
// for (const property in theme['common']) {
|
|
110
|
+
// tempObj[property] = theme['common'][property]
|
|
111
|
+
// }
|
|
112
|
+
// for (const property in theme[type]) {
|
|
113
|
+
// delete theme.common[property]
|
|
114
|
+
// tempObj[property] = theme[type][property]
|
|
115
|
+
// }
|
|
116
|
+
// for (const property in theme[`${type}${size}`]) {
|
|
117
|
+
// tempObj[property] = theme[`${type}${size}`][property]
|
|
118
|
+
// delete theme.common[property]
|
|
119
|
+
// }
|
|
120
|
+
// }
|
|
121
|
+
return { ...tempObj, ...customStylesHover };
|
|
122
|
+
}
|
|
123
|
+
}}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
`;
|
|
127
|
+
|
|
128
|
+
export const AvatarSB = ({
|
|
129
|
+
theme,
|
|
130
|
+
customStylesContainer,
|
|
131
|
+
customStylesImage,
|
|
132
|
+
customStylesCircle,
|
|
133
|
+
customStylesName,
|
|
134
|
+
customStylesNameHover,
|
|
135
|
+
size,
|
|
136
|
+
toggleName,
|
|
137
|
+
user,
|
|
138
|
+
border,
|
|
139
|
+
isSelected,
|
|
140
|
+
...props
|
|
141
|
+
}) => {
|
|
142
|
+
|
|
143
|
+
const [avatarStatus, setAvatarStatus] = useState("loading");
|
|
144
|
+
|
|
145
|
+
const handleImageStatus = (imageStatus) => {
|
|
146
|
+
setAvatarStatus(imageStatus);
|
|
147
|
+
}
|
|
148
|
+
// console.log('user', user)
|
|
149
|
+
return (
|
|
150
|
+
<StyledContainer border={border} theme={theme} customStyles={customStylesContainer} type={'avatarContainer'} {...props}>
|
|
151
|
+
{user?.url && <Image
|
|
152
|
+
{...props}
|
|
153
|
+
theme={theme}
|
|
154
|
+
customStyles={customStylesImage}
|
|
155
|
+
type={'imageAvatar'}
|
|
156
|
+
size={size}
|
|
157
|
+
alt="user-picture"
|
|
158
|
+
src={user.url}
|
|
159
|
+
handleImageStatus={handleImageStatus}
|
|
160
|
+
style={{ visibility: avatarStatus !== "loaded" ? 'hidden' : 'visible' }}
|
|
161
|
+
/>}
|
|
162
|
+
|
|
163
|
+
<StyledCircle {...props}
|
|
164
|
+
theme={theme}
|
|
165
|
+
type={'avatarCircle'}
|
|
166
|
+
customStyles={customStylesCircle} size={size}
|
|
167
|
+
style={{ visibility: avatarStatus !== "loaded" ? 'visible' : 'hidden' }}
|
|
168
|
+
isSelected={isSelected}
|
|
169
|
+
>
|
|
170
|
+
{
|
|
171
|
+
user?.userName && user?.userName.split(" ").length >= 2 ? user?.userName.split(" ")[0].charAt(0).toUpperCase() + user?.userName.split(" ")[1].charAt(0).toUpperCase()
|
|
172
|
+
: user?.userName && user?.userName.split(" ").length === 1 && user?.userName.split(" ")[0].charAt(0).toUpperCase()
|
|
173
|
+
}
|
|
174
|
+
</StyledCircle>
|
|
175
|
+
{toggleName && <StyledName {...props} theme={theme} type={'avatarName'} customStyles={customStylesName} customStylesHover={customStylesNameHover} size={size}>{user.userName} </StyledName>}
|
|
176
|
+
</StyledContainer>
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
AvatarSB.propTypes = {
|
|
181
|
+
/**
|
|
182
|
+
* Custom style for circle
|
|
183
|
+
*/
|
|
184
|
+
customStylesCircle: PropTypes.object,
|
|
185
|
+
/**
|
|
186
|
+
* Custom style for name
|
|
187
|
+
*/
|
|
188
|
+
customStylesName: PropTypes.object,
|
|
189
|
+
/**
|
|
190
|
+
* Optional Custom color of the circle
|
|
191
|
+
*/
|
|
192
|
+
customStylesContainer: PropTypes.object,
|
|
193
|
+
/**
|
|
194
|
+
* Optional Custom color of the border circle (if missing no border displayed)
|
|
195
|
+
*/
|
|
196
|
+
customStylesImage: PropTypes.object,
|
|
197
|
+
/**
|
|
198
|
+
* Toggle name visibility
|
|
199
|
+
*/
|
|
200
|
+
toggleName: PropTypes.bool,
|
|
201
|
+
/**
|
|
202
|
+
* How large should the Avatar be?
|
|
203
|
+
*/
|
|
204
|
+
size: PropTypes.oneOf(['SM', 'MD', 'LG']),
|
|
205
|
+
/**
|
|
206
|
+
* Object with user information. To display the user's picture need a key "url". To display the name need a key "userName"
|
|
207
|
+
*/
|
|
208
|
+
user: PropTypes.object,
|
|
209
|
+
/**
|
|
210
|
+
* Theme object
|
|
211
|
+
*/
|
|
212
|
+
theme: PropTypes.object,
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
AvatarSB.defaultProps = {
|
|
216
|
+
theme: defaultStyles,
|
|
217
|
+
block: false,
|
|
218
|
+
size: 'MD',
|
|
219
|
+
toggleName: false,
|
|
220
|
+
user: null,
|
|
221
|
+
customStylesContainer: null,
|
|
222
|
+
customStylesImage: null,
|
|
223
|
+
customStylesCircle: null,
|
|
224
|
+
customStylesName: null,
|
|
225
|
+
};
|
|
226
|
+
|