Skip to content

Commit

Permalink
feat: Update network select (#385)
Browse files Browse the repository at this point in the history
Co-authored-by: Thibaut Sardan <[email protected]>
  • Loading branch information
Lykhoyda and Tbaut authored Oct 9, 2023
1 parent fc3915f commit eac29c0
Show file tree
Hide file tree
Showing 8 changed files with 293 additions and 70 deletions.
30 changes: 20 additions & 10 deletions packages/ui/src/components/ConnectOrWatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ export const ConnectOrWatch = () => {

return (
<ConnectButtonWrapperStyled>
No multisig found for your accounts or watched accounts.{' '}
{isAllowedToConnectToExtension ? (
<Button onClick={() => navigate('/create')}>Create one</Button>
) : (
<Button onClick={allowConnectionToExtension}>Connect Wallet</Button>
)}
or
<Button onClick={() => navigate(`/settings${WATCH_ACCOUNT_ANCHOR}`)}>Watch one</Button>
<div>No multisig found for your accounts or watched accounts.</div>
<ButtonWrapperStyled>
{isAllowedToConnectToExtension ? (
<Button onClick={() => navigate('/create')}>Create one</Button>
) : (
<Button onClick={allowConnectionToExtension}>Connect Wallet</Button>
)}
or
<Button onClick={() => navigate(`/settings${WATCH_ACCOUNT_ANCHOR}`)}>Watch one</Button>
</ButtonWrapperStyled>
</ConnectButtonWrapperStyled>
)
}
Expand All @@ -26,8 +28,16 @@ const ConnectButtonWrapperStyled = styled('div')`
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
`

const ButtonWrapperStyled = styled('div')`
display: flex;
align-items: center;
justify-content: center;
padding: 1rem 0;
& > button {
margin: 0 1rem;
button {
margin: 0 0.5rem;
}
`
18 changes: 16 additions & 2 deletions packages/ui/src/components/Drawer/DrawerMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function DrawerMenu({ handleDrawerClose }: DrawerMenuProps) {
<ChevronRightIcon size={20} />
</IconButton>
</DrawerHeader>
<List>
<List disablePadding={true}>
{!isAllowedToConnectToExtension && (
<ListItemStyled disablePadding>
<ButtonStyled
Expand Down Expand Up @@ -65,7 +65,21 @@ function DrawerMenu({ handleDrawerClose }: DrawerMenuProps) {
)
}
const ListItemStyled = styled(ListItem)`
justify-content: flex-end;
justify-content: center;
width: 100%;
@media (min-width: ${({ theme }) => theme.breakpoints.values.md}px) {
justify-content: flex-end;
}
a {
width: 100%;
text-align: center;
@media (min-width: ${({ theme }) => theme.breakpoints.values.md}px) {
width: auto;
}
}
`

const ButtonStyled = styled(Button)`
Expand Down
16 changes: 14 additions & 2 deletions packages/ui/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,28 @@ const RightButtonsWrapperStyled = styled(Box)`
display: flex;
align-items: center;
justify-content: flex-end;
flex: 1;
`

const MenuWrapperStyled = styled(Box)`
width: 100%;
display: flex;
align-items: center;
`

const DesktopMenuStyled = styled(Box)`
display: none;
@media (min-width: ${({ theme }) => theme.breakpoints.values.md}px) {
flex-grow: 1;
width: 100%;
flex-grow: 0;
display: flex;
align-items: center;
}
@media (min-width: ${({ theme }) => theme.breakpoints.values.lg}px) {
flex-grow: 1;
}
`

const LogoWrapperStyled = styled(Box)`
Expand All @@ -119,8 +127,12 @@ const LogoWrapperStyled = styled(Box)`
flex: 1;
@media (min-width: ${({ theme }) => theme.breakpoints.values.md}px) {
margin-right: 1rem;
flex: 0;
margin-right: 0.5rem;
}
@media (min-width: ${({ theme }) => theme.breakpoints.values.lg}px) {
margin-right: 1rem;
}
`

Expand Down
56 changes: 29 additions & 27 deletions packages/ui/src/components/library/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import { theme } from '../../styles/theme'
interface SelectProps {
value: string
menuItems?: { value: string; logo?: string }[]
onChange: (event: SelectChangeEvent<string>) => void
onChange: (event: SelectChangeEvent<unknown>) => void
minified?: boolean
inputSize?: 'medium' | 'large'
fullWidth?: boolean
children?: React.ReactNode[]
children?: React.ReactNode[] | React.ReactNode
sx?: SxProps<Theme>
}

Expand All @@ -43,30 +43,8 @@ const Select = ({
value={value}
fullWidth={fullWidth}
IconComponent={HiOutlineChevronDown}
MenuProps={{
sx: {
marginTop: '.75rem',
'.MuiPaper-root': {
boxShadow: 'none'
},

'.MuiList-root': {
padding: 0,
border: `1px solid ${theme.custom.text.borderColor}`,
borderRadius: '0.5rem'
},

'.MuiMenuItem-root': {
maxWidth: '100%',
padding: '0.75rem',
borderBottom: `1px solid ${theme.custom.text.borderColor}`,
'&:last-child': {
borderBottom: 'none'
}
}
}
}}
onChange={(event) => onChange(event as SelectChangeEvent<string>)}
MenuProps={MenuPropsStyles}
onChange={onChange}
>
{menuItems
? menuItems.map(({ value, logo }) => (
Expand All @@ -81,7 +59,7 @@ const Select = ({
src={logo}
/>
)}
{<ItemNameStyled>{value}</ItemNameStyled>}
<ItemNameStyled>{value}</ItemNameStyled>
</MenuItemStyled>
))
: children}
Expand All @@ -94,6 +72,30 @@ Select.defaultProps = {
inputSize: 'medium'
}

const MenuPropsStyles = {
sx: {
marginTop: '.75rem',
'.MuiPaper-root': {
boxShadow: 'none'
},

'.MuiList-root': {
padding: 0,
border: `1px solid ${theme.custom.text.borderColor}`,
borderRadius: '0.5rem'
},

'.MuiMenuItem-root': {
maxWidth: '100%',
padding: '0.75rem',
borderBottom: `1px solid ${theme.custom.text.borderColor}`,
'&:last-child': {
borderBottom: 'none'
}
}
}
}

const SelectMuiStyled = styled(SelectMui)<
SelectMuiProps & { slotProps: { minifiedVersion: boolean; inputSize?: string } }
>`
Expand Down
18 changes: 13 additions & 5 deletions packages/ui/src/components/modals/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,19 @@ const Send = ({ onClose, className, onSuccess, onFinalized }: Props) => {
getSubscanExtrinsicLink
])

const onChangeEasySetupOption = useCallback((event: SelectChangeEvent<string>) => {
setErrorMessage('')
setEasyOptionErrorMessage('')
setSelectedEasyOption(event.target.value)
}, [])
const onChangeEasySetupOption = useCallback(
({ target: { value } }: SelectChangeEvent<unknown>) => {
if (typeof value !== 'string') {
console.error('Unexpected network value, expect string but received', value)
return
}

setErrorMessage('')
setEasyOptionErrorMessage('')
setSelectedEasyOption(value)
},
[]
)

if (!possibleOrigin) {
return null
Expand Down
16 changes: 9 additions & 7 deletions packages/ui/src/components/select/MultiProxySelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,18 @@ const BoxStyled = styled(Box)`
`

export default styled(MultiProxySelection)`
min-width: 200px;
@media (min-width: ${(props) => props.theme.breakpoints.values.md}px) {
min-width: 260px;
}
min-width: 12.5rem;
text-align: right;
width: 100%;
.MuiTextField-root {
max-width: 18.875rem;
@media (min-width: ${(props) => props.theme.breakpoints.values.md}px) {
min-width: 13.6875rem;
}
@media (min-width: ${(props) => props.theme.breakpoints.values.lg}px) {
min-width: 18.6875rem;
}
}
.MuiAutocomplete-endAdornment {
Expand Down
Loading

0 comments on commit eac29c0

Please sign in to comment.