Skip to content

Commit 1d10524

Browse files
authored
refactor: 미사용 코드 삭제, 컴포넌트 cva 적용 (#137)
* chore: 24 -> 25 version up * remove: 미사용 파일 삭제 * remove: global.css 미사용 디자인 삭제 * docs: update README.md * rename: /libs/utils -> utils/designUtils로 cn() 위치이동 * refactor: BlockBtn cva 적용, 디자인 일부 수정 * design: BlockBtn 색상 변경 * refactor: RoundBtn cva 적용 * fix: 어학 증명서 예시 링크 오류 수정 * remove: 레거시 block-btn 제거
1 parent fd94fa4 commit 1d10524

File tree

16 files changed

+91
-310
lines changed

16 files changed

+91
-310
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
솔리드 커넥션 웹
1+
# 솔리드 커넥션 웹
22

3-
React + Next.js
3+
- Next.js (App Router)
4+
- TypeScript
5+
- Tailwind CSS
6+
- Clsx
7+
- Axios
8+
- ESLint
9+
- Prettier
10+
- Vercel
411

512
## Commands
613

714
```bash
815
npm run dev
916

1017
npm run lint
11-
```
18+
```

src/app/my/activity/legacy.tsx

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/app/score/example/gpa-cert/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import Image from "next/image";
44
import Link from "next/link";
55

6-
import BlockBtn from "@/components/button/block-btn";
6+
import BlockBtn from "@/components/button/BlockBtn";
77
import TopDetailNavigation from "@/components/layout/TopDetailNavigation";
88

99
const GpaCertExamplePage = () => {

src/app/score/example/lang-cert/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import Image from "next/image";
44

5-
import BlockBtn from "@/components/button/block-btn";
5+
import BlockBtn from "@/components/button/BlockBtn";
66
import TopDetailNavigation from "@/components/layout/TopDetailNavigation";
77

88
const GpaCertExamplePage = () => {

src/app/score/submit/gpa/GpaSubmitForm.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import Link from "next/link";
44
import { useRouter } from "next/navigation";
55
import { useRef, useState } from "react";
66

7-
import clsx from "clsx";
8-
97
import { postGpaScoreApi } from "@/services/score";
108

119
import BlockBtn from "@/components/button/BlockBtn";
@@ -122,14 +120,11 @@ const GpaSubmitForm = () => {
122120
}}
123121
/>
124122
<div className="mt-[30px] flex gap-[9px]">
125-
<RoundBtn
126-
className={clsx({ "bg-primary text-k-0": file, "bg-k-300 text-k-0": !file })}
127-
onClick={() => fileInputRef.current?.click()}
128-
>
123+
<RoundBtn variant={file ? "default" : "inactive"} onClick={() => fileInputRef.current?.click()}>
129124
파일 첨부하기
130125
</RoundBtn>
131126
<Link href="/score/example/gpa-cert" target="_blank">
132-
<RoundBtn className="bg-primary-400 text-k-0">증명서 예시</RoundBtn>
127+
<RoundBtn variant="primary-400">증명서 예시</RoundBtn>
133128
</Link>
134129
</div>
135130
</div>

src/app/score/submit/language-test/LanguageTestSubmitForm.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import Link from "next/link";
44
import { useRouter } from "next/navigation";
55
import { useRef, useState } from "react";
66

7-
import clsx from "clsx";
8-
97
import { postLanguageTestScoreApi } from "@/services/score";
108
import { validateLanguageScore } from "@/utils/scoreUtils";
119

@@ -139,14 +137,11 @@ const LanguageTestSubmitForm = () => {
139137
}}
140138
/>
141139
<div className="mt-[30px] flex gap-[9px]">
142-
<RoundBtn
143-
className={clsx({ "bg-primary text-k-0": file, "bg-k-300 text-k-0": !file })}
144-
onClick={() => fileInputRef.current?.click()}
145-
>
140+
<RoundBtn variant={file ? "default" : "inactive"} onClick={() => fileInputRef.current?.click()}>
146141
파일 첨부하기
147142
</RoundBtn>
148-
<Link href="/score/example/gpa-cert" target="_blank">
149-
<RoundBtn className="bg-primary-400 text-k-0">증명서 예시</RoundBtn>
143+
<Link href="/score/example/lang-cert" target="_blank">
144+
<RoundBtn variant="primary-400">증명서 예시</RoundBtn>
150145
</Link>
151146
</div>
152147
</div>

src/components/button/BlockBtn.tsx

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,41 @@
1-
import React from "react";
1+
import * as React from "react";
22

3-
export interface BlockBtnProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3+
import { type VariantProps, cva } from "class-variance-authority";
4+
5+
import { cn } from "@/utils/designUtils";
6+
7+
const blockBtnVariants = cva("h-13 w-full min-w-80 max-w-screen-sm rounded-lg flex items-center justify-center", {
8+
variants: {
9+
variant: {
10+
default: "bg-secondary hover:bg-secondary/90 disabled:bg-k-100",
11+
primary: "bg-primary hover:bg-primary/90 disabled:bg-k-100",
12+
},
13+
text: {
14+
default: "text-base font-medium text-white",
15+
},
16+
},
17+
defaultVariants: {
18+
variant: "default",
19+
text: "default",
20+
},
21+
});
22+
23+
export interface BlockBtnProps
24+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
25+
VariantProps<typeof blockBtnVariants> {
426
onClick: () => void;
527
children: React.ReactNode;
628
}
729

8-
const BlockBtn = React.forwardRef<HTMLButtonElement, BlockBtnProps>(({ onClick, children, ...props }, ref) => (
9-
<button
10-
ref={ref}
11-
className="h-[3.125rem] w-full min-w-80 max-w-screen-sm rounded-lg bg-primary disabled:opacity-50"
12-
onClick={onClick}
13-
type="button"
14-
{...props}
15-
>
16-
<span className="font-serif text-base font-medium text-white">{children}</span>
17-
</button>
18-
));
30+
const BlockBtn = React.forwardRef<HTMLButtonElement, BlockBtnProps>(
31+
({ className, variant, text, children, ...props }, ref) => {
32+
return (
33+
<button ref={ref} className={cn(blockBtnVariants({ variant, text, className }))} {...props}>
34+
<span>{children}</span>
35+
</button>
36+
);
37+
},
38+
);
1939
BlockBtn.displayName = "BlockBtn";
2040

2141
export default BlockBtn;

src/components/button/RoundBtn.tsx

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,43 @@
1-
type RoundBtnProps = {
2-
className?: string;
1+
import * as React from "react";
2+
3+
import { type VariantProps, cva } from "class-variance-authority";
4+
5+
import { cn } from "@/utils/designUtils";
6+
7+
const roundBtnVariants = cva("h-[2.375rem] w-[6.375rem] rounded-3xl px-4 py-2.5 ", {
8+
variants: {
9+
variant: {
10+
default: "bg-secondary hover:bg-secondary/90 text-k-0",
11+
primary: "bg-primary hover:bg-primary/90 text-k-0",
12+
"primary-400": "bg-primary-400 hover:bg-primary-400/90 text-k-0",
13+
inactive: "bg-k-100 hover:bg-k-100/90 text-k-0",
14+
},
15+
text: {
16+
default: "text-xs font-bold leading-normal",
17+
},
18+
},
19+
defaultVariants: {
20+
variant: "default",
21+
text: "default",
22+
},
23+
});
24+
25+
export interface RoundBtnProps
26+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
27+
VariantProps<typeof roundBtnVariants> {
328
onClick?: () => void;
429
children: React.ReactNode;
5-
};
30+
}
631

7-
const RoundBtn = ({ onClick, className, children }: RoundBtnProps) => {
8-
return (
9-
<button
10-
className={`${"h-10 w-[102px] rounded-full px-3 py-[5px] font-serif text-xs font-bold leading-normal"} ${className || ""}`}
11-
onClick={onClick}
12-
type="button"
13-
>
14-
{children}
15-
</button>
16-
);
17-
};
32+
const RoundBtn = React.forwardRef<HTMLButtonElement, RoundBtnProps>(
33+
({ className, variant, text, children, ...props }, ref) => {
34+
return (
35+
<button ref={ref} className={cn(roundBtnVariants({ variant, text, className }))} {...props}>
36+
<span>{children}</span>
37+
</button>
38+
);
39+
},
40+
);
41+
RoundBtn.displayName = "RoundBtn";
1842

1943
export default RoundBtn;

src/components/button/block-btn.tsx

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/components/college/college-review-form.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState } from "react";
22

3-
import BlockBtn from "@/components/button/block-btn";
3+
import BlockBtn from "@/components/button/BlockBtn";
44
import StarFilledIcon from "@/components/ui/icon/star-filled";
55

66
import styles from "./college-review-form.module.css";
@@ -116,7 +116,7 @@ const CollegeReviewForm = () => {
116116
</div>
117117
</div>
118118
</div>
119-
<BlockBtn style={{ marginTop: "24px" }} onClick={() => {}}>
119+
<BlockBtn className="mt-6" onClick={() => {}}>
120120
작성하기
121121
</BlockBtn>
122122
</form>

0 commit comments

Comments
 (0)