Skip to content

Commit

Permalink
Fixing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
LourdesRsdp committed Jul 29, 2024
1 parent 9ce68f7 commit b75509a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
4 changes: 2 additions & 2 deletions public/widgets/progressbar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 13 additions & 20 deletions src/common/components/front-components/progressbar-shape.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
import { ShapeSizeRestrictions } from '@/core/model';
import { forwardRef } from 'react';
import { Group, Rect } from 'react-konva';
import { ShapeConfig } from 'konva/lib/Shape';
import { ShapeProps } from './shape.model';

export const getProgressBarShapeSizeRestrictions =
(): ShapeSizeRestrictions => ({
minWidth: 80,
minHeight: 50,
maxWidth: -1,
maxHeight: 50,
defaultWidth: 220,
defaultWidth: 280,
defaultHeight: 20,
});

interface ProgressBarShapeProps extends ShapeConfig {
id: string;
x: number;
y: number;
width: number;
height: number;
progress: number;
onSelected: (id: string, name: string) => void;
}

export const ProgressBarShape = forwardRef<any, ProgressBarShapeProps>(
({ x, y, width, height, id, onSelected, progress, ...shapeProps }, ref) => {
export const ProgressBarShape = forwardRef<any, ShapeProps>(
({ x, y, width, height, id, onSelected, ...shapeProps }, ref) => {
const margin = 10;
const barHeight = 20;
const progressBarWidth = (width - 2 * margin) * progress;
const progressBarWidth = width / 2;

return (
<Group
Expand All @@ -39,7 +29,7 @@ export const ProgressBarShape = forwardRef<any, ProgressBarShapeProps>(
{...shapeProps}
onClick={() => onSelected(id, 'progressbar')}
>
{/* ProgressBar background */}
{/* Progressbar background */}
<Rect
x={margin}
y={height / 2 - barHeight / 2}
Expand All @@ -48,16 +38,19 @@ export const ProgressBarShape = forwardRef<any, ProgressBarShapeProps>(
cornerRadius={10}
stroke="black"
strokeWidth={2}
fill="none"
fill="white"
/>
{/* Progressbar */}

{/* Progressbar progress */}
<Rect
x={margin}
y={height / 2 - barHeight / 2}
width={progressBarWidth}
height={height}
height={barHeight}
cornerRadius={10}
fill="blue"
stroke="black"
strokeWidth={2}
fill="lightgrey"
/>
</Group>
);
Expand Down

0 comments on commit b75509a

Please sign in to comment.