-
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.
Merge branch 'main' into #56-Progressbar
- Loading branch information
Showing
78 changed files
with
1,336 additions
and
133 deletions.
There are no files selected for viewing
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,25 @@ | ||
name: CI Workflow | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js 18.13.0 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '18.13.0' | ||
cache: 'npm' | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Build | ||
run: npm run tsc-check | ||
|
||
- name: Run tests | ||
run: npm test |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
69 changes: 69 additions & 0 deletions
69
src/common/components/front-components/datepickerinput-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,69 @@ | ||
import { Group, Rect, Line } from 'react-konva'; | ||
import { forwardRef } from 'react'; | ||
import { ShapeProps } from './shape.model'; | ||
import { ShapeSizeRestrictions } from '@/core/model'; | ||
|
||
export const getDatepickerInputShapeSizeRestrictions = | ||
(): ShapeSizeRestrictions => ({ | ||
minWidth: 80, | ||
minHeight: 50, | ||
maxWidth: -1, | ||
maxHeight: 50, | ||
defaultWidth: 220, | ||
defaultHeight: 50, | ||
}); | ||
|
||
export const DatepickerInputShape = forwardRef<any, ShapeProps>( | ||
({ x, y, width, height, id, onSelected, ...shapeProps }, ref) => { | ||
const margin = 10; | ||
const separatorPadding = 15; // Extra padding for spacers | ||
const separator1X = width / 3 + margin; | ||
const separator2X = (2 * width) / 3 - margin; | ||
|
||
return ( | ||
<Group | ||
x={x} | ||
y={y} | ||
ref={ref} | ||
width={width} | ||
height={height} | ||
{...shapeProps} | ||
onClick={() => onSelected(id, 'datepickerinput')} | ||
> | ||
{/* input frame */} | ||
<Rect | ||
x={margin} | ||
y={margin * 3} | ||
width={width - 2 * margin} | ||
height={height} | ||
cornerRadius={10} | ||
stroke="black" | ||
strokeWidth={2} | ||
fill="white" | ||
/> | ||
|
||
{/* Inverted diagonal spacers */} | ||
<Line | ||
points={[ | ||
separator1X + separatorPadding, | ||
margin * 2 + separatorPadding, | ||
separator1X - separatorPadding, | ||
margin * 4 + height - separatorPadding, | ||
]} | ||
stroke="black" | ||
strokeWidth={2} | ||
/> | ||
<Line | ||
points={[ | ||
separator2X + separatorPadding, | ||
margin * 2 + separatorPadding, | ||
separator2X - separatorPadding, | ||
margin * 4 + height - separatorPadding, | ||
]} | ||
stroke="black" | ||
strokeWidth={2} | ||
/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { ShapeSizeRestrictions } from '@/core/model'; | ||
import { forwardRef, useEffect, useRef, useState } from 'react'; | ||
import { Group, Rect, Text } from 'react-konva'; | ||
import { ShapeProps } from './shape.model'; | ||
import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes/shape-restrictions'; | ||
|
||
const listboxShapeSizeRestrictions: ShapeSizeRestrictions = { | ||
minWidth: 75, | ||
minHeight: 180, | ||
maxWidth: 300, | ||
maxHeight: 300, | ||
defaultWidth: 120, | ||
defaultHeight: 220, | ||
}; | ||
|
||
export const getListboxShapeSizeRestrictions = (): ShapeSizeRestrictions => | ||
listboxShapeSizeRestrictions; | ||
|
||
interface ListBoxShapeProps extends ShapeProps { | ||
items: string[]; | ||
} | ||
|
||
export const ListBoxShape = forwardRef<any, ListBoxShapeProps>( | ||
({ x, y, width, height, id, items, onSelected, ...shapeProps }, ref) => { | ||
const [selectedItem, setSelectedItem] = useState<number | null>(null); | ||
const rectRef = useRef<any>(null); | ||
const listRef = useRef<any>(null); | ||
|
||
const { width: restrictedWidth, height: restrictedHeight } = | ||
fitSizeToShapeSizeRestrictions( | ||
listboxShapeSizeRestrictions, | ||
width, | ||
height | ||
); | ||
|
||
useEffect(() => { | ||
rectRef?.current.moveToTop(); | ||
}, []); | ||
|
||
const handleClick = (itemIndex: number) => { | ||
setSelectedItem(itemIndex); | ||
onSelected(id, 'listbox'); | ||
}; | ||
|
||
return ( | ||
<Group | ||
x={x} | ||
y={y} | ||
width={restrictedWidth} | ||
height={restrictedHeight} | ||
ref={ref} | ||
{...shapeProps} | ||
clipFunc={ctx => { | ||
ctx.rect(0, 0, restrictedWidth, restrictedHeight); | ||
}} | ||
> | ||
{/* Rectángulo del listbox */} | ||
<Rect | ||
x={0} | ||
y={0} | ||
width={restrictedWidth} | ||
height={restrictedHeight} | ||
ref={rectRef} | ||
cornerRadius={10} | ||
stroke="black" | ||
strokeWidth={4} | ||
fill="transparent" | ||
listening={false} | ||
/> | ||
|
||
{/* Elementos de la lista con desplazamiento */} | ||
<Group ref={listRef}> | ||
{items.map((item, index) => ( | ||
<Group key={index} onClick={() => handleClick(index)}> | ||
<Rect | ||
x={2} | ||
y={index === 0 ? 4 : index * 30} | ||
width={width - 4} | ||
height={30} | ||
fill={selectedItem === index ? 'lightblue' : 'white'} | ||
/> | ||
<Text | ||
x={10} | ||
y={30 * index + 5} | ||
text={item} | ||
fontFamily="Comic Sans MS, cursive" | ||
fontSize={20} | ||
fill="black" | ||
/> | ||
</Group> | ||
))} | ||
</Group> | ||
</Group> | ||
); | ||
} | ||
); | ||
|
||
export default ListBoxShape; |
Oops, something went wrong.