Last active
August 9, 2021 21:04
-
-
Save nautilytics/2ab6b81db299f340c29e37c0a099e7d0 to your computer and use it in GitHub Desktop.
Base Web Accordion with Panel Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import { | |
StatelessAccordion, | |
} from 'baseui/accordion'; | |
import type { | |
StatelessAccordionProps, | |
} from 'baseui/accordion'; | |
export function Accordion(props: StatelessAccordionProps): JSX.Element { | |
const { | |
children, | |
...otherProps | |
} = props; | |
return ( | |
<StatelessAccordion | |
overrides={{ | |
ToggleIcon: { | |
style: { | |
display: 'none', | |
}, | |
}, | |
}} | |
{...otherProps} | |
> | |
{children} | |
</StatelessAccordion> | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { styled } from 'baseui'; | |
const ColumnLayout = styled('div', { | |
display: 'flex', | |
flexDirection: 'column', | |
}); | |
function CustomPanelContent(props: any): JSX.Element { | |
return ( | |
<ColumnLayout> | |
Lots of content | |
</ColumnLayout> | |
); | |
} | |
export default CustomPanelContent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Panel as BasePanel, styled } from 'baseui'; | |
const ColumnLayout = styled('div', { | |
display: 'flex', | |
flexDirection: 'column', | |
}); | |
function CustomPanelContentNotWorking(props: any): JSX.Element { | |
return ( | |
<BasePanel | |
key='1' | |
title="Panel 1" | |
> | |
<ColumnLayout> | |
Lots of content | |
</ColumnLayout> | |
</BasePanel> | |
); | |
} | |
export default CustomPanelContentNotWorking; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Panel as BasePanel } from 'baseui'; | |
import { Accordion as StatelessAccordion } from './Accordion'; | |
import { CustomPanelContent } from './CustomPanelContent'; | |
function CustomAccordion(props): JSX.Element { | |
const [expanded, setExpanded] = React.useState<React.Key[]>([]); | |
return ( | |
<StatelessAccordion | |
expanded={expanded} | |
accordion={false} | |
onChange={({ key }) => { | |
setExpanded([key]); | |
}} | |
> | |
<BasePanel | |
key='1' | |
title="Panel 1" | |
> | |
<CustomPanelContent /> | |
</BasePanel> | |
<CustomPanelContentNotWorking /> | |
</StatelessAccordion> | |
); | |
} | |
export default CustomAccordion; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment