@@ -7,27 +7,44 @@ const FeatureDetailsWrapper = styled.div`
77 display: inline;
88 cursor: pointer;
99
10- .open {
11- margin: 0rem;
12- list-style: none;
13- height: auto !important;
14- opacity: 1 !important;
10+ .details > * {
11+ max-height: 0;
12+ opacity: 0;
13+ margin: 0;
14+ visibility: hidden;
15+ overflow: hidden;
16+ transition: opacity 0.2s ease-in-out,
17+ max-height 0.3s ease-in-out 0.1s,
18+ margin 0.3s ease-in-out 0.1s,
19+ visibility 0s linear 0.4s;
20+ }
21+
22+ .details > .open {
23+ max-height: 200px;
24+ opacity: 1;
1525 margin-bottom: 1rem;
16- transition: all 0.4s !important;
26+ visibility: visible;
27+ transition: visibility 0s linear,
28+ opacity 0.2s ease-in-out 0.1s,
29+ max-height 0.3s ease-in-out 0.2s,
30+ margin 0.3s ease-in-out 0.2s;
1731 }
1832
1933 .toggle-icon {
2034 width: 1.2rem;
2135 height: 1.2rem;
2236 fill: ${ ( props ) => props . theme . primaryColor } ;
23- transition: 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
37+ transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
38+ }
39+
40+ .toggle-icon.expanded {
41+ transform: rotate(90deg);
2442 }
2543
2644 p {
2745 font-size: 0.9rem;
2846 margin: 0.5rem;
2947 color: ${ ( props ) => props . theme . greyC1C1C1ToGreyB3B3B3 } ;
30- transition: 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
3148 }
3249
3350 .toggle-btn {
@@ -36,17 +53,6 @@ const FeatureDetailsWrapper = styled.div`
3653 vertical-align: middle;
3754 }
3855
39- .closed {
40- opacity: 1;
41- height: 0;
42- transition: none;
43- visibility: hidden;
44- }
45-
46- .open {
47- visibility: visible;
48- }
49-
5056 h5 {
5157 display: inline-block;
5258 vertical-align: middle;
@@ -65,26 +71,25 @@ const FeatureDetailsWrapper = styled.div`
6571 }
6672` ;
6773
68- const FeatureDetails = ( { category, description, tier } ) => {
74+ const FeatureDetails = ( { category, description, tier, children , onToggle } ) => {
6975 const [ expand , setExpand ] = React . useState ( false ) ;
7076
77+ // Call onToggle when expand changes
78+ React . useEffect ( ( ) => {
79+ onToggle ?. ( expand ) ;
80+ } , [ expand , onToggle ] ) ;
81+
7182 const BetaTag = ( ) => < span className = "beta-tag" > Coming Soon</ span > ;
7283
7384 return (
7485 < FeatureDetailsWrapper >
7586 < div onClick = { ( ) => setExpand ( ! expand ) } >
76- { description && (
87+ { ( description || children ) && (
7788 < div className = "toggle-btn" >
7889 { expand ? (
79- < MdExpandMore
80- className = "toggle-icon"
81- onClick = { ( ) => setExpand ( ! expand ) }
82- />
90+ < MdExpandMore className = "toggle-icon" />
8391 ) : (
84- < RiArrowRightSLine
85- className = "toggle-icon"
86- onClick = { ( ) => setExpand ( ! expand ) }
87- />
92+ < RiArrowRightSLine className = "toggle-icon" />
8893 ) }
8994 </ div >
9095 ) }
@@ -93,13 +98,18 @@ const FeatureDetails = ({ category, description, tier }) => {
9398 { tier === "Team-Beta" && < BetaTag /> }
9499 </ h5 >
95100 < div className = "details" >
96- < p className = { `closed ${ expand ? "open" : "" } ` }
97- dangerouslySetInnerHTML = { { __html : description } } >
98- </ p >
101+ { description && (
102+ < p className = { expand ? "open" : "" } dangerouslySetInnerHTML = { { __html : description } } />
103+ ) }
104+ { children && (
105+ < div className = { expand ? "open" : "" } >
106+ { children }
107+ </ div >
108+ ) }
99109 </ div >
100110 </ div >
101111 </ FeatureDetailsWrapper >
102112 ) ;
103113} ;
104114
105- export default FeatureDetails ;
115+ export default FeatureDetails ;
0 commit comments