Skip to content

Commit e07c4cf

Browse files
committed
merge resolved
2 parents e0d8dab + acc5fc5 commit e07c4cf

File tree

13 files changed

+131
-4
lines changed

13 files changed

+131
-4
lines changed
Lines changed: 3 additions & 0 deletions
Loading

src/common/components/mock-components/front-components/shape.const.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ export const BASIC_SHAPE: DefaultStyleShape = {
6060
DEFAULT_DISABLED,
6161
};
6262

63+
export const LOW_WIREFRAME_SHAPE = {
64+
DEFAULT_STROKE_WIDTH: 6,
65+
};
66+
6367
export const INPUT_SHAPE: DefaultStyleShape = {
6468
DEFAULT_CORNER_RADIUS,
6569
DEFAULT_STROKE_COLOR,
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { ShapeSizeRestrictions, ShapeType } from '@/core/model';
2+
import { forwardRef } from 'react';
3+
import { ShapeProps } from '../shape.model';
4+
import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes/shape-restrictions';
5+
import { Circle, Group } from 'react-konva';
6+
import { useShapeProps } from '../../shapes/use-shape-props.hook';
7+
import {
8+
BASIC_SHAPE,
9+
LOW_WIREFRAME_SHAPE,
10+
} from '../front-components/shape.const';
11+
import { useGroupShapeProps } from '../mock-components.utils';
12+
13+
const circleLowShapeRestrictions: ShapeSizeRestrictions = {
14+
minWidth: 10,
15+
minHeight: 10,
16+
maxWidth: -1,
17+
maxHeight: -1,
18+
defaultWidth: 160,
19+
defaultHeight: 100,
20+
};
21+
22+
export const getCircleLowShapeSizeRestrictions = (): ShapeSizeRestrictions =>
23+
circleLowShapeRestrictions;
24+
25+
const shapeType: ShapeType = 'circleLow';
26+
27+
export const CircleLowShape = forwardRef<any, ShapeProps>((props, ref) => {
28+
const { x, y, width, height, id, onSelected, otherProps, ...shapeProps } =
29+
props;
30+
31+
const restrictedSize = fitSizeToShapeSizeRestrictions(
32+
circleLowShapeRestrictions,
33+
width,
34+
height
35+
);
36+
37+
const { width: restrictedWidth, height: restrictedHeight } = restrictedSize;
38+
39+
const radius = Math.min(restrictedWidth, restrictedHeight) / 2;
40+
41+
const { stroke, fill, strokeStyle } = useShapeProps(otherProps, BASIC_SHAPE);
42+
43+
const commonGroupProps = useGroupShapeProps(
44+
props,
45+
restrictedSize,
46+
shapeType,
47+
ref
48+
);
49+
50+
return (
51+
<Group {...commonGroupProps} {...shapeProps}>
52+
<Circle
53+
x={restrictedWidth / 2}
54+
y={restrictedHeight / 2}
55+
radius={radius}
56+
stroke={stroke}
57+
strokeWidth={LOW_WIREFRAME_SHAPE.DEFAULT_STROKE_WIDTH}
58+
fill={fill}
59+
dash={strokeStyle}
60+
/>
61+
</Group>
62+
);
63+
});

src/common/components/mock-components/front-low-wireframes-components/ellipse-low-shape.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { ShapeSizeRestrictions, ShapeType } from '@/core/model';
44
import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes/shape-restrictions';
55
import { ShapeProps } from '../shape.model';
66
import { useGroupShapeProps } from '../mock-components.utils';
7-
import { BASIC_SHAPE } from '../front-components/shape.const';
7+
import {
8+
BASIC_SHAPE,
9+
LOW_WIREFRAME_SHAPE,
10+
} from '../front-components/shape.const';
811
import { useShapeProps } from '../../shapes/use-shape-props.hook';
912

1013
const EllipseLowShapeRestrictions: ShapeSizeRestrictions = {
@@ -58,7 +61,7 @@ export const EllipseLowShape = forwardRef<any, ShapeProps>((props, ref) => {
5861
radiusX={restrictedWidth}
5962
radiusY={restrictedHeight}
6063
stroke={stroke}
61-
strokeWidth={4}
64+
strokeWidth={LOW_WIREFRAME_SHAPE.DEFAULT_STROKE_WIDTH}
6265
dash={strokeStyle}
6366
/>
6467
</Group>

src/common/components/mock-components/front-low-wireframes-components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from './horizontal-line-low-shape';
33
export * from './image-placeholder-shape';
44
export * from './vertical-line-low-shape';
55
export * from './rectangle-low-shape';
6+
export * from './circle-low-shape';

src/core/model/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ export type ShapeType =
8181
| 'horizontalLineLow'
8282
| 'verticalLineLow'
8383
| 'ellipseLow'
84-
| 'rectangleLow';
84+
| 'rectangleLow'
85+
| 'circleLow';
8586

8687
export const ShapeDisplayName: Record<ShapeType, string> = {
8788
multiple: 'multiple',
@@ -152,6 +153,7 @@ export const ShapeDisplayName: Record<ShapeType, string> = {
152153
verticalLineLow: 'Vertical Divider',
153154
ellipseLow: 'Ellipse',
154155
rectangleLow: 'Rectangle Placeholder',
156+
circleLow: 'Circle',
155157
};
156158

157159
export type EditType = 'input' | 'textarea' | 'imageupload';

src/pods/canvas/model/shape-other-props.utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export const generateDefaultOtherProps = (
124124
case 'horizontalLine':
125125
case 'horizontalLineLow':
126126
case 'rectangleLow':
127+
case 'circleLow':
127128
case 'verticalLineLow':
128129
case 'ellipseLow':
129130
return {

src/pods/canvas/model/shape-size.mapper.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@ import {
7979
} from '@/common/components/mock-components/front-text-components';
8080

8181
import {
82-
getEllipseLowShapeRestrictions,
8382
getHorizontalLineLowShapeRestrictions,
8483
getImagePlaceholderShapeSizeRestrictions,
8584
getVerticalLineLowShapeRestrictions,
8685
getRectangleLowShapeRestrictions,
86+
getEllipseLowShapeRestrictions,
87+
getCircleLowShapeSizeRestrictions,
8788
} from '@/common/components/mock-components/front-low-wireframes-components';
8889

8990
const getMultipleNodeSizeRestrictions = (): ShapeSizeRestrictions => ({
@@ -165,6 +166,7 @@ const shapeSizeMap: Record<ShapeType, () => ShapeSizeRestrictions> = {
165166
verticalLineLow: getVerticalLineLowShapeRestrictions,
166167
ellipseLow: getEllipseLowShapeRestrictions,
167168
rectangleLow: getRectangleLowShapeRestrictions,
169+
circleLow: getCircleLowShapeSizeRestrictions,
168170
};
169171

170172
export default shapeSizeMap;

src/pods/canvas/model/transformer.model.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ export const generateTypeOfTransformer = (shapeType: ShapeType): string[] => {
7575
case 'verticalScrollBar':
7676
case 'verticalLineLow':
7777
return ['top-center', 'bottom-center'];
78+
case 'circleLow':
79+
return [
80+
'top-left',
81+
'top-right',
82+
'bottom-left',
83+
'bottom-right',
84+
'top-center',
85+
'bottom-center',
86+
];
7887
case 'icon':
7988
case 'multiple':
8089
return [];

src/pods/canvas/shape-renderer/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import {
7474
renderSmalltext,
7575
} from './simple-text-components';
7676
import {
77+
renderCircleLow,
7778
renderHorizontalLowLine,
7879
renderImagePlaceHolder,
7980
renderVerticalLowLine,
@@ -220,6 +221,8 @@ export const renderShapeComponent = (
220221
return renderEllipseLow(shape, shapeRenderedProps);
221222
case 'rectangleLow':
222223
return renderRectangleLow(shape, shapeRenderedProps);
224+
case 'circleLow':
225+
return renderCircleLow(shape, shapeRenderedProps);
223226
default:
224227
return renderNotFound(shape, shapeRenderedProps);
225228
}

0 commit comments

Comments
 (0)