Skip to content

Commit

Permalink
feat: 퀵메뉴 코드 리뷰
Browse files Browse the repository at this point in the history
  • Loading branch information
minSsan committed May 29, 2024
1 parent 663218a commit cd9694e
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 91 deletions.
65 changes: 11 additions & 54 deletions src/app/(default)/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,18 @@
import React, { FormEvent, useCallback } from "react";
import styles from "./main.module.css";
import Image from "next/image";
import {
Banner,
MenuSchool,
MenuStudent ,
MenuSchedule,
MenuWorld,
MenuWelfare,
MenuFinance,
MenuEmploy,
MenuStudy,
MenuGraduate
} from "../../../public/svgs";
import { Banner } from "../../../public/svgs";
import { SearchBox, QuickMenu, DataBoard } from "../../components";
import { useIncreaseCount } from "../../hooks";
import { useRouter } from "next/navigation";
import Link from "next/link";
import {
QUICK_MENU,
SERVER_PARAMS_KEY,
} from "../../constants/dataset-search-params";

const DATA_COUNT = 2379;

const QUICK_MENU = [
{
src: MenuSchool,
title: "입학",
},
{
src: MenuStudent,
title: "학생",
},
{
src: MenuSchedule,
title: "학사",
},
{
src: MenuWorld,
title: "국제",
},
{
src: MenuWelfare,
title: "복지",
},
{
src: MenuFinance,
title: "재정",
},
{
src: MenuEmploy,
title: "취창업",
},
{
src: MenuStudy,
title: "학술",
},
{
src: MenuGraduate,
title: "장학",
},
];

export default function Main({ populars, news }) {
const dataCount = useIncreaseCount(DATA_COUNT);

Expand All @@ -71,7 +26,7 @@ export default function Main({ populars, news }) {
event.preventDefault();

if (keyword) {
router.push(`search-result?keyword=${keyword}`);
router.push(`search-result?${SERVER_PARAMS_KEY.KEYWORD}=${keyword}`);
return;
}
},
Expand Down Expand Up @@ -118,7 +73,9 @@ export default function Main({ populars, news }) {
{/* 퀵메뉴 */}
<div className={styles.menuGrid}>
{QUICK_MENU.map((menu) => (
<QuickMenu image={menu.src} title={menu.title} />
<Link href={`search-result?${SERVER_PARAMS_KEY.THEME}=${menu.title}`}>
<QuickMenu image={menu.src} title={menu.title} />
</Link>
))}
</div>
</div>
Expand All @@ -131,7 +88,7 @@ export default function Main({ populars, news }) {
<DataBoard
title="인기 데이터"
dataList={populars}
url={`search-result?sort=스크랩순`}
url={`search-result?${SERVER_PARAMS_KEY.SORT}=스크랩순`}
/>

{/* 신규데이터 */}
Expand Down
14 changes: 0 additions & 14 deletions src/components/quick-menu/quick-menu.jsx

This file was deleted.

26 changes: 13 additions & 13 deletions src/components/quick-menu/quick-menu.module.css
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;

width: 100px;
height: 130px;
width: 6.25rem;
height: 8.125rem;
}

.image {
width: 70%;
height: auto;
width: 70%;
height: auto;
}

.title {
width: auto;
height: 25px;
width: auto;
height: 1.625rem;

font-size: 16px;
font-size: 1rem;

margin-top: 5px;
}
margin-top: 5px;
}
21 changes: 21 additions & 0 deletions src/components/quick-menu/quick-menu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"use client";

import Image from "next/image";
import styles from "./quick-menu.module.css";
import { CSSProperties } from "react";

interface Props {
image: string;
title: string;
className?: string;
style?: CSSProperties;
}

export function QuickMenu({ image, title, className, style }: Props) {
return (
<div className={`${styles.container} ${className}`} style={style}>
<Image alt={`${title}`} className={styles.image} src={image} />
<h3 className={styles.title}>{title}</h3>
</div>
);
}
61 changes: 51 additions & 10 deletions src/constants/dataset-search-params.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,56 @@
export const THEME_VALUES = [
"입학",
"학생",
"학사",
"국제",
"복지",
"재정",
"취창업",
"학술",
"장학",
import {
MenuEmploy,
MenuFinance,
MenuGraduate,
MenuSchedule,
MenuSchool,
MenuStudent,
MenuStudy,
MenuWelfare,
MenuWorld,
} from "../../public/svgs";

export const QUICK_MENU = [
{
src: MenuSchool,
title: "입학",
},
{
src: MenuStudent,
title: "학생",
},
{
src: MenuSchedule,
title: "학사",
},
{
src: MenuWorld,
title: "국제",
},
{
src: MenuWelfare,
title: "복지",
},
{
src: MenuFinance,
title: "재정",
},
{
src: MenuEmploy,
title: "취창업",
},
{
src: MenuStudy,
title: "학술",
},
{
src: MenuGraduate,
title: "장학",
},
] as const;

export const THEME_VALUES = QUICK_MENU.map((menu) => menu.title);

export const ORGANIZATION_VALUES = [
"소프트융합대학",
"공과대학",
Expand Down

0 comments on commit cd9694e

Please sign in to comment.