Skip to content

Commit

Permalink
✨ : #492 - 발자취 페이지 상단 탭 FootPrintTab 컴포넌트 기능 및 디자인 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
MinwooP committed Mar 27, 2024
1 parent 7281ae2 commit 7b29439
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/app/footprints/_Components/FootPrintFilter/FootPrintFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,22 @@ export default function FootPrintFilter({
// plan-DropDown의 selectedValue 값으로 setPlan() 호출

// 자체 state
// year에 해당하는 모든 계획 리스트 state
// TODO: props으로 받은 year에 해당하는 모든 계획들을 return 하는 useQuery 정의하고 여기서로부터 data return
// 이를 plan-dropdown의 options로 넣어주기
// const [selectedYear, setSelectedYear] = useState(2024);
// const [selectedPlan, setSelectedPlan] = useState<planType>({
// planId: -1,
// planTitle: '모든 계획',
// });

// useEffect로 year이 바뀔 때마다, selectedPlan의 값은 "모든 계획"
// TODO: useEffect로 year이 바뀔 때마다, selectedPlan의 값은 "모든 계획"으로 변경해주기
// useEffect(() => {
// setSelectedPlan({
// planId: -1,
// planTitle: '모든 계획',
// });
// }, [year]);

return (
<div
onClick={() => {
Expand Down
64 changes: 62 additions & 2 deletions src/app/footprints/_Components/FootPrintTab/FootPrintTab.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,71 @@
import classNames from 'classnames';
import React from 'react';
import './index.scss';

interface FootPrintTabProps {
isMyFootPrintsTab: boolean;
setMyFootPrintsTab: () => void;
setAllFootPrintsTab: () => void;
}

export default function FootPrintTab({}: FootPrintTabProps) {
return <div></div>;
const TAB_MENU = {
MY: '내 발자취',
ALL: '둘러보기',
};

export default function FootPrintTab({
isMyFootPrintsTab,
setMyFootPrintsTab,
setAllFootPrintsTab,
}: FootPrintTabProps) {
// TODO: isMyFootPrintsTab이 true => 내 발자취, false => 둘러보기 표시

const handleClickMyFootPrintsTab = () => {
if (!isMyFootPrintsTab) {
setMyFootPrintsTab();
}
};

const handleClickAllFootPrintsTab = () => {
if (isMyFootPrintsTab) {
setAllFootPrintsTab();
}
};

return (
<div className={classNames('footprint-tab')}>
<div
className={classNames(
'footprint-tab__menu',
'font-size-base',
isMyFootPrintsTab
? 'footprint-tab--focused'
: 'footprint-tab--normal',
)}
onClick={handleClickMyFootPrintsTab}>
{TAB_MENU.MY}
<div
className={classNames('footprint-tab__underline', {
'footprint-tab__underline--focused': isMyFootPrintsTab,
})}
/>
</div>
<div
className={classNames(
'footprint-tab__menu',
'font-size-base',
!isMyFootPrintsTab
? 'footprint-tab--focused'
: 'footprint-tab--normal',
)}
onClick={handleClickAllFootPrintsTab}>
{TAB_MENU.ALL}
<div
className={classNames('footprint-tab__underline', {
'footprint-tab__underline--focused': !isMyFootPrintsTab,
})}
/>
</div>
</div>
);
}
34 changes: 34 additions & 0 deletions src/app/footprints/_Components/FootPrintTab/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.footprint-tab {
margin-top: 2rem;
display: flex;
gap: 0rem;
&:hover {
cursor: pointer;
}

&__menu {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.5rem;
width: 6rem;
}

&__underline {
background-color: var(--origin-secondary);
height: 0.125rem;
width: 100%;

&--focused {
background-color: var(--origin-primary);
}
}

&--normal {
color: var(--origin-secondary);
}

&--focused {
color: var(--origin-primary);
}
}
7 changes: 7 additions & 0 deletions src/app/footprints/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.footprint-page {
display: flex;
flex-direction: column;
gap: 1.5rem;
width: 100%;
height: 100%;
}
6 changes: 4 additions & 2 deletions src/app/footprints/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
'use client';

import classNames from 'classnames';
import { useState } from 'react';
import AllFootPrints from './_Components/AllFootPrints/AllFootPrints';
import FootPrintTab from './_Components/FootPrintTab/FootPrintTab';
import MyFootPrints from './_Components/MyFootPrints/MyFootPrints';
import './index.scss';

export default function FootPrintsPage() {
const [isMyFootPrintsTab, setIsMyFootPrintsTab] = useState(true);
Expand All @@ -16,13 +18,13 @@ export default function FootPrintsPage() {
};

return (
<>
<div className={classNames('footprint-page')}>
<FootPrintTab
isMyFootPrintsTab={isMyFootPrintsTab}
setMyFootPrintsTab={setMyFootPrintsTab}
setAllFootPrintsTab={setAllFootPrintsTab}
/>
{isMyFootPrintsTab ? <MyFootPrints /> : <AllFootPrints />}
</>
</div>
);
}

0 comments on commit 7b29439

Please sign in to comment.