extracted speeddial
This commit is contained in:
1 parent
fe4f0e9881
commit
6da5a7592e
5 files changed
+117
-52
No files matched your search
@@ -1,24 +1,3 @@
|
||||
.dagnode--actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.dagnode--actions--list.close {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.dagnode--actions--list {
|
||||
position: absolute;
|
||||
bottom: -3em;
|
||||
left: 0em;
|
||||
background: var(--secondary);
|
||||
}
|
||||
|
||||
.dagnode--actions--move.right {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import DeleteForeverIcon from "@mui/icons-material/DeleteForever";
|
||||
import SettingsOutlinedIcon from "@mui/icons-material/SettingsOutlined";
|
||||
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
|
||||
import { createToNodeMakerFunction } from "./helpers";
|
||||
import { SpeedDial } from "components/SpeedDial";
|
||||
|
||||
export type DAGNodeOnMove<Direction extends string> = Record<
|
||||
Direction,
|
||||
@@ -95,38 +96,26 @@ export const DAGNode: FC<DAGNodeProps> = ({
|
||||
/>
|
||||
<div className={classes.root}>
|
||||
<div className={classes.inner}>
|
||||
<ClickAwayListener onClickAway={() => setOpen(false)}>
|
||||
<div
|
||||
className={classes.leftEdge}
|
||||
onClick={() => setOpen(!open)}
|
||||
onMouseEnter={() => setOpen(true)}
|
||||
>
|
||||
<SettingsOutlinedIcon className="dagnode--actions" />
|
||||
<div
|
||||
className={[
|
||||
"dagnode--actions--list",
|
||||
open ? "open" : "close",
|
||||
].join(" ")}
|
||||
<SpeedDial
|
||||
icon={<SettingsOutlinedIcon className="dagnode--actions" />}
|
||||
>
|
||||
<IconButton onClick={onXClick} size="small">
|
||||
<DeleteForeverIcon fontSize="inherit" color="warning" />
|
||||
</IconButton>
|
||||
<IconButton onClick={onEditClick} size="small">
|
||||
<PencilIcon color={theme.green} size={0.8} />
|
||||
</IconButton>
|
||||
{Object.entries(onMove).map(([key, action]) => (
|
||||
<IconButton
|
||||
key={key}
|
||||
onClick={action}
|
||||
size="small"
|
||||
className={["dagnode--actions--move", key].join(" ")}
|
||||
>
|
||||
<IconButton onClick={onXClick} size="small">
|
||||
<DeleteForeverIcon fontSize="inherit" color="warning" />
|
||||
</IconButton>
|
||||
<IconButton onClick={onEditClick} size="small">
|
||||
<PencilIcon color={theme.green} size={0.8} />
|
||||
</IconButton>
|
||||
{Object.entries(onMove).map(([key, action]) => (
|
||||
<IconButton
|
||||
key={key}
|
||||
onClick={action}
|
||||
size="small"
|
||||
className={["dagnode--actions--move", key].join(" ")}
|
||||
>
|
||||
<ArrowBackIcon fontSize="inherit" />
|
||||
</IconButton>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</ClickAwayListener>
|
||||
<ArrowBackIcon fontSize="inherit" />
|
||||
</IconButton>
|
||||
))}
|
||||
</SpeedDial>
|
||||
<div className={classes.textWrap}>
|
||||
<span className={classes.text}>{label}</span>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
.speed-dial, .speed-dial--button {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.speed-dial .speed-dial--button {
|
||||
max-height: 2em;
|
||||
max-width: 2em;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.speed-dial--list.close {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.speed-dial--list {
|
||||
position: absolute;
|
||||
bottom: -3em;
|
||||
left: 0em;
|
||||
background: var(--secondary);
|
||||
}
|
||||
|
||||
.speed-dial--list.open.row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { ComponentStory } from "@storybook/react";
|
||||
|
||||
import { Page } from "components/Page";
|
||||
import { SpeedDial } from ".";
|
||||
import SettingsApplicationsIcon from "@mui/icons-material/SettingsApplications";
|
||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
import { DeleteForeverOutlined } from "@mui/icons-material";
|
||||
import EditIcon from "@mui/icons-material/Edit";
|
||||
|
||||
export default {
|
||||
title: "Nav/SpeedDial",
|
||||
component: SpeedDial,
|
||||
};
|
||||
|
||||
export const IconList: ComponentStory<typeof SpeedDial> = () => {
|
||||
return (
|
||||
<Page>
|
||||
<div
|
||||
style={{
|
||||
maxWidth: "10em",
|
||||
maxHeight: "10em",
|
||||
}}
|
||||
>
|
||||
<SpeedDial icon={<SettingsApplicationsIcon />}>
|
||||
<ButtonIcon icon={<DeleteForeverOutlined />} />
|
||||
<ButtonIcon icon={<EditIcon />} />
|
||||
</SpeedDial>
|
||||
</div>
|
||||
</Page>
|
||||
);
|
||||
};
|
||||
@@ -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