parent
fd9b5e2063
commit
30df4e74bf
@ -0,0 +1,58 @@
|
||||
import {StepInfoNode} from "../../model/tactic/Tactic";
|
||||
import "../../style/steps-tree.css"
|
||||
import BendableArrow from "../arrows/BendableArrow";
|
||||
import {useRef} from "react";
|
||||
|
||||
export interface StepsTreeProps {
|
||||
root: StepInfoNode
|
||||
}
|
||||
|
||||
export default function StepsTree({root}: StepsTreeProps) {
|
||||
return <div className="steps-tree">
|
||||
<StepsTreeNode node={root}/>
|
||||
</div>
|
||||
}
|
||||
|
||||
interface StepsTreeContentProps {
|
||||
node: StepInfoNode
|
||||
}
|
||||
|
||||
function StepsTreeNode({node}: StepsTreeContentProps) {
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
return (
|
||||
<div ref={ref}
|
||||
className={"step-group"}>
|
||||
<StepPiece id={node.id}/>
|
||||
{node.children.map(child => (
|
||||
<BendableArrow
|
||||
key={child.id}
|
||||
area={ref}
|
||||
startPos={"step-piece-" + node.id}
|
||||
segments={[{next: "step-piece-" + child.id}]}
|
||||
onSegmentsChanges={() => {
|
||||
}}
|
||||
forceStraight={true}
|
||||
wavy={false}
|
||||
//TODO remove magic constant
|
||||
startRadius={10}
|
||||
endRadius={10}
|
||||
/>
|
||||
))}
|
||||
<div className={"step-children"}>
|
||||
{node.children.map(child => <StepsTreeNode key={child.id} node={child}/>)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
interface StepPieceProps {
|
||||
id: number
|
||||
}
|
||||
|
||||
function StepPiece({id}: StepPieceProps) {
|
||||
return (
|
||||
<div id={"step-piece-" + id} className={"step-piece"}>
|
||||
<p>{id}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
.step-piece {
|
||||
font-family: monospace;
|
||||
pointer-events: all;
|
||||
|
||||
background-color: var(--editor-tree-step-piece);
|
||||
color: var(--selected-team-secondarycolor);
|
||||
|
||||
border-radius: 100px;
|
||||
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
|
||||
display: flex;
|
||||
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.step-children {
|
||||
margin-top: 10vh;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.step-group {
|
||||
position: relative;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.steps-tree {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding-top: 10%;
|
||||
|
||||
height: 100%;
|
||||
}
|
Loading…
Reference in new issue