-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…itransparent-Rectangle-Component Feature/#473 create a gray semitransparent rectangle component
- Loading branch information
Showing
9 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/common/components/mock-components/front-basic-shapes/modal-cover-shape.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes'; | ||
import { ShapeSizeRestrictions } from '@/core/model'; | ||
import { Group, Rect } from 'react-konva'; | ||
import { useGroupShapeProps } from '../mock-components.utils'; | ||
import { forwardRef } from 'react'; | ||
import { ShapeProps } from '../shape.model'; | ||
|
||
const modalCoverShapeSizeRestrictions: ShapeSizeRestrictions = { | ||
minWidth: 50, | ||
minHeight: 50, | ||
maxWidth: -1, | ||
maxHeight: -1, | ||
defaultWidth: 200, | ||
defaultHeight: 200, | ||
}; | ||
|
||
export const getModalCoverShapeSizeRestrictions = (): ShapeSizeRestrictions => | ||
modalCoverShapeSizeRestrictions; | ||
|
||
const shapeType = 'modalCover'; | ||
|
||
export const ModalCoverShape = forwardRef<any, ShapeProps>((props, ref) => { | ||
const { | ||
x, | ||
y, | ||
width, | ||
height, | ||
id, | ||
onSelected, | ||
text, | ||
otherProps, | ||
...shapeProps | ||
} = props; | ||
|
||
const restrictedSize = fitSizeToShapeSizeRestrictions( | ||
modalCoverShapeSizeRestrictions, | ||
width, | ||
height | ||
); | ||
|
||
const { width: restrictedWidth, height: restrictedHeight } = restrictedSize; | ||
|
||
const commonGroupProps = useGroupShapeProps( | ||
props, | ||
restrictedSize, | ||
shapeType, | ||
ref | ||
); | ||
|
||
return ( | ||
<Group {...commonGroupProps} {...shapeProps}> | ||
<Rect | ||
x={0} | ||
y={0} | ||
width={restrictedWidth} | ||
height={restrictedHeight} | ||
fill={'gray'} | ||
strokeWidth={2} | ||
dash={[1]} | ||
opacity={0.7} | ||
listening={true} | ||
/> | ||
</Group> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/pods/canvas/shape-renderer/simple-basic-shapes/modal-cover.rerender.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ModalCoverShape } from '@/common/components/mock-components/front-basic-shapes'; | ||
import { ShapeRendererProps } from '../model'; | ||
import { ShapeModel } from '@/core/model'; | ||
|
||
export const renderModalCover = ( | ||
shape: ShapeModel, | ||
shapeRenderedProps: ShapeRendererProps | ||
) => { | ||
const { handleSelected, shapeRefs, handleDragEnd, handleTransform } = | ||
shapeRenderedProps; | ||
|
||
return ( | ||
<ModalCoverShape | ||
id={shape.id} | ||
key={shape.id} | ||
ref={shapeRefs.current[shape.id]} | ||
x={shape.x} | ||
y={shape.y} | ||
width={shape.width} | ||
height={shape.height} | ||
draggable | ||
typeOfTransformer={shape.typeOfTransformer} | ||
onSelected={handleSelected} | ||
onDragEnd={handleDragEnd(shape.id)} | ||
onTransform={handleTransform} | ||
onTransformEnd={handleTransform} | ||
otherProps={shape.otherProps} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters