-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from vgihan/main
feat(view): add transition in ClusterGraph
- Loading branch information
Showing
6 changed files
with
92 additions
and
70 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
packages/view/src/components/VerticalClusterList/ClusterGraph/ClusterGraph.const.ts
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
8 changes: 4 additions & 4 deletions
8
packages/view/src/components/VerticalClusterList/ClusterGraph/ClusterGraph.scss
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
36 changes: 33 additions & 3 deletions
36
packages/view/src/components/VerticalClusterList/ClusterGraph/ClusterGraph.util.ts
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,15 +1,45 @@ | ||
import type { ClusterNode } from "types"; | ||
import type { ClusterNode, SelectedDataProps } from "types"; | ||
|
||
import { COMMIT_HEIGHT, NODE_GAP } from "./ClusterGraph.const"; | ||
import { | ||
CLUSTER_HEIGHT, | ||
DETAIL_HEIGHT, | ||
NODE_GAP, | ||
SVG_MARGIN, | ||
} from "./ClusterGraph.const"; | ||
import type { ClusterGraphElement } from "./ClusterGraph.type"; | ||
|
||
export function getClusterSizes(data: ClusterNode[]) { | ||
return data.map((node) => node.commitNodeList.length); | ||
} | ||
|
||
export function getGraphHeight(clusterSizes: number[]) { | ||
return ( | ||
clusterSizes.length * COMMIT_HEIGHT + | ||
clusterSizes.length * CLUSTER_HEIGHT + | ||
clusterSizes.length * NODE_GAP + | ||
NODE_GAP | ||
); | ||
} | ||
|
||
export function getClusterPosition( | ||
d: ClusterGraphElement, | ||
i: number, | ||
isPrev = false | ||
) { | ||
const curSelected = d.selected || Infinity; | ||
const selected = isPrev ? Infinity : curSelected; | ||
const margin = selected >= 0 && selected < i ? DETAIL_HEIGHT : 0; | ||
const x = SVG_MARGIN.left; | ||
const y = SVG_MARGIN.top + i * (CLUSTER_HEIGHT + NODE_GAP) + margin; | ||
return `translate(${x}, ${y})`; | ||
} | ||
|
||
export function getSelectedIndex( | ||
data: ClusterNode[], | ||
selectedData: SelectedDataProps | ||
) { | ||
const selectedId = selectedData?.commitNodeList[0].clusterId; | ||
const selectedIndex = data.findIndex( | ||
(item) => item.commitNodeList[0].clusterId === selectedId | ||
); | ||
return selectedIndex; | ||
} |
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