Skip to content

Commit

Permalink
Add Popup component
Browse files Browse the repository at this point in the history
  • Loading branch information
petertheprocess committed Apr 3, 2024
1 parent 89f2c3a commit 263fdaa
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/components/ui/Popup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, { forwardRef } from "react";
import { Button } from "./Button";

type PopupProps = {
children: React.ReactNode;
toggleDialog: () => void;
};

const Popup = forwardRef<HTMLDivElement, PopupProps>((props, ref) => {
return (
<dialog ref={ref} className="popup"
onClick={
(e) => {
if (e.target === e.currentTarget) {
props.toggleDialog();
}
}
}
>
<div>
{props.children}
<Button onClick={props.toggleDialog}>Close</Button>
</div>
</dialog>
);
});

Popup.displayName = "Popup";

export default Popup;

0 comments on commit 263fdaa

Please sign in to comment.