11import { ShapeSizeRestrictions , ShapeType } from '@/core/model' ;
22import { forwardRef } from 'react' ;
33import { ShapeProps } from '../shape.model' ;
4- import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes/shape-restrictions' ;
4+ import {
5+ fitSizeToShapeSizeRestrictions ,
6+ calculateShapeAdjustedDimensionsBasedOnStrokeHeight ,
7+ } from '@/common/utils/shapes' ;
58import { Circle , Group } from 'react-konva' ;
69import { useShapeProps } from '../../shapes/use-shape-props.hook' ;
7- import {
8- BASIC_SHAPE ,
9- LOW_WIREFRAME_SHAPE ,
10- } from '../front-components/shape.const' ;
10+ import { BASIC_SHAPE } from '../front-components/shape.const' ;
1111import { useGroupShapeProps } from '../mock-components.utils' ;
1212
1313const circleLowShapeRestrictions : ShapeSizeRestrictions = {
@@ -36,9 +36,18 @@ export const CircleLowShape = forwardRef<any, ShapeProps>((props, ref) => {
3636
3737 const { width : restrictedWidth , height : restrictedHeight } = restrictedSize ;
3838
39- const radius = Math . min ( restrictedWidth , restrictedHeight ) / 2 ;
39+ const { stroke, fill, strokeStyle, strokeWidth } = useShapeProps (
40+ otherProps ,
41+ BASIC_SHAPE
42+ ) ;
4043
41- const { stroke, fill, strokeStyle } = useShapeProps ( otherProps , BASIC_SHAPE ) ;
44+ const adjustedDimensions =
45+ calculateShapeAdjustedDimensionsBasedOnStrokeHeight (
46+ strokeWidth ,
47+ restrictedWidth ,
48+ restrictedHeight ,
49+ shapeType
50+ ) ;
4251
4352 const commonGroupProps = useGroupShapeProps (
4453 props ,
@@ -49,15 +58,17 @@ export const CircleLowShape = forwardRef<any, ShapeProps>((props, ref) => {
4958
5059 return (
5160 < 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+ { adjustedDimensions . type === 'circleLow' && (
62+ < Circle
63+ x = { adjustedDimensions . centerX }
64+ y = { adjustedDimensions . centerY }
65+ radius = { adjustedDimensions . adjustedRadius }
66+ stroke = { stroke }
67+ strokeWidth = { strokeWidth }
68+ fill = { fill }
69+ dash = { strokeStyle }
70+ />
71+ ) }
6172 </ Group >
6273 ) ;
6374} ) ;
0 commit comments