Skip to content

Commit

Permalink
Update code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaslehnertum committed Oct 4, 2023
1 parent aff01d9 commit 58b76f9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
25 changes: 17 additions & 8 deletions src/main/components/canvas/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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<typeof UMLElementRepository.move>;
Expand Down Expand Up @@ -158,8 +161,11 @@ class EditorComponent extends Component<Props, State> {

if (this.state.isMobile) {
return (
<div ref={this.zoomContainer} style={{ height: '100%', width: '100%', overflow: zoomFactor > 1.0 ? 'auto' : 'hidden' }}>
<StyledEditor ref={this.editor} {...props} onTouchMove={this.customScrolling} zoomFactor={zoomFactor}/>
<div
ref={this.zoomContainer}
style={{ height: '100%', width: '100%', overflow: zoomFactor > 1.0 ? 'auto' : 'hidden' }}
>
<StyledEditor ref={this.editor} {...props} onTouchMove={this.customScrolling} zoomFactor={zoomFactor} />
<ZoomPane
value={zoomFactor}
onChange={(zoomFactor) => this.props.changeZoomFactor(zoomFactor)}
Expand All @@ -171,8 +177,11 @@ class EditorComponent extends Component<Props, State> {
);
} else {
return (
<div ref={this.zoomContainer} style={{ height: '100%', width: '100%', overflow: zoomFactor > 1.0 ? 'auto' : 'hidden' }}>
<StyledEditor ref={this.editor} {...props} zoomFactor={zoomFactor}/>
<div
ref={this.zoomContainer}
style={{ height: '100%', width: '100%', overflow: zoomFactor > 1.0 ? 'auto' : 'hidden' }}
>
<StyledEditor ref={this.editor} {...props} zoomFactor={zoomFactor} />
<ZoomPane
value={zoomFactor}
onChange={(zoomFactor) => this.props.changeZoomFactor(zoomFactor)}
Expand Down
7 changes: 3 additions & 4 deletions src/main/components/connectable/connection-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,9 @@ class Preview extends Component<Props, State> {
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 });
Expand Down
3 changes: 1 addition & 2 deletions src/main/components/uml-element/movable/movable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/services/editor/editor-repository.ts
Original file line number Diff line number Diff line change
@@ -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 => ({
Expand Down
2 changes: 1 addition & 1 deletion src/main/utils/clamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
*/
export const clamp = (value: number, min: number, max: number): number => {
return Math.max(min, Math.min(value, max));
};
};

0 comments on commit 58b76f9

Please sign in to comment.