make arrows removeable
continuous-integration/drone/push Build is passing Details

pull/82/head
maxime 1 year ago committed by maxime.batista
parent e1da73f6c5
commit df52d758ae

@ -24,7 +24,7 @@ export default function TitleInput({
value={value} value={value}
onChange={(event) => setValue(event.target.value)} onChange={(event) => setValue(event.target.value)}
onBlur={(_) => on_validated(value)} onBlur={(_) => on_validated(value)}
onKeyDown={(event) => { onKeyUp={(event) => {
if (event.key == "Enter") ref.current?.blur() if (event.key == "Enter") ref.current?.blur()
}} }}
/> />

@ -28,6 +28,8 @@ export interface BendableArrowProps {
startRadius?: number startRadius?: number
endRadius?: number endRadius?: number
onDeleteRequested?: () => void
style?: ArrowStyle style?: ArrowStyle
} }
@ -73,6 +75,7 @@ export default function BendableArrow({
style, style,
startRadius = 0, startRadius = 0,
endRadius = 0, endRadius = 0,
onDeleteRequested = () => {},
}: BendableArrowProps) { }: BendableArrowProps) {
const containerRef = useRef<HTMLDivElement>(null) const containerRef = useRef<HTMLDivElement>(null)
const svgRef = useRef<SVGSVGElement>(null) const svgRef = useRef<SVGSVGElement>(null)
@ -265,6 +268,10 @@ export default function BendableArrow({
stroke={"#000"} stroke={"#000"}
strokeWidth={styleWidth} strokeWidth={styleWidth}
fill="none" fill="none"
tabIndex={0}
onKeyUp={(e) => {
if (e.key == "Delete") onDeleteRequested()
}}
/> />
</svg> </svg>
@ -327,7 +334,7 @@ function ControlPoint({
width: radius * 2, width: radius * 2,
height: radius * 2, height: radius * 2,
}} }}
onKeyDown={(e) => { onKeyUp={(e) => {
if (e.key == "Delete") { if (e.key == "Delete") {
onPosValidated(undefined) onPosValidated(undefined)
} }

@ -13,6 +13,7 @@
.arrow-path { .arrow-path {
pointer-events: stroke; pointer-events: stroke;
cursor: pointer; cursor: pointer;
outline: none;
} }
.arrow-path:hover, .arrow-path:hover,

@ -169,7 +169,7 @@ function EditorView({
players: [ players: [
...content.players, ...content.players,
{ {
id: "player-" + content.players.length, id: "player-" + element.key + "-" + element.team,
team: element.team, team: element.team,
role: element.key, role: element.key,
rightRatio: x, rightRatio: x,
@ -450,6 +450,16 @@ function EditorView({
key={i} key={i}
action={action} action={action}
courtRef={courtDivContentRef} courtRef={courtDivContentRef}
onActionDeleted={() => {
setContent((content) => ({
...content,
players: content.players,
actions: content.actions.toSpliced(
i,
1,
),
}))
}}
onActionChanges={(a) => onActionChanges={(a) =>
setContent((content) => ({ setContent((content) => ({
...content, ...content,

@ -5,12 +5,14 @@ import { RefObject } from "react"
export interface CourtActionProps { export interface CourtActionProps {
action: Action action: Action
onActionChanges: (a: Action) => void onActionChanges: (a: Action) => void
onActionDeleted: () => void
courtRef: RefObject<HTMLElement> courtRef: RefObject<HTMLElement>
} }
export function CourtAction({ export function CourtAction({
action, action,
onActionChanges, onActionChanges,
onActionDeleted,
courtRef, courtRef,
}: CourtActionProps) { }: CourtActionProps) {
return ( return (
@ -24,6 +26,7 @@ export function CourtAction({
//TODO place those magic values in constants //TODO place those magic values in constants
endRadius={action.toPlayerId ? 26 : 17} endRadius={action.toPlayerId ? 26 : 17}
startRadius={26} startRadius={26}
onDeleteRequested={onActionDeleted}
/> />
) )
} }

@ -17,6 +17,7 @@
</script> </script>
<link rel="icon" href="<?= asset("assets/favicon.ico") ?>"> <link rel="icon" href="<?= asset("assets/favicon.ico") ?>">
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" <meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

Loading…
Cancel
Save