groundfloor-react-ui 1.0.20 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Accordion/Accordion.js +79 -35
- package/components/Accordion/AccordionSB.js +50 -54
- package/components/Accordion/AccordionSBfooter.js +51 -55
- package/components/ArrowBar/ArrowBar.js +6 -23
- package/components/Avatar/Avatar.js +49 -45
- package/components/Avatar/AvatarSB.js +121 -92
- package/components/Avatar/AvatarSBfooter.js +113 -92
- package/components/Banner/Banner.js +40 -35
- package/components/Breadcrumb/Breadcrumb.js +178 -163
- package/components/Cards/CardRef.js +41 -34
- package/components/Drawer/Drawer.js +46 -55
- package/components/Images/Image.js +16 -21
- package/components/Sidebar/Navbar.js +196 -170
- package/components/Typography/Typography.js +9 -10
- package/components/constants/defaultStyle.js +10 -3
- package/dist/index.es.js +414 -381
- package/dist/index.js +387 -354
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef } from 'react';
|
|
2
1
|
import PropTypes from 'prop-types';
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import styled, { css, useTheme } from 'styled-components';
|
|
4
4
|
import defaultThemeColor from '../constants/defaultThemeColor';
|
|
5
5
|
|
|
@@ -8,185 +8,200 @@ import defaultThemeColor from '../constants/defaultThemeColor';
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
const StyledBreadcrumb = styled.div`
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/* Hide scrollbar for IE, Edge and Firefox */
|
|
35
|
-
&-ms-overflow-style: none; /* IE and Edge */
|
|
36
|
-
scrollbar-width: none; /* Firefox */
|
|
37
|
-
`
|
|
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 }) =>
|
|
30
|
+
isBreadcrumbVisible ? 'visible' : 'hidden'};
|
|
31
|
+
/* Hide scrollbar for Chrome, Safari and Opera */
|
|
32
|
+
&::-webkit-scrollbar {
|
|
33
|
+
display: none;
|
|
38
34
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
/* Hide scrollbar for IE, Edge and Firefox */
|
|
36
|
+
&-ms-overflow-style: none; /* IE and Edge */
|
|
37
|
+
scrollbar-width: none; /* Firefox */
|
|
38
|
+
`;
|
|
43
39
|
}
|
|
40
|
+
}};
|
|
44
41
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
.breadcrumb-icon svg path {
|
|
43
|
+
fill: ${({ theme, variant }) => theme.variant[variant]};
|
|
44
|
+
}
|
|
48
45
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
.breadcrumb-icon-separator svg path {
|
|
47
|
+
fill: ${({ theme, variantSeparator }) => theme.variant[variantSeparator]};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.breadcrumb-icon-separator {
|
|
51
|
+
margin: 0 ${({ isPrimary }) => (isPrimary ? '12px' : '7px')};
|
|
52
|
+
}
|
|
52
53
|
`;
|
|
53
54
|
|
|
54
55
|
const StyledCombo = styled.div`
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-wrap: nowrap;
|
|
57
58
|
`;
|
|
58
59
|
|
|
59
60
|
const StyledItem = styled.div`
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
61
|
+
cursor: ${({ href }) => (href ? 'pointer' : 'default')};
|
|
62
|
+
list-style: none;
|
|
63
|
+
color: ${({ theme, variant }) => theme.variant[variant]};
|
|
64
|
+
white-space: nowrap;
|
|
65
|
+
max-width: 15ch;
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
overflow: hidden;
|
|
68
|
+
text-overflow: ellipsis;
|
|
69
|
+
|
|
70
|
+
&:hover {
|
|
71
|
+
text-decoration: ${({ href }) => (href ? 'underline' : 'none')};
|
|
72
|
+
}
|
|
72
73
|
`;
|
|
73
74
|
|
|
74
|
-
export const Breadcrumb = ({
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
75
|
+
export const Breadcrumb = ({
|
|
76
|
+
wrap,
|
|
77
|
+
block,
|
|
78
|
+
style,
|
|
79
|
+
variant,
|
|
80
|
+
variantSeparator,
|
|
81
|
+
appLogo,
|
|
82
|
+
separator,
|
|
83
|
+
items,
|
|
84
|
+
onClick,
|
|
85
|
+
isPrimary,
|
|
86
|
+
...props
|
|
87
|
+
}) => {
|
|
88
|
+
const activeTheme = useTheme() || defaultThemeColor;
|
|
89
|
+
|
|
90
|
+
const breadcrumbRef = useRef(null);
|
|
91
|
+
|
|
92
|
+
const [isBreadcrumbVisible, setIsBreadcrumbVisible] = useState(undefined);
|
|
93
|
+
|
|
94
|
+
const handleWindowResize = () => {
|
|
95
|
+
if (
|
|
96
|
+
breadcrumbRef?.current?.scrollWidth < breadcrumbRef?.current?.offsetWidth
|
|
97
|
+
) {
|
|
98
|
+
setIsBreadcrumbVisible(true);
|
|
99
|
+
} else {
|
|
100
|
+
setIsBreadcrumbVisible(false);
|
|
87
101
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
<StyledBreadcrumb
|
|
116
|
-
isWrap={wrap}
|
|
117
|
-
ref={!wrap ? breadcrumbRef : null}
|
|
118
|
-
isBreadcrumbVisible={isBreadcrumbVisible}
|
|
119
|
-
block={block}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
handleWindowResize();
|
|
106
|
+
}, [items]);
|
|
107
|
+
|
|
108
|
+
//On component mount add event listener
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (!wrap) {
|
|
111
|
+
// Monitor the width of the viewPort to adjust the text of the arrow accordingly
|
|
112
|
+
window.addEventListener('resize', handleWindowResize);
|
|
113
|
+
return () => window.removeEventListener('resize', handleWindowResize);
|
|
114
|
+
}
|
|
115
|
+
}, []);
|
|
116
|
+
|
|
117
|
+
const list = items
|
|
118
|
+
? items.map((item, i) => {
|
|
119
|
+
return (
|
|
120
|
+
<StyledCombo key={item.label}>
|
|
121
|
+
{i === 0 && !appLogo ? null : (
|
|
122
|
+
<div className='breadcrumb-icon-separator'>{separator}</div>
|
|
123
|
+
)}
|
|
124
|
+
<StyledItem
|
|
125
|
+
theme={activeTheme}
|
|
126
|
+
onClick={() => {
|
|
127
|
+
if (item.href) onClick(item.href);
|
|
128
|
+
}}
|
|
120
129
|
variant={variant}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
)
|
|
130
|
+
href={item.href}
|
|
131
|
+
title={item.label}
|
|
132
|
+
>
|
|
133
|
+
{/* If label longer than 15chs trim it by css */}
|
|
134
|
+
{item.label}
|
|
135
|
+
</StyledItem>
|
|
136
|
+
</StyledCombo>
|
|
137
|
+
);
|
|
138
|
+
})
|
|
139
|
+
: null;
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<StyledBreadcrumb
|
|
143
|
+
theme={activeTheme}
|
|
144
|
+
isWrap={wrap}
|
|
145
|
+
ref={!wrap ? breadcrumbRef : null}
|
|
146
|
+
isBreadcrumbVisible={isBreadcrumbVisible}
|
|
147
|
+
block={block}
|
|
148
|
+
variant={variant}
|
|
149
|
+
variantSeparator={variantSeparator}
|
|
150
|
+
style={style}
|
|
151
|
+
isPrimary={isPrimary}
|
|
152
|
+
{...props}
|
|
153
|
+
>
|
|
154
|
+
{appLogo && <div className='breadcrumb-icon'>{appLogo}</div>}
|
|
155
|
+
{list}
|
|
156
|
+
</StyledBreadcrumb>
|
|
157
|
+
);
|
|
130
158
|
};
|
|
131
159
|
|
|
132
160
|
Breadcrumb.propTypes = {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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,
|
|
161
|
+
/**
|
|
162
|
+
* Color of text. primary-1, 2, error, etc.
|
|
163
|
+
*/
|
|
164
|
+
variant: PropTypes.string,
|
|
165
|
+
/**
|
|
166
|
+
* Color of separator. primary-1, 2, error, etc.
|
|
167
|
+
*/
|
|
168
|
+
variantSeparator: PropTypes.string,
|
|
169
|
+
/**
|
|
170
|
+
* Click handler
|
|
171
|
+
*/
|
|
172
|
+
onClick: PropTypes.func,
|
|
173
|
+
/**
|
|
174
|
+
* Optional Icon element with app icon
|
|
175
|
+
*/
|
|
176
|
+
appLogo: PropTypes.any,
|
|
177
|
+
/**
|
|
178
|
+
* Optional Icon element with separator icon
|
|
179
|
+
*/
|
|
180
|
+
separator: PropTypes.any,
|
|
181
|
+
/**
|
|
182
|
+
* List of the elements of breadcramb
|
|
183
|
+
*/
|
|
184
|
+
items: PropTypes.array,
|
|
185
|
+
/**
|
|
186
|
+
* Optional width selector
|
|
187
|
+
*/
|
|
188
|
+
block: PropTypes.bool,
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* If true wrap items when shrink else hide
|
|
192
|
+
*/
|
|
193
|
+
wrap: PropTypes.bool,
|
|
194
|
+
/**
|
|
195
|
+
* If true bigger font and margin, if false it means secondary breadcrum with smaller font and less margin
|
|
196
|
+
*/
|
|
197
|
+
isPrimary: PropTypes.bool,
|
|
173
198
|
};
|
|
174
199
|
|
|
175
|
-
StyledBreadcrumb.defaultProps = {
|
|
176
|
-
theme: defaultThemeColor,
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
StyledItem.defaultProps = {
|
|
180
|
-
theme: defaultThemeColor,
|
|
181
|
-
}
|
|
182
|
-
|
|
183
200
|
Breadcrumb.defaultProps = {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
};
|
|
192
|
-
|
|
201
|
+
variant: 'neutral-2',
|
|
202
|
+
variantSeparator: 'neutral-3',
|
|
203
|
+
block: false,
|
|
204
|
+
onClick: undefined,
|
|
205
|
+
wrap: false,
|
|
206
|
+
isPrimary: true,
|
|
207
|
+
};
|
|
@@ -1,64 +1,71 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
1
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import styled, { useTheme } from 'styled-components';
|
|
4
4
|
import defaultStyles from '../constants/defaultStyle';
|
|
5
|
+
import defaultThemeColor from '../constants/defaultThemeColor';
|
|
5
6
|
|
|
6
7
|
const CardWrapper = styled.div`
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
color: ${({ activeTheme }) => activeTheme.textColor};
|
|
10
|
+
padding-top: 25px;
|
|
11
|
+
padding-bottom: 25px;
|
|
12
|
+
padding-left: 32px;
|
|
13
|
+
padding-right: 32px;
|
|
14
|
+
background-color: ${({ activeTheme }) => activeTheme.bgColor};
|
|
15
|
+
width: inherit;
|
|
16
|
+
border-radius: 5px;
|
|
17
|
+
box-shadow: 0px 5px 37px rgba(56, 66, 100, 0.0880136);
|
|
18
|
+
border-color: ${({ activeTheme }) => activeTheme.border};
|
|
19
|
+
transition: all .5s ease .95ms !important;
|
|
20
|
+
|
|
21
|
+
//Set the styles from the default styles object
|
|
22
|
+
${({ inBuiltCss, type }) => {
|
|
23
|
+
if (inBuiltCss) {
|
|
10
24
|
let tempObj = {};
|
|
11
|
-
if (
|
|
12
|
-
for (const property in
|
|
13
|
-
tempObj[property] =
|
|
14
|
-
delete
|
|
25
|
+
if (inBuiltCss[type]) {
|
|
26
|
+
for (const property in inBuiltCss[type]) {
|
|
27
|
+
tempObj[property] = inBuiltCss[type][property];
|
|
28
|
+
delete inBuiltCss.common[property];
|
|
15
29
|
}
|
|
16
|
-
for (const property in
|
|
17
|
-
tempObj[property] =
|
|
30
|
+
for (const property in inBuiltCss['common']) {
|
|
31
|
+
tempObj[property] = inBuiltCss['common'][property];
|
|
18
32
|
}
|
|
19
33
|
}
|
|
20
34
|
return tempObj;
|
|
21
35
|
}
|
|
22
36
|
}}
|
|
23
|
-
|
|
24
|
-
|
|
37
|
+
|
|
38
|
+
// custom styles
|
|
25
39
|
${({ customStyles }) => customStyles}
|
|
26
40
|
`;
|
|
27
41
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
42
|
+
export const CardRef = forwardRef(({ type, header, content, ...props }, ref) => {
|
|
43
|
+
const activeTheme = useTheme() || defaultThemeColor;
|
|
31
44
|
|
|
32
|
-
export const CardRef = forwardRef(({ type, theme, header, content, ...props }, ref) => {
|
|
33
45
|
return (
|
|
34
|
-
<CardWrapper
|
|
46
|
+
<CardWrapper
|
|
47
|
+
inBuiltCss={defaultStyles}
|
|
48
|
+
activeTheme={activeTheme}
|
|
49
|
+
{...props}
|
|
50
|
+
ref={ref}
|
|
51
|
+
>
|
|
35
52
|
{header}
|
|
36
53
|
{content}
|
|
37
54
|
</CardWrapper>
|
|
38
|
-
)
|
|
39
|
-
})
|
|
55
|
+
);
|
|
56
|
+
});
|
|
40
57
|
|
|
41
58
|
CardRef.propTypes = {
|
|
42
|
-
/**
|
|
43
|
-
* theme Object
|
|
44
|
-
*/
|
|
45
|
-
theme: PropTypes.object,
|
|
46
59
|
/**
|
|
47
60
|
* the type of the element
|
|
48
|
-
|
|
61
|
+
*/
|
|
49
62
|
type: PropTypes.string,
|
|
50
63
|
/**
|
|
51
|
-
|
|
64
|
+
* header of the card
|
|
52
65
|
*/
|
|
53
66
|
header: PropTypes.any,
|
|
54
67
|
/**
|
|
55
68
|
* the content of the card
|
|
56
|
-
|
|
69
|
+
*/
|
|
57
70
|
content: PropTypes.any,
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
CardRef.defaultProps = {
|
|
61
|
-
theme: defaultStyles,
|
|
62
|
-
type: 'card',
|
|
63
|
-
}
|
|
64
|
-
|
|
71
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
2
|
+
import React from "react";
|
|
3
|
+
import styled from 'styled-components';
|
|
4
4
|
import defaultStyles from '../constants/defaultStyle';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -26,68 +26,59 @@ import defaultStyles from '../constants/defaultStyle';
|
|
|
26
26
|
|
|
27
27
|
const StyledContainer = styled.div`
|
|
28
28
|
//Set the styles from the default styles object
|
|
29
|
-
${({
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return { ...tempObj, ...customStyles };
|
|
29
|
+
${({ inBuiltCss, type, drawerOpen, customStyles }) => {
|
|
30
|
+
if (inBuiltCss) {
|
|
31
|
+
let tempObj = {};
|
|
32
|
+
if (inBuiltCss[type]) {
|
|
33
|
+
for (const property in inBuiltCss['common']) {
|
|
34
|
+
tempObj[property] = inBuiltCss['common'][property]
|
|
35
|
+
}
|
|
36
|
+
for (const property in inBuiltCss[type]) {
|
|
37
|
+
delete inBuiltCss.common[property]
|
|
38
|
+
tempObj[property] = inBuiltCss[type][property]
|
|
39
|
+
}
|
|
40
|
+
if (drawerOpen) {
|
|
41
|
+
tempObj = { ...tempObj, ...inBuiltCss['drawer-open'] }
|
|
42
|
+
} else {
|
|
43
|
+
tempObj = { ...tempObj, ...inBuiltCss['drawer-close'] }
|
|
47
44
|
}
|
|
48
|
-
|
|
45
|
+
}
|
|
46
|
+
return { ...tempObj, ...customStyles };
|
|
47
|
+
}
|
|
48
|
+
}}
|
|
49
49
|
`;
|
|
50
50
|
|
|
51
51
|
export const Drawer = ({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
...props
|
|
52
|
+
customStyles,
|
|
53
|
+
drawerOpen,
|
|
54
|
+
children,
|
|
55
|
+
...props
|
|
57
56
|
}) => {
|
|
58
57
|
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
// return ReactDom.createPortal(
|
|
60
|
+
return (
|
|
61
|
+
<StyledContainer
|
|
62
|
+
inBuiltCss={defaultStyles}
|
|
63
|
+
customStyles={customStyles}
|
|
64
|
+
type={'drawer'}
|
|
65
|
+
drawerOpen={drawerOpen}
|
|
66
|
+
{...props}
|
|
67
|
+
>
|
|
68
|
+
{children}
|
|
69
|
+
</StyledContainer>
|
|
71
70
|
|
|
72
|
-
|
|
71
|
+
);
|
|
73
72
|
};
|
|
74
73
|
|
|
75
74
|
Drawer.propTypes = {
|
|
76
|
-
/**
|
|
77
|
-
* Theme object
|
|
78
|
-
*/
|
|
79
|
-
theme: PropTypes.object,
|
|
80
|
-
/**
|
|
81
|
-
* Custom style object
|
|
82
|
-
*/
|
|
83
|
-
customStyles: PropTypes.object,
|
|
84
|
-
/**
|
|
85
|
-
* Boolean value to to open and close the drawer
|
|
86
|
-
*/
|
|
87
|
-
drawerOpen: PropTypes.bool,
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
Drawer.defaultProps = {
|
|
91
|
-
theme: defaultStyles,
|
|
92
|
-
};
|
|
93
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Custom style object
|
|
78
|
+
*/
|
|
79
|
+
customStyles: PropTypes.object,
|
|
80
|
+
/**
|
|
81
|
+
* Boolean value to to open and close the drawer
|
|
82
|
+
*/
|
|
83
|
+
drawerOpen: PropTypes.bool,
|
|
84
|
+
};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef } from "react";
|
|
2
1
|
import PropTypes from 'prop-types';
|
|
2
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import defaultStyles from '../constants/defaultStyle';
|
|
5
5
|
|
|
6
6
|
const ImageLayout = styled.img`
|
|
7
7
|
//Set the styles from the default styles object
|
|
8
|
-
${({
|
|
9
|
-
if (
|
|
8
|
+
${({ inBuiltCss, type, size, customStyles }) => {
|
|
9
|
+
if (inBuiltCss) {
|
|
10
10
|
let tempObj = {};
|
|
11
|
-
if (
|
|
12
|
-
for (const property in
|
|
13
|
-
tempObj[property] =
|
|
11
|
+
if (inBuiltCss[type]) {
|
|
12
|
+
for (const property in inBuiltCss['common']) {
|
|
13
|
+
tempObj[property] = inBuiltCss['common'][property]
|
|
14
14
|
}
|
|
15
|
-
for (const property in
|
|
16
|
-
tempObj[property] =
|
|
17
|
-
delete
|
|
15
|
+
for (const property in inBuiltCss[type]) {
|
|
16
|
+
tempObj[property] = inBuiltCss[type][property]
|
|
17
|
+
delete inBuiltCss.common[property]
|
|
18
18
|
}
|
|
19
|
-
for (const property in
|
|
20
|
-
tempObj[property] =
|
|
21
|
-
delete
|
|
19
|
+
for (const property in inBuiltCss[`${type}${size}`]) {
|
|
20
|
+
tempObj[property] = inBuiltCss[`${type}${size}`][property]
|
|
21
|
+
delete inBuiltCss.common[property]
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
return { ...tempObj, ...customStyles };
|
|
@@ -26,7 +26,7 @@ const ImageLayout = styled.img`
|
|
|
26
26
|
}}
|
|
27
27
|
`;
|
|
28
28
|
|
|
29
|
-
export const Image = ({
|
|
29
|
+
export const Image = ({ customStyles, type, size, alt, src, handleImageStatus, ...props }) => {
|
|
30
30
|
|
|
31
31
|
const [imageStatus, setImageStatus] = useState("loading");
|
|
32
32
|
|
|
@@ -58,7 +58,7 @@ export const Image = ({ theme, customStyles, type, size, alt, src, handleImageSt
|
|
|
58
58
|
return (
|
|
59
59
|
<ImageLayout
|
|
60
60
|
{...props}
|
|
61
|
-
|
|
61
|
+
inBuiltCss={defaultStyles}
|
|
62
62
|
customStyles={customStyles}
|
|
63
63
|
type={type}
|
|
64
64
|
alt={alt}
|
|
@@ -70,10 +70,7 @@ export const Image = ({ theme, customStyles, type, size, alt, src, handleImageSt
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
Image.propTypes = {
|
|
73
|
-
|
|
74
|
-
* Theme props
|
|
75
|
-
*/
|
|
76
|
-
theme: PropTypes.object,
|
|
73
|
+
|
|
77
74
|
/**
|
|
78
75
|
* Custom style object
|
|
79
76
|
*/
|
|
@@ -102,11 +99,9 @@ Image.propTypes = {
|
|
|
102
99
|
}
|
|
103
100
|
|
|
104
101
|
Image.defaultProps = {
|
|
105
|
-
theme: defaultStyles,
|
|
106
102
|
customStyles: null,
|
|
107
103
|
type: 'image',
|
|
108
104
|
alt: 'image alternative',
|
|
109
105
|
src: null,
|
|
110
106
|
handleImageStatus: null
|
|
111
|
-
}
|
|
112
|
-
|
|
107
|
+
}
|