fix collapse icon

This commit is contained in:
Aykut Saraç 2022-02-16 23:29:55 +03:00
parent bbf98a958f
commit 5394bbb0b3

View File

@ -22,13 +22,19 @@ const StyledEditorWrapper = styled.div`
const StyledErrorWrapper = styled.div``; const StyledErrorWrapper = styled.div``;
const StyledErrorHeader = styled.div` const StyledErrorHeader = styled.a`
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center;
background: ${({ theme }) => theme.BLACK_DARK}; background: ${({ theme }) => theme.BLACK_DARK};
padding: 6px 12px; padding: 6px 12px;
color: ${({ theme }) => theme.DANGER}; color: ${({ theme }) => theme.DANGER};
font-size: 22px; font-size: 22px;
cursor: pointer;
&:hover {
color: ${({ theme }) => theme.DANGER};
}
`; `;
const StyledTitle = styled.span` const StyledTitle = styled.span`
@ -39,19 +45,6 @@ const StyledTitle = styled.span`
gap: 10px; gap: 10px;
`; `;
const StyledCollapse = styled.button`
display: flex;
justify-content: center;
align-items: center;
background: none;
color: ${({ theme }) => theme.DANGER};
cursor: pointer;
&:hover {
box-shadow: none;
}
`;
const StyledError = styled.pre` const StyledError = styled.pre`
color: ${({ theme }) => theme.DANGER}; color: ${({ theme }) => theme.DANGER};
border: 1px solid ${({ theme }) => theme.SILVER_DARK}; border: 1px solid ${({ theme }) => theme.SILVER_DARK};
@ -142,17 +135,19 @@ const JsonEditor: React.FC<{
<StyledEditorWrapper> <StyledEditorWrapper>
{error.message && ( {error.message && (
<StyledErrorWrapper> <StyledErrorWrapper>
<StyledErrorHeader> <StyledErrorHeader
onClick={() =>
setError((err) => ({ ...err, isExpanded: !err.isExpanded }))
}
>
<StyledTitle> <StyledTitle>
<MdReportGmailerrorred size={26} /> Error <MdReportGmailerrorred size={26} /> Error
</StyledTitle> </StyledTitle>
<StyledCollapse {error.isExpanded ? (
onClick={() => <MdExpandLess size={22} />
setError((err) => ({ ...err, isExpanded: !err.isExpanded })) ) : (
} <MdExpandMore size={22} />
> )}
{true ? <MdExpandMore size={22} /> : <MdExpandLess size={22} />}
</StyledCollapse>
</StyledErrorHeader> </StyledErrorHeader>
{error.isExpanded && <StyledError>{error.message}</StyledError>} {error.isExpanded && <StyledError>{error.message}</StyledError>}
</StyledErrorWrapper> </StyledErrorWrapper>