-
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 Summary in VerticalClusterList Component #63
Changes from all commits
29dade1
30d60f3
13b7823
5f84904
cc224df
e418d78
678a46c
5e3ecc0
63d1a7c
fc14125
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
@import "../../../styles/pallete"; | ||
|
||
@mixin animation { | ||
-webkit-transition: bottom .3s ease-in-out, opacity .3s ease-in-out; | ||
-moz-transition: bottom .3s ease-in-out, opacity .3s ease-in-out; | ||
transition: bottom .3s ease-in-out, opacity .3s ease-in-out; | ||
} | ||
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. ㅎㅎ 훌륭하십니다! |
||
|
||
@mixin shadow { | ||
-webkit-box-shadow: 0px 0px 3px 1px rgba(50, 50, 50, 0.4); | ||
-moz-box-shadow: 0px 0px 3px 1px rgba(50, 50, 50, 0.4); | ||
box-shadow: 0px 0px 3px 1px rgba(50, 50, 50, 0.4); | ||
} | ||
|
||
@mixin border($border--radius) { | ||
-webkit-border-radius: $border--radius; | ||
-moz-border-radius: $border--radius; | ||
border-radius: $border--radius; | ||
} | ||
|
||
body { | ||
background-color: #fff; | ||
color: #222 | ||
} | ||
|
||
.entire { | ||
width: 85%; | ||
margin-left: 20px; | ||
} | ||
|
||
.cluster { | ||
align-items: center; | ||
width: 85%; | ||
padding-top: 10px; | ||
padding-bottom: 10px; | ||
} | ||
|
||
.commit { | ||
display: flex; | ||
align-items: center; | ||
flex-direction: row; | ||
padding-top: 10px; | ||
padding-bottom: 10px; | ||
} | ||
|
||
.nameBox { | ||
display: flex; | ||
justify-content: center; | ||
} | ||
|
||
.name { | ||
@include border(50px); | ||
|
||
display: flex; | ||
width: 30px; | ||
height: 30px; | ||
font-weight: bold; | ||
background-color: $blue-light-A700; | ||
color: white; | ||
justify-content: center; | ||
align-items: center; | ||
text-align: center; | ||
font-size: 15pt; | ||
|
||
&::after { | ||
@include animation() | ||
} | ||
|
||
&:hover { | ||
background-color: $blue-light-A200; | ||
} | ||
} | ||
|
||
[data-tooltip-text] { | ||
&:hover { | ||
position: relative; | ||
} | ||
|
||
&::after { | ||
@include animation(); | ||
|
||
@include shadow(); | ||
|
||
@include border(5px); | ||
|
||
content: attr(data-tooltip-text); | ||
|
||
position: absolute; | ||
bottom: 30%; | ||
left: -9999px; | ||
|
||
color: #FFFFFF; | ||
font-size: 12px; | ||
padding: 7px 12px; | ||
margin-bottom: 10px; | ||
width: auto; | ||
min-width: max-content; | ||
word-wrap: break-word; | ||
|
||
opacity: 0; | ||
z-index: 9999; | ||
} | ||
|
||
&:hover::after { | ||
left: 100%; | ||
background-color: rgba(0, 119, 170, 0.8); | ||
opacity: 1; | ||
} | ||
} | ||
|
||
.message { | ||
width: 100%; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
margin-left: 15px; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import "./Summary.scss"; | ||
import type { GlobalProps } from "types/global"; | ||
|
||
import type { Commit, Author, Cluster } from "."; | ||
import { getInitData } from "."; | ||
|
||
const Summary = ({ data }: GlobalProps) => { | ||
const info = getInitData({ data }); | ||
|
||
return ( | ||
<div className="entire"> | ||
{info.map((cluster: Cluster) => { | ||
return ( | ||
<div className="cluster" key={cluster.id}> | ||
{cluster.commits.map((commit: Commit) => { | ||
return ( | ||
<p className="commit" key={commit.commitId}> | ||
<span className="nameBox"> | ||
{commit.authorNames.map((authorName: Author) => { | ||
return ( | ||
<span | ||
key={authorName.id} | ||
className="name" | ||
data-tooltip-text={authorName.name} | ||
> | ||
{authorName.name.slice(0, 1)} | ||
</span> | ||
); | ||
})} | ||
</span> | ||
<span className="message">{commit.message}</span> | ||
</p> | ||
); | ||
})} | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Summary; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export type Author = { | ||
id: string; | ||
name: string; | ||
}; | ||
|
||
export type Commit = { | ||
commitId: string; | ||
authorNames: Array<Author>; | ||
message: string; | ||
}; | ||
|
||
export type Cluster = { | ||
id: string; | ||
commits: Array<Commit>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { nanoid } from "nanoid"; | ||
import type { GlobalProps } from "types/global"; | ||
|
||
import type { CommitNode } from "types/NodeTypes.temp"; | ||
|
||
import type { Cluster, Commit } from "."; | ||
|
||
export function getInitData({ data }: GlobalProps) { | ||
const clusters: Cluster[] = []; | ||
|
||
data.map((clusterNode) => { | ||
const cluster: Cluster = { | ||
id: nanoid(), | ||
commits: [], | ||
}; | ||
|
||
const commitArray: Commit[] = []; | ||
|
||
clusterNode.commitNodeList.map((commitNode: CommitNode) => { | ||
const temp = { | ||
commitId: commitNode.commit.id, | ||
authorNames: commitNode.commit.author.names.map((name) => ({ | ||
id: nanoid(), | ||
name: name.trim(), | ||
})), | ||
message: commitNode.commit.message, | ||
}; | ||
|
||
commitArray.push(temp); | ||
|
||
cluster.commits = commitArray; | ||
|
||
return temp; | ||
}); | ||
|
||
clusters.push(cluster); | ||
return cluster; | ||
}); | ||
|
||
return clusters; | ||
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. js에서 선언형 프로그래밍 대신 명령형 프로그래밍을 작성하기 위해 사용되는 방법 중 하나가 고차함수라고 생각합니다. 현재 코드는 고차함수를 사용하지만 선언형 코드로 작성되어있으며, 새로운 객체를 반환해주는 값을 사용하지 않는 것 같아서 오히려 고차함수보다는 for문을 사용하거나
위 로직을
와 같이 고차함수를 사용해 반환되는 객체를 사용하는 건 어떨찌 의견을 내봅니다. 다른 분들 의견도 궁금합니다! 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. 아래 코드가 매우 간결하고 직관적인 것 같습니다 :-) 👍 고차함수가 뭔지 기억이 잘 안나서 ^^; 찾아봤는데,
함수를 인자로 받고, return이 가능하다고는 있지만, 불변성 보장에 대한 내용은 없는 것 같은데용. 심도있는 comment들 덕분에 오늘도 많이 배워 갑니다 ㅎㅎ |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { default as Summary } from "./Summary"; | ||
export type { Commit, Cluster, Author } from "./Summary.type"; | ||
export { getInitData } from "./Summary.util"; |
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.
nanoid 추가 댔군요!!
다른분들도 알고 계시면 좋을 듯 하네용. 이미 논의된 내용이라면 죄송합니다. 🙏
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.
저는 uuid가 익숙해서 왜 nanoId를 사용하셨을까 궁금해서 nanoid vs uuid 키워드로 구글링해봤는데
https://blog.bitsrc.io/why-is-nanoid-replacing-uuid-1b5100e62ed2
여기에 설명이 나와있네요!
star 수가 uuid보다 nanoid가 더욱 많고,
뿐만아니라, nanoid에서 더 작은 데이터로 uuid를 대체할 수 있으며,
nanoid가 uuid보다 크기가 적다고하네요!