Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove padding on left for accordion content , add font to Accordion #792

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/lib/components/accordion/Accordion.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export type AccordionProps = {
style?: React.CSSProperties;
};

const AccordionContainer = styled(Box)`
width: 100%;
height: auto;
`;

const AccordionHeader = styled.button`
-webkit-appearance: none;
-moz-appearance: none;
Expand All @@ -25,8 +30,9 @@ const AccordionHeader = styled.button`
background-color: transparent;
color: ${(props) => props.theme.textPrimary};
padding: 0;
font-family: 'Lato';
`;
const AccordionContainer = styled.div<{
const AccordionContent = styled.div<{
isOpen: boolean;
}>`
overflow: hidden;
Expand All @@ -38,7 +44,7 @@ const AccordionContainer = styled.div<{
visibility: ${(props) => (props.isOpen ? 'visible' : 'hidden')};
`;
const Wrapper = styled.div`
padding: ${spacing.r8} 0 ${spacing.r8} ${spacing.r20};
padding: ${spacing.r8} 0 ${spacing.r8} 0;
`;

export const Accordion = ({ title, id, style, children }: AccordionProps) => {
Expand All @@ -53,7 +59,7 @@ export const Accordion = ({ title, id, style, children }: AccordionProps) => {
};

return (
<Box style={{ width: '100%', height: 'auto' }}>
<AccordionContainer>
<h3 style={{ margin: 0 }}>
<AccordionHeader
type="button"
Expand All @@ -79,7 +85,7 @@ export const Accordion = ({ title, id, style, children }: AccordionProps) => {
</AccordionHeader>
</h3>

<AccordionContainer
<AccordionContent
ref={(element) => {
if (isOpen) {
element?.style.setProperty('height', element.scrollHeight + 'px');
Expand All @@ -93,7 +99,7 @@ export const Accordion = ({ title, id, style, children }: AccordionProps) => {
role="region"
>
<Wrapper style={style}>{children}</Wrapper>
</AccordionContainer>
</Box>
</AccordionContent>
</AccordionContainer>
);
};
Loading