Skip to content
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): return Summary value and modify content data #97

Merged
merged 8 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
922 changes: 663 additions & 259 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const authorBgColorArray = [
"00ADF7",
"0077AA",
"4AC3F7",
"0BD9E0",
"33C2FF",
"4BC4F9",
"0089C4",
];
Comment on lines +1 to +9
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

최대한 비슷한 계열로 넣어보았는데 너무 색이 튀면 다시 조정해보는 게 필요해보입니다.

Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
border-radius: $border--radius;
}

// body {
// background-color: #fff;
// color: #222
// }

.entire {
width: 85%;
margin-left: 20px;
Expand All @@ -32,10 +27,9 @@
align-items: center;
width: 85%;
padding-top: 10px;
padding-bottom: 10px;
}

.commit {
.summary {
display: flex;
align-items: center;
flex-direction: row;
Expand All @@ -46,6 +40,7 @@
.nameBox {
display: flex;
justify-content: center;
position: relative;
}

.name {
Expand All @@ -55,19 +50,32 @@
width: 30px;
height: 30px;
font-weight: bold;
background-color: $blue-light-A700;
color: white;

color: $white;
justify-content: center;
align-items: center;
text-align: center;
font-size: 15pt;
margin-left: -5px;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

author 간 간격이 넓다는 의견을 주셔서 지정하였습니다 !

margin-right: -5px;

&::after {
&:hover {
@include animation();
background-color: $gray-200 !important;
color: $black !important;
z-index: 9999;
}

&:hover {
background-color: $blue-light-A200;
&:nth-child(2n){
&:hover {
@include animation();
z-index: 9999;
}
}

&:nth-child(3n):hover {
@include animation();
z-index: 9999;
}
}

Expand All @@ -78,9 +86,7 @@

&::after {
@include animation();

@include shadow();

@include border(5px);

content: attr(data-tooltip-text);
Expand All @@ -103,15 +109,46 @@

&:hover::after {
left: 100%;
background-color: rgba(0, 119, 170, 0.8);
background-color: rgba(34, 34, 34, 0.8);
opacity: 1;
}
}

.message {
.keywords {
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-left: 15px;
}

.keyword {
margin-left: 5px;
margin-right: 5px;

&:hover {
@include animation();
font-weight: 700;
cursor: pointer;
}

&.large {
font-size: 18pt;
font-weight: 900;

&:hover {
@include animation();
cursor: pointer;
}
}

&.medium {
font-size: 16pt;
font-weight: 700;

&:hover {
@include animation();
cursor: pointer;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,37 +1,57 @@
import type { GlobalProps } from "types";

import type { Commit, Author, Cluster } from "./Summary.type";
import { getInitData } from "./Summary.util";
import type { Cluster, Keyword } from "./Summary.type";
import { getColorValue, getInitData } from "./Summary.util";

import "./Summary.scss";

const Summary = ({ data }: GlobalProps) => {
const info = getInitData({ data });
const clusters = getInitData({ data });

return (
<div className="entire">
{info.map((cluster: Cluster) => {
{clusters.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) => {
<div className="cluster" key={cluster.clusterId}>
<p className="summary">
<span className="nameBox">
{cluster.summary.authorNames.map(
(authorArray: Array<string>) => {
return authorArray.map((authorName: string) => {
const colorValue = getColorValue(authorName);
return (
<span
key={authorName.id}
className="name"
data-tooltip-text={authorName.name}
key={authorName}
className={["name"].join(" ")}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

처음에는 className으로 어떻게 해보려고 하다가 어떻게 해야할지 감이 잘 안와서 style 인라인 태그로 계산된 color값을 넣고 있습니다!

data-tooltip-text={authorName}
style={{ backgroundColor: colorValue }}
>
{authorName.name.slice(0, 1)}
{authorName.slice(0, 1)}
</span>
);
})}
</span>
<span className="message">{commit.message}</span>
</p>
);
})}
});
}
)}
</span>
<span className="keywords">
{cluster.summary.keywords.map((keywordObj: Keyword) => {
let size = "";

if (keywordObj.count > 6) size = "large";
else if (keywordObj.count > 3) size = "medium";
else size = "small";

return (
<span
className={["keyword", size].join(" ")}
key={keywordObj.keyword}
>
{keywordObj.keyword}
</span>
);
})}
</span>
</p>
</div>
);
})}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
export type Author = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존의 Author를 제거한 이유는 현재 중복제거가 된 name이 들어가기 때문에 name 자체가 고유한 값입니다. 그래서 id를 따로 지정해주지 않아도 된다고 생각하여 id 속성을 제거하다보니 Author type도 굳이 사용할 필요가 없어서 그렇게 진행하였습니다.

id: string;
name: string;
export type Keyword = {
keyword: string;
count: number;
};

export type Commit = {
commitId: string;
authorNames: Array<Author>;
message: string;
export type Summary = {
authorNames: Array<Array<string>>;
keywords: Array<Keyword>;
};

export type Cluster = {
id: string;
commits: Array<Commit>;
clusterId: number;
summary: Summary;
};
Original file line number Diff line number Diff line change
@@ -1,40 +1,82 @@
import { nanoid } from "nanoid";

import type { GlobalProps, CommitNode } from "types";

import type { Cluster, Commit } from "./Summary.type";
import { authorBgColorArray } from "./Summary.const";
import type { Cluster } from "./Summary.type";

const colorName = [...authorBgColorArray];

export function getInitData({ data }: GlobalProps) {
const clusters: Cluster[] = [];

data.map((clusterNode) => {
const cluster: Cluster = {
id: nanoid(),
commits: [],
clusterId: clusterNode.commitNodeList[0].clusterId,
summary: {
authorNames: [],
keywords: [],
},
};

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,
// set names
const authorSet: Set<string> = new Set();
commitNode.commit.author.names.map((name) => {
authorSet.add(name.trim());
return name.trim();
});
Comment on lines +21 to +26
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기서는 한 커밋 안에 있는 author를 중복 제거해줍니다.


cluster.summary.authorNames.push(Array.from(authorSet));

// set keywords
const keywordObject = {
keyword: commitNode.commit.message.split(" ")[0],
count: 1,
};

commitArray.push(temp);
const findKeywordIndex = cluster.summary.keywords.findIndex(
(key) => key.keyword === commitNode.commit.message.split(" ")[0]
);

if (findKeywordIndex === -1) cluster.summary.keywords.push(keywordObject);
else {
cluster.summary.keywords[findKeywordIndex].count += 1;
}

cluster.commits = commitArray;
cluster.summary.keywords.sort((a, b) => b.count - a.count);

return temp;
return commitNode;
});

// remove name overlap
const authorsSet = cluster.summary.authorNames.reduce(
(set, authorArray) => {
authorArray.forEach((author) => {
set.add(author);
});
return set;
},
new Set()
);

cluster.summary.authorNames = [];

cluster.summary.authorNames.push(Array.from(authorsSet) as Array<string>);
Comment on lines +51 to +63
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기서 한 클러스터 안에 있는 author를 중복 제거 해줍니다.


clusters.push(cluster);

return cluster;
});

return clusters;
}

export function getColorValue(name: string) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

author의 앞 2자를 가져와서 컬러값을 지정해줍니다.

let result = "";

const index =
(name[0].charCodeAt(0) + name[1].charCodeAt(0)) % colorName.length;
result = `#${colorName[index]}`;
colorName.slice(0 + index, index + 1);

return result;
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default as Summary } from "./Summary";
export type { Commit, Cluster, Author } from "./Summary.type";
export type { Cluster } from "./Summary.type";