mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-27 05:07:50 +02:00
♻️ Switch to turborepo (#532)
This commit is contained in:
parent
41ef81aa75
commit
0a836aeec7
419 changed files with 2300 additions and 2504 deletions
27
apps/web/src/components/modal/use-modal.tsx
Normal file
27
apps/web/src/components/modal/use-modal.tsx
Normal file
|
@ -0,0 +1,27 @@
|
|||
import React from "react";
|
||||
|
||||
import Modal, { ModalProps } from "./modal";
|
||||
|
||||
type OpenModalFn = () => void;
|
||||
type CloseModalFn = () => void;
|
||||
|
||||
export const useModal = (
|
||||
props?: ModalProps,
|
||||
): [React.ReactElement<ModalProps>, OpenModalFn, CloseModalFn] => {
|
||||
const [visible, setVisible] = React.useState(false);
|
||||
const modal = (
|
||||
<Modal
|
||||
{...props}
|
||||
visible={visible}
|
||||
onOk={() => {
|
||||
props?.onOk?.();
|
||||
setVisible(false);
|
||||
}}
|
||||
onCancel={() => {
|
||||
props?.onCancel?.();
|
||||
setVisible(false);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
return [modal, () => setVisible(true), () => setVisible(false)];
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue