-
Notifications
You must be signed in to change notification settings - Fork 6
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
11 changed files
with
98 additions
and
64 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
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
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
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
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
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
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 |
---|---|---|
@@ -1,37 +1,53 @@ | ||
import * as Tabs from '@radix-ui/react-tabs'; | ||
import { useRecoilState } from 'recoil'; | ||
import { tapState } from '@recoil/plan'; | ||
|
||
interface TabProps { | ||
lists: string[]; | ||
contents: React.ReactNode[]; | ||
} | ||
|
||
const Tab = ({ lists, contents }: TabProps) => ( | ||
<Tabs.Root className="flex w-full flex-col" defaultValue="tab0"> | ||
<Tabs.List | ||
className="border-b-1 no-scrollbar flex shrink-0 overflow-x-scroll" | ||
aria-label="Manage your account"> | ||
{lists.map((list, index) => { | ||
const Tab = ({ lists, contents }: TabProps) => { | ||
const [, setTapState] = useRecoilState(tapState); | ||
|
||
const handleTabChange = (value: string) => { | ||
const tabIndex = value.replace('tab', ''); | ||
if (tabIndex !== '') { | ||
setTapState(tabIndex); | ||
} | ||
}; | ||
|
||
return ( | ||
<Tabs.Root | ||
className="flex w-full flex-col" | ||
defaultValue="tab0" | ||
onValueChange={handleTabChange}> | ||
<Tabs.List | ||
className="border-b-1 no-scrollbar flex shrink-0 overflow-x-scroll" | ||
aria-label="Manage your account"> | ||
{lists.map((list, index) => { | ||
return ( | ||
<Tabs.Trigger | ||
key={index} | ||
className="headline1 flex flex-1 cursor-pointer select-none items-center justify-center border-b-2 border-solid border-gray2 py-[8px] leading-none text-gray4 outline-none data-[state=active]:border-b-2 data-[state=active]:border-solid data-[state=active]:border-black data-[state=active]:text-black" | ||
value={`tab${index}`}> | ||
{list} | ||
</Tabs.Trigger> | ||
); | ||
})} | ||
</Tabs.List> | ||
{contents.map((content, index) => { | ||
return ( | ||
<Tabs.Trigger | ||
<Tabs.Content | ||
key={index} | ||
className="headline1 flex flex-1 cursor-pointer select-none items-center justify-center border-b-2 border-solid border-gray2 py-[8px] leading-none text-gray4 outline-none data-[state=active]:border-b-2 data-[state=active]:border-solid data-[state=active]:border-black data-[state=active]:text-black" | ||
className="grow py-5 outline-none" | ||
value={`tab${index}`}> | ||
{list} | ||
</Tabs.Trigger> | ||
{content} | ||
</Tabs.Content> | ||
); | ||
})} | ||
</Tabs.List> | ||
{contents.map((content, index) => { | ||
return ( | ||
<Tabs.Content | ||
key={index} | ||
className="grow py-5 outline-none" | ||
value={`tab${index}`}> | ||
{content} | ||
</Tabs.Content> | ||
); | ||
})} | ||
</Tabs.Root> | ||
); | ||
</Tabs.Root> | ||
); | ||
}; | ||
|
||
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
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
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
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