You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<svgwidth="120"height="50"xmlns="http://www.w3.org/2000/svg">
<!-- Caja del input -->
<rectx="10"y="10"width="60"height="30"style="fill:white;stroke:black;stroke-width:2"/>
<!-- Texto del input -->
<textx="60"y="30"font-family="Arial"font-size="16"fill="black"text-anchor="end">0</text>
<!-- Botón de incremento (flecha arriba) -->
<rectx="70"y="10"width="20"height="15"style="fill:lightgray;stroke:black;stroke-width:2"/>
<textx="77"y="22"font-family="Arial"font-size="14"fill="black">▲</text>
<!-- Botón de decremento (flecha abajo) -->
<rectx="70"y="25"width="20"height="15"style="fill:lightgray;stroke:black;stroke-width:2"/>
<textx="77"y="37"font-family="Arial"font-size="14"fill="black">▼</text>
</svg>
Tsx (just take it as starting point):
importReact,{useState,forwardRef}from'react';import{Group,Rect,Text}from'react-konva';import{ShapeConfig}from'konva/lib/Shape';interfaceInputWithStepperPropsextendsShapeConfig{id: string;x: number;y: number;width: number;height: number;initialValue?: number;}exportconstInputWithStepper=forwardRef<any,InputWithStepperProps>(({ x, y, width, height, initialValue =0, id, ...shapeProps},ref)=>{const[value,setValue]=useState(initialValue);consthandleIncrement=()=>{setValue(value+1);};consthandleDecrement=()=>{setValue(value-1);};constinputWidth=width-30;// Reservar espacio para el stepperconstbuttonHeight=height/2;return(<Groupx={x}y={y}ref={ref}{...shapeProps}>{/* Caja del input */}<Rectx={0}y={0}width={inputWidth/2}// Reducir ancho a la mitadheight={height}fill="white"stroke="black"strokeWidth={2}cornerRadius={0}// Sin bordes redondeados/>{/* Texto del input */}<Textx={inputWidth/2-10}// Alinear a la derechay={height/2-8}// Centrar verticalmentetext={value.toString()}fontFamily="Arial"fontSize={16}fill="black"align="right"/>{/* Botón de incremento (flecha arriba) */}<Groupx={inputWidth/2}y={0}onClick={handleIncrement}><Rectx={0}y={0}width={30}height={buttonHeight}fill="lightgray"stroke="black"strokeWidth={2}/><Textx={10}y={buttonHeight/2-8}text="▲"fontFamily="Arial"fontSize={14}fill="black"/></Group>{/* Botón de decremento (flecha abajo) */}<Groupx={inputWidth/2}y={buttonHeight}onClick={handleDecrement}><Rectx={0}y={0}width={30}height={buttonHeight}fill="lightgray"stroke="black"strokeWidth={2}/><Textx={10}y={buttonHeight/2-8}text="▼"fontFamily="Arial"fontSize={14}fill="black"/></Group></Group>);});exportdefaultInputWithStepper;
The text was updated successfully, but these errors were encountered:
Tsx (just take it as starting point):
The text was updated successfully, but these errors were encountered: