-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create an vertical scroll bar and place it under Front Components
- Loading branch information
1 parent
5cb17a6
commit df2d725
Showing
9 changed files
with
165 additions
and
1 deletion.
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
105 changes: 105 additions & 0 deletions
105
src/common/components/front-components/verticalscrollbar-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,105 @@ | ||
import { Group, Line, Rect } from 'react-konva'; | ||
import { ShapeSizeRestrictions } from '@/core/model'; | ||
import { forwardRef } from 'react'; | ||
import { ShapeProps } from '../front-components/shape.model'; | ||
import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes/shape-restrictions'; | ||
|
||
const VerticalScrollBarShapeSizeRestrictions: ShapeSizeRestrictions = { | ||
minWidth: 10, | ||
minHeight: 100, | ||
maxWidth: 20, | ||
maxHeight: -1, | ||
defaultWidth: 20, | ||
defaultHeight: 250, | ||
}; | ||
|
||
export const getVerticalScrollBarShapeSizeRestrictions = | ||
(): ShapeSizeRestrictions => VerticalScrollBarShapeSizeRestrictions; | ||
|
||
export const VerticalScrollBarShape = forwardRef<any, ShapeProps>( | ||
({ x, y, width, height, id, onSelected, ...shapeProps }, ref) => { | ||
const { width: restrictedWidth, height: restrictedHeight } = | ||
fitSizeToShapeSizeRestrictions( | ||
VerticalScrollBarShapeSizeRestrictions, | ||
width, | ||
height | ||
); | ||
|
||
const arrowHeight = 20; | ||
const thumbHeight = restrictedHeight * 0.3; // Ajuste de la altura del thumb al 30% de la barra | ||
const thumbY = | ||
arrowHeight + (restrictedHeight - thumbHeight - arrowHeight * 2) / 2; // Centrar el thumb dentro del área disponible | ||
|
||
return ( | ||
<Group | ||
x={x} | ||
y={y} | ||
ref={ref} | ||
width={restrictedWidth} | ||
height={restrictedHeight} | ||
{...shapeProps} | ||
onClick={() => onSelected(id, 'verticalScrollBar')} | ||
> | ||
{/* Fondo de la barra de scroll */} | ||
<Rect | ||
x={0} | ||
y={arrowHeight} | ||
width={restrictedWidth} | ||
height={restrictedHeight - arrowHeight * 2} | ||
fill="#D0D0D0" | ||
stroke="#A0A0A0" | ||
strokeWidth={1} | ||
/> | ||
|
||
{/* Flecha superior */} | ||
<Rect | ||
x={0} | ||
y={6} | ||
width={restrictedWidth} | ||
height={arrowHeight} | ||
fill="#E0E0E0" | ||
stroke="#A0A0A0" | ||
strokeWidth={1} | ||
/> | ||
|
||
<Line | ||
x={restrictedWidth / 2} | ||
y={arrowHeight - 8} | ||
points={[-2, 8, 0, 2, 4, 8]} | ||
fill="black" | ||
closed={true} | ||
/> | ||
|
||
{/* Thumb de la barra de scroll */} | ||
<Rect | ||
x={0} | ||
y={thumbY} | ||
width={restrictedWidth} | ||
height={thumbHeight} | ||
fill="#C0C0C0" | ||
stroke="#808080" | ||
strokeWidth={1} | ||
/> | ||
|
||
{/* Flecha inferior */} | ||
<Rect | ||
x={0} | ||
y={restrictedHeight - arrowHeight - 6} | ||
width={restrictedWidth} | ||
height={arrowHeight} | ||
fill="#E0E0E0" | ||
stroke="#A0A0A0" | ||
strokeWidth={1} | ||
/> | ||
|
||
<Line | ||
x={restrictedWidth / 2} | ||
y={restrictedHeight - arrowHeight + 8} | ||
points={[-4, -8, 0, -2, 4, -8]} | ||
fill="black" | ||
closed={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-component/verticalscrollbar.renderer.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 { ShapeModel } from '@/core/model'; | ||
import { ShapeRendererProps } from '../model'; | ||
import { VerticalScrollBarShape } from '@/common/components/front-components'; | ||
|
||
export const renderVerticalScrollBar = ( | ||
shape: ShapeModel, | ||
shapeRenderedProps: ShapeRendererProps | ||
) => { | ||
const { handleSelected, shapeRefs, handleDragEnd, handleTransform } = | ||
shapeRenderedProps; | ||
|
||
return ( | ||
<VerticalScrollBarShape | ||
id={shape.id} | ||
key={shape.id} | ||
x={shape.x} | ||
y={shape.y} | ||
width={shape.width} | ||
height={shape.height} | ||
name="shape" | ||
draggable | ||
typeOfTransformer={shape.typeOfTransformer} | ||
onSelected={handleSelected} | ||
ref={shapeRefs.current[shape.id]} | ||
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