-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(view): add transition in ClusterGraph #142
Changes from all commits
19266e1
49a5c94
34aee96
7466762
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (궁금) 혹시 selectedIndex를 다시 전체 data에서 찾는 구조인가요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 맞습니다...! 전체 데이터에서 selected 된 데이터를 찾는 구조인데, 추후에 selectedIndex를 추가해서 한 번더 탐색하는 작업을 줄일 수 있을 것 같습니다 :) |
||
data: ClusterNode[], | ||
selectedData: SelectedDataProps | ||
) { | ||
const selectedId = selectedData?.commitNodeList[0].clusterId; | ||
const selectedIndex = data.findIndex( | ||
(item) => item.commitNodeList[0].clusterId === selectedId | ||
); | ||
return selectedIndex; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
변수 naming부분은 이전 리뷰들을 보니까 view팀에서 정의하신 부분들이 있는 것 같아요.
@githru/view 팀분들 확인부탁드립니다~.