2021-07-05 11:23:23 +01:00
|
|
|
import { ChevronDown } from "@styled-icons/boxicons-regular";
|
|
|
|
|
2021-12-11 14:34:12 +00:00
|
|
|
import { useApplicationState } from "../../mobx/State";
|
2021-07-05 11:23:23 +01:00
|
|
|
|
|
|
|
import Details from "../ui/Details";
|
|
|
|
|
2021-07-04 15:53:06 +01:00
|
|
|
import { Children } from "../../types/Preact";
|
|
|
|
|
|
|
|
interface Props {
|
2021-07-05 11:25:20 +01:00
|
|
|
id: string;
|
|
|
|
defaultValue: boolean;
|
2021-07-04 15:53:06 +01:00
|
|
|
|
2021-07-05 11:25:20 +01:00
|
|
|
sticky?: boolean;
|
|
|
|
large?: boolean;
|
2021-07-04 15:53:06 +01:00
|
|
|
|
2021-07-05 11:25:20 +01:00
|
|
|
summary: Children;
|
|
|
|
children: Children;
|
2021-07-04 15:53:06 +01:00
|
|
|
}
|
|
|
|
|
2021-07-05 11:23:23 +01:00
|
|
|
export default function CollapsibleSection({
|
2021-07-05 11:25:20 +01:00
|
|
|
id,
|
|
|
|
defaultValue,
|
|
|
|
summary,
|
|
|
|
children,
|
|
|
|
...detailsProps
|
2021-07-05 11:23:23 +01:00
|
|
|
}: Props) {
|
2021-12-11 14:34:12 +00:00
|
|
|
const layout = useApplicationState().layout;
|
2021-07-05 11:25:20 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Details
|
2021-12-11 14:34:12 +00:00
|
|
|
open={layout.getSectionState(id, defaultValue)}
|
|
|
|
onToggle={(e) =>
|
|
|
|
layout.setSectionState(id, e.currentTarget.open, defaultValue)
|
|
|
|
}
|
2021-07-05 11:25:20 +01:00
|
|
|
{...detailsProps}>
|
|
|
|
<summary>
|
|
|
|
<div class="padding">
|
|
|
|
<ChevronDown size={20} />
|
|
|
|
{summary}
|
|
|
|
</div>
|
|
|
|
</summary>
|
|
|
|
{children}
|
|
|
|
</Details>
|
|
|
|
);
|
2021-07-04 15:53:06 +01:00
|
|
|
}
|