1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-16 02:04:54 +01:00
market/src/components/atoms/Tabs.tsx

40 lines
952 B
TypeScript
Raw Normal View History

2020-07-23 12:26:08 +02:00
import React, { ReactElement, ReactNode } from 'react'
import { Tab, Tabs as ReactTabs, TabList, TabPanel } from 'react-tabs'
import styles from './Tabs.module.css'
interface TabsItem {
title: string
content: ReactNode
}
export default function Tabs({
items,
2020-08-05 11:54:10 +02:00
className,
handleTabChange
2020-07-23 12:26:08 +02:00
}: {
items: TabsItem[]
className?: string
2020-08-05 11:54:10 +02:00
handleTabChange?: (tabName: string) => void
2020-07-23 12:26:08 +02:00
}): ReactElement {
return (
<ReactTabs className={`${className && className}`}>
<TabList className={styles.tabList}>
{items.map((item) => (
2020-08-05 11:54:10 +02:00
<Tab
className={styles.tab}
key={item.title}
onClick={() => handleTabChange(item.title)}
>
2020-07-23 12:26:08 +02:00
{item.title}
</Tab>
))}
</TabList>
<div className={styles.tabContent}>
{items.map((item) => (
2020-08-03 11:34:51 +02:00
<TabPanel key={item.title}>{item.content}</TabPanel>
2020-07-23 12:26:08 +02:00
))}
</div>
</ReactTabs>
)
}