groundfloor-react-ui 1.0.18 → 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 +83 -33
- 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/Button/PrimaryButton.js +15 -8
- package/components/Button/SecondaryButton.js +11 -9
- package/components/Cards/Card.js +25 -30
- package/components/Cards/CardRef.js +41 -34
- package/components/Cards/DocumentCard.js +83 -89
- package/components/Divider/Divider.js +23 -30
- package/components/Drawer/Drawer.js +46 -55
- package/components/FilterChip/FilterChip.js +34 -32
- package/components/Form/HeaderComponent.js +57 -27
- package/components/GroupAvatars/GroupAvatars.js +12 -16
- package/components/GroupButtons/GroupButtonsPopup.js +3 -9
- package/components/Images/Image.js +16 -21
- package/components/Inputs/CheckBoxInput.js +71 -33
- package/components/Inputs/DateSelect.js +22 -17
- package/components/Inputs/DropdownSelect.js +86 -30
- package/components/Inputs/DropzoneInput.js +83 -68
- package/components/Inputs/NumericInput.js +66 -63
- package/components/Inputs/PasswordInput.js +36 -27
- package/components/Inputs/RadioInput.js +55 -29
- package/components/Inputs/Signature.js +88 -38
- package/components/Inputs/TextArea.js +24 -40
- package/components/Inputs/TextInput.js +43 -28
- package/components/Inputs/TimeInput.js +92 -107
- package/components/Inputs/ToggleSwitch.js +87 -59
- package/components/Modal/ModalComp.js +61 -37
- package/components/Pagination/Pagination.js +30 -54
- package/components/ProgressBar/ProgressBar.js +57 -40
- package/components/Rating/Rating.js +8 -14
- package/components/Sidebar/Navbar.js +196 -170
- package/components/Tables/Table.js +56 -34
- package/components/Tooltip/Tooltip.js +135 -141
- package/components/Typography/Typography.js +9 -10
- package/components/constants/defaultStyle.js +38 -41
- package/dist/index.es.js +675 -596
- package/dist/index.js +660 -581
- package/package.json +1 -1
|
@@ -1,14 +1,28 @@
|
|
|
1
|
-
import React, { useState, useRef } from "react";
|
|
2
1
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import styled, { useTheme } from 'styled-components';
|
|
4
|
+
import { Card, CardRef } from '../Cards';
|
|
5
|
+
import defaultThemeColor from '../constants/defaultThemeColor';
|
|
6
|
+
import { Icon } from '../Icon';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Primary UI component for user interaction
|
|
8
10
|
*/
|
|
9
11
|
|
|
12
|
+
const Wrapper = styled.div`
|
|
13
|
+
display: flex;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
align-items: center;
|
|
16
|
+
|
|
17
|
+
span {
|
|
18
|
+
margin-right: 5px;
|
|
19
|
+
margin-left: 5px;
|
|
20
|
+
font-size: 12px;
|
|
21
|
+
color: ${({ theme }) => theme.neutral['neutral-3']};
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
|
|
10
25
|
export const Accordion = ({
|
|
11
|
-
theme,
|
|
12
26
|
customStylesAccordionContainer,
|
|
13
27
|
customStylesAccordionTogggle,
|
|
14
28
|
customStylesAccordionIcon,
|
|
@@ -17,60 +31,95 @@ export const Accordion = ({
|
|
|
17
31
|
icon,
|
|
18
32
|
content,
|
|
19
33
|
contentToggle,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
34
|
+
toggleState,
|
|
35
|
+
contentIsOpen,
|
|
36
|
+
...props
|
|
37
|
+
}) => {
|
|
38
|
+
// const [contentIsOpen, setContentIsOpen] = useState(false);
|
|
23
39
|
const contentRef = useRef(null); //Used to get the height of the content
|
|
40
|
+
const activeTheme = useTheme() || defaultThemeColor;
|
|
41
|
+
const [height, setHeight] = useState(0)
|
|
42
|
+
const [contentVisibility, setcontentVisibility] = useState(false);
|
|
43
|
+
|
|
44
|
+
// useEffect(() => {
|
|
45
|
+
// setHeight(contentRef.current.scrollHeight);
|
|
46
|
+
// }, [content])
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
setcontentVisibility(contentIsOpen)
|
|
50
|
+
}, [contentIsOpen])
|
|
51
|
+
|
|
24
52
|
|
|
25
53
|
return (
|
|
26
54
|
<Card
|
|
27
|
-
theme={theme}
|
|
28
55
|
customStyles={customStylesAccordionContainer}
|
|
29
56
|
type={'accordionContainer'}
|
|
30
57
|
{...props}
|
|
31
58
|
header={
|
|
32
59
|
<Card
|
|
33
|
-
theme={theme}
|
|
34
60
|
customStyles={customStylesAccordionTogggle}
|
|
35
61
|
type={'accordionToggle'}
|
|
36
62
|
{...props}
|
|
37
|
-
onClick={() => {
|
|
63
|
+
onClick={() => {
|
|
64
|
+
setcontentVisibility(!contentVisibility);
|
|
65
|
+
}}
|
|
38
66
|
header={contentToggle} //Label of the toggle
|
|
39
|
-
content={
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
67
|
+
content={
|
|
68
|
+
//Icon of the toggle
|
|
69
|
+
|
|
70
|
+
<Wrapper theme={activeTheme}>
|
|
71
|
+
<span>{!contentVisibility ? 'Click to open' : 'Click to hide'}</span>
|
|
72
|
+
<div
|
|
73
|
+
style={
|
|
74
|
+
toggleIconAnimation && contentVisibility
|
|
75
|
+
? {
|
|
76
|
+
transform: 'rotate(180deg)',
|
|
77
|
+
transition: 'transform ease 95ms',
|
|
78
|
+
background: 'transparent',
|
|
79
|
+
}
|
|
80
|
+
: {
|
|
81
|
+
transform: 'rotate(0deg)',
|
|
82
|
+
transition: 'transform ease 95ms',
|
|
83
|
+
background: 'transparent',
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
>
|
|
87
|
+
{icon ? (
|
|
88
|
+
icon
|
|
89
|
+
) : (
|
|
90
|
+
<Icon
|
|
91
|
+
icon='chevron-down'
|
|
92
|
+
size={11}
|
|
93
|
+
transform={'translate(0px,-1px)'}
|
|
94
|
+
color='#A9B1B8'
|
|
95
|
+
/>
|
|
96
|
+
)}
|
|
97
|
+
</div>
|
|
98
|
+
</Wrapper>
|
|
99
|
+
}
|
|
50
100
|
/>
|
|
51
101
|
}
|
|
52
102
|
content={
|
|
103
|
+
|
|
53
104
|
<CardRef
|
|
54
|
-
theme={theme}
|
|
55
105
|
customStyles={customStylesAccordionContent}
|
|
56
106
|
type={'accordionContent'}
|
|
57
107
|
ref={contentRef}
|
|
58
108
|
// contentIsOpen={contentIsOpen}
|
|
59
109
|
{...props}
|
|
60
110
|
style={
|
|
61
|
-
|
|
111
|
+
contentVisibility
|
|
112
|
+
? { minHeight: contentRef.current.scrollHeight + 'px', borderColor: activeTheme.borderColor }
|
|
113
|
+
: { height: '0px', borderBottom: 'none' }
|
|
62
114
|
}
|
|
63
115
|
content={content}
|
|
64
|
-
/>
|
|
116
|
+
/>
|
|
117
|
+
}
|
|
65
118
|
/>
|
|
66
119
|
);
|
|
67
120
|
};
|
|
68
121
|
|
|
69
122
|
Accordion.propTypes = {
|
|
70
|
-
/**
|
|
71
|
-
* Theme object
|
|
72
|
-
*/
|
|
73
|
-
theme: PropTypes.object,
|
|
74
123
|
/**
|
|
75
124
|
* Custom style for the Container
|
|
76
125
|
*/
|
|
@@ -92,7 +141,7 @@ Accordion.propTypes = {
|
|
|
92
141
|
*/
|
|
93
142
|
toggleIconAnimation: PropTypes.bool,
|
|
94
143
|
/**
|
|
95
|
-
* Icon to apply rotation animation when toggle accordion
|
|
144
|
+
* Icon to apply rotation animation when toggle accordion
|
|
96
145
|
*/
|
|
97
146
|
icon: PropTypes.any,
|
|
98
147
|
/**
|
|
@@ -103,12 +152,13 @@ Accordion.propTypes = {
|
|
|
103
152
|
* String or element to be display in the header of the accordion
|
|
104
153
|
*/
|
|
105
154
|
contentToggle: PropTypes.any,
|
|
155
|
+
toggleState: PropTypes.func,
|
|
106
156
|
};
|
|
107
157
|
|
|
108
158
|
Accordion.defaultProps = {
|
|
109
|
-
theme: defaultStyles,
|
|
110
159
|
contentToggle: 'Toggle',
|
|
111
|
-
content: 'Content'
|
|
112
|
-
|
|
113
|
-
}
|
|
160
|
+
content: 'Content',
|
|
161
|
+
toggleIconAnimation: true,
|
|
162
|
+
toggleState: () => { },
|
|
114
163
|
|
|
164
|
+
};
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef, useMemo } from "react";
|
|
2
1
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { Card, CardRef } from "../Cards";
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Card, CardRef } from '../Cards';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* Primary UI component for user interaction
|
|
9
7
|
*/
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
theme,
|
|
9
|
+
export const AccordionSB = ({
|
|
13
10
|
customStylesAccordionContainer,
|
|
14
11
|
customStylesAccordionTogggle,
|
|
15
12
|
customStylesAccordionIcon,
|
|
@@ -22,14 +19,13 @@ import { Card, CardRef } from "../Cards";
|
|
|
22
19
|
index,
|
|
23
20
|
handleClick,
|
|
24
21
|
isAccordionOpen,
|
|
25
|
-
...props
|
|
26
|
-
|
|
22
|
+
...props
|
|
23
|
+
}) => {
|
|
27
24
|
const [contentIsOpen, setContentIsOpen] = useState(false);
|
|
28
25
|
const contentRef = useRef(null); //Used to get the height of the content
|
|
29
26
|
|
|
30
|
-
const [customStylesContainer, setCustomStylesContainer] = useState({})
|
|
31
|
-
const [customStylesTogggle, setCustomStylesTogggle] = useState({})
|
|
32
|
-
|
|
27
|
+
const [customStylesContainer, setCustomStylesContainer] = useState({});
|
|
28
|
+
const [customStylesTogggle, setCustomStylesTogggle] = useState({});
|
|
33
29
|
|
|
34
30
|
useEffect(() => {
|
|
35
31
|
if (isSelected) {
|
|
@@ -39,9 +35,8 @@ import { Card, CardRef } from "../Cards";
|
|
|
39
35
|
backgroundColor: '#2444d8',
|
|
40
36
|
marginBottom: '15.5px',
|
|
41
37
|
marginTop: index !== 0 ? '15.5px' : '0px',
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
})
|
|
38
|
+
};
|
|
39
|
+
});
|
|
45
40
|
setCustomStylesTogggle((prev) => {
|
|
46
41
|
return {
|
|
47
42
|
...prev,
|
|
@@ -49,82 +44,86 @@ import { Card, CardRef } from "../Cards";
|
|
|
49
44
|
paddingTop: '14px',
|
|
50
45
|
paddingBottom: '14px',
|
|
51
46
|
paddingLeft: '14px',
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
};
|
|
48
|
+
});
|
|
56
49
|
} else {
|
|
57
|
-
setCustomStylesContainer({})
|
|
58
|
-
setCustomStylesTogggle({})
|
|
50
|
+
setCustomStylesContainer({});
|
|
51
|
+
setCustomStylesTogggle({});
|
|
59
52
|
}
|
|
60
|
-
}, [isSelected])
|
|
53
|
+
}, [isSelected]);
|
|
61
54
|
|
|
62
55
|
useEffect(() => {
|
|
63
56
|
if (isAccordionOpen) {
|
|
64
|
-
setContentIsOpen(true)
|
|
57
|
+
setContentIsOpen(true);
|
|
65
58
|
} else {
|
|
66
|
-
setContentIsOpen(false)
|
|
59
|
+
setContentIsOpen(false);
|
|
67
60
|
}
|
|
68
|
-
|
|
69
|
-
}, [isAccordionOpen])
|
|
61
|
+
}, [isAccordionOpen]);
|
|
70
62
|
|
|
71
63
|
return (
|
|
72
64
|
<Card
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
customStyles={{
|
|
66
|
+
...customStylesAccordionContainer,
|
|
67
|
+
...customStylesContainer,
|
|
68
|
+
}}
|
|
75
69
|
type={'accordionContainer'}
|
|
76
70
|
{...props}
|
|
77
|
-
header={
|
|
71
|
+
header={
|
|
72
|
+
//Header of Accordion
|
|
78
73
|
<Card
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
customStyles={{
|
|
75
|
+
...customStylesAccordionTogggle,
|
|
76
|
+
...customStylesTogggle,
|
|
77
|
+
}}
|
|
81
78
|
type={'accordionToggle'}
|
|
82
79
|
{...props}
|
|
83
80
|
// onClick={() => { setContentIsOpen(!contentIsOpen) }}
|
|
84
81
|
onClick={() => {
|
|
85
82
|
if (!contentIsOpen) {
|
|
86
|
-
handleClick(index)
|
|
83
|
+
handleClick(index);
|
|
87
84
|
}
|
|
88
|
-
setContentIsOpen(!contentIsOpen)
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
setContentIsOpen(!contentIsOpen);
|
|
91
86
|
}}
|
|
92
87
|
header={contentToggle} //Label of the toggle
|
|
93
|
-
content={
|
|
88
|
+
content={
|
|
89
|
+
//Icon of the toggle
|
|
94
90
|
<div
|
|
95
|
-
theme={theme}
|
|
96
91
|
style={
|
|
97
|
-
toggleIconAnimation &&
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
toggleIconAnimation && contentIsOpen
|
|
93
|
+
? {
|
|
94
|
+
transform: 'rotate(180deg)',
|
|
95
|
+
transition: 'transform ease 95ms',
|
|
96
|
+
background: 'transparent',
|
|
97
|
+
}
|
|
98
|
+
: { transform: 'rotate(0deg)', background: 'transparent' }
|
|
100
99
|
}
|
|
101
100
|
>
|
|
102
101
|
{icon}
|
|
103
|
-
</div>
|
|
102
|
+
</div>
|
|
103
|
+
}
|
|
104
104
|
/>
|
|
105
105
|
}
|
|
106
|
-
content={
|
|
106
|
+
content={
|
|
107
|
+
//Body of Accordion
|
|
107
108
|
<CardRef
|
|
108
|
-
theme={theme}
|
|
109
109
|
customStyles={customStylesAccordionContent}
|
|
110
110
|
type={'accordionContent'}
|
|
111
111
|
ref={contentRef}
|
|
112
112
|
// contentIsOpen={contentIsOpen}
|
|
113
113
|
{...props}
|
|
114
114
|
style={
|
|
115
|
-
contentIsOpen
|
|
115
|
+
contentIsOpen
|
|
116
|
+
? { height: contentRef.current.scrollHeight + 'px' }
|
|
117
|
+
: { height: '0px', borderBottom: 'none' }
|
|
116
118
|
}
|
|
117
119
|
content={content}
|
|
118
|
-
/>
|
|
120
|
+
/>
|
|
121
|
+
}
|
|
119
122
|
/>
|
|
120
123
|
);
|
|
121
124
|
};
|
|
122
125
|
|
|
123
126
|
AccordionSB.propTypes = {
|
|
124
|
-
/**
|
|
125
|
-
* Theme object
|
|
126
|
-
*/
|
|
127
|
-
theme: PropTypes.object,
|
|
128
127
|
/**
|
|
129
128
|
* Custom style for the Container
|
|
130
129
|
*/
|
|
@@ -146,7 +145,7 @@ AccordionSB.propTypes = {
|
|
|
146
145
|
*/
|
|
147
146
|
toggleIconAnimation: PropTypes.bool,
|
|
148
147
|
/**
|
|
149
|
-
* Icon to apply rotation animation when toggle accordion
|
|
148
|
+
* Icon to apply rotation animation when toggle accordion
|
|
150
149
|
*/
|
|
151
150
|
icon: PropTypes.any,
|
|
152
151
|
/**
|
|
@@ -160,9 +159,6 @@ AccordionSB.propTypes = {
|
|
|
160
159
|
};
|
|
161
160
|
|
|
162
161
|
AccordionSB.defaultProps = {
|
|
163
|
-
theme: defaultStyles,
|
|
164
162
|
contentToggle: 'Toggle',
|
|
165
|
-
content: 'Content'
|
|
166
|
-
|
|
167
|
-
};
|
|
168
|
-
|
|
163
|
+
content: 'Content',
|
|
164
|
+
};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef, useMemo } from "react";
|
|
2
1
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
4
|
-
import { Card, CardRef } from
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Card, CardRef } from '../Cards';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Primary UI component for user interaction
|
|
8
7
|
*/
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
theme,
|
|
9
|
+
export const AccordionSBfooter = ({
|
|
12
10
|
customStylesAccordionContainer,
|
|
13
11
|
customStylesAccordionTogggle,
|
|
14
12
|
customStylesAccordionIcon,
|
|
@@ -22,14 +20,13 @@ import { Card, CardRef } from "../Cards";
|
|
|
22
20
|
handleClick,
|
|
23
21
|
isAccordionOpen,
|
|
24
22
|
disable,
|
|
25
|
-
...props
|
|
26
|
-
|
|
23
|
+
...props
|
|
24
|
+
}) => {
|
|
27
25
|
const [contentIsOpen, setContentIsOpen] = useState(false);
|
|
28
26
|
const contentRef = useRef(null); //Used to get the height of the content
|
|
29
27
|
|
|
30
|
-
const [customStylesContainer, setCustomStylesContainer] = useState({})
|
|
31
|
-
const [customStylesTogggle, setCustomStylesTogggle] = useState({})
|
|
32
|
-
|
|
28
|
+
const [customStylesContainer, setCustomStylesContainer] = useState({});
|
|
29
|
+
const [customStylesTogggle, setCustomStylesTogggle] = useState({});
|
|
33
30
|
|
|
34
31
|
useEffect(() => {
|
|
35
32
|
if (isSelected) {
|
|
@@ -39,9 +36,8 @@ import { Card, CardRef } from "../Cards";
|
|
|
39
36
|
backgroundColor: '#2444d8',
|
|
40
37
|
marginBottom: '15.5px',
|
|
41
38
|
marginTop: index !== 0 ? '15.5px' : '0px',
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
})
|
|
39
|
+
};
|
|
40
|
+
});
|
|
45
41
|
setCustomStylesTogggle((prev) => {
|
|
46
42
|
return {
|
|
47
43
|
...prev,
|
|
@@ -49,85 +45,88 @@ import { Card, CardRef } from "../Cards";
|
|
|
49
45
|
paddingTop: '14px',
|
|
50
46
|
paddingBottom: '14px',
|
|
51
47
|
paddingLeft: '14px',
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
};
|
|
49
|
+
});
|
|
57
50
|
} else {
|
|
58
|
-
setCustomStylesContainer({})
|
|
59
|
-
setCustomStylesTogggle({})
|
|
51
|
+
setCustomStylesContainer({});
|
|
52
|
+
setCustomStylesTogggle({});
|
|
60
53
|
}
|
|
61
|
-
}, [isSelected])
|
|
54
|
+
}, [isSelected]);
|
|
62
55
|
// console.log("customStylesContainer", customStylesContainer)
|
|
63
56
|
|
|
64
57
|
useEffect(() => {
|
|
65
58
|
if (isAccordionOpen) {
|
|
66
|
-
setContentIsOpen(true)
|
|
59
|
+
setContentIsOpen(true);
|
|
67
60
|
} else {
|
|
68
|
-
setContentIsOpen(false)
|
|
61
|
+
setContentIsOpen(false);
|
|
69
62
|
}
|
|
70
|
-
|
|
71
|
-
}, [isAccordionOpen])
|
|
63
|
+
}, [isAccordionOpen]);
|
|
72
64
|
|
|
73
65
|
return (
|
|
74
66
|
<Card
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
customStyles={{
|
|
68
|
+
...customStylesAccordionContainer,
|
|
69
|
+
...customStylesContainer,
|
|
70
|
+
}}
|
|
77
71
|
type={'accordionContainer'}
|
|
78
72
|
{...props}
|
|
79
|
-
header={
|
|
73
|
+
header={
|
|
74
|
+
//Header of Accordion
|
|
80
75
|
<Card
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
customStyles={{
|
|
77
|
+
...customStylesAccordionTogggle,
|
|
78
|
+
...customStylesTogggle,
|
|
79
|
+
}}
|
|
83
80
|
type={'accordionToggle'}
|
|
84
81
|
{...props}
|
|
85
82
|
// onClick={() => { setContentIsOpen(!contentIsOpen) }}
|
|
86
83
|
onClick={() => {
|
|
87
|
-
if (disable) return
|
|
84
|
+
if (disable) return;
|
|
88
85
|
if (!contentIsOpen) {
|
|
89
|
-
handleClick(index)
|
|
86
|
+
handleClick(index);
|
|
90
87
|
}
|
|
91
|
-
setContentIsOpen(!contentIsOpen)
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
setContentIsOpen(!contentIsOpen);
|
|
94
89
|
}}
|
|
95
90
|
header={contentToggle} //Label of the toggle
|
|
96
|
-
content={
|
|
91
|
+
content={
|
|
92
|
+
//Icon of the toggle
|
|
97
93
|
<div
|
|
98
|
-
theme={theme}
|
|
99
94
|
style={
|
|
100
|
-
toggleIconAnimation &&
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
toggleIconAnimation && contentIsOpen
|
|
96
|
+
? {
|
|
97
|
+
transform: 'rotate(180deg)',
|
|
98
|
+
transition: 'transform ease 95ms',
|
|
99
|
+
background: 'transparent',
|
|
100
|
+
}
|
|
101
|
+
: { transform: 'rotate(0deg)', background: 'transparent' }
|
|
103
102
|
}
|
|
104
103
|
>
|
|
105
104
|
{icon}
|
|
106
|
-
</div>
|
|
105
|
+
</div>
|
|
106
|
+
}
|
|
107
107
|
/>
|
|
108
108
|
}
|
|
109
|
-
content={
|
|
109
|
+
content={
|
|
110
|
+
//Body of Accordion
|
|
110
111
|
<CardRef
|
|
111
|
-
theme={theme}
|
|
112
112
|
customStyles={customStylesAccordionContent}
|
|
113
113
|
type={'accordionContent'}
|
|
114
114
|
ref={contentRef}
|
|
115
115
|
// contentIsOpen={contentIsOpen}
|
|
116
116
|
{...props}
|
|
117
117
|
style={
|
|
118
|
-
contentIsOpen
|
|
118
|
+
contentIsOpen
|
|
119
|
+
? { height: contentRef.current.scrollHeight + 'px' }
|
|
120
|
+
: { height: '0px', borderBottom: 'none' }
|
|
119
121
|
}
|
|
120
122
|
content={content}
|
|
121
|
-
/>
|
|
123
|
+
/>
|
|
124
|
+
}
|
|
122
125
|
/>
|
|
123
126
|
);
|
|
124
127
|
};
|
|
125
128
|
|
|
126
129
|
AccordionSBfooter.propTypes = {
|
|
127
|
-
/**
|
|
128
|
-
* Theme object
|
|
129
|
-
*/
|
|
130
|
-
theme: PropTypes.object,
|
|
131
130
|
/**
|
|
132
131
|
* Custom style for the Container
|
|
133
132
|
*/
|
|
@@ -149,7 +148,7 @@ AccordionSBfooter.propTypes = {
|
|
|
149
148
|
*/
|
|
150
149
|
toggleIconAnimation: PropTypes.bool,
|
|
151
150
|
/**
|
|
152
|
-
* Icon to apply rotation animation when toggle accordion
|
|
151
|
+
* Icon to apply rotation animation when toggle accordion
|
|
153
152
|
*/
|
|
154
153
|
icon: PropTypes.any,
|
|
155
154
|
/**
|
|
@@ -163,9 +162,6 @@ AccordionSBfooter.propTypes = {
|
|
|
163
162
|
};
|
|
164
163
|
|
|
165
164
|
AccordionSBfooter.defaultProps = {
|
|
166
|
-
theme: defaultStyles,
|
|
167
165
|
contentToggle: 'Toggle',
|
|
168
|
-
content: 'Content'
|
|
169
|
-
|
|
170
|
-
};
|
|
171
|
-
|
|
166
|
+
content: 'Content',
|
|
167
|
+
};
|
|
@@ -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
|
|
|
@@ -145,7 +145,7 @@ const StyledArrowContent = styled.div`
|
|
|
145
145
|
`;
|
|
146
146
|
|
|
147
147
|
export const ArrowBar = ({ variant, data, scroll, onClick, clickable, ...props }) => {
|
|
148
|
-
const
|
|
148
|
+
const activeTheme = useTheme() || defaultThemeColor;
|
|
149
149
|
|
|
150
150
|
const arrowBarRef = useRef(null)
|
|
151
151
|
const arrowRef = useRef(null)
|
|
@@ -228,11 +228,11 @@ export const ArrowBar = ({ variant, data, scroll, onClick, clickable, ...props }
|
|
|
228
228
|
};
|
|
229
229
|
|
|
230
230
|
return (
|
|
231
|
-
<StyledArrowBar variant={variant} ref={scroll ? null : arrowBarRef} arrowNumber={data.length} scroll={scroll} >
|
|
231
|
+
<StyledArrowBar theme={activeTheme} variant={variant} ref={scroll ? null : arrowBarRef} arrowNumber={data.length} scroll={scroll} >
|
|
232
232
|
{data.map((singleData, index) => {
|
|
233
233
|
return (
|
|
234
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}>
|
|
235
|
+
<StyledArrow theme={activeTheme} onClick={clickable ? (e) => onClick(e, singleData) : null} clickable={clickable} scroll={scroll} ref={scroll ? null : singleData.label === longest.label ? arrowRef : null} key={'fa' + index + '-' + singleData.label} index={index} dataLength={data.length} color={singleData.color}>
|
|
236
236
|
{ArrowContent(singleData.value, singleData.label)}
|
|
237
237
|
</StyledArrow>
|
|
238
238
|
)
|
|
@@ -246,10 +246,7 @@ ArrowBar.propTypes = {
|
|
|
246
246
|
* Color of the arrows text. primary-1, 2, error, etc.
|
|
247
247
|
*/
|
|
248
248
|
variant: PropTypes.string,
|
|
249
|
-
|
|
250
|
-
* Theme object
|
|
251
|
-
*/
|
|
252
|
-
theme: PropTypes.object,
|
|
249
|
+
|
|
253
250
|
/**
|
|
254
251
|
* Array of data. Each element of the array is an object in this format:
|
|
255
252
|
* { value: 16, label: "Complete", color: '#34cc73' },
|
|
@@ -270,24 +267,10 @@ ArrowBar.propTypes = {
|
|
|
270
267
|
clickable: PropTypes.bool,
|
|
271
268
|
}
|
|
272
269
|
|
|
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
270
|
ArrowBar.defaultProps = {
|
|
286
|
-
theme: defaultThemeColor,
|
|
287
271
|
variant: null,
|
|
288
272
|
data: [],
|
|
289
273
|
scroll: true,
|
|
290
274
|
onClick: undefined,
|
|
291
275
|
clickable: false
|
|
292
|
-
}
|
|
293
|
-
|
|
276
|
+
}
|