From 58b76f92830966047c8918e401c1473f93daea31 Mon Sep 17 00:00:00 2001 From: Matthias Lehner Date: Wed, 4 Oct 2023 23:27:41 +0200 Subject: [PATCH] Update code formatting --- src/main/components/canvas/editor.tsx | 25 +++++++++++++------ .../connectable/connection-preview.tsx | 7 +++--- .../uml-element/movable/movable.tsx | 3 +-- src/main/services/editor/editor-repository.ts | 2 +- src/main/utils/clamp.ts | 2 +- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/main/components/canvas/editor.tsx b/src/main/components/canvas/editor.tsx index d55fdd7c..d86d5c12 100644 --- a/src/main/components/canvas/editor.tsx +++ b/src/main/components/canvas/editor.tsx @@ -19,7 +19,7 @@ const borderWidth: number = 1; const StyledEditor = styled.div<{ zoomFactor: number }>` display: block; overflow: auto; - + position: relative; min-height: inherit; max-height: inherit; @@ -30,7 +30,7 @@ const StyledEditor = styled.div<{ zoomFactor: number }>` -ms-overflow-style: -ms-autohiding-scrollbar; border: ${borderWidth}px solid ${(props) => props.theme.color.gray}; background-position: calc(50% + ${(grid * subdivisions - borderWidth) / 2}px) - calc(50% + ${(grid * subdivisions - borderWidth) / 2}px); + calc(50% + ${(grid * subdivisions - borderWidth) / 2}px); background-size: ${grid * subdivisions}px ${grid * subdivisions}px, ${grid * subdivisions}px ${grid * subdivisions}px, @@ -42,14 +42,17 @@ const StyledEditor = styled.div<{ zoomFactor: number }>` linear-gradient(to bottom, ${(props) => props.theme.color.gray} 1px, transparent 1px); background-repeat: repeat; background-attachment: local; - transition: transform 500ms, width 500ms, height 500ms; + transition: + transform 500ms, + width 500ms, + height 500ms; transform-origin: top left; transform: scale(${(props) => props.zoomFactor ?? 1}); `; type OwnProps = { children: ReactNode }; -type StateProps = { moving: string[]; connecting: boolean; reconnecting: boolean; zoomFactor: number; }; +type StateProps = { moving: string[]; connecting: boolean; reconnecting: boolean; zoomFactor: number }; type DispatchProps = { move: AsyncDispatch; @@ -158,8 +161,11 @@ class EditorComponent extends Component { if (this.state.isMobile) { return ( -
1.0 ? 'auto' : 'hidden' }}> - +
1.0 ? 'auto' : 'hidden' }} + > + this.props.changeZoomFactor(zoomFactor)} @@ -171,8 +177,11 @@ class EditorComponent extends Component { ); } else { return ( -
1.0 ? 'auto' : 'hidden' }}> - +
1.0 ? 'auto' : 'hidden' }} + > + this.props.changeZoomFactor(zoomFactor)} diff --git a/src/main/components/connectable/connection-preview.tsx b/src/main/components/connectable/connection-preview.tsx index 42a70414..54dc8a0d 100644 --- a/src/main/components/connectable/connection-preview.tsx +++ b/src/main/components/connectable/connection-preview.tsx @@ -96,10 +96,9 @@ class Preview extends Component { if (event instanceof PointerEvent) { position = new Point(event.clientX - offset.x, event.clientY - offset.y).scale(1 / zoomFactor); } else { - position = new Point( - event.targetTouches[0].clientX - offset.x, - event.targetTouches[0].clientY - offset.y, - ).scale(1 / zoomFactor); + position = new Point(event.targetTouches[0].clientX - offset.x, event.targetTouches[0].clientY - offset.y).scale( + 1 / zoomFactor, + ); } this.setState({ position }); diff --git a/src/main/components/uml-element/movable/movable.tsx b/src/main/components/uml-element/movable/movable.tsx index d0959e5b..bc67f38c 100644 --- a/src/main/components/uml-element/movable/movable.tsx +++ b/src/main/components/uml-element/movable/movable.tsx @@ -51,8 +51,7 @@ export const movable = ( moveWindow: { x: number; y: number } = { x: 0, y: 0 }; move = (x: number, y: number) => { - - const {zoomFactor = 1} = this.props; + const { zoomFactor = 1 } = this.props; x = Math.round(x / 10) * 10; y = Math.round(y / 10) * 10; diff --git a/src/main/services/editor/editor-repository.ts b/src/main/services/editor/editor-repository.ts index 880b6dac..274f9826 100644 --- a/src/main/services/editor/editor-repository.ts +++ b/src/main/services/editor/editor-repository.ts @@ -1,4 +1,4 @@ -import {ApollonView, ChangeViewAction, ChangeZoomFactorAction, EditorActionTypes} from './editor-types'; +import { ApollonView, ChangeViewAction, ChangeZoomFactorAction, EditorActionTypes } from './editor-types'; export class EditorRepository { static changeView = (view: ApollonView): ChangeViewAction => ({ diff --git a/src/main/utils/clamp.ts b/src/main/utils/clamp.ts index 1c982590..844c8f47 100644 --- a/src/main/utils/clamp.ts +++ b/src/main/utils/clamp.ts @@ -6,4 +6,4 @@ */ export const clamp = (value: number, min: number, max: number): number => { return Math.max(min, Math.min(value, max)); -}; \ No newline at end of file +};