feat: add DrawerClose

This commit is contained in:
p-sw 2024-06-01 20:48:04 +09:00
parent 92eeed2700
commit 91ccb82929

View File

@ -317,4 +317,18 @@ const DrawerContent = forwardRef<HTMLDivElement, DrawerContentProps>(
}
);
export { DrawerRoot, DrawerTrigger, DrawerOverlay, DrawerContent };
const DrawerClose = forwardRef<
HTMLButtonElement,
ComponentPropsWithoutRef<"button">
>((props, ref) => {
const [_, setState] = useContext(DrawerContext);
return (
<Slot
ref={ref}
{...props}
onClick={() => setState((prev) => ({ ...prev, opened: false }))}
/>
);
});
export { DrawerRoot, DrawerTrigger, DrawerOverlay, DrawerContent, DrawerClose };