From 0088dd844817067c64220286d182d9b1b19082c2 Mon Sep 17 00:00:00 2001 From: Ari Date: Wed, 29 Jun 2022 16:34:59 -0400 Subject: [PATCH] cleaned up options styles --- .../ConditionEditor/ConditionNodeSettings.css | 16 ++++++ .../ConditionNodeSettings.mobile.css | 19 ------- .../ConditionEditor/ConditionNodeSettings.tsx | 55 +++++++------------ webapp/src/components/DAGFlow/helpers.tsx | 29 +++++++++- webapp/src/components/DAGFlow/index.tsx | 16 +----- webapp/src/components/DAGFlow/updater.ts | 38 ++++++------- webapp/src/components/NodeEditor/index.css | 7 ++- webapp/src/components/NodeEditor/index.tsx | 4 +- .../ServiceEditor/ServiceEditorTarget.css | 2 +- webapp/src/components/SpeedDial/index.css | 17 +++--- webapp/src/components/SpeedDial/index.tsx | 7 ++- 11 files changed, 106 insertions(+), 104 deletions(-) delete mode 100644 webapp/src/components/ConditionEditor/ConditionNodeSettings.mobile.css diff --git a/webapp/src/components/ConditionEditor/ConditionNodeSettings.css b/webapp/src/components/ConditionEditor/ConditionNodeSettings.css index 63e3dd8..74ae867 100644 --- a/webapp/src/components/ConditionEditor/ConditionNodeSettings.css +++ b/webapp/src/components/ConditionEditor/ConditionNodeSettings.css @@ -1,3 +1,7 @@ +.condition-node--settings { + width: 3em; +} + .condition-node--settings--icons { display: inline-block; max-width: 5em; @@ -15,4 +19,16 @@ .condition-node--settings button.Mui-disabled { cursor: not-allowed; +} + + +.condition-node--settings .speed-dial--button { + max-width: 4em; + max-height: 4em; + height: 4em; + width: 4em; +} + +.condition-node--settings .speed-dial--button:hover button { + background-color: var(--secondary-accent); } \ No newline at end of file diff --git a/webapp/src/components/ConditionEditor/ConditionNodeSettings.mobile.css b/webapp/src/components/ConditionEditor/ConditionNodeSettings.mobile.css deleted file mode 100644 index 04e190d..0000000 --- a/webapp/src/components/ConditionEditor/ConditionNodeSettings.mobile.css +++ /dev/null @@ -1,19 +0,0 @@ -.condition-node--settings.mobile { - width: 3em; -} - -.condition-node--settings.mobile .speed-dial--button { - max-width: 4em; - max-height: 4em; - height: 4em; - width: 4em; -} - -.condition-node--settings.mobile .speed-dial--button:hover button { - background-color: var(--secondary-accent); -} - -.condition-node--settings.mobile .speed-dial--list.open { - top: 3.5em; - /* left: 0.5em; */ -} \ No newline at end of file diff --git a/webapp/src/components/ConditionEditor/ConditionNodeSettings.tsx b/webapp/src/components/ConditionEditor/ConditionNodeSettings.tsx index ba0a0d4..4452002 100644 --- a/webapp/src/components/ConditionEditor/ConditionNodeSettings.tsx +++ b/webapp/src/components/ConditionEditor/ConditionNodeSettings.tsx @@ -1,5 +1,4 @@ import "./ConditionNodeSettings.css"; -import "./ConditionNodeSettings.mobile.css"; import { ButtonIcon, ButtonIconProps } from "components/Icons/ButtonIcons"; import CodeOutlinedIcon from "@mui/icons-material/CodeOutlined"; @@ -64,38 +63,26 @@ export const ConditionNodeSettings: FC = ( }); } // render - if (isMobile) { - return ( -
+ } + color={props.isEdited ? "success" : "default"} + /> + } + direction="left" > - } - color={props.isEdited ? "success" : "default"} - /> - } - direction="column" - > - {buttons.map((opt, i) => ( - - ))} - -
- ); - } else { - return ( -
-
- {buttons.map((opt, i) => ( - - ))} -
-
- ); - } + {buttons.map((opt, i) => ( + + ))} + + + ); }; diff --git a/webapp/src/components/DAGFlow/helpers.tsx b/webapp/src/components/DAGFlow/helpers.tsx index 4589ad3..d78ed8e 100644 --- a/webapp/src/components/DAGFlow/helpers.tsx +++ b/webapp/src/components/DAGFlow/helpers.tsx @@ -1,6 +1,10 @@ import { FC } from "react"; -import { DAGAutomationFlowDims } from "components/DAGFlow/types"; +import { + DAGAutomationFlowDims, + UpdateModalState, +} from "components/DAGFlow/types"; import { Node, XYPosition } from "react-flow-renderer"; +import { AutomationCondition } from "types/automations/conditions"; export const convertToFlowNode = (Component: FC): FC<{ data: D }> => @@ -23,3 +27,26 @@ export const createToNodeMakerFunction = position, data: convert(data, dims), }); + +export const makeOnEditAutomationConditions = + ( + conditions: AutomationCondition[], + updateConditions: (c: AutomationCondition[]) => void, + openModal: UpdateModalState + ) => + () => + openModal({ + single: true, + node: { + condition: "and", + conditions, + }, + allowedTypes: ["condition"], + update: (c: AutomationCondition) => { + if (c.condition === "and") { + updateConditions(c.conditions); + } else { + updateConditions([c]); + } + }, + }); diff --git a/webapp/src/components/DAGFlow/index.tsx b/webapp/src/components/DAGFlow/index.tsx index 7f99f5a..d47727a 100644 --- a/webapp/src/components/DAGFlow/index.tsx +++ b/webapp/src/components/DAGFlow/index.tsx @@ -18,7 +18,7 @@ import { NodeEditor } from "components/NodeEditor"; import { MultiNodeEditor } from "components/MultiNodeEditors"; import { Modal } from "components/Modal"; import { AutomationCondition } from "types/automations/conditions"; -import { convertToFlowNode } from "./helpers"; +import { convertToFlowNode, makeOnEditAutomationConditions } from "./helpers"; import { DAGErrorNode } from "./DAGErrorNode"; import { useHA } from "haService"; import { getDescriptionFromAutomationNode } from "utils/formatting"; @@ -29,20 +29,6 @@ const nodeTypes = { dagcircle: DAGCircle, }; -const makeOnEditAutomationConditions = - ( - conditions: AutomationCondition[], - updateConditions: (c: AutomationCondition[]) => void, - openModal: UpdateModalState - ) => - () => - openModal({ - single: false, - node: conditions, - allowedTypes: ["condition"], - update: (c) => updateConditions(c as any), - }); - export interface DAGAutomationFlowProps { className?: string; trigger: AutomationTrigger[]; diff --git a/webapp/src/components/DAGFlow/updater.ts b/webapp/src/components/DAGFlow/updater.ts index 30a7e5b..ea98313 100644 --- a/webapp/src/components/DAGFlow/updater.ts +++ b/webapp/src/components/DAGFlow/updater.ts @@ -5,6 +5,7 @@ import { UpdateModalState } from "./types"; import { getNodeType } from "../../utils/automations"; import { DAGNodeOnMoveEvents } from "./DAGNode"; import { cleanUpUndefined } from "components/NodeEditor/OptionManager/OptionManager"; +import { makeOnEditAutomationConditions } from "./helpers"; export type SequenceUpdater = ReturnType; @@ -91,26 +92,23 @@ export const makeSequenceUpdater = ( }); }, makeOnEditConditionsForChooseNode(i: number, j: number) { - return () => { - const node = sequence[i] as ChooseAction; - return openModal({ - single: false, - node: node.choose[j].conditions, - allowedTypes: ["condition"], - update: (conditions) => - this.updateNode(i, { - ...node, - choose: [ - ...node.choose.slice(0, j), - { - sequence: node.choose[j].sequence, - conditions: conditions as AutomationCondition[], - }, - ...node.choose.slice(j + 1), - ], - }), - }); - }; + const node = sequence[i] as ChooseAction; + return makeOnEditAutomationConditions( + node.choose[j].conditions, + (conditions) => + this.updateNode(i, { + ...node, + choose: [ + ...node.choose.slice(0, j), + { + sequence: node.choose[j].sequence, + conditions: conditions as AutomationCondition[], + }, + ...node.choose.slice(j + 1), + ], + }), + openModal + ); }, makeOnEditForBadNode(i: number) { const node = sequence[i]; diff --git a/webapp/src/components/NodeEditor/index.css b/webapp/src/components/NodeEditor/index.css index bbe1267..951beb6 100644 --- a/webapp/src/components/NodeEditor/index.css +++ b/webapp/src/components/NodeEditor/index.css @@ -41,7 +41,7 @@ } .node-editor--body { - overflow: overlay; + overflow: hidden; padding-left: 1%; padding-right: 1%; @@ -50,6 +50,11 @@ max-width: 100%; } +.node-editor--body--options { + overflow: auto; + max-height: 60vh; +} + .node-editor--footer { bottom: 0; left: 0; diff --git a/webapp/src/components/NodeEditor/index.tsx b/webapp/src/components/NodeEditor/index.tsx index b5d6690..62279a7 100644 --- a/webapp/src/components/NodeEditor/index.tsx +++ b/webapp/src/components/NodeEditor/index.tsx @@ -96,7 +96,9 @@ export const NodeEditor: FC = ({ /> - {state.renderOptionList()} +
+ {state.renderOptionList()} +