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 Forget Account
</Link> </Link>
<MenuDivider /> <MenuDivider />
<Checkbox <div className='menuItem'>
checked={!isHidden} <Checkbox
className='menuItem' checked={!isHidden}
label='Visible (always inject)' className='inputItem'
onClick={_toggleVisibility} label='Visible (always inject)'
/> onClick={_toggleVisibility}
<Dropdown />
className='menuItem' </div>
label='' <div className='menuItem'>
onChange={_onChangeGenesis} <Dropdown
options={genesisOptions} className='inputItem'
value={genesisHash || ''} label=''
/> onChange={_onChangeGenesis}
options={genesisOptions}
value={genesisHash || ''}
/>
</div>
</> </>
), [_onChangeGenesis, _toggleEdit, _toggleVisibility, address, genesisHash, isExternal, isHidden]); ), [_onChangeGenesis, _toggleEdit, _toggleVisibility, address, genesisHash, isExternal, isHidden]);
@ -160,5 +164,9 @@ export default styled(Account)`
margin: 0; margin: 0;
min-width: 13rem; min-width: 13rem;
padding: 4px 16px; 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 }>` const MovableMenu = styled(Menu)<{ isMoved: boolean }>`
${({ isMoved }): string => isMoved ? 'bottom: 50px' : ''}; ${({ isMoved }): string => isMoved ? 'bottom: 0;' : ''}
right: 28px;
`; `;
export default styled(Address)(({ theme }: ThemeProps) => ` export default styled(Address)(({ theme }: ThemeProps) => `

View File

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

View File

@ -2,14 +2,14 @@
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details. // 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 { 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)) { if (ref.current && !ref.current.contains(e.target as HTMLInputElement)) {
callback(); callback();
} }
}; }, [callback, ref]);
useEffect(() => { useEffect(() => {
document.addEventListener('click', handleClick); document.addEventListener('click', handleClick);