Skip to content

Commit 93f7e75

Browse files
authored
카테고리 원자 컴포넌트 (#115)
* feat: 카테고리 원자 컴포넌트 * chore: interface 패턴 추가
1 parent e8d9743 commit 93f7e75

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

.eslintrc.json

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
"pattern": "@til-log.lab/**",
4646
"group": "parent"
4747
},
48+
{
49+
"pattern": "**/interface",
50+
"group": "type"
51+
},
4852
{
4953
"pattern": "**/interface/**",
5054
"group": "type"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { useRouter } from "next/router";
2+
import React from "react";
3+
4+
import LinkTo from "@Components/molecules/LinkTo";
5+
6+
import { CategoryCardProps } from "@Components/atom/card/category/interface";
7+
8+
const CategoryCard = ({
9+
categoryCardStyle,
10+
categoryName,
11+
}: CategoryCardProps) => {
12+
const router = useRouter();
13+
14+
if (router.query.category !== categoryName) {
15+
return (
16+
<LinkTo
17+
href={{
18+
pathname: router.pathname,
19+
query: { ...router.query, category: categoryName },
20+
}}
21+
>
22+
<span
23+
className={`${categoryCardStyle} text-neutral-400 text-xl font-eng-sub-font-1`}
24+
>
25+
# {categoryName}
26+
</span>
27+
</LinkTo>
28+
);
29+
}
30+
return (
31+
<LinkTo
32+
href={{
33+
pathname: router.pathname,
34+
query: { ...router.query, category: null },
35+
}}
36+
>
37+
<span
38+
className={`${categoryCardStyle} text-xl text-${categoryName} font-semibold font-eng-sub-font-1`}
39+
>
40+
# {categoryName}
41+
</span>
42+
</LinkTo>
43+
);
44+
};
45+
46+
export default CategoryCard;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default interface CategoryCardProps {
2+
categoryCardStyle?: string;
3+
categoryName: string;
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import CategoryCardProps from "@Components/atom/card/category/interface/categoryCardProps";
2+
3+
export type { CategoryCardProps };

0 commit comments

Comments
 (0)