-
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
…gallery Adding Basic shape gallery
- Loading branch information
Showing
12 changed files
with
112 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './rectangle-basic-shape'; |
47 changes: 47 additions & 0 deletions
47
src/common/components/front-basic-sapes/rectangle-basic-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,47 @@ | ||
import { ShapeSizeRestrictions } from '@/core/model'; | ||
import { forwardRef } from 'react'; | ||
import { ShapeProps } from '../front-components/shape.model'; | ||
import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes/shape-restrictions'; | ||
import { Group, Rect } from 'react-konva'; | ||
|
||
const rectangleShapeRestrictions: ShapeSizeRestrictions = { | ||
minWidth: 60, | ||
minHeight: 45, | ||
maxWidth: -1, | ||
maxHeight: -1, | ||
defaultWidth: 170, | ||
defaultHeight: 45, | ||
}; | ||
|
||
export const getRectangleShapeSizeRestrictions = (): ShapeSizeRestrictions => | ||
rectangleShapeRestrictions; | ||
|
||
export const RectangleShape = forwardRef<any, ShapeProps>( | ||
({ x, y, width, height, id, onSelected, text, ...shapeProps }, ref) => { | ||
const { width: restrictedWidth, height: restrictedHeight } = | ||
fitSizeToShapeSizeRestrictions(rectangleShapeRestrictions, width, height); | ||
|
||
return ( | ||
<Group | ||
x={x} | ||
y={y} | ||
ref={ref} | ||
width={restrictedWidth} | ||
height={restrictedHeight} | ||
{...shapeProps} | ||
onClick={() => onSelected(id, 'rectangle')} | ||
> | ||
<Rect | ||
x={0} | ||
y={0} | ||
width={restrictedWidth} | ||
height={restrictedHeight} | ||
strokeWidth={2} | ||
stroke="black" | ||
fille={null} | ||
cornerRadius={5} | ||
/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { ItemInfo } from '@/common/components/gallery/components/model'; | ||
|
||
export const mockBasicShapesCollection: ItemInfo[] = [ | ||
{ thumbnailSrc: '/shapes/rectangle.svg', type: 'rectangle' }, | ||
]; |
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,6 @@ | ||
import { GalleryComponent } from '@/common/components/gallery/gallery-component'; | ||
import { mockBasicShapesCollection } from '../basic-shapes-gallery/basic-gallery-data'; | ||
|
||
export const BasicShapesGalleryPod = () => { | ||
return <GalleryComponent itemCollection={mockBasicShapesCollection} />; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './rectangle.rerender'; |
28 changes: 28 additions & 0 deletions
28
src/pods/canvas/shape-renderer/simple-basic-shapes/rectangle.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,28 @@ | ||
import { RectangleShape } from '@/common/components/front-basic-sapes'; | ||
import { ShapeRendererProps } from '../model'; | ||
import { ShapeModel } from '@/core/model'; | ||
|
||
export const renderRectangle = ( | ||
shape: ShapeModel, | ||
shapeRenderedProps: ShapeRendererProps | ||
) => { | ||
const { handleSelected, shapeRefs, handleDragEnd, handleTransform } = | ||
shapeRenderedProps; | ||
|
||
return ( | ||
<RectangleShape | ||
id={shape.id} | ||
key={shape.id} | ||
ref={shapeRefs.current[shape.id]} | ||
x={shape.x} | ||
y={shape.y} | ||
width={shape.width} | ||
height={shape.height} | ||
draggable | ||
onSelected={handleSelected} | ||
onDragEnd={handleDragEnd(shape.id)} | ||
onTransform={handleTransform} | ||
onTransformEnd={handleTransform} | ||
/> | ||
); | ||
}; |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from "./canvas/canvas.pod"; | ||
export * from "./container-gallery/container-gallery.pod"; | ||
export * from "./component-gallery/component-gallery.pod"; | ||
export * from "./toolbar/toolbar.pod"; | ||
export * from './canvas/canvas.pod'; | ||
export * from './container-gallery/container-gallery.pod'; | ||
export * from './component-gallery/component-gallery.pod'; | ||
export * from './basic-shapes-gallery/basic-shapes-gallery.pod'; | ||
export * from './toolbar/toolbar.pod'; |
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