-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathindex.tsx
61 lines (54 loc) · 1.65 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React, { useState } from 'react'
import { ChainNamespace, ConstantsUtil } from '@reown/appkit-common'
import { sprinkles } from '../../css/sprinkless.css'
import { Btc } from '../Icons/Btc'
import { Eth } from '../Icons/Eth'
import { Sol } from '../Icons/Sol'
const Tab = ({ onTabClick }: { onTabClick: (tab: ChainNamespace) => void }) => {
const [activeTab, setActiveTab] = useState<ChainNamespace>('eip155')
const tabs: ChainNamespace[] = ['eip155', 'solana', 'bip122']
const icons: React.ReactNode[] = [<Eth />, <Sol />, <Btc />]
const handleTabClick = (tab: ChainNamespace) => {
setActiveTab(tab)
onTabClick(tab)
}
return (
<div
className={sprinkles({
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
padding: '2',
width: 'full',
background: 'neutrals900',
borderRadius: '16'
})}
>
{tabs.map((tab, index) => (
<button
key={tab}
onClick={() => handleTabClick(tab)}
className={sprinkles({
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: '1',
width: 'auto',
flex: '1',
padding: '2',
borderRadius: '8',
border: 'none',
background: activeTab === tab ? 'neutrals800' : 'neutrals900',
color: 'white',
cursor: 'pointer',
transition: 'default'
})}
>
{icons[index]}
{ConstantsUtil.CHAIN_NAME_MAP[tab].replaceAll('EVM Networks', 'Ethereum')}
</button>
))}
</div>
)
}
export default Tab