|
@@ -15,9 +15,15 @@ interface Props {
|
|
|
expandedIndex: number;
|
|
|
items: AccordionItemContent[];
|
|
|
setExpandedIndex: (index: number) => void;
|
|
|
+ buttonOnLeft?: boolean;
|
|
|
}
|
|
|
|
|
|
-export default function Accordion({expandedIndex, setExpandedIndex, items}: Props) {
|
|
|
+export default function Accordion({
|
|
|
+ expandedIndex,
|
|
|
+ setExpandedIndex,
|
|
|
+ items,
|
|
|
+ buttonOnLeft,
|
|
|
+}: Props) {
|
|
|
return (
|
|
|
<AccordionContainer>
|
|
|
{items.map((item, index) => (
|
|
@@ -27,6 +33,7 @@ export default function Accordion({expandedIndex, setExpandedIndex, items}: Prop
|
|
|
key={index}
|
|
|
content={item.content()}
|
|
|
setExpandedIndex={setExpandedIndex}
|
|
|
+ buttonOnLeft={buttonOnLeft}
|
|
|
>
|
|
|
{item.header()}
|
|
|
</AccordionItem>
|
|
@@ -41,14 +48,31 @@ function AccordionItem({
|
|
|
children,
|
|
|
setExpandedIndex,
|
|
|
content,
|
|
|
+ buttonOnLeft,
|
|
|
}: {
|
|
|
children: ReactNode;
|
|
|
content: ReactNode;
|
|
|
currentIndex: number;
|
|
|
isExpanded: boolean;
|
|
|
setExpandedIndex: (index: number) => void;
|
|
|
+ buttonOnLeft?: boolean;
|
|
|
}) {
|
|
|
- return (
|
|
|
+ return buttonOnLeft ? (
|
|
|
+ <StyledLineItem>
|
|
|
+ <ButtonLeftListItemContainer>
|
|
|
+ <Button
|
|
|
+ icon={<IconChevron size="xs" direction={isExpanded ? 'up' : 'down'} />}
|
|
|
+ aria-label={t('Expand')}
|
|
|
+ aria-expanded={isExpanded}
|
|
|
+ size="zero"
|
|
|
+ borderless
|
|
|
+ onClick={() => setExpandedIndex(index)}
|
|
|
+ />
|
|
|
+ {children}
|
|
|
+ </ButtonLeftListItemContainer>
|
|
|
+ <LeftContentContainer>{isExpanded && content}</LeftContentContainer>
|
|
|
+ </StyledLineItem>
|
|
|
+ ) : (
|
|
|
<StyledLineItem>
|
|
|
<ListItemContainer>
|
|
|
{children}
|
|
@@ -76,6 +100,14 @@ const AccordionContainer = styled('ul')`
|
|
|
list-style-type: none;
|
|
|
`;
|
|
|
|
|
|
+const ButtonLeftListItemContainer = styled('div')`
|
|
|
+ display: flex;
|
|
|
+ border-top: 1px solid ${p => p.theme.border};
|
|
|
+ padding: ${space(1)} ${space(2)};
|
|
|
+ font-size: ${p => p.theme.fontSizeMedium};
|
|
|
+ column-gap: ${space(1.5)};
|
|
|
+`;
|
|
|
+
|
|
|
const ListItemContainer = styled('div')`
|
|
|
display: flex;
|
|
|
border-top: 1px solid ${p => p.theme.border};
|
|
@@ -86,3 +118,7 @@ const ListItemContainer = styled('div')`
|
|
|
const StyledContentContainer = styled('div')`
|
|
|
padding: ${space(0)} ${space(2)};
|
|
|
`;
|
|
|
+
|
|
|
+const LeftContentContainer = styled('div')`
|
|
|
+ padding: ${space(0)} ${space(0.25)};
|
|
|
+`;
|