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 @@
|
|
|
1
|
+
export * from './Header';
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled, { useTheme, css } from 'styled-components';
|
|
4
|
+
import defaultThemeColor from '../constants/defaultThemeColor';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Primary UI component for user interaction
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const sizes = {
|
|
11
|
+
xsm: {
|
|
12
|
+
fontSize: '12px'
|
|
13
|
+
},
|
|
14
|
+
sm: {
|
|
15
|
+
fontSize: '14px'
|
|
16
|
+
},
|
|
17
|
+
md: {
|
|
18
|
+
fontSize: '16px'
|
|
19
|
+
},
|
|
20
|
+
lg: {
|
|
21
|
+
fontSize: '18px'
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Define style css
|
|
26
|
+
const StyledHyperLink = styled.button`
|
|
27
|
+
${({ underlined }) => !underlined ? css`&:hover {text-decoration: underline}` : null};
|
|
28
|
+
background: transparent;
|
|
29
|
+
color: ${({ theme, variant }) => theme.variant[variant]};
|
|
30
|
+
text-decoration: ${({ underlined }) => underlined ? 'underline' : 'none'};
|
|
31
|
+
display: flex;
|
|
32
|
+
width: ${({ block }) => block ? '100%' : 'auto'};
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: start;
|
|
35
|
+
border: none;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
font-size: ${({ size }) => sizes[size].fontSize};
|
|
38
|
+
|
|
39
|
+
&:disabled {
|
|
40
|
+
color: ${({ theme }) => theme.variant['neutral-3']};
|
|
41
|
+
cursor: not-allowed;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
* {
|
|
45
|
+
outline: none;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
export const HyperLink = ({ block, size, style, variant, disabled, underlined, ...props }) => {
|
|
50
|
+
const theme = useTheme() || defaultThemeColor;
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<StyledHyperLink
|
|
54
|
+
block={block}
|
|
55
|
+
variant={variant}
|
|
56
|
+
type="button"
|
|
57
|
+
style={style}
|
|
58
|
+
size={size}
|
|
59
|
+
disabled={disabled}
|
|
60
|
+
underlined={underlined}
|
|
61
|
+
{...props}
|
|
62
|
+
>
|
|
63
|
+
{props.children}
|
|
64
|
+
</StyledHyperLink>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
HyperLink.propTypes = {
|
|
69
|
+
/**
|
|
70
|
+
* HyperLink color: 'primary-1', 'primary-2', 'error', etc.
|
|
71
|
+
*/
|
|
72
|
+
variant: PropTypes.string,
|
|
73
|
+
/**
|
|
74
|
+
* Is the button disabled?
|
|
75
|
+
*/
|
|
76
|
+
disabled: PropTypes.bool,
|
|
77
|
+
/**
|
|
78
|
+
* How big should the text be?
|
|
79
|
+
*/
|
|
80
|
+
size: PropTypes.oneOf(['xsm', 'sm', 'md', 'lg']),
|
|
81
|
+
/**
|
|
82
|
+
* Optional width (block true width = 100%)
|
|
83
|
+
*/
|
|
84
|
+
block: PropTypes.bool,
|
|
85
|
+
/**
|
|
86
|
+
* Optional click handler
|
|
87
|
+
*/
|
|
88
|
+
onClick: PropTypes.func,
|
|
89
|
+
/**
|
|
90
|
+
* Theme object
|
|
91
|
+
*/
|
|
92
|
+
theme: PropTypes.object,
|
|
93
|
+
/**
|
|
94
|
+
* Optional: add underline
|
|
95
|
+
*/
|
|
96
|
+
underlined: PropTypes.bool,
|
|
97
|
+
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
StyledHyperLink.defaultProps = {
|
|
101
|
+
theme: defaultThemeColor,
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
HyperLink.defaultProps = {
|
|
105
|
+
theme: defaultThemeColor,
|
|
106
|
+
variant: "primary-1",
|
|
107
|
+
block: false,
|
|
108
|
+
disabled: false,
|
|
109
|
+
size: "sm",
|
|
110
|
+
onClick: undefined,
|
|
111
|
+
label: "Remove",
|
|
112
|
+
underlined: false
|
|
113
|
+
};
|
|
114
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HyperLink';
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { ReactSVG } from "react-svg";
|
|
4
|
+
import styled, { css } from 'styled-components';
|
|
5
|
+
import defaultThemeColor from '../constants/defaultThemeColor';
|
|
6
|
+
|
|
7
|
+
/** import icons from assets here */
|
|
8
|
+
import plusOutline from '../../assets/icons/plus-outlined.svg'
|
|
9
|
+
import checkMark from '../../assets/icons/checkmark.svg'
|
|
10
|
+
import chevronRight from '../../assets/icons/chevron-right.svg'
|
|
11
|
+
import chevronLeft from '../../assets/icons/chevron-left.svg'
|
|
12
|
+
import appLogo from '../../assets/icons/app-logo.svg'
|
|
13
|
+
import email from '../../assets/icons/email.svg'
|
|
14
|
+
import chevronDown from '../../assets/icons/chevron-down.svg'
|
|
15
|
+
import triangleDown from '../../assets/icons/triangle-down.svg'
|
|
16
|
+
import info from '../../assets/icons/info.svg'
|
|
17
|
+
import crossIcon from '../../assets/icons/cross-icon.svg'
|
|
18
|
+
import fileAttach from '../../assets/icons/file-attach.svg'
|
|
19
|
+
import jpgIcon from '../../assets/icons/jpg-icon.svg'
|
|
20
|
+
import pdfIcon from '../../assets/icons/pdf-icon.svg'
|
|
21
|
+
import arrowUp from '../../assets/icons/arrow-up.svg'
|
|
22
|
+
import arrowDown from '../../assets/icons/arrow-down.svg'
|
|
23
|
+
import penIcon from '../../assets/icons/pen-icon.svg'
|
|
24
|
+
import signIcon from '../../assets/icons/sign-icon.svg'
|
|
25
|
+
import editIcon from '../../assets/icons/edit-icon.svg'
|
|
26
|
+
import hamburgerMenu from '../../assets/icons/hamburger-menu.svg'
|
|
27
|
+
import bell from '../../assets/icons/bell.svg'
|
|
28
|
+
import star from '../../assets/icons/star.svg'
|
|
29
|
+
import cloudIcon from '../../assets/icons/cloud-icon.svg'
|
|
30
|
+
import checkIcon from '../../assets/icons/check.svg'
|
|
31
|
+
import arrowRotate from '../../assets/icons/arrow-rotate.svg'
|
|
32
|
+
import connection from '../../assets/icons/connection.svg'
|
|
33
|
+
import magnifier from '../../assets/icons/magnifier.svg'
|
|
34
|
+
import doorInternalActive from '../../assets/icons/door-internal-active.svg'
|
|
35
|
+
import ellipsesHorizontal from '../../assets/icons/ellipses-horizontal.svg'
|
|
36
|
+
import ellipses from '../../assets/icons/ellipses.svg'
|
|
37
|
+
import fileAttachWhite from '../../assets/icons/file-attach-white.svg'
|
|
38
|
+
import equation from '../../assets/icons/functional-equation-regular.svg'
|
|
39
|
+
import menuEllipseTwo from '../../assets/icons/menu-ellipse-two.svg'
|
|
40
|
+
import menuEllipse from '../../assets/icons/menu-ellipse.svg'
|
|
41
|
+
import pauseAll from '../../assets/icons/pause-all.svg'
|
|
42
|
+
import resume from '../../assets/icons/resume.svg'
|
|
43
|
+
import trashIcon from '../../assets/icons/trash-icon.svg'
|
|
44
|
+
import zoomInWhite from '../../assets/icons/zoom-in-white.svg'
|
|
45
|
+
import view from '../../assets/icons/view.svg'
|
|
46
|
+
import user from '../../assets/icons/users.svg'
|
|
47
|
+
import watcher from '../../assets/icons/watcher.svg'
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
/** icon name should be kebab-case, e.g "plus-outline" */
|
|
51
|
+
const iconObj = {
|
|
52
|
+
'plus-outlined': plusOutline,
|
|
53
|
+
'check-mark': checkMark,
|
|
54
|
+
'chevron-right': chevronRight,
|
|
55
|
+
'chevron-left': chevronLeft,
|
|
56
|
+
'app-logo': appLogo,
|
|
57
|
+
'email': email,
|
|
58
|
+
'chevron-down': chevronDown,
|
|
59
|
+
'triangle-down': triangleDown,
|
|
60
|
+
'info': info,
|
|
61
|
+
'cross-icon': crossIcon,
|
|
62
|
+
'file-attach': fileAttach,
|
|
63
|
+
'jpg-icon': jpgIcon,
|
|
64
|
+
'pdf-icon': pdfIcon,
|
|
65
|
+
'arrow-up': arrowUp,
|
|
66
|
+
'arrow-down': arrowDown,
|
|
67
|
+
'pen-icon': penIcon,
|
|
68
|
+
'sign-icon': signIcon,
|
|
69
|
+
'edit-icon': editIcon,
|
|
70
|
+
'hamburger-menu': hamburgerMenu,
|
|
71
|
+
'bell': bell,
|
|
72
|
+
'star': star,
|
|
73
|
+
'cloud-icon': cloudIcon,
|
|
74
|
+
'check-icon': checkIcon,
|
|
75
|
+
'arrow-rotate':arrowRotate,
|
|
76
|
+
'magnifier-icon': magnifier,
|
|
77
|
+
'connection': connection,
|
|
78
|
+
'door-internal-active': doorInternalActive,
|
|
79
|
+
'ellipses-horizontal': ellipsesHorizontal,
|
|
80
|
+
'ellipses': ellipses,
|
|
81
|
+
'file-attach-white': fileAttachWhite,
|
|
82
|
+
'functional-equation':equation,
|
|
83
|
+
"menu-ellipse-two": menuEllipseTwo,
|
|
84
|
+
'menu-ellipse': menuEllipse,
|
|
85
|
+
'pause-all': pauseAll,
|
|
86
|
+
'resume': resume,
|
|
87
|
+
'trash-icon': trashIcon,
|
|
88
|
+
'zoom-in-white': zoomInWhite,
|
|
89
|
+
'watcher': watcher,
|
|
90
|
+
'view': view,
|
|
91
|
+
'user-icon':user,
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const StyledSVGIcon = styled(ReactSVG)`
|
|
97
|
+
div {
|
|
98
|
+
${({ size }) =>
|
|
99
|
+
size &&
|
|
100
|
+
css`
|
|
101
|
+
width: ${size}px;
|
|
102
|
+
height: ${size}px;
|
|
103
|
+
`}
|
|
104
|
+
}
|
|
105
|
+
svg {
|
|
106
|
+
fill: black;
|
|
107
|
+
|
|
108
|
+
${({ size }) =>
|
|
109
|
+
size &&
|
|
110
|
+
css`
|
|
111
|
+
width: ${size}px;
|
|
112
|
+
height: ${size}px;
|
|
113
|
+
`}
|
|
114
|
+
|
|
115
|
+
${({ transform }) =>
|
|
116
|
+
transform &&
|
|
117
|
+
css`
|
|
118
|
+
transform: ${transform};
|
|
119
|
+
`}
|
|
120
|
+
|
|
121
|
+
path {
|
|
122
|
+
${({ color }) =>
|
|
123
|
+
color &&
|
|
124
|
+
css`
|
|
125
|
+
fill: ${color};
|
|
126
|
+
`}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
`;
|
|
130
|
+
|
|
131
|
+
export const Icon = ({ icon, color, size, transform, ...props }) => {
|
|
132
|
+
return (
|
|
133
|
+
<StyledSVGIcon
|
|
134
|
+
src={iconObj[icon]}
|
|
135
|
+
color={color}
|
|
136
|
+
size={size}
|
|
137
|
+
transform={transform}
|
|
138
|
+
{...props}
|
|
139
|
+
/>
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
Icon.propTypes = {
|
|
144
|
+
/**
|
|
145
|
+
* name of icon
|
|
146
|
+
*/
|
|
147
|
+
icon: PropTypes.string.isRequired,
|
|
148
|
+
/**
|
|
149
|
+
* set size of icon in px
|
|
150
|
+
*/
|
|
151
|
+
size: PropTypes.number,
|
|
152
|
+
/**
|
|
153
|
+
* color of icon
|
|
154
|
+
*/
|
|
155
|
+
color: PropTypes.string,
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
Icon.defaultProps = {
|
|
159
|
+
size: 16,
|
|
160
|
+
color: defaultThemeColor.primary['primary-1'],
|
|
161
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Icon';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from "react";
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import defaultStyles from '../constants/defaultStyle';
|
|
5
|
+
|
|
6
|
+
const ImageLayout = styled.img`
|
|
7
|
+
//Set the styles from the default styles object
|
|
8
|
+
${({ theme, type, size, customStyles }) => {
|
|
9
|
+
if (theme) {
|
|
10
|
+
let tempObj = {};
|
|
11
|
+
if (theme[type]) {
|
|
12
|
+
for (const property in theme['common']) {
|
|
13
|
+
tempObj[property] = theme['common'][property]
|
|
14
|
+
}
|
|
15
|
+
for (const property in theme[type]) {
|
|
16
|
+
tempObj[property] = theme[type][property]
|
|
17
|
+
delete theme.common[property]
|
|
18
|
+
}
|
|
19
|
+
for (const property in theme[`${type}${size}`]) {
|
|
20
|
+
tempObj[property] = theme[`${type}${size}`][property]
|
|
21
|
+
delete theme.common[property]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return { ...tempObj, ...customStyles };
|
|
25
|
+
}
|
|
26
|
+
}}
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
export const Image = ({ theme, customStyles, type, size, alt, src, handleImageStatus, ...props }) => {
|
|
30
|
+
|
|
31
|
+
const [imageStatus, setImageStatus] = useState("loading");
|
|
32
|
+
|
|
33
|
+
const imgEl = useRef(null);
|
|
34
|
+
|
|
35
|
+
const onImageLoaded = () => {
|
|
36
|
+
setImageStatus("loaded")
|
|
37
|
+
handleImageStatus && handleImageStatus("loaded")
|
|
38
|
+
};
|
|
39
|
+
const onImageError = () => {
|
|
40
|
+
setImageStatus("failed")
|
|
41
|
+
handleImageStatus && handleImageStatus("failed")
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const imgElCurrent = imgEl.current;
|
|
46
|
+
|
|
47
|
+
if (imgElCurrent) {
|
|
48
|
+
imgElCurrent.addEventListener("load", onImageLoaded);
|
|
49
|
+
imgElCurrent.addEventListener("error", onImageError);
|
|
50
|
+
|
|
51
|
+
return () => {
|
|
52
|
+
imgElCurrent.removeEventListener("load", onImageLoaded);
|
|
53
|
+
imgElCurrent.removeEventListener("error", onImageError);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}, [imageStatus]);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<ImageLayout
|
|
60
|
+
{...props}
|
|
61
|
+
theme={theme}
|
|
62
|
+
customStyles={customStyles}
|
|
63
|
+
type={type}
|
|
64
|
+
alt={alt}
|
|
65
|
+
src={src}
|
|
66
|
+
ref={imgEl}
|
|
67
|
+
size={size}
|
|
68
|
+
/>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
Image.propTypes = {
|
|
73
|
+
/**
|
|
74
|
+
* Theme props
|
|
75
|
+
*/
|
|
76
|
+
theme: PropTypes.object,
|
|
77
|
+
/**
|
|
78
|
+
* Custom style object
|
|
79
|
+
*/
|
|
80
|
+
customStyles: PropTypes.object,
|
|
81
|
+
/**
|
|
82
|
+
* Type of the component which define the default style
|
|
83
|
+
*/
|
|
84
|
+
type: PropTypes.string,
|
|
85
|
+
/**
|
|
86
|
+
* How large should the Avatar be?
|
|
87
|
+
* Only apply if type='imageAvatar'
|
|
88
|
+
*/
|
|
89
|
+
size: PropTypes.oneOf(['SM', 'MD', 'LG']),
|
|
90
|
+
/**
|
|
91
|
+
* Alternative text for the image
|
|
92
|
+
*/
|
|
93
|
+
alt: PropTypes.string,
|
|
94
|
+
/**
|
|
95
|
+
* URL for the image
|
|
96
|
+
*/
|
|
97
|
+
src: PropTypes.string,
|
|
98
|
+
/**
|
|
99
|
+
* Function that is triggered when the status of the image changes and pass as a parameter the image status itself
|
|
100
|
+
*/
|
|
101
|
+
handleImageStatus: PropTypes.func
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
Image.defaultProps = {
|
|
105
|
+
theme: defaultStyles,
|
|
106
|
+
customStyles: null,
|
|
107
|
+
type: 'image',
|
|
108
|
+
alt: 'image alternative',
|
|
109
|
+
src: null,
|
|
110
|
+
handleImageStatus: null
|
|
111
|
+
}
|
|
112
|
+
|