errors in bottom panel are collapsible
This commit is contained in:
parent
297905a4af
commit
60a7d12857
6 changed files with 74 additions and 69 deletions
15
src/App/PersistentDetails.tsx
Normal file
15
src/App/PersistentDetails.tsx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { usePersistentState } from "@/util/persistent_state"
|
||||
import { DetailsHTMLAttributes, PropsWithChildren } from "react";
|
||||
|
||||
type Props = {
|
||||
localStorageKey: string,
|
||||
initiallyOpen?: boolean,
|
||||
} & DetailsHTMLAttributes<HTMLDetailsElement>;
|
||||
|
||||
// A <details> node that remembers whether it was open or closed by storing that state in localStorage.
|
||||
export function PersistentDetails({localStorageKey, initiallyOpen, children, ...rest}: PropsWithChildren<Props>) {
|
||||
const [open, setOpen] = usePersistentState(localStorageKey, initiallyOpen);
|
||||
return <details open={open} onToggle={e => setOpen(e.newState === "open")} {...rest}>
|
||||
{children}
|
||||
</details>;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue