From c25640051894b02de8df5ac60ab99690c4b71b32 Mon Sep 17 00:00:00 2001 From: Ari Date: Thu, 5 May 2022 15:03:33 -0400 Subject: [PATCH] fixed up styling for autos --- .../src/components/AutomationEditor/index.css | 65 +++++++++++++++++- .../AutomationEditor/index.stories.tsx | 3 + .../src/components/AutomationEditor/index.tsx | 23 +++---- .../src/components/AutomationEditor/state.ts | 12 ++-- .../src/components/AutomationEditor/styles.ts | 67 ------------------- .../AutomationList/AutomationList.stories.tsx | 16 +++-- .../src/components/AutomationList/index.css | 19 +++--- .../src/components/AutomationList/index.tsx | 3 +- webapp/src/components/DAGFlow/index.tsx | 3 + 9 files changed, 104 insertions(+), 107 deletions(-) delete mode 100644 webapp/src/components/AutomationEditor/styles.ts diff --git a/webapp/src/components/AutomationEditor/index.css b/webapp/src/components/AutomationEditor/index.css index 41f43ce..8175605 100644 --- a/webapp/src/components/AutomationEditor/index.css +++ b/webapp/src/components/AutomationEditor/index.css @@ -1,10 +1,69 @@ -.automation-editor--info-icon { +.automation-editor { + display: flex; + flex-direction: row; + width: 100%; + height: 100%; +} + +.automation-editor--flow-wrapper { + flex: 1; + padding: 0 0.5em 0 0.5em; + max-height: 100%; + max-width: 100%; + + display: flex; + flex-direction: column; + gap: 0.5em; +} + +.automation-editor--flow-wrapper--toolbar { + display: flex; + flex-direction: row; + justify-content: flex-end; +} + +.automation-editor--flow-wrapper.unchanged>.automation-editor--flow-wrapper--toolbar { + height: 0; + opacity: 0; + overflow: hidden; +} + +.automation-editor--flow-wrapper.changed>.automation-editor--flow-wrapper--toolbar * { + border-color: var(--change); + color: var(--change) +} + + +.automation-editor--flow-wrapper--toolbar--save-btn { + display: flex; + gap: 0.5em; + align-items: center; + padding: 0.25em; +} + +.automation-editor--flow-wrapper.changed>.automation-editor--flow-wrapper--flow { + border-color: var(--change); +} + +.automation-editor--flow-wrapper--flow { + flex: 1; + border: 1px solid var(--secondary-accent); + margin: 0 0 0.5em 0; + z-index: 1; +} + +.automation-editor--info-box { + position: relative; +} + +.automation-editor--info-box--icon { position: absolute; - right: 1.5em; + right: 0em; bottom: 0.5em; z-index: 10; } -.automation-editor--info-box.hide>.automation-editor--info-icon { +.automation-editor--info-box.hide>.automation-editor--info-box--icon { transform: rotate(180deg); + z-index: 2; } \ No newline at end of file diff --git a/webapp/src/components/AutomationEditor/index.stories.tsx b/webapp/src/components/AutomationEditor/index.stories.tsx index ffc8ca4..df20f1f 100644 --- a/webapp/src/components/AutomationEditor/index.stories.tsx +++ b/webapp/src/components/AutomationEditor/index.stories.tsx @@ -36,6 +36,9 @@ const Template: ComponentStory = args => { } +export const Loading = Template.bind({}); + + export const Simple = Template.bind({}) Simple.args = { ...Simple.args, diff --git a/webapp/src/components/AutomationEditor/index.tsx b/webapp/src/components/AutomationEditor/index.tsx index 6f788bf..2ac4d90 100644 --- a/webapp/src/components/AutomationEditor/index.tsx +++ b/webapp/src/components/AutomationEditor/index.tsx @@ -12,7 +12,7 @@ import { DAGAutomationFlow } from "components/DAGFlow"; import { DAGAutomationFlowDims } from "components/DAGFlow/types"; interface Props { - automation: AutomationData; + automation?: AutomationData; dims: DAGAutomationFlowDims; onUpdate: (auto: AutomationData) => void; } @@ -30,22 +30,15 @@ export const AutomationEditor: FC = ({ save, } = useAutomatioEditorState(propsAutos, propsOnUpdate); - const { ratioWbh } = useWindowSize(); const [closeInfo, setCloseInfo] = useState(false); - const { classes } = useEditorStyles({ - closeInfo, - horizontalMode: ratioWbh < 0.75, - autoChanged: state.status, - }); - // render if (state.status === 'loading') { - return
+ return
Loading...
} - return
+ return
= ({ onUpdate={updateMetadata} > setCloseInfo(!closeInfo)} title={closeInfo ? "Show Metadata" : "Hide Metadata"} >{ArrowIcon} -
-
- +
+
void, ) => { const [state, update] = useState({ @@ -30,10 +30,12 @@ export const useAutomatioEditorState = ( }) useEffect(() => { - update({ - status: 'unchanged', - data: genEditorData(automation), - }) + if (automation) { + update({ + status: 'unchanged', + data: genEditorData(automation), + }) + } }, [automation]); return { diff --git a/webapp/src/components/AutomationEditor/styles.ts b/webapp/src/components/AutomationEditor/styles.ts deleted file mode 100644 index 3350507..0000000 --- a/webapp/src/components/AutomationEditor/styles.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { createAppUseStyles } from "styles/theme"; - - -export const useEditorStyles = createAppUseStyles<{ - closeInfo: boolean; - horizontalMode: boolean; - autoChanged: string; -}>(theme => ({ - wrapper: { - display: 'flex', - flexDirection: 'column', - alignItems: "flex-end", - height: '100%', - width: '100%', - overflow: 'hidden', - }, - root: ({ horizontalMode }) => ({ - height: '100%', - width: '100%', - color: theme.primaryAccent, - display: 'flex', - flexDirection: horizontalMode ? 'column' : 'row', - }), - dag: { - borderWidth: 1, - borderStyle: 'solid', - borderColor: theme.secondaryAccent, - width: '100%', - }, - infoIcon: ({ horizontalMode }) => ({ - bottom: horizontalMode ? '90%' : 10 - }), - zoom: { - backgroundColor: theme.secondary, - color: theme.secondaryAccent, - textAlign: 'center', - maxWidth: "3em", - }, - zoomImg: { - - }, - 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, - height: autoChanged === "changed" ? undefined : 0, - fontSize: autoChanged === "changed" ? undefined : 0, - gap: '0.5em', - maxHeight: '1em', - justifyContent: 'center', - alignItems: 'center', - borderColor: "var(--change) !important", - color: "var(--change) !important", - paddingTop: '1em !important', - paddingBottom: '1em !important', - }), -})) diff --git a/webapp/src/components/AutomationList/AutomationList.stories.tsx b/webapp/src/components/AutomationList/AutomationList.stories.tsx index 878c435..3214d8b 100644 --- a/webapp/src/components/AutomationList/AutomationList.stories.tsx +++ b/webapp/src/components/AutomationList/AutomationList.stories.tsx @@ -2,8 +2,8 @@ import "styles/root.css"; import { ComponentMeta, ComponentStory } from "@storybook/react"; import { useState } from "react"; import { AutomationList } from "."; -import { NODE_HEIGHT, NODE_WIDTH, ADD_HEIGHT, ADD_WIDTH, CIRCLE_SIZE, DISTANCE_FACTOR } from 'components/DAGSvgs/constants'; import { createMockAuto } from "utils/mocks"; +import * as dgconst from 'components/DAGSvgs/constants'; export default { title: 'App/AutomationList', @@ -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/AutomationList/index.css b/webapp/src/components/AutomationList/index.css index 2b182be..ec3d695 100644 --- a/webapp/src/components/AutomationList/index.css +++ b/webapp/src/components/AutomationList/index.css @@ -1,21 +1,22 @@ /* root elements */ .automation-list--root { - width : 100%; - height : 100%; - display : flex; + width: 100%; + height: 100%; + display: flex; flex-direction: row; - overflow : hidden; + overflow: hidden; } .automation-list--list { - flex : 1; + flex: 1; min-width: 400px; max-width: 400px; - position : relative; + position: relative; } .automation-list--viewer { overflow: hidden; + flex: 1; } /* list children: on hide */ @@ -41,6 +42,6 @@ .automation-list--list-hide { position: absolute; - bottom : 10px; - right : 5px; -} + bottom: 0.5em; + right: 0.5em; +} \ No newline at end of file diff --git a/webapp/src/components/AutomationList/index.tsx b/webapp/src/components/AutomationList/index.tsx index b62d7c7..64890c1 100644 --- a/webapp/src/components/AutomationList/index.tsx +++ b/webapp/src/components/AutomationList/index.tsx @@ -8,6 +8,7 @@ import { ArrowIcon } from "components/Icons"; import { ButtonIcon } from "components/Icons/ButtonIcons"; import { ApiService } from "apiService/core"; import { AutomationListBox } from "./AutomationListBox"; +import { DAGAutomationFlowDims } from 'DAGFlow/types'; interface AutomationListParams { @@ -15,7 +16,7 @@ interface AutomationListParams { onUpdate: (i: number, auto: AutomationData) => void; onAdd: (auto: AutomationData) => void; onRemove: (i: number) => void; - dims: DAGBoardElmDims; + dims: DAGAutomationFlowDims; } export const AutomationList: FC = ({ diff --git a/webapp/src/components/DAGFlow/index.tsx b/webapp/src/components/DAGFlow/index.tsx index fe8f27f..1ad3795 100644 --- a/webapp/src/components/DAGFlow/index.tsx +++ b/webapp/src/components/DAGFlow/index.tsx @@ -19,6 +19,7 @@ const nodeTypes = { } interface Props { + className?: string; sequence: AutomationSequenceNode[]; trigger: AutomationTrigger[]; dims: DAGAutomationFlowDims; @@ -27,6 +28,7 @@ interface Props { } export const DAGAutomationFlow: FC = ({ + className, sequence, trigger, onTriggerUpdate, @@ -103,6 +105,7 @@ export const DAGAutomationFlow: FC = ({ {modalBody}