extracted speeddial
This commit is contained in:
1 parent
fe4f0e9881
commit
6da5a7592e
5 files changed
+117
-52
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import "./index.css";
|
||||
import { FC, ReactNode, useState } from "react";
|
||||
import ClickAwayListener from "@mui/material/ClickAwayListener";
|
||||
|
||||
export type SpeedDialProps = {
|
||||
icon: ReactNode;
|
||||
className?: string;
|
||||
children: ReactNode;
|
||||
direction?: "row" | "column";
|
||||
};
|
||||
export const SpeedDial: FC<SpeedDialProps> = (props) => {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<ClickAwayListener onClickAway={() => setOpen(false)}>
|
||||
<div
|
||||
className={["speed-dial", props.className ?? ""].join(" ")}
|
||||
onClick={() => setOpen(!open)}
|
||||
onMouseEnter={() => setOpen(true)}
|
||||
>
|
||||
<div className="speed-dial--button">{props.icon}</div>
|
||||
<div
|
||||
className={[
|
||||
"speed-dial--list",
|
||||
open ? "open" : "close",
|
||||
props.direction ?? "row",
|
||||
].join(" ")}
|
||||
>
|
||||
{props.children}
|
||||
</div>
|
||||
</div>
|
||||
</ClickAwayListener>
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user