add in tooltip
This commit is contained in:
1 parent
edb3dafe12
commit
649c1fbdeb
7 files changed
+58
-14
No files matched your search
@@ -22,7 +22,7 @@ export const DEFAULT_DIMS: DAGDims = {
|
||||
width: CIRCLE_SIZE,
|
||||
},
|
||||
distanceFactor: {
|
||||
node: 2,
|
||||
node: 1.5,
|
||||
collection: 1.25,
|
||||
},
|
||||
position: {
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
import { AutomationCondition } from "types/automations/conditions";
|
||||
import { CollectionNodeMaker } from "../nodes/CollectionNode";
|
||||
import { SequenceNodeMaker } from "../nodes/SequenceNode";
|
||||
import { getNodeType } from "utils/automations";
|
||||
|
||||
export const makeAutomationNodes = (
|
||||
automation: AutomationActionData,
|
||||
@@ -70,7 +71,7 @@ export const makeTriggerNodes: ElementMaker<AutomationTrigger> = (
|
||||
CollectionNodeMaker.makeElement({ id: nodeId, position }, dims, {
|
||||
...dims.trigger,
|
||||
color: "red",
|
||||
onAddNode: () => stateUpdater.basic.trigger.addNode(),
|
||||
onAddNode: () => stateUpdater.basic.trigger.addNode(null),
|
||||
nodes: nodes.map((node, index) => ({
|
||||
enabled: node.enabled ?? true,
|
||||
label: getDescriptionFromAutomationNode(node, namer, true),
|
||||
@@ -97,7 +98,7 @@ export const makeConditionNodes: ElementMaker<AutomationCondition> = (
|
||||
...dims.condition,
|
||||
color: "blue",
|
||||
hasInput: !!lastNodeId,
|
||||
onAddNode: stateUpdater.basic.condition.addNode,
|
||||
onAddNode: () => stateUpdater.basic.condition.addNode(null),
|
||||
nodes: nodes.map((node, index) => ({
|
||||
enabled: node.enabled ?? true,
|
||||
label: getDescriptionFromAutomationNode(node, namer, true),
|
||||
@@ -142,7 +143,7 @@ export const makeSequenceNodes: ElementMaker<AutomationSequenceNode> = (
|
||||
},
|
||||
dims,
|
||||
{
|
||||
color: "green",
|
||||
color: getNodeType(node) === "action" ? "green" : "blue",
|
||||
enabled: node.enabled ?? true,
|
||||
hasInput: true,
|
||||
label: getDescriptionFromAutomationNode(node, namer, true),
|
||||
|
||||
@@ -84,6 +84,13 @@
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.sequence-node--actions--move .icon-2 {
|
||||
position: absolute;
|
||||
bottom: 10%;
|
||||
left: 60%;
|
||||
font-size: 0.75em;
|
||||
}
|
||||
|
||||
.sequence-node--actions--move.right {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
@@ -91,4 +91,10 @@ OnMoveAllDirections.args = {
|
||||
left: console.log,
|
||||
right: console.log,
|
||||
},
|
||||
onAdd: {
|
||||
up: console.log,
|
||||
down: console.log,
|
||||
left: console.log,
|
||||
right: console.log,
|
||||
},
|
||||
};
|
||||
@@ -17,6 +17,7 @@ import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
import { SpeedDial } from "components/SpeedDial";
|
||||
import { SequenceNodeElementProps } from "./types";
|
||||
import { useSequenceNodeColor } from "./util";
|
||||
import { AddOutlined } from "@mui/icons-material";
|
||||
|
||||
export const SequenceNodeElement: FC<
|
||||
PropsWithChildren<SequenceNodeElementProps>
|
||||
@@ -26,7 +27,7 @@ export const SequenceNodeElement: FC<
|
||||
width,
|
||||
onXClick,
|
||||
onEditClick = () => {},
|
||||
onAddNode,
|
||||
onAdd = {},
|
||||
onMove = {},
|
||||
color,
|
||||
flipped,
|
||||
@@ -38,6 +39,7 @@ export const SequenceNodeElement: FC<
|
||||
const confirm = useConfirm();
|
||||
const snackbr = useSnackbar();
|
||||
const nodeColor = useSequenceNodeColor(color);
|
||||
console.log({ onAdd });
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
@@ -76,12 +78,23 @@ export const SequenceNodeElement: FC<
|
||||
</IconButton>
|
||||
{Object.entries(onMove).map(([key, action]) => (
|
||||
<IconButton
|
||||
key={key}
|
||||
key={"move" + key}
|
||||
onClick={action}
|
||||
size="small"
|
||||
className={["sequence-node--actions--move", key].join(" ")}
|
||||
>
|
||||
<ArrowBackIcon fontSize="inherit" />
|
||||
<ArrowBackIcon className="icon" fontSize="inherit" />
|
||||
</IconButton>
|
||||
))}
|
||||
{Object.entries(onAdd).map(([key, action]) => (
|
||||
<IconButton
|
||||
key={"add" + key}
|
||||
onClick={action}
|
||||
size="small"
|
||||
className={["sequence-node--actions--move", key].join(" ")}
|
||||
>
|
||||
<ArrowBackIcon className="icon" fontSize="inherit" />
|
||||
<AddOutlined className="icon-2" fontSize="inherit" />
|
||||
</IconButton>
|
||||
))}
|
||||
{onXClick && (
|
||||
@@ -129,11 +142,11 @@ export const SequenceNodeElement: FC<
|
||||
{typeof label === "string" ? <span>{label}</span> : label}
|
||||
</div>
|
||||
</div>
|
||||
{onAddNode && (
|
||||
{/* {onAddNode && (
|
||||
<div className="sequence-node--midway-options">
|
||||
<ButtonIcon icon={<Add />} onClick={onAddNode} />
|
||||
</div>
|
||||
)}
|
||||
)} */}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -11,6 +11,7 @@ export type SequenceNodeActions = {
|
||||
onSetEnabled: () => void;
|
||||
onAddNode: () => void;
|
||||
onMove: SequenceNodeOnMoveEvents;
|
||||
onAdd: SequenceNodeOnMoveEvents;
|
||||
};
|
||||
export type SequenceNodeOnMoveEvents = Partial<
|
||||
SequenceNodeOnMove<"up" | "down" | "left" | "right">
|
||||
|
||||
@@ -36,12 +36,22 @@ export const createBasicUpdater =
|
||||
...args[k].data.slice(i + 1),
|
||||
]),
|
||||
|
||||
addNode: () =>
|
||||
addNode: (afterIndex: number | null) =>
|
||||
args.openModal({
|
||||
allowedTypes: mapAutoActionKeyToNodeType(k),
|
||||
saveBtnCreateText: true,
|
||||
node: JSON.parse(JSON.stringify(defaultNode)),
|
||||
update: (n) => args[k].onUpdate([...args[k].data, n]),
|
||||
update: (n) => {
|
||||
if (afterIndex !== null) {
|
||||
args[k].onUpdate([
|
||||
...args[k].data.slice(0, afterIndex),
|
||||
n,
|
||||
...args[k].data.slice(afterIndex),
|
||||
]);
|
||||
} else {
|
||||
args[k].onUpdate([...args[k].data, n]);
|
||||
}
|
||||
},
|
||||
}),
|
||||
onMove: (i: number, direction: "back" | "forward") => {
|
||||
if (direction === "back" && i > 0) {
|
||||
@@ -121,9 +131,15 @@ export const createUpdater = (
|
||||
}
|
||||
}
|
||||
// build add
|
||||
let onAddNode: (() => void) | undefined = undefined;
|
||||
let onAdd: SequenceNodeActions["onAdd"] = {};
|
||||
if (flags.includeAdd) {
|
||||
onAddNode = basic[k].addNode;
|
||||
if (!flags.flipped) {
|
||||
onAdd["left"] = () => basic[k].addNode(i);
|
||||
onAdd["right"] = () => basic[k].addNode(i + 1);
|
||||
} else {
|
||||
onAdd["up"] = () => basic[k].addNode(i);
|
||||
onAdd["down"] = () => basic[k].addNode(i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -136,7 +152,7 @@ export const createUpdater = (
|
||||
}),
|
||||
onXClick: () => basic[k].deleteNode(i),
|
||||
onSetEnabled: () => basic[k].setEnabled(i),
|
||||
onAddNode,
|
||||
onAdd,
|
||||
onMove,
|
||||
};
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user