Skip to content

Commit f7227a5

Browse files
committed
created a common tabs component
1 parent 49c23e8 commit f7227a5

File tree

2 files changed

+37
-36
lines changed

2 files changed

+37
-36
lines changed

src/App.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import MainTab from './components/tabs/mainTab'
44
import TabsComponent from './components/tabs/tabsComponent'
55
import useYoroi from './hooks/yoroiProvider'
66
import {CONNECTED, NO_CARDANO} from './utils/connectionStates'
7+
import Cip30Tab from './components/tabs/subtabs/cip30Tab'
8+
import Cip95Tab from './components/tabs/subtabs/cip95Tab'
9+
import Cip95TabTools from './components/tabs/subtabs/cip95ToolsTab'
10+
import NFTTab from './components/tabs/subtabs/NFTTab'
711

812
const App = () => {
913
const {connectionState} = useYoroi()
@@ -15,11 +19,34 @@ const App = () => {
1519
isNotCardanoWallet,
1620
}
1721

22+
const data = [
23+
{
24+
label: 'CIP-30',
25+
value: 'cip30',
26+
children: <Cip30Tab />,
27+
},
28+
{
29+
label: 'CIP-95',
30+
value: 'cip95',
31+
children: <Cip95Tab />,
32+
},
33+
{
34+
label: 'CIP-95 Tools',
35+
value: 'cip95Tools',
36+
children: <Cip95TabTools />,
37+
},
38+
{
39+
label: 'NFTs',
40+
value: 'nfts',
41+
children: <NFTTab />,
42+
},
43+
]
44+
1845
return (
1946
<div className="min-h-screen bg-gray-800">
2047
<AccessButton />
2148
<MainTab {...mainTabProps} />
22-
<TabsComponent />
49+
<TabsComponent tabsData={data} />
2350
</div>
2451
)
2552
}

src/components/tabs/tabsComponent.js

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,27 @@
11
import React, {useState} from 'react'
22
import {Tabs, TabsHeader, TabsBody, Tab, TabPanel} from '@material-tailwind/react'
3-
import Cip30Tab from './subtabs/cip30Tab'
4-
import Cip95Tab from './subtabs/cip95Tab'
5-
import Cip95TabTools from './subtabs/cip95ToolsTab'
6-
import NFTTab from './subtabs/NFTTab'
73

8-
const TabsComponent = () => {
9-
const [activeTab, setActiveTab] = useState('cip30')
10-
const data = [
11-
{
12-
label: 'CIP-30',
13-
value: 'cip30',
14-
children: <Cip30Tab />,
15-
},
16-
{
17-
label: 'CIP-95',
18-
value: 'cip95',
19-
children: <Cip95Tab />,
20-
},
21-
{
22-
label: 'CIP-95 Tools',
23-
value: 'cip95Tools',
24-
children: <Cip95TabTools />,
25-
},
26-
{
27-
label: 'NFTs',
28-
value: 'nfts',
29-
children: <NFTTab />,
30-
},
31-
]
4+
const TabsComponent = ({tabsData}) => {
5+
const [activeTab, setActiveTab] = useState(tabsData[0].value)
326

337
return (
348
<Tabs value={activeTab}>
35-
<TabsHeader
36-
className="rounded-none border-b-2 border-gray-700 bg-transparent p-0"
37-
>
38-
{data.map(({label, value}) => (
9+
<TabsHeader className="rounded-none border-b-2 border-gray-700 bg-transparent p-0">
10+
{tabsData.map(({label, value}) => (
3911
<Tab
4012
key={value}
4113
value={value}
42-
className={activeTab === value ? 'bg-orange-700 hover:bg-orange-800 text-white rounded-t-lg' : 'text-gray-300'}
14+
className={
15+
activeTab === value ? 'bg-orange-700 text-white rounded-t-lg' : 'text-gray-300 border-x border-gray-700'
16+
}
4317
onClick={() => setActiveTab(value)}
44-
>
18+
>
4519
{label}
4620
</Tab>
4721
))}
4822
</TabsHeader>
4923
<TabsBody>
50-
{data.map(({value, children}) => (
24+
{tabsData.map(({value, children}) => (
5125
<TabPanel key={value} value={value} children={children} />
5226
))}
5327
</TabsBody>

0 commit comments

Comments
 (0)