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,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 AvatarSBfooter = ({
|
|
129
|
+
theme,
|
|
130
|
+
customStylesContainer,
|
|
131
|
+
customStylesImage,
|
|
132
|
+
customStylesCircle,
|
|
133
|
+
customStylesName,
|
|
134
|
+
customStylesNameHover,
|
|
135
|
+
size,
|
|
136
|
+
toggleName,
|
|
137
|
+
user,
|
|
138
|
+
border,
|
|
139
|
+
isSelected,
|
|
140
|
+
value,
|
|
141
|
+
...props
|
|
142
|
+
}) => {
|
|
143
|
+
|
|
144
|
+
const [avatarStatus, setAvatarStatus] = useState("loading");
|
|
145
|
+
|
|
146
|
+
const handleImageStatus = (imageStatus) => {
|
|
147
|
+
setAvatarStatus(imageStatus);
|
|
148
|
+
}
|
|
149
|
+
// console.log('user', user)
|
|
150
|
+
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
|
+
/>}
|
|
163
|
+
|
|
164
|
+
<StyledCircle {...props}
|
|
165
|
+
theme={theme}
|
|
166
|
+
type={'avatarCircle'}
|
|
167
|
+
customStyles={customStylesCircle} size={size}
|
|
168
|
+
style={{ visibility: avatarStatus !== "loaded" ? 'visible' : 'hidden' }}
|
|
169
|
+
isSelected={isSelected}
|
|
170
|
+
>
|
|
171
|
+
{
|
|
172
|
+
value
|
|
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
|
+
AvatarSBfooter.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
|
+
AvatarSBfooter.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
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import defaultThemeColor from '../constants/defaultThemeColor';
|
|
5
|
+
|
|
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
|
+
}
|
|
20
|
+
|
|
21
|
+
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
|
+
`
|
|
28
|
+
|
|
29
|
+
BannerContent.defaultProps = {
|
|
30
|
+
theme: defaultThemeColor,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const Banner = ({ backgroundColor, borderColor,variant, children,...props}) =>{
|
|
34
|
+
return (
|
|
35
|
+
<>
|
|
36
|
+
<BannerWrapper backgroundColor={backgroundColor} borderColor={borderColor} {...props}>
|
|
37
|
+
<BannerContent {...props}>
|
|
38
|
+
{children}
|
|
39
|
+
</BannerContent>
|
|
40
|
+
</BannerWrapper>
|
|
41
|
+
</>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
Banner.propTypes = {
|
|
46
|
+
/**
|
|
47
|
+
* background color of the banner
|
|
48
|
+
*/
|
|
49
|
+
backgroundColor: PropTypes.string,
|
|
50
|
+
/**
|
|
51
|
+
* border color of the banner
|
|
52
|
+
*/
|
|
53
|
+
borderColor: PropTypes.string,
|
|
54
|
+
/**
|
|
55
|
+
* What will be rendered inside the bannaer
|
|
56
|
+
*/
|
|
57
|
+
children: PropTypes.any
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
Banner.defaultProps = {
|
|
61
|
+
children: '',
|
|
62
|
+
backgroundColor:'#f7f2ff',
|
|
63
|
+
borderColor:'#8b2dff',
|
|
64
|
+
}
|
|
65
|
+
|
|
@@ -0,0 +1,192 @@
|
|
|
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
|
+
/**
|
|
7
|
+
* Primary UI component for user interaction
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const StyledBreadcrumb = styled.div`
|
|
11
|
+
background: transparent;
|
|
12
|
+
color: ${({ theme, variant }) => theme.variant[variant]};
|
|
13
|
+
font-size: ${({ isPrimary }) => isPrimary ? '16px' : '14px'};
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
|
|
17
|
+
${({ isWrap }) => {
|
|
18
|
+
if (isWrap) {
|
|
19
|
+
return css`
|
|
20
|
+
width: ${({ block }) => block ? 'auto' : 'fit-content'};
|
|
21
|
+
flex-wrap: wrap;
|
|
22
|
+
visibility: visible;
|
|
23
|
+
`
|
|
24
|
+
} else {
|
|
25
|
+
return css`
|
|
26
|
+
border: 1px solid transparent;
|
|
27
|
+
overflow-x: auto;
|
|
28
|
+
overflow-y: hidden;
|
|
29
|
+
visibility: ${({ isBreadcrumbVisible }) => isBreadcrumbVisible ? 'visible' : 'hidden'};
|
|
30
|
+
/* Hide scrollbar for Chrome, Safari and Opera */
|
|
31
|
+
&::-webkit-scrollbar {
|
|
32
|
+
display: none;
|
|
33
|
+
}
|
|
34
|
+
/* Hide scrollbar for IE, Edge and Firefox */
|
|
35
|
+
&-ms-overflow-style: none; /* IE and Edge */
|
|
36
|
+
scrollbar-width: none; /* Firefox */
|
|
37
|
+
`
|
|
38
|
+
}
|
|
39
|
+
}};
|
|
40
|
+
|
|
41
|
+
.breadcrumb-icon svg path {
|
|
42
|
+
fill: ${({ theme, variant }) => theme.variant[variant]};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.breadcrumb-icon-separator svg path {
|
|
46
|
+
fill: ${({ theme, variantSeparator }) => theme.variant[variantSeparator]};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.breadcrumb-icon-separator {
|
|
50
|
+
margin: 0 ${({ isPrimary }) => isPrimary ? '12px' : '7px'};
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
const StyledCombo = styled.div`
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-wrap: nowrap;
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
const StyledItem = styled.div`
|
|
60
|
+
cursor: ${({ href }) => href ? 'pointer' : 'default'};
|
|
61
|
+
list-style: none;
|
|
62
|
+
color: ${({ theme, variant }) => theme.variant[variant]};
|
|
63
|
+
white-space: nowrap;
|
|
64
|
+
max-width: 15ch;
|
|
65
|
+
white-space: nowrap;
|
|
66
|
+
overflow: hidden;
|
|
67
|
+
text-overflow: ellipsis;
|
|
68
|
+
|
|
69
|
+
&:hover {
|
|
70
|
+
text-decoration: ${({ href }) => href ? 'underline' : 'none'};
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
export const Breadcrumb = ({ wrap, block, style, variant, variantSeparator, appLogo, separator, items, onClick, isPrimary, ...props }) => {
|
|
75
|
+
const theme = useTheme() || defaultThemeColor;
|
|
76
|
+
|
|
77
|
+
const breadcrumbRef = useRef(null)
|
|
78
|
+
|
|
79
|
+
const [isBreadcrumbVisible, setIsBreadcrumbVisible] = useState(undefined);
|
|
80
|
+
|
|
81
|
+
const handleWindowResize = () => {
|
|
82
|
+
if (breadcrumbRef?.current?.scrollWidth < breadcrumbRef?.current?.offsetWidth) {
|
|
83
|
+
setIsBreadcrumbVisible(true)
|
|
84
|
+
} else {
|
|
85
|
+
setIsBreadcrumbVisible(false)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
handleWindowResize();
|
|
91
|
+
}, [items])
|
|
92
|
+
|
|
93
|
+
//On component mount add event listener
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (!wrap) {
|
|
96
|
+
// Monitor the width of the viewPort to adjust the text of the arrow accordingly
|
|
97
|
+
window.addEventListener("resize", handleWindowResize);
|
|
98
|
+
return () => (window.removeEventListener("resize", handleWindowResize));
|
|
99
|
+
}
|
|
100
|
+
}, [])
|
|
101
|
+
|
|
102
|
+
const list = (items) ? items.map((item, i) => {
|
|
103
|
+
return (
|
|
104
|
+
<StyledCombo key={item.label} >
|
|
105
|
+
{(i === 0 && !appLogo) ? null : (<div className="breadcrumb-icon-separator">{separator}</div>)}
|
|
106
|
+
<StyledItem onClick={() => { if (item.href) onClick(item.href) }} variant={variant} href={item.href} title={item.label}>
|
|
107
|
+
{/* If label longer than 15chs trim it by css */}
|
|
108
|
+
{item.label}
|
|
109
|
+
</StyledItem>
|
|
110
|
+
</StyledCombo>
|
|
111
|
+
)
|
|
112
|
+
}) : (null)
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<StyledBreadcrumb
|
|
116
|
+
isWrap={wrap}
|
|
117
|
+
ref={!wrap ? breadcrumbRef : null}
|
|
118
|
+
isBreadcrumbVisible={isBreadcrumbVisible}
|
|
119
|
+
block={block}
|
|
120
|
+
variant={variant}
|
|
121
|
+
variantSeparator={variantSeparator}
|
|
122
|
+
style={style}
|
|
123
|
+
isPrimary={isPrimary}
|
|
124
|
+
{...props}
|
|
125
|
+
>
|
|
126
|
+
{appLogo && (<div className="breadcrumb-icon">{appLogo}</div>)}
|
|
127
|
+
{list}
|
|
128
|
+
</StyledBreadcrumb>
|
|
129
|
+
)
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
Breadcrumb.propTypes = {
|
|
133
|
+
/**
|
|
134
|
+
* Color of text. primary-1, 2, error, etc.
|
|
135
|
+
*/
|
|
136
|
+
variant: PropTypes.string,
|
|
137
|
+
/**
|
|
138
|
+
* Color of separator. primary-1, 2, error, etc.
|
|
139
|
+
*/
|
|
140
|
+
variantSeparator: PropTypes.string,
|
|
141
|
+
/**
|
|
142
|
+
* Click handler
|
|
143
|
+
*/
|
|
144
|
+
onClick: PropTypes.func,
|
|
145
|
+
/**
|
|
146
|
+
* Optional Icon element with app icon
|
|
147
|
+
*/
|
|
148
|
+
appLogo: PropTypes.any,
|
|
149
|
+
/**
|
|
150
|
+
* Optional Icon element with separator icon
|
|
151
|
+
*/
|
|
152
|
+
separator: PropTypes.any,
|
|
153
|
+
/**
|
|
154
|
+
* List of the elements of breadcramb
|
|
155
|
+
*/
|
|
156
|
+
items: PropTypes.array,
|
|
157
|
+
/**
|
|
158
|
+
* Optional width selector
|
|
159
|
+
*/
|
|
160
|
+
block: PropTypes.bool,
|
|
161
|
+
/**
|
|
162
|
+
* Theme object
|
|
163
|
+
*/
|
|
164
|
+
theme: PropTypes.object,
|
|
165
|
+
/**
|
|
166
|
+
* If true wrap items when shrink else hide
|
|
167
|
+
*/
|
|
168
|
+
wrap: PropTypes.bool,
|
|
169
|
+
/**
|
|
170
|
+
* If true bigger font and margin, if false it means secondary breadcrum with smaller font and less margin
|
|
171
|
+
*/
|
|
172
|
+
isPrimary: PropTypes.bool,
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
StyledBreadcrumb.defaultProps = {
|
|
176
|
+
theme: defaultThemeColor,
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
StyledItem.defaultProps = {
|
|
180
|
+
theme: defaultThemeColor,
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
Breadcrumb.defaultProps = {
|
|
184
|
+
theme: defaultThemeColor,
|
|
185
|
+
variant: 'neutral-2',
|
|
186
|
+
variantSeparator: 'neutral-3',
|
|
187
|
+
block: false,
|
|
188
|
+
onClick: undefined,
|
|
189
|
+
wrap: false,
|
|
190
|
+
isPrimary: true
|
|
191
|
+
};
|
|
192
|
+
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled, { useTheme } from 'styled-components';
|
|
4
|
+
import defaultThemeColor from '../constants/defaultThemeColor';
|
|
5
|
+
import { Loader } from '../Loaders';
|
|
6
|
+
import getDefaultStyles, { hexToRGB } from "../constants/utils";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Primary UI component for user interaction
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const sizes = {
|
|
13
|
+
sm: {
|
|
14
|
+
fontSize: '14px',
|
|
15
|
+
padding: '5px 15px'
|
|
16
|
+
},
|
|
17
|
+
md: {
|
|
18
|
+
fontSize: '16px',
|
|
19
|
+
padding: '6px 15px'
|
|
20
|
+
},
|
|
21
|
+
lg: {
|
|
22
|
+
fontSize: '18px',
|
|
23
|
+
padding: '8px 20px'
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// const buttonDisabledBg = '#BBC4CF';
|
|
28
|
+
const buttonDisabledBg = ({ theme, variant }) => hexToRGB(theme.variant[variant], 0.6);
|
|
29
|
+
const fontColor = defaultThemeColor.bgColor;
|
|
30
|
+
// console.log(color)
|
|
31
|
+
|
|
32
|
+
const StyledButton = styled.button`
|
|
33
|
+
background: ${({ theme, variant }) => theme.variant[variant]};
|
|
34
|
+
color: ${fontColor};
|
|
35
|
+
padding: ${({ size }) => sizes[size].padding};
|
|
36
|
+
border: 1px solid ${({ theme, variant }) => theme.variant[variant]};
|
|
37
|
+
border-radius: 5px;
|
|
38
|
+
font-size: ${({ size }) => sizes[size].fontSize};
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
width: ${({ block }) => block ? '100%' : 'auto'};
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
|
|
44
|
+
&:disabled {
|
|
45
|
+
color: ${fontColor};
|
|
46
|
+
background: ${buttonDisabledBg};
|
|
47
|
+
border: 1px solid ${buttonDisabledBg};
|
|
48
|
+
cursor: not-allowed;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//Set the styles from the default styles object
|
|
52
|
+
${({ theme, defaultStyle }) => {
|
|
53
|
+
return getDefaultStyles(theme, defaultStyle);
|
|
54
|
+
}}
|
|
55
|
+
`;
|
|
56
|
+
// console.log(fontColor)
|
|
57
|
+
|
|
58
|
+
export const PrimaryButton = ({ block, size, style, variant, disabled, isLoading, type, ...props }) => {
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<StyledButton
|
|
62
|
+
block={block}
|
|
63
|
+
variant={variant}
|
|
64
|
+
defaultStyle="button"
|
|
65
|
+
type={type}
|
|
66
|
+
style={style}
|
|
67
|
+
size={size}
|
|
68
|
+
disabled={disabled}
|
|
69
|
+
{...props}
|
|
70
|
+
>
|
|
71
|
+
{isLoading && <div style={{ paddingRight: '10px', marginTop: '6px' }}><Loader customStyles={{ 'background-color': fontColor }} size={16} /></div>}
|
|
72
|
+
{props.children}
|
|
73
|
+
</StyledButton>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
PrimaryButton.propTypes = {
|
|
78
|
+
/**
|
|
79
|
+
* Type of Button. primary-1, 2, error, etc.
|
|
80
|
+
*/
|
|
81
|
+
variant: PropTypes.string,
|
|
82
|
+
/**
|
|
83
|
+
* Is the button disabled?
|
|
84
|
+
*/
|
|
85
|
+
disabled: PropTypes.bool,
|
|
86
|
+
/**
|
|
87
|
+
* How large should the button be?
|
|
88
|
+
*/
|
|
89
|
+
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
90
|
+
/**
|
|
91
|
+
* Optional click handler
|
|
92
|
+
*/
|
|
93
|
+
block: PropTypes.bool,
|
|
94
|
+
/**
|
|
95
|
+
* Optional loading handler
|
|
96
|
+
*/
|
|
97
|
+
isLoading: PropTypes.bool,
|
|
98
|
+
/**
|
|
99
|
+
* Optional click handler
|
|
100
|
+
*/
|
|
101
|
+
onClick: PropTypes.func,
|
|
102
|
+
/**
|
|
103
|
+
* Theme object
|
|
104
|
+
*/
|
|
105
|
+
theme: PropTypes.object,
|
|
106
|
+
/**
|
|
107
|
+
* Type of the btn i.e: button or submit etc.
|
|
108
|
+
*/
|
|
109
|
+
type: PropTypes.string,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
StyledButton.defaultProps = {
|
|
113
|
+
theme: defaultThemeColor,
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
PrimaryButton.defaultProps = {
|
|
117
|
+
theme: defaultThemeColor,
|
|
118
|
+
variant: 'primary-1',
|
|
119
|
+
block: false,
|
|
120
|
+
isLoading: false,
|
|
121
|
+
disabled: false,
|
|
122
|
+
size: 'md',
|
|
123
|
+
onClick: undefined,
|
|
124
|
+
};
|
|
125
|
+
|