Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

RightPanelSheet.tsx

35 lines1.1 KB

1import { type ReactNode, useContext } from "react";
2​
3import { KeptViewWarmingContext } from "./keptView";
4import { Sheet, SheetPopup } from "./ui/sheet";
5​
6export function RightPanelSheet(props: {
7 animationDurationMs: number;
8 children: ReactNode;
9 open: boolean;
10 onClose: () => void;
11}) {
12 // A view warming out of sight must not lock the page or hide it from the shown thread.
13 const warming = useContext(KeptViewWarmingContext);
14 return (
15 <Sheet
16 modal={!warming}
17 open={props.open}
18 onOpenChange={(open) => {
19 if (!open) {
20 props.onClose();
21 }
22 }}
23 >
24 <SheetPopup
25 transitionDurationMs={props.animationDurationMs}
26 side="right"
27 showCloseButton={false}
28 keepMounted
29 className="w-[min(42vw,28rem)] min-w-80 max-w-[28rem] max-[760px]:w-[min(88vw,24rem)] max-[760px]:min-w-0 wco:mt-(--workspace-topbar-height) wco:h-[calc(100%-var(--workspace-topbar-height))] wco:max-h-[calc(100%-var(--workspace-topbar-height))]"
30 >
31 {props.children}
32 </SheetPopup>
33 </Sheet>
34 );