Skip to content

Instantly share code, notes, and snippets.

@dancasttro
Forked from leonardosal/arccodion.jsx
Created September 20, 2020 22:00
Show Gist options
  • Save dancasttro/cdb5a4a1b5ce7e3c1c6512c2efa9c938 to your computer and use it in GitHub Desktop.
Save dancasttro/cdb5a4a1b5ce7e3c1c6512c2efa9c938 to your computer and use it in GitHub Desktop.
arccodion
import React, { useState } from 'react';
import styled from 'styled-components';
import media from 'styled-media-query';
import * as S from './styles';
import * as T from '../Typograph';
import Icon from '../Icons';
export const Wrapper = styled.div`
padding: 16px;
background: #ffffff;
border: 2px solid #e4e5e8;
box-sizing: border-box;
border-radius: 16px;
margin-bottom: 16px;
${media.greaterThan('medium')`
`}
`;
export const Header = styled.div`
display: flex;
align-items: center;
justify-content: space-between;
`;
export const Body = styled.div``;
export const IconBox = styled.div`
margin-left: 24px;
color: #d53436;
`;
export const TextContent = styled.div``;
const Accordion = ({ title, children }) => {
const [isOpen, setIsOpen] = useState(false);
return (
<S.Wrapper onClick={() => setIsOpen(!isOpen)}>
<S.Header>
<S.TextContent>
<T.ParagraphBold>{title}</T.ParagraphBold>
</S.TextContent>
<S.IconBox>
<Icon name="chevron" />
</S.IconBox>
</S.Header>
{isOpen && (
<S.Body>
<T.ParagraphLight>{children}</T.ParagraphLight>
</S.Body>
)}
</S.Wrapper>
);
};
export default Accordion;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment