From 967508c29e928664c0875aeea78d459fd9a3c99c Mon Sep 17 00:00:00 2001 From: Ari Date: Wed, 13 Apr 2022 16:53:04 -0400 Subject: [PATCH] added zoomability --- .../src/components/AutomationEditor/index.tsx | 88 ++++++++++--------- .../src/components/AutomationEditor/styles.ts | 26 +++++- webapp/src/components/Icons/index.stories.tsx | 4 +- webapp/src/components/Icons/index.tsx | 13 ++- webapp/src/components/Inputs/styles.ts | 4 +- 5 files changed, 84 insertions(+), 51 deletions(-) diff --git a/webapp/src/components/AutomationEditor/index.tsx b/webapp/src/components/AutomationEditor/index.tsx index c8d4510..bde36ee 100644 --- a/webapp/src/components/AutomationEditor/index.tsx +++ b/webapp/src/components/AutomationEditor/index.tsx @@ -1,6 +1,6 @@ import "./index.css"; import { DAGBoardElmDims } from "components/DAGSvgs/DAGBoard"; -import { ArrowIcon } from "components/Icons"; +import { ArrowIcon, ZoomIcon } from "components/Icons"; import { SequenceNodes } from "components/SequenceNodes"; import { FC, useState } from "react"; import { AutomationData, AutomationSequenceNode } from "types/automations"; @@ -13,7 +13,6 @@ import { AutomationTrigger } from 'types/automations/triggers'; import { Modal } from "components/Modal"; import { NodeEditor } from "components/NodeEditor"; import { ButtonIcon } from "components/Icons/ButtonIcons"; -import InputNumber from "components/Inputs/InputNumber"; interface TriggerEditorModalState { trigger: AutomationTrigger; @@ -51,13 +50,6 @@ export const AutomationEditor: FC = ({ // render return
- setZoomLevel(z ?? 40)} - /> {!!modalState && = ({ >{ArrowIcon} - chain([ - computeExtraField([1, 0.5], [2, 0.5]), - computeTriggerPos( - [0.5, 0.5], - automation.trigger, - [1.5, 0.5], - updateTriggers, - () => { - setModalState({ - trigger: { - $smType: "trigger", - platform: "device", - device_id: "", - domain: "", - type: "", - subtype: "" - }, - onSave: (t) => updateTriggers([...automation.trigger, t]) - }); - }, - (trigger, onSave) => setModalState({ - trigger, - onSave, - }) - ), - ])} - /> +
+
+ + setZoomLevel(z.target.valueAsNumber ?? 40)} + /> +
+ chain([ + computeExtraField([1, 0.5], [2, 0.5]), + computeTriggerPos( + [0.5, 0.5], + automation.trigger, + [1.5, 0.5], + updateTriggers, + () => { + setModalState({ + trigger: { + $smType: "trigger", + platform: "device", + device_id: "", + domain: "", + type: "", + subtype: "" + }, + onSave: (t) => updateTriggers([...automation.trigger, t]) + }); + }, + (trigger, onSave) => setModalState({ + trigger, + onSave, + }) + ), + ])} + /> +
} diff --git a/webapp/src/components/AutomationEditor/styles.ts b/webapp/src/components/AutomationEditor/styles.ts index 4cffbbf..33bcdb3 100644 --- a/webapp/src/components/AutomationEditor/styles.ts +++ b/webapp/src/components/AutomationEditor/styles.ts @@ -5,6 +5,14 @@ export const useEditorStyles = createAppUseStyles<{ closeInfo: boolean; horizontalMode: boolean; }>(theme => ({ + wrapper: { + display: 'flex', + flexDirection: 'column', + alignItems: "flex-end", + height: '100%', + width: '100%', + overflow: 'hidden', + }, root: ({ horizontalMode }) => ({ height: '100%', width: '100%', @@ -22,10 +30,20 @@ export const useEditorStyles = createAppUseStyles<{ bottom: horizontalMode ? '90%' : 10 }), zoom: { - position: 'absolute !important', - right: 0, - bottom: 0, + backgroundColor: theme.secondary, + color: theme.secondaryAccent, + textAlign: 'center', + maxWidth: "3em", + }, + zoomImg: { + // width: "1em", + + }, + toolbar: { width: "100%", - // maxWidth: "10em", + display: "flex", + flexDirection: "row", + justifyContent: 'start', + alignItems: "center", } })) diff --git a/webapp/src/components/Icons/index.stories.tsx b/webapp/src/components/Icons/index.stories.tsx index acb14e1..e0197ec 100644 --- a/webapp/src/components/Icons/index.stories.tsx +++ b/webapp/src/components/Icons/index.stories.tsx @@ -1,8 +1,7 @@ import { ComponentStory } from "@storybook/react"; import { IconBase } from "./base"; -import { PencilIcon, CheckMarkIcon, TrashIcon, InfoIcon, ArrowIcon } from "."; -import { AddIcon } from './index'; +import { PencilIcon, CheckMarkIcon, TrashIcon, InfoIcon, ArrowIcon, AddIcon, ZoomIcon } from "."; import { ButtonIcon } from "./ButtonIcons"; export default { @@ -19,6 +18,7 @@ export const IconList: ComponentStory = (args) => { + } IconList.args = { diff --git a/webapp/src/components/Icons/index.tsx b/webapp/src/components/Icons/index.tsx index 22ed499..ef08526 100644 --- a/webapp/src/components/Icons/index.tsx +++ b/webapp/src/components/Icons/index.tsx @@ -1,5 +1,5 @@ import { FC } from "react"; -import { IconBase, IconBaseProps } from "./base"; +import { IconBase, IconBaseProps } from './base'; export const PencilIcon: FC = props => = props => + + +export const ZoomIcon: FC = props => + + \ No newline at end of file diff --git a/webapp/src/components/Inputs/styles.ts b/webapp/src/components/Inputs/styles.ts index 53ba6a9..4ec4967 100644 --- a/webapp/src/components/Inputs/styles.ts +++ b/webapp/src/components/Inputs/styles.ts @@ -97,8 +97,8 @@ export const useInputNumberStyles = createAppUseStyles<{}>(theme => { }, deleteIcon: { position: "absolute", - left: 30, - top: 17, + left: "1em", + top: "1.5em", color: theme.secondaryAccent, backgroundColor: theme.secondary, borderWidth: 1,