-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add timeline view connectors (#3623)
- Loading branch information
Showing
4 changed files
with
46 additions
and
39 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
77 changes: 43 additions & 34 deletions
77
web/src/components/Visualization/components/Timeline/BaseSpanNode/ConnectorV2.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 |
---|---|---|
@@ -1,47 +1,56 @@ | ||
import {BaseLeftPaddingV2} from 'constants/Timeline.constants'; | ||
import * as S from '../TimelineV2.styled'; | ||
|
||
interface IProps { | ||
hasParent: boolean; | ||
id: string; | ||
isCollapsed: boolean; | ||
leftPadding: number; | ||
nodeDepth: number; | ||
onCollapse(id: string): void; | ||
totalChildren: number; | ||
} | ||
|
||
const Connector = ({hasParent, id, isCollapsed, leftPadding, onCollapse, totalChildren}: IProps) => ( | ||
<S.Connector height="100%" width={leftPadding + 30}> | ||
{hasParent && ( | ||
<> | ||
<S.LineBase x1={leftPadding - 3} x2={leftPadding + 12} y1="16" y2="16" /> | ||
<S.LineBase x1={leftPadding - 4} x2={leftPadding - 4} y1="0" y2="16.5" /> | ||
</> | ||
)} | ||
const Connector = ({hasParent, id, isCollapsed, nodeDepth, onCollapse, totalChildren}: IProps) => { | ||
const leftPadding = nodeDepth * BaseLeftPaddingV2; | ||
|
||
{totalChildren > 0 ? ( | ||
<> | ||
{!isCollapsed && <S.LineBase x1={leftPadding + 12} x2={leftPadding + 12} y1="16" y2="32" />} | ||
<S.RectBase x={leftPadding + 2} y="8" width="20" height="16" rx="3px" ry="3px" $isActive={isCollapsed} /> | ||
<S.TextConnector x={leftPadding + 12} y="20" textAnchor="middle" $isActive={isCollapsed}> | ||
{totalChildren} | ||
</S.TextConnector> | ||
<S.RectBaseTransparent | ||
x={leftPadding + 2} | ||
y="8" | ||
width="20" | ||
height="16" | ||
rx="3px" | ||
ry="3px" | ||
onClick={event => { | ||
event.stopPropagation(); | ||
onCollapse(id); | ||
}} | ||
/> | ||
</> | ||
) : ( | ||
<S.CircleDot cx={leftPadding + 12} cy="16" r="3" /> | ||
)} | ||
</S.Connector> | ||
); | ||
return ( | ||
<S.Connector height="100%" width={leftPadding + 30}> | ||
{hasParent && ( | ||
<> | ||
<S.LineBase x1={leftPadding - 3} x2={leftPadding + 12} y1="16" y2="16" /> | ||
<S.LineBase x1={leftPadding - 4} x2={leftPadding - 4} y1="0" y2="16.5" /> | ||
</> | ||
)} | ||
|
||
{totalChildren > 0 ? ( | ||
<> | ||
{!isCollapsed && <S.LineBase x1={leftPadding + 12} x2={leftPadding + 12} y1="16" y2="32" />} | ||
<S.RectBase x={leftPadding + 2} y="8" width="20" height="16" rx="3px" ry="3px" $isActive={isCollapsed} /> | ||
<S.TextConnector x={leftPadding + 12} y="20" textAnchor="middle" $isActive={isCollapsed}> | ||
{totalChildren} | ||
</S.TextConnector> | ||
<S.RectBaseTransparent | ||
x={leftPadding + 2} | ||
y="8" | ||
width="20" | ||
height="16" | ||
rx="3px" | ||
ry="3px" | ||
onClick={event => { | ||
event.stopPropagation(); | ||
onCollapse(id); | ||
}} | ||
/> | ||
</> | ||
) : ( | ||
<S.CircleDot cx={leftPadding + 12} cy="16" r="3" /> | ||
)} | ||
|
||
{new Array(nodeDepth).fill(0).map((_, index) => { | ||
return <S.LineBase x1={index * BaseLeftPaddingV2 + 12} x2={index * BaseLeftPaddingV2 + 12} y1="0" y2="32" />; | ||
})} | ||
</S.Connector> | ||
); | ||
}; | ||
|
||
export default Connector; |
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