Skip to content

Commit a7b2ede

Browse files
authored
Merge pull request #921 from nxnaxx/refactor/#900_extract-issue-link-component
refactor(view): processMessage 함수 내 GIthubIssueLink 컴포넌트 분리
2 parents 57935b1 + 215eaba commit a7b2ede

8 files changed

Lines changed: 70 additions & 68 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@import "styles/app";
2+
3+
.commit-message__issue-link {
4+
color: var(--color-primary);
5+
text-decoration: none;
6+
font-weight: 500;
7+
padding: 0.125rem 0.25rem;
8+
border-radius: 0.125rem;
9+
background-color: rgba(224, 96, 145, 0.1);
10+
transition: all 0.2s ease-in-out;
11+
12+
&:hover {
13+
background-color: rgba(224, 96, 145, 0.2);
14+
text-decoration: underline;
15+
transform: translateY(-1px);
16+
}
17+
18+
&:active {
19+
transform: translateY(0);
20+
}
21+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import cn from "classnames";
2+
3+
import type { GithubIssueLinkProps } from "./GithubIssueLink.type";
4+
import "./GithubIssueLink.scss";
5+
6+
const GithubIssueLink = ({ owner, repo, issueNumber, className, ...rest }: GithubIssueLinkProps) => {
7+
const issueLink = `https://github.com/${owner}/${repo}/issues/${issueNumber}`;
8+
9+
return (
10+
<a
11+
href={issueLink}
12+
target="_blank"
13+
rel="noopener noreferrer"
14+
className={cn("commit-message__issue-link", className)}
15+
title={`GitHub Issue #${issueNumber}`}
16+
{...rest}
17+
>
18+
#{issueNumber}
19+
</a>
20+
);
21+
};
22+
23+
export default GithubIssueLink;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { ComponentPropsWithoutRef } from "react";
2+
3+
export interface GithubIssueLinkProps
4+
extends Omit<ComponentPropsWithoutRef<"a">, "href" | "target" | "rel" | "children"> {
5+
owner: string;
6+
repo: string;
7+
issueNumber: string;
8+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as GithubIssueLink } from "./GithubIssueLink";

packages/view/src/components/Detail/Detail.scss

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
gap: 0.625rem;
7777
width: 100%;
7878
flex: 1;
79-
margin-left: 0.125rem; // 아주 미세한 여백
79+
margin-left: 0.125rem;
8080
min-width: 0;
8181
padding-top: 0.3rem;
8282
padding-right: 3.125rem;
@@ -90,7 +90,6 @@
9090
gap: 0.75rem;
9191
margin-bottom: 0.5rem;
9292

93-
// 아바타를 맨 앞에 배치
9493
.author {
9594
width: 1.5rem;
9695
height: 1.5rem;
@@ -176,7 +175,7 @@
176175
}
177176

178177
.commit-item__right {
179-
display: none; // 오른쪽 레이아웃 숨김
178+
display: none;
180179
}
181180
}
182181
}
@@ -194,23 +193,3 @@
194193
color: $color-light-gray;
195194
}
196195
}
197-
198-
.commit-message__issue-link {
199-
color: var(--color-primary);
200-
text-decoration: none;
201-
font-weight: 500;
202-
padding: 0.125rem 0.25rem;
203-
border-radius: 0.125rem;
204-
background-color: rgba(224, 96, 145, 0.1);
205-
transition: all 0.2s ease-in-out;
206-
207-
&:hover {
208-
background-color: rgba(224, 96, 145, 0.2);
209-
text-decoration: underline;
210-
transform: translateY(-1px);
211-
}
212-
213-
&:active {
214-
transform: translateY(0);
215-
}
216-
}

packages/view/src/components/Detail/Detail.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import {
1111
} from "@mui/icons-material";
1212
import { Tooltip } from "@mui/material";
1313

14-
import { Author } from "components/@common/Author";
1514
import { useGithubInfo, useDataStore } from "store";
15+
import { Author } from "components/@common/Author";
16+
import { GithubIssueLink } from "components/@common/GithubIssueLink";
1617

1718
import { useCommitListHide } from "./Detail.hook";
1819
import { getCommitListDetail } from "./Detail.util";
@@ -57,21 +58,15 @@ const Detail = ({ clusterId, authSrcMap }: DetailProps) => {
5758
parts.push(message.slice(lastIndex, match.index));
5859
}
5960

60-
// 이슈 번호를 링크로 변환
61-
const issueNumber = match[1].substring(1); // # 제거
62-
const issueLink = `https://github.com/${owner}/${repo}/issues/${issueNumber}`;
61+
const issueNumber = match[1].substring(1);
6362

6463
parts.push(
65-
<a
64+
<GithubIssueLink
6665
key={`issue-${issueNumber}-${match.index}`}
67-
href={issueLink}
68-
target="_blank"
69-
rel="noopener noreferrer"
70-
className="commit-message__issue-link"
71-
title={`GitHub Issue #${issueNumber}`}
72-
>
73-
{match[1]}
74-
</a>
66+
owner={owner}
67+
repo={repo}
68+
issueNumber={issueNumber}
69+
/>
7570
);
7671

7772
lastIndex = match.index + match[0].length;

packages/view/src/components/VerticalClusterList/Summary/Content/Content.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from "react";
22
import ArrowDropDownCircleRoundedIcon from "@mui/icons-material/ArrowDropDownCircleRounded";
33

44
import { useGithubInfo } from "store";
5+
import { GithubIssueLink } from "components/@common/GithubIssueLink";
56

67
import type { ContentProps } from "../Summary.type";
78

@@ -32,21 +33,15 @@ const Content = ({ content, clusterId, selectedClusterIds }: ContentProps) => {
3233
parts.push(message.slice(lastIndex, match.index));
3334
}
3435

35-
// 이슈 번호를 링크로 변환
36-
const issueNumber = match[1].substring(1); // # 제거
37-
const issueLink = `https://github.com/${owner}/${repo}/issues/${issueNumber}`;
36+
const issueNumber = match[1].substring(1);
3837

3938
parts.push(
40-
<a
39+
<GithubIssueLink
4140
key={`issue-${issueNumber}-${match.index}`}
42-
href={issueLink}
43-
target="_blank"
44-
rel="noopener noreferrer"
45-
className="summary__commit-issue-link"
46-
title={`GitHub Issue #${issueNumber}`}
47-
>
48-
{match[1]}
49-
</a>
41+
owner={owner}
42+
repo={repo}
43+
issueNumber={issueNumber}
44+
/>
5045
);
5146

5247
lastIndex = match.index + match[0].length;

packages/view/src/components/VerticalClusterList/Summary/Summary.scss

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -143,23 +143,3 @@
143143
max-height: fit-content;
144144
padding: 0.625rem 1.075rem;
145145
}
146-
147-
.summary__commit-issue-link {
148-
color: var(--color-primary);
149-
text-decoration: none;
150-
font-weight: 500;
151-
padding: 0.125rem 0.25rem;
152-
border-radius: 0.125rem;
153-
background-color: rgba(224, 96, 145, 0.1);
154-
transition: all 0.2s ease-in-out;
155-
156-
&:hover {
157-
background-color: rgba(224, 96, 145, 0.2);
158-
text-decoration: underline;
159-
transform: translateY(-1px);
160-
}
161-
162-
&:active {
163-
transform: translateY(0);
164-
}
165-
}

0 commit comments

Comments
 (0)