From 93fe26e787fe620e155692d7138e849cd02865de Mon Sep 17 00:00:00 2001 From: Ari Date: Wed, 13 Apr 2022 16:20:12 -0400 Subject: [PATCH] proper zoom level --- .../src/components/AutomationEditor/index.tsx | 11 +++++++++- .../src/components/AutomationEditor/styles.ts | 13 +++++++++--- webapp/src/components/DAGSvgs/Board.tsx | 9 +++++---- .../components/DAGSvgs/DAGBoard.stories.tsx | 2 +- webapp/src/components/Inputs/InputNumber.tsx | 20 +++++++++++++++++-- .../SequenceNodes/index.stories.tsx | 2 +- 6 files changed, 45 insertions(+), 12 deletions(-) diff --git a/webapp/src/components/AutomationEditor/index.tsx b/webapp/src/components/AutomationEditor/index.tsx index 8ad09c6..c8d4510 100644 --- a/webapp/src/components/AutomationEditor/index.tsx +++ b/webapp/src/components/AutomationEditor/index.tsx @@ -13,6 +13,7 @@ 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; @@ -29,6 +30,7 @@ export const AutomationEditor: FC = ({ onUpdate, }) => { // state + const [zoomLevel, setZoomLevel] = useState(40); const { ratioWbh } = useWindowSize(); const [closeInfo, setCloseInfo] = useState(false); const [modalState, setModalState] = useState(null); @@ -49,6 +51,13 @@ export const AutomationEditor: FC = ({ // render return
+ setZoomLevel(z ?? 40)} + /> {!!modalState && = ({ (theme => ({ - root: ({horizontalMode}) => ({ + root: ({ horizontalMode }) => ({ height: '100%', width: '100%', color: theme.primaryAccent, @@ -18,7 +18,14 @@ export const useEditorStyles = createAppUseStyles<{ borderColor: theme.secondaryAccent, width: '100%', }, - infoIcon: ({horizontalMode}) => ({ + infoIcon: ({ horizontalMode }) => ({ bottom: horizontalMode ? '90%' : 10 - }) + }), + zoom: { + position: 'absolute !important', + right: 0, + bottom: 0, + width: "100%", + // maxWidth: "10em", + } })) diff --git a/webapp/src/components/DAGSvgs/Board.tsx b/webapp/src/components/DAGSvgs/Board.tsx index e7037dd..267239c 100644 --- a/webapp/src/components/DAGSvgs/Board.tsx +++ b/webapp/src/components/DAGSvgs/Board.tsx @@ -16,25 +16,26 @@ export const SVGBoard: FC<{ minGraphWidth = 300, nodeHeight = NODE_HEIGHT, nodeWidth = NODE_WIDTH, - zoomLevel = 1, + zoomLevel = 100, }) => { // state const { ratioWbh } = useWindowSize(); // alias + const paddedZoomLevel = zoomLevel / 100; const graphWidth = Math.max( Math.round(graphHeight * ratioWbh), minGraphWidth ); const { classes, theme } = useBoardStyles({ - boardHeight: Math.max(nodeHeight, graphHeight) * zoomLevel, - boardWidth: Math.max(4 * nodeWidth, graphWidth) * zoomLevel, + boardHeight: Math.max(nodeHeight, graphHeight) * paddedZoomLevel, + boardWidth: Math.max(4 * nodeWidth, graphWidth) * paddedZoomLevel, }); // render return
diff --git a/webapp/src/components/DAGSvgs/DAGBoard.stories.tsx b/webapp/src/components/DAGSvgs/DAGBoard.stories.tsx index 97735ac..189e01f 100644 --- a/webapp/src/components/DAGSvgs/DAGBoard.stories.tsx +++ b/webapp/src/components/DAGSvgs/DAGBoard.stories.tsx @@ -10,7 +10,7 @@ export default { component: DAGBoard, parameters: { actions: { argTypesRegex: '^on.*' } }, args: { - zoomLevel: 1, + zoomLevel: 100, settings: { nodeHeight: NODE_HEIGHT, nodeWidth: NODE_WIDTH, diff --git a/webapp/src/components/Inputs/InputNumber.tsx b/webapp/src/components/Inputs/InputNumber.tsx index 1b88ff4..5cc8c45 100644 --- a/webapp/src/components/Inputs/InputNumber.tsx +++ b/webapp/src/components/Inputs/InputNumber.tsx @@ -6,22 +6,38 @@ export interface Props { label: string; value: number | undefined; onChange: (v: number | undefined) => void; + className?: string; + min?: number, + max?: number, + step?: number, } export default function InputNumber({ label, value = undefined, onChange, + className = "", + min, max, step, }: Props) { const { classes } = useInputNumberStyles({}); - return + return diff --git a/webapp/src/components/SequenceNodes/index.stories.tsx b/webapp/src/components/SequenceNodes/index.stories.tsx index f121268..e974cdf 100644 --- a/webapp/src/components/SequenceNodes/index.stories.tsx +++ b/webapp/src/components/SequenceNodes/index.stories.tsx @@ -11,7 +11,7 @@ export default { component: SequenceNodes, parameters: { actions: { argTypesRegex: '^on.*' } }, args: { - zoomLevel: 1.5, + zoomLevel: 100, startPoint: [0.5, 0.5], dims: { nodeHeight: NODE_HEIGHT,