From 634f3e921956ef06d39562cb6758ae70a3ff797d Mon Sep 17 00:00:00 2001 From: Ari Date: Thu, 5 May 2022 13:57:44 -0400 Subject: [PATCH] automation editor fixed up --- .../AutomationEditor/index.stories.tsx | 16 ++--- .../src/components/AutomationEditor/index.tsx | 58 +++---------------- .../src/components/AutomationEditor/styles.ts | 13 +++-- 3 files changed, 25 insertions(+), 62 deletions(-) diff --git a/webapp/src/components/AutomationEditor/index.stories.tsx b/webapp/src/components/AutomationEditor/index.stories.tsx index 9d9e8ec..ffc8ca4 100644 --- a/webapp/src/components/AutomationEditor/index.stories.tsx +++ b/webapp/src/components/AutomationEditor/index.stories.tsx @@ -1,8 +1,8 @@ import React from "react"; import { ComponentMeta, ComponentStory } from '@storybook/react'; import { AutomationEditor } from './index'; -import { NODE_HEIGHT, NODE_WIDTH, DISTANCE_FACTOR, ADD_HEIGHT, ADD_WIDTH, CIRCLE_SIZE } from '../DAGSvgs/constants'; import { useState } from 'react'; +import * as dgconst from 'components/DAGSvgs/constants'; export default { @@ -11,12 +11,14 @@ export default { parameters: { actions: { argTypesRegex: '^on.*' } }, args: { dims: { - nodeHeight: NODE_HEIGHT, - nodeWidth: NODE_WIDTH, - addHeight: ADD_HEIGHT, - addWidth: ADD_WIDTH, - circleSize: CIRCLE_SIZE, - distanceFactor: DISTANCE_FACTOR, + nodeHeight: dgconst.NODE_HEIGHT, + nodeWidth: dgconst.NODE_WIDTH, + distanceFactor: dgconst.DISTANCE_FACTOR, + circleSize: dgconst.CIRCLE_SIZE, + padding: { + x: dgconst.PADDING, + y: dgconst.PADDING, + }, } } } as ComponentMeta diff --git a/webapp/src/components/AutomationEditor/index.tsx b/webapp/src/components/AutomationEditor/index.tsx index a8e113d..6f788bf 100644 --- a/webapp/src/components/AutomationEditor/index.tsx +++ b/webapp/src/components/AutomationEditor/index.tsx @@ -1,30 +1,19 @@ import "./index.css"; -import { DAGBoardElmDims } from "components/DAGSvgs/DAGBoard"; import { ArrowIcon, CheckMarkIcon, ZoomIcon } from "components/Icons"; -import { SequenceNodes } from "components/SequenceNodes"; -import { FC, useEffect, useState } from "react"; -import { AutomationData, AutomationSequenceNode } from "types/automations"; +import { FC, useState } from "react"; +import { AutomationData } from "types/automations"; import useWindowSize from "utils/useWindowSize"; import { AutoInfoBox } from "./AutoInfoBox"; import { useEditorStyles } from "./styles"; -import { computeTriggerPos, computeExtraField } from './positions'; -import { chain } from "utils/iter"; -import { AutomationTrigger } from 'types/automations/triggers'; -import { Modal } from "components/Modal"; -import { NodeEditor } from "components/NodeEditor"; import { ButtonIcon } from "components/Icons/ButtonIcons"; import { Button } from "components/Inputs/Button"; import { useAutomatioEditorState } from "./state"; import { DAGAutomationFlow } from "components/DAGFlow"; -import * as dgconst from 'components/DAGSvgs/constants'; +import { DAGAutomationFlowDims } from "components/DAGFlow/types"; -interface TriggerEditorModalState { - trigger: AutomationTrigger; - onSave: (node: AutomationTrigger) => void; -} interface Props { automation: AutomationData; - dims: DAGBoardElmDims; + dims: DAGAutomationFlowDims; onUpdate: (auto: AutomationData) => void; } export const AutomationEditor: FC = ({ @@ -41,10 +30,8 @@ export const AutomationEditor: FC = ({ save, } = useAutomatioEditorState(propsAutos, propsOnUpdate); - const [zoomLevel, setZoomLevel] = useState(40); const { ratioWbh } = useWindowSize(); const [closeInfo, setCloseInfo] = useState(false); - const [modalState, setModalState] = useState(null); const { classes } = useEditorStyles({ closeInfo, horizontalMode: ratioWbh < 0.75, @@ -59,17 +46,6 @@ export const AutomationEditor: FC = ({ } return
- - {!!modalState && setModalState(null)} - onSave={(n) => { - modalState.onSave(n as any); - setModalState(null); - }} - allowedTypes={['trigger']} - />} - = ({
-
- - setZoomLevel(z.target.valueAsNumber ?? 40)} - /> -
+
diff --git a/webapp/src/components/AutomationEditor/styles.ts b/webapp/src/components/AutomationEditor/styles.ts index 35399a3..3350507 100644 --- a/webapp/src/components/AutomationEditor/styles.ts +++ b/webapp/src/components/AutomationEditor/styles.ts @@ -39,14 +39,17 @@ export const useEditorStyles = createAppUseStyles<{ zoomImg: { }, - toolbar: { + toolbar: ({ autoChanged }) => ({ width: "100%", + height: autoChanged === 'changed' ? 'initial' : 0, display: "flex", flexDirection: "row", justifyContent: 'space-between', alignItems: "center", padding: "0.5em", - }, + borderBottom: autoChanged === 'changed' ? '1px solid var(--change)' : undefined, + borderLeft: autoChanged === 'changed' ? '1px solid var(--change)' : undefined, + }), saveBtn: ({ autoChanged }) => ({ display: "flex", opacity: autoChanged === "changed" ? 1 : 0, @@ -56,7 +59,9 @@ export const useEditorStyles = createAppUseStyles<{ maxHeight: '1em', justifyContent: 'center', alignItems: 'center', - borderColor: "#bf4 !important", - color: "#bf4 !important" + borderColor: "var(--change) !important", + color: "var(--change) !important", + paddingTop: '1em !important', + paddingBottom: '1em !important', }), }))