Skip to content

Commit

Permalink
Access user guide: collapse everything but current accordion on click (
Browse files Browse the repository at this point in the history
  • Loading branch information
savathoon authored Oct 28, 2024
1 parent 1c1ff99 commit 45292a0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,19 @@ interface AccordionMakerProps {
}

function AccordionMaker(props: AccordionMakerProps) {
const [expanded, setExpanded] = React.useState<string | false>(false);

const handleChange = (panel: string) => (event: React.SyntheticEvent, newExpanded: boolean) => {
setExpanded(newExpanded ? panel : false);
};

return (
<>
<Typography variant="h4" color="primary" sx={{margin: '15px 0'}}>
{sections[props.which][0]}
</Typography>
{Object.entries(guide[props.which]).map(([key, value]: [string, string]) => (
<Accordion>
<Accordion expanded={expanded === key} onChange={handleChange(key)}>
<AccordionSummary
expandIcon={<ExpandMoreIcon />}
aria-controls={'panel-content' + key}
Expand Down

0 comments on commit 45292a0

Please sign in to comment.