Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 2f9cc10

Browse files
committed
fixed handle position
1 parent 436feaa commit 2f9cc10

File tree

17 files changed

+120
-78
lines changed

17 files changed

+120
-78
lines changed

examples/react/release/boxes/src/components/PageContainer.tsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/react/release/boxes/src/components/Rectangle/components/RectangleInner.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export default RectangleInner;
4040
const Container = styled.div<{ borderColor: string }>`
4141
display: flex;
4242
position: absolute;
43-
padding: 3px;
4443
border: ${(props) => `1px solid ${props.borderColor}`};
4544
width: 100%;
4645
height: 100%;

examples/react/release/boxes/src/components/actionComponents/Resize/components/Handle.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ const Handle: React.FC<HandlePropsInterface> = (props) => {
2525

2626
// Calculate handle position
2727
if (handleAxis.startsWith('n')) position.top = 0;
28-
if (handleAxis.startsWith('s')) position.bottom = -8;
28+
if (handleAxis.startsWith('s')) position.bottom = 0;
2929
if (handleAxis.includes('w')) position.left = 0;
30-
if (handleAxis.includes('e')) position.right = -8;
30+
if (handleAxis.includes('e')) position.right = 0;
3131

3232
if (handleAxis === 'n' || handleAxis === 's') position.left = '50%';
3333
if (handleAxis === 'e' || handleAxis === 'w') position.top = '50%';

examples/react/release/boxes/src/core/entities/ui/ui.actions.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,28 @@ export const unselectSelectedElement = () => {
144144
SELECTED_ELEMENT.unselect();
145145
};
146146

147+
export const deleteSelectedElement = () => {
148+
const toRemoveElementKey = SELECTED_ELEMENT.itemKey;
149+
if (toRemoveElementKey != null)
150+
ELEMENTS.remove(toRemoveElementKey).everywhere();
151+
};
152+
153+
export const assignDefaultElementStyle = (
154+
windowWidth?: number,
155+
windowHeight?: number
156+
) => {
157+
if (windowWidth != null && windowHeight != null) {
158+
core.ui.defaultElementStyle.position = {
159+
left: Math.floor(
160+
windowWidth / 2 - core.ui.defaultElementStyle.size.width / 2
161+
),
162+
top: Math.floor(
163+
windowHeight / 2 - core.ui.defaultElementStyle.size.height / 2
164+
),
165+
};
166+
}
167+
};
168+
147169
export const getBorderColor = (visible: boolean) => {
148170
return visible ? '#000000' : 'rgba(0, 0, 0, 0)';
149171
};

examples/react/release/boxes/src/core/entities/ui/ui.controller.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { App } from '../../app';
2-
import { ElementInterface } from './ui.interfaces';
2+
import { CanvasInterface, ElementInterface } from './ui.interfaces';
33

44
export const defaultElementStyle = {
55
position: { top: 0, left: 0 },
66
size: { width: 200, height: 200 },
77
};
88

9+
export const CANVAS = App.createState<CanvasInterface>({
10+
width: 5000,
11+
height: 5000,
12+
});
13+
914
export const ELEMENTS = App.createCollection<ElementInterface>();
1015

1116
export const SELECTED_ELEMENT = ELEMENTS.createSelector(

examples/react/release/boxes/src/core/entities/ui/ui.interfaces.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ export interface ElementInterface {
1313
style: ElementStyleInterface;
1414
image?: ElementImageInterface;
1515
}
16+
17+
export interface CanvasInterface {
18+
width: number;
19+
height: number;
20+
}

examples/react/release/boxes/src/screens/Canvas.tsx

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
import { useAgile } from '@agile-ts/react';
4+
import core from '../../../core';
5+
6+
interface PageContainerProps {
7+
onClick: () => void;
8+
}
9+
10+
const CanvasContainer: React.FC<PageContainerProps> = (props) => {
11+
const { onClick, children } = props;
12+
const canvas = useAgile(core.ui.CANVAS);
13+
14+
return (
15+
<Container width={canvas.width} height={canvas.height} onClick={onClick}>
16+
{children}
17+
</Container>
18+
);
19+
};
20+
21+
export default CanvasContainer;
22+
23+
const Container = styled.div<{ width: number; height: number }>`
24+
display: flex;
25+
flex: 1;
26+
width: ${(props) => props.width}px;
27+
height: ${(props) => props.height}px;
28+
background-color: #8a8a8e;
29+
`;

examples/react/release/boxes/src/components/EditProperties/components/Card.tsx renamed to examples/react/release/boxes/src/screens/Canvas/components/EditProperties/components/Card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const Card: React.FC = ({ children }) => (
88
export default Card;
99

1010
const Container = styled.div`
11-
position: absolute;
11+
position: fixed;
1212
top: 20px;
1313
right: 20px;
1414
background: #ffffff;

0 commit comments

Comments
 (0)