Adjust account menu position (#367)

This commit is contained in:
Jaco Greeff 2020-06-07 12:47:53 +02:00 committed by GitHub
parent 01822ef44a
commit a7132a95aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 17 deletions

View File

@ -95,19 +95,23 @@ function Account ({ address, className, genesisHash, isExternal, isHidden, paren
Forget Account
</Link>
<MenuDivider />
<Checkbox
checked={!isHidden}
className='menuItem'
label='Visible (always inject)'
onClick={_toggleVisibility}
/>
<Dropdown
className='menuItem'
label=''
onChange={_onChangeGenesis}
options={genesisOptions}
value={genesisHash || ''}
/>
<div className='menuItem'>
<Checkbox
checked={!isHidden}
className='inputItem'
label='Visible (always inject)'
onClick={_toggleVisibility}
/>
</div>
<div className='menuItem'>
<Dropdown
className='inputItem'
label=''
onChange={_onChangeGenesis}
options={genesisOptions}
value={genesisHash || ''}
/>
</div>
</>
), [_onChangeGenesis, _toggleEdit, _toggleVisibility, address, genesisHash, isExternal, isHidden]);
@ -160,5 +164,9 @@ export default styled(Account)`
margin: 0;
min-width: 13rem;
padding: 4px 16px;
.inputItem {
margin: 0;
}
}
`;

View File

@ -250,7 +250,8 @@ const ArrowLabel = styled(Svg).attrs(() => ({ src: parentArrow }))`
`;
const MovableMenu = styled(Menu)<{ isMoved: boolean }>`
${({ isMoved }): string => isMoved ? 'bottom: 50px' : ''};
${({ isMoved }): string => isMoved ? 'bottom: 0;' : ''}
right: 28px;
`;
export default styled(Address)(({ theme }: ThemeProps) => `

View File

@ -26,6 +26,7 @@ function MenuItem ({ children, className = '', title }: Props): React.ReactEleme
}
export default styled(MenuItem)`
min-width: 13rem;
padding: 0 16px;
max-width: 100%;

View File

@ -2,14 +2,14 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { useEffect, RefObject } from 'react';
import { useCallback, useEffect, RefObject } from 'react';
export default function useOutsideClick (ref: RefObject<HTMLDivElement>, callback: () => void): void {
const handleClick = (e: MouseEvent): void => {
const handleClick = useCallback((e: MouseEvent): void => {
if (ref.current && !ref.current.contains(e.target as HTMLInputElement)) {
callback();
}
};
}, [callback, ref]);
useEffect(() => {
document.addEventListener('click', handleClick);