|
@@ -1,5 +1,6 @@
|
|
|
import React, { useEffect, useState } from "react";
|
|
import React, { useEffect, useState } from "react";
|
|
|
import styled from "styled-components";
|
|
import styled from "styled-components";
|
|
|
|
|
+import Container from "./Container";
|
|
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
|
isInitiallyExpanded?: boolean;
|
|
isInitiallyExpanded?: boolean;
|
|
@@ -7,6 +8,10 @@ type Props = {
|
|
|
ExpandedSection: any;
|
|
ExpandedSection: any;
|
|
|
color?: any;
|
|
color?: any;
|
|
|
background?: string;
|
|
background?: string;
|
|
|
|
|
+ noWrapper?: boolean;
|
|
|
|
|
+ expandText?: string;
|
|
|
|
|
+ collapseText?: string;
|
|
|
|
|
+ maxHeight?: string;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const ExpandableSection: React.FC<Props> = ({
|
|
const ExpandableSection: React.FC<Props> = ({
|
|
@@ -15,6 +20,10 @@ const ExpandableSection: React.FC<Props> = ({
|
|
|
ExpandedSection,
|
|
ExpandedSection,
|
|
|
color,
|
|
color,
|
|
|
background,
|
|
background,
|
|
|
|
|
+ noWrapper,
|
|
|
|
|
+ expandText,
|
|
|
|
|
+ collapseText,
|
|
|
|
|
+ maxHeight,
|
|
|
}) => {
|
|
}) => {
|
|
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
@@ -25,15 +34,26 @@ const ExpandableSection: React.FC<Props> = ({
|
|
|
<StyledExpandableSection
|
|
<StyledExpandableSection
|
|
|
isExpanded={isExpanded}
|
|
isExpanded={isExpanded}
|
|
|
background={background}
|
|
background={background}
|
|
|
|
|
+ noWrapper={noWrapper}
|
|
|
|
|
+ maxHeight={maxHeight}
|
|
|
>
|
|
>
|
|
|
- <HeaderRow
|
|
|
|
|
- isExpanded={isExpanded}
|
|
|
|
|
- onClick={() => setIsExpanded(!isExpanded)}
|
|
|
|
|
- color={color}
|
|
|
|
|
- >
|
|
|
|
|
- <i className="material-icons">arrow_drop_down</i>
|
|
|
|
|
- {Header}
|
|
|
|
|
- </HeaderRow>
|
|
|
|
|
|
|
+ {noWrapper ? (
|
|
|
|
|
+ <Container row>
|
|
|
|
|
+ {Header}
|
|
|
|
|
+ <ExpandButton onClick={() => setIsExpanded(!isExpanded)}>
|
|
|
|
|
+ {isExpanded ? collapseText : expandText}
|
|
|
|
|
+ </ExpandButton>
|
|
|
|
|
+ </Container>
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ <HeaderRow
|
|
|
|
|
+ isExpanded={isExpanded}
|
|
|
|
|
+ onClick={() => setIsExpanded(!isExpanded)}
|
|
|
|
|
+ color={color}
|
|
|
|
|
+ >
|
|
|
|
|
+ {!noWrapper && <i className="material-icons">arrow_drop_down</i>}
|
|
|
|
|
+ {Header}
|
|
|
|
|
+ </HeaderRow>
|
|
|
|
|
+ )}
|
|
|
{
|
|
{
|
|
|
isExpanded && (
|
|
isExpanded && (
|
|
|
ExpandedSection
|
|
ExpandedSection
|
|
@@ -45,6 +65,13 @@ const ExpandableSection: React.FC<Props> = ({
|
|
|
|
|
|
|
|
export default ExpandableSection;
|
|
export default ExpandableSection;
|
|
|
|
|
|
|
|
|
|
+const ExpandButton = styled.div`
|
|
|
|
|
+ margin-left: 15px;
|
|
|
|
|
+ color: #aaaabb;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ font-size: 13px;
|
|
|
|
|
+`;
|
|
|
|
|
+
|
|
|
const HeaderRow = styled.div<{
|
|
const HeaderRow = styled.div<{
|
|
|
isExpanded: boolean;
|
|
isExpanded: boolean;
|
|
|
color?: string;
|
|
color?: string;
|
|
@@ -74,16 +101,17 @@ const HeaderRow = styled.div<{
|
|
|
const StyledExpandableSection = styled.div<{
|
|
const StyledExpandableSection = styled.div<{
|
|
|
isExpanded: boolean;
|
|
isExpanded: boolean;
|
|
|
background?: string;
|
|
background?: string;
|
|
|
|
|
+ noWrapper?: boolean;
|
|
|
}>`
|
|
}>`
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
- height: ${props => props.isExpanded ? "" : "40px"};
|
|
|
|
|
- max-height: 255px;
|
|
|
|
|
|
|
+ height: ${props => (props.isExpanded || props.noWrapper) ? "" : "40px"};
|
|
|
|
|
+ max-height: 300px;
|
|
|
overflow: hidden;
|
|
overflow: hidden;
|
|
|
border-radius: 5px;
|
|
border-radius: 5px;
|
|
|
- background: ${props => props.background || "#26292e"};
|
|
|
|
|
- border: 1px solid #494b4f;
|
|
|
|
|
|
|
+ background: ${props => !props.noWrapper && (props.background || "#26292e")};
|
|
|
|
|
+ border: ${props => !props.noWrapper && "1px solid #494b4f"};
|
|
|
:hover {
|
|
:hover {
|
|
|
- border: 1px solid #7a7b80;
|
|
|
|
|
|
|
+ border: ${props => !props.noWrapper && "1px solid #7a7b80"};
|
|
|
}
|
|
}
|
|
|
animation: ${props => props.isExpanded ? "expandRevisions 0.3s" : ""};
|
|
animation: ${props => props.isExpanded ? "expandRevisions 0.3s" : ""};
|
|
|
animation-timing-function: ease-out;
|
|
animation-timing-function: ease-out;
|
|
@@ -92,7 +120,7 @@ const StyledExpandableSection = styled.div<{
|
|
|
max-height: 40px;
|
|
max-height: 40px;
|
|
|
}
|
|
}
|
|
|
to {
|
|
to {
|
|
|
- max-height: 250px;
|
|
|
|
|
|
|
+ max-height: 300px;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
`;
|
|
`;
|