Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.

Commit 3e241a9

Browse files
committed
Chain selection feature added
1 parent a289b58 commit 3e241a9

File tree

5 files changed

+59
-11
lines changed

5 files changed

+59
-11
lines changed

toolkit/theme/globalCss.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { SystemConfig } from '@chakra-ui/react';
22

33
import addressEntity from './globals/address-entity';
4+
import networkMenu from './globals/network-menu';
45
import recaptcha from './globals/recaptcha';
56
import scrollbar from './globals/scrollbar';
67

@@ -52,6 +53,7 @@ const globalCss: SystemConfig['globalCss'] = {
5253
...recaptcha,
5354
...scrollbar,
5455
...addressEntity,
56+
...networkMenu,
5557
};
5658

5759
export default globalCss;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const styles = {
2+
'.network-title': {
3+
paddingBlock: 2,
4+
paddingInline: 3,
5+
fontWeight: 'bold',
6+
backgroundColor: 'var(--chakra-colors-blue-50)',
7+
marginBlockEnd: 4,
8+
borderRadius: 'var(--chakra-radii-base)',
9+
},
10+
'.network-menu': {
11+
display: 'grid !important',
12+
gridTemplateColumns: 'repeat(5, 1fr)',
13+
gap: '12px !important',
14+
padding: 0,
15+
listStyle: 'none',
16+
17+
'& .network-menu-li': {
18+
aspectRatio: '1 / 1',
19+
display: 'flex',
20+
alignItems: 'center',
21+
justifyContent: 'center',
22+
fontSize: '1.2rem',
23+
fontWeight: 'bold',
24+
background: '#f0f0f0',
25+
borderRadius: '8px',
26+
boxShadow: '0 1px 2px rgba(0,0,0,0.05)',
27+
flexDirection: 'column',
28+
29+
'& span': {
30+
display: 'block',
31+
},
32+
'& .network-menu-link': {
33+
fontWeight: 'bold',
34+
35+
'& .network-menu-li-icon': {
36+
display: 'none !important',
37+
},
38+
},
39+
},
40+
},
41+
};
42+
43+
export default styles;

ui/snippets/networkMenu/NetworkMenuContentDesktop.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ interface Props {
1515
}
1616

1717
const NetworkMenuPopup = ({ items, tabs }: Props) => {
18+
const [ defaultTab ] = tabs ?? [ 'Mainnets' ];
1819
const selectedNetwork = items?.find(({ isActive }) => isActive);
19-
const defaultTab = tabs.find((tab) => selectedNetwork?.group === tab);
20+
const selectedTab = tabs.find((tab) => selectedNetwork?.group === tab) ?? defaultTab;
2021

21-
const [ value, setValue ] = React.useState<NetworkGroup>(defaultTab ?? 'Mainnets');
22+
const [ value, setValue ] = React.useState<NetworkGroup>(selectedTab);
2223

2324
const handleTabChange = React.useCallback(({ value }: { value: string }) => {
2425
setValue(value as NetworkGroup);
@@ -72,7 +73,8 @@ const NetworkMenuPopup = ({ items, tabs }: Props) => {
7273
<Box>
7374
{ tabs.map((tab) => (
7475
<TabsContent key={ tab } value={ tab } p={ 0 }>
75-
<VStack as="ul" gap={ 1 } alignItems="stretch" maxH="516px" overflowY="scroll">
76+
{ defaultTab ? <h6 className="network-title">"{ defaultTab }" Chains</h6> : null }
77+
<VStack as="ul" gap={ 1 } alignItems="stretch" maxH="516px" overflowY="scroll" className="network-menu">
7678
{ items
7779
.filter((network) => network.group === tab)
7880
.map((network) => (

ui/snippets/networkMenu/NetworkMenuContentMobile.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ interface Props {
1515
}
1616

1717
const NetworkMenuContentMobile = ({ items, tabs }: Props) => {
18+
const [ defaultTab ] = tabs ?? [ 'Mainnets' ];
1819
const selectedNetwork = items?.find(({ isActive }) => isActive);
19-
const [ selectedTab, setSelectedTab ] = React.useState<NetworkGroup>('Mainnets');
20+
const [ selectedTab, setSelectedTab ] = React.useState<NetworkGroup>(defaultTab);
2021

2122
React.useEffect(() => {
2223
if (items) {
23-
setSelectedTab(tabs.find((tab) => selectedNetwork?.group === tab) || 'Mainnets');
24+
setSelectedTab(tabs.find((tab) => selectedNetwork?.group === tab) ?? defaultTab);
2425
}
25-
}, [ items, selectedNetwork?.group, tabs ]);
26+
}, [ defaultTab, items, selectedNetwork?.group, tabs ]);
2627

2728
const handleSelectChange = React.useCallback(({ value }: { value: Array<string> }) => {
2829
setSelectedTab(value[0] as NetworkGroup);
@@ -61,7 +62,8 @@ const NetworkMenuContentMobile = ({ items, tabs }: Props) => {
6162
contentProps={{ zIndex: 'modal' }}
6263
/>
6364
) }
64-
<VStack as="ul" gap={ 2 } alignItems="stretch">
65+
{ selectedTab ? <h6 className="network-title">"{ selectedTab }" Chains</h6> : null }
66+
<VStack as="ul" gap={ 2 } alignItems="stretch" className="network-menu">
6567
{ items
6668
.filter(({ group }) => group === selectedTab)
6769
.map((network) => (

ui/snippets/networkMenu/NetworkMenuLink.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ const NetworkMenuLink = ({ title, icon, isActive: isActiveProp, isMobile, url, i
4242
})();
4343

4444
return (
45-
<Box as="li" listStyleType="none">
45+
<Box as="li" listStyleType="none" className="network-menu-li">
4646
<chakra.a
47+
className="network-menu-link"
4748
display="flex"
4849
href={ url }
4950
px={ 3 }
@@ -56,10 +57,8 @@ const NetworkMenuLink = ({ title, icon, isActive: isActiveProp, isMobile, url, i
5657
bgColor={ isActive ? { base: 'blue.50', _dark: 'whiteAlpha.100' } : 'transparent' }
5758
_hover={{ color: isActive ? { base: 'blackAlpha.900', _dark: 'whiteAlpha.900' } : 'link.primary.hover' }}
5859
>
59-
{ iconEl }
60+
<div className="network-menu-li-icon">{ iconEl }</div>
6061
<Text
61-
marginLeft={ 3 }
62-
fontWeight="500"
6362
color="inherit"
6463
fontSize={ isMobile ? 'sm' : 'md' }
6564
lineHeight={ isMobile ? '20px' : '24px' }

0 commit comments

Comments
 (0)