Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions public/low-wireframes/horizontalLineLow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { forwardRef } from 'react';
import { Group, Line, Rect } from 'react-konva';
import { ShapeSizeRestrictions, ShapeType } from '@/core/model';
import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes/shape-restrictions';
import { ShapeProps } from '../shape.model';
import { useShapeProps } from '../../shapes/use-shape-props.hook';
import { BASIC_SHAPE } from '../front-components/shape.const';
import { useGroupShapeProps } from '../mock-components.utils';

const horizontalLineLowShapeRestrictions: ShapeSizeRestrictions = {
minWidth: 30,
minHeight: 10,
maxWidth: -1,
maxHeight: 10,
defaultWidth: 200,
defaultHeight: 10,
};

export const getHorizontalLineLowShapeRestrictions =
(): ShapeSizeRestrictions => horizontalLineLowShapeRestrictions;

const shapeType: ShapeType = 'horizontalLine';

export const HorizontalLineLowShape = forwardRef<any, ShapeProps>(
(props, ref) => {
const {
x,
y,
width,
height,
id,
onSelected,
text,
otherProps,
...shapeProps
} = props;
const restrictedSize = fitSizeToShapeSizeRestrictions(
horizontalLineLowShapeRestrictions,
width,
height
);

const { width: restrictedWidth, height: restrictedHeight } = restrictedSize;

const { stroke, strokeStyle } = useShapeProps(otherProps, BASIC_SHAPE);

const commonGroupProps = useGroupShapeProps(
props,
restrictedSize,
shapeType,
ref
);

return (
<Group {...commonGroupProps} {...shapeProps}>
{/* Transparent rectangle for applying margin */}
<Rect
width={restrictedWidth}
height={restrictedHeight}
fill="transparent"
/>

<Line
x={0}
y={restrictedHeight / 2}
points={[0, 0, restrictedWidth, 0]}
stroke={stroke}
strokeWidth={4}
dash={strokeStyle}
/>
</Group>
);
}
);
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './image-placeholder-shape';
export * from './horizontal-line-low-shape';
export * from './vertical-line-low-shape';
2 changes: 2 additions & 0 deletions src/core/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export type ShapeType =
| 'richtext'
| 'gauge'
| 'imagePlaceholder'
| 'horizontalLineLow'
| 'verticalLineLow';

export const ShapeDisplayName: Record<ShapeType, string> = {
Expand Down Expand Up @@ -145,6 +146,7 @@ export const ShapeDisplayName: Record<ShapeType, string> = {
videoconference: 'Videoconference',
gauge: 'Gauge',
imagePlaceholder: 'Image Placeholder',
horizontalLineLow: 'Horizontal Divider',
verticalLineLow: 'Vertical Divider',
};

Expand Down
1 change: 1 addition & 0 deletions src/pods/canvas/model/shape-other-props.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export const generateDefaultOtherProps = (
borderRadius: `${INPUT_SHAPE.DEFAULT_CORNER_RADIUS}`,
};
case 'horizontalLine':
case 'horizontalLineLow':
case 'verticalLineLow':
return {
stroke: '#000000',
Expand Down
6 changes: 5 additions & 1 deletion src/pods/canvas/model/shape-size.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ import {
// other imports
} from '@/common/components/mock-components/front-text-components';

import { getImagePlaceholderShapeSizeRestrictions } from '@/common/components/mock-components/front-low-wireframes-components';
import {
getHorizontalLineLowShapeRestrictions,
getImagePlaceholderShapeSizeRestrictions,
} from '@/common/components/mock-components/front-low-wireframes-components';
import { getVerticalLineLowShapeRestrictions } from '@/common/components/mock-components/front-low-wireframes-components/vertical-line-low-shape';

const getMultipleNodeSizeRestrictions = (): ShapeSizeRestrictions => ({
Expand Down Expand Up @@ -156,6 +159,7 @@ const shapeSizeMap: Record<ShapeType, () => ShapeSizeRestrictions> = {
gauge: getGaugeShapeSizeRestrictions,
imagePlaceholder: getImagePlaceholderShapeSizeRestrictions,
chip: getChipShapeSizeRestrictions,
horizontalLineLow: getHorizontalLineLowShapeRestrictions,
verticalLineLow: getVerticalLineLowShapeRestrictions,
};

Expand Down
1 change: 1 addition & 0 deletions src/pods/canvas/model/transformer.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const generateTypeOfTransformer = (shapeType: ShapeType): string[] => {
case 'combobox':
case 'datepickerinput':
case 'horizontalLine':
case 'horizontalLineLow':
case 'listbox':
case 'checkbox':
case 'toggleswitch':
Expand Down
3 changes: 3 additions & 0 deletions src/pods/canvas/shape-renderer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import {
renderSmalltext,
} from './simple-text-components';
import {
renderHorizontalLowLine,
renderImagePlaceHolder,
renderVerticalLowLine,
} from './simple-low-wireframes-components';
Expand Down Expand Up @@ -209,6 +210,8 @@ export const renderShapeComponent = (
return renderImagePlaceHolder(shape, shapeRenderedProps);
case 'chip':
return renderChip(shape, shapeRenderedProps);
case 'horizontalLineLow':
return renderHorizontalLowLine(shape, shapeRenderedProps);
case 'verticalLineLow':
return renderVerticalLowLine(shape, shapeRenderedProps);
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './image-placeholder.renderer';
export * from './low-horizontal-line.renderer';
export * from './low-vertical-line.renderer';
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ShapeRendererProps } from '../model';
import { ShapeModel } from '@/core/model';
import { HorizontalLineLowShape } from '@/common/components/mock-components/front-low-wireframes-components';

export const renderHorizontalLowLine = (
shape: ShapeModel,
shapeRenderedProps: ShapeRendererProps
) => {
const { handleSelected, shapeRefs, handleDragEnd, handleTransform } =
shapeRenderedProps;

return (
<HorizontalLineLowShape
id={shape.id}
key={shape.id}
ref={shapeRefs.current[shape.id]}
x={shape.x}
y={shape.y}
name="shape"
width={shape.width}
height={shape.height}
draggable
typeOfTransformer={shape.typeOfTransformer}
onSelected={handleSelected}
onDragEnd={handleDragEnd(shape.id)}
onTransform={handleTransform}
onTransformEnd={handleTransform}
otherProps={shape.otherProps}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ export const mockLowWireframeCollection: ItemInfo[] = [
thumbnailSrc: '/low-wireframes/imagePlaceholder.svg',
type: 'imagePlaceholder',
},
{
thumbnailSrc: '/low-wireframes/horizontalLineLow.svg',
type: 'horizontalLineLow',
},
{
thumbnailSrc: '/low-wireframes/verticalLineLow.svg',
type: 'verticalLineLow',
Expand Down