Skip to content

Commit

Permalink
disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSammyM committed Dec 1, 2024
1 parent b5f29ec commit 9321c2b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions client/src/components/DetailsSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,32 @@ export default function DetailsSummary(props: Readonly<{
children?: ReactNode,
defaultOpen?: boolean,
open?: boolean,
disabled?: boolean,
onClick?: () => void
}>): ReactElement {

const [openState, setOpen] = React.useState(props.defaultOpen??false);

const open = useMemo(() => {
if(props.disabled) return false;
if(props.open !== undefined) return props.open;
return openState;
}, [props.open, openState]);
}, [props.open, openState, props.disabled]);

return <div className="details-summary-container">
<div className="details-summary-summary-container"
onClick={() => {
if(props.disabled) return;
setOpen(!open);
if(props.onClick) props.onClick();
}}
>
{props.dropdownArrow === undefined || props.dropdownArrow === true ?
<Icon>{open ? "expand_more" : "expand_less"}</Icon> :
{(props.dropdownArrow === undefined || props.dropdownArrow === true) ?
((props.disabled === undefined || props.disabled===false) ?
<Icon>{open ? "expand_more" : "expand_less"}</Icon>
:
<Icon>close</Icon>
) :
null
}
{props.summary}
Expand Down

0 comments on commit 9321c2b

Please sign in to comment.