Skip to content

Commit

Permalink
relay chain icon in network selector
Browse files Browse the repository at this point in the history
  • Loading branch information
TopETH committed Apr 24, 2024
1 parent 33d71e7 commit 0993181
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 18 deletions.
45 changes: 42 additions & 3 deletions src/components/Elements/NetworkSelect/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { FormControl, InputLabel, MenuItem, Select } from '@mui/material';
import {
Box,
FormControl,
InputLabel,
MenuItem,
Select,
Typography,
} from '@mui/material';
import Image from 'next/image';
import { useRouter } from 'next/router';

import KusamaIcon from '@/assets/networks/relay/kusama.png';
import RococoIcon from '@/assets/networks/relay/rococo.png';
import { useNetwork } from '@/contexts/network';
import { NetworkType } from '@/models';

Expand All @@ -19,6 +29,19 @@ const RelaySelect = () => {
);
};

const menuItems = [
{
value: NetworkType.ROCOCO,
label: 'Rococo',
icon: RococoIcon,
},
{
value: NetworkType.KUSAMA,
label: 'Kusama',
icon: KusamaIcon,
},
];

return network !== NetworkType.NONE ? (
<FormControl sx={{ m: 2, minWidth: 150 }} fullWidth>
<InputLabel>Network</InputLabel>
Expand All @@ -28,8 +51,24 @@ const RelaySelect = () => {
label='Relay chain'
onChange={handleChange}
>
<MenuItem value={NetworkType.ROCOCO}>Rococo</MenuItem>
<MenuItem value={NetworkType.KUSAMA}>Kusama</MenuItem>
{menuItems.map(({ value, label, icon }, index) => (
<MenuItem value={value} key={index}>
<Box sx={{ display: 'flex', gap: '0.5rem', alignItems: 'center' }}>
<Image
src={icon}
alt={label.toLowerCase()}
style={{
width: '1.5rem',
height: '1.5rem',
borderRadius: '100%',
}}
/>
<Typography sx={{ lineHeight: 1.5, fontSize: '1rem' }}>
{label}
</Typography>
</Box>
</MenuItem>
))}
</Select>
</FormControl>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
.option {
min-width: 250px;
margin: 1em 5em;
}
}
38 changes: 24 additions & 14 deletions src/components/Elements/Selectors/AssetSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ export default function AssetSelector({
symbol,
}: AssetSelectorProps) {
const theme = useTheme();
const items = [
{
value: AssetType.TOKEN,
label: symbol,
},
{
value: AssetType.REGION,
label: 'Region',
},
];

return (
<FormControl>
<ToggleButtonGroup
Expand All @@ -25,20 +36,19 @@ export default function AssetSelector({
onChange={(e: any) => setAsset(parseInt(e.target.value) as AssetType)}
className={styles.options}
>
<ToggleButton
className={styles.option}
sx={{ color: theme.palette.text.primary }}
value={AssetType.TOKEN}
>
{symbol}
</ToggleButton>
<ToggleButton
className={styles.option}
sx={{ color: theme.palette.text.primary }}
value={AssetType.REGION}
>
Region
</ToggleButton>
{items.map(({ label, value }, index) => (
<ToggleButton
className={styles.option}
sx={{
color: theme.palette.text.primary,
border: `1px solid ${theme.palette.grey['200']}`,
}}
value={value}
key={index}
>
{label}
</ToggleButton>
))}
</ToggleButtonGroup>
</FormControl>
);
Expand Down
7 changes: 7 additions & 0 deletions src/utils/muiTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ let theme = createTheme({
},
},
},
MuiToggleButtonGroup: {
styleOverrides: {
lastButton: {
borderLeft: '1px solid',
},
},
},
},
});

Expand Down

0 comments on commit 0993181

Please sign in to comment.