-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
탭 컴포넌트 구현
- Loading branch information
Showing
6 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const CommentTest = () => { | ||
return <div>댓글 페이지</div> | ||
} | ||
|
||
export default CommentTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use client' | ||
|
||
import React, { useState } from 'react' | ||
import Tab from '@/components/common/Tab/Tab' | ||
import TabItem from '@/components/common/Tab/TabItem' | ||
|
||
const TabTestPage = ({ children }: { children: React.ReactNode }) => { | ||
const [currentTab, setCurrentTab] = useState(0) | ||
|
||
const tabArr = [ | ||
{ text: '스페이스', content: '스페이스 페이지', dest: '/bomiTest/tabTest' }, | ||
{ text: '댓글', content: '댓글 페이지', dest: '/bomiTest/tabTest/comment' }, | ||
{ text: '설정', content: '설정 페이지', dest: '/bomiTest/tabTest/setting' }, | ||
] | ||
|
||
return ( | ||
<div className="m-2"> | ||
<Tab> | ||
{tabArr.map((tabItem, index) => ( | ||
<TabItem | ||
key={index} | ||
active={currentTab === index ? true : false} | ||
dest={tabItem.dest} | ||
text={tabItem.text} | ||
onClick={() => setCurrentTab(index)} | ||
/> | ||
))} | ||
</Tab> | ||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
export default TabTestPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react' | ||
|
||
const SpaceTest = () => { | ||
return <div>스페이스 페이지</div> | ||
} | ||
|
||
export default SpaceTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const SettingTest = () => { | ||
return <div>세팅 페이지</div> | ||
} | ||
|
||
export default SettingTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
interface TabProps { | ||
children?: React.ReactNode | ||
} | ||
|
||
const Tab = ({ children }: TabProps) => { | ||
return <div className="flex transition ease-in-out">{children}</div> | ||
} | ||
|
||
export default Tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { cls } from '@/utils' | ||
import Link from 'next/link' | ||
|
||
interface TabItemProps { | ||
active?: boolean | ||
text?: string | ||
dest: string | ||
onClick: (_e?: React.MouseEvent<HTMLDivElement>) => void | ||
} | ||
|
||
const TabItem = ({ active, text, dest, onClick }: TabItemProps) => { | ||
return ( | ||
<Link | ||
style={{ width: '100%' }} | ||
href={dest}> | ||
<div | ||
onClick={onClick} | ||
className={cls( | ||
active ? 'border-emerald5' : 'border-slate3', | ||
`flex w-[100%] cursor-pointer items-center justify-center border-b py-4 text-sm font-bold text-gray9 transition ease-in-out`, | ||
)}> | ||
{text} | ||
</div> | ||
</Link> | ||
) | ||
} | ||
|
||
export default TabItem |