Sidebar split (#3280)

* Seidebar split

* Update packages/react-components/src/SideBar.tsx

* Rename
This commit is contained in:
Jaco Greeff 2020-07-28 12:20:03 +02:00 committed by GitHub
parent 5d4bd81a00
commit 7129c26b42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 31 deletions

View File

@ -6,7 +6,7 @@ import React, { useCallback } from 'react';
import styled from 'styled-components';
import { useAccountInfo, useToggle } from '@polkadot/react-hooks';
import { colorLink } from '@polkadot/react-components/styles/theme';
import { AccountName, Button, Icon, IdentityIcon, Input, LinkExternal, Tags } from '@polkadot/react-components';
import { AccountName, Button, Icon, IdentityIcon, Input, LinkExternal, Sidebar, Tags } from '@polkadot/react-components';
import Transfer from '../Accounts/modals/Transfer';
import { useTranslation } from '../translate';
@ -22,7 +22,7 @@ interface Props {
onUpdateName: () => void;
}
function Sidebar ({ address, className = '', onClose, onUpdateName }: Props): React.ReactElement<Props> {
function FullSidebar ({ address, className = '', onClose, onUpdateName }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { accountIndex, flags, identity, isEditingName, isEditingTags, meta, name, onForgetAddress, onSaveName, onSaveTags, setName, setTags, tags, toggleIsEditingName, toggleIsEditingTags } = useAccountInfo(address);
const [isTransferOpen, toggleIsTransferOpen] = useToggle();
@ -44,14 +44,11 @@ function Sidebar ({ address, className = '', onClose, onUpdateName }: Props): Re
);
return (
<div className={className}>
<Button
className='ui--AddressMenu-close'
icon='times'
isBasic
isCircular
onClick={onClose}
/>
<Sidebar
className={className}
onClose={onClose}
position='right'
>
<div className='ui--AddressMenu-header'>
<IdentityIcon
size={80}
@ -159,32 +156,15 @@ function Sidebar ({ address, className = '', onClose, onUpdateName }: Props): Re
type='address'
/>
</section>
</div>
</Sidebar>
);
}
export default React.memo(styled(Sidebar)`
bottom: 0;
position: fixed;
top: 0;
right: 0;
bottom: 0;
max-width: 24rem;
background: #f5f4f3;
padding: 1rem;
box-shadow: -6px 0px 20px 0px rgba(0,0,0,0.2);
z-index: 999;
export default React.memo(styled(FullSidebar)`
input {
width: auto !important;
}
.ui--AddressMenu-close {
position: absolute;
right: 0.5rem;
top: 0.5rem;
}
.ui--AddressMenu-header {
align-items: center;
background: white;

View File

@ -54,7 +54,6 @@ function Selection (): React.ReactElement {
<TxButton
extrinsic={extrinsic}
icon='sign-in-alt'
isBasic
isDisabled={!extrinsic}
isUnsigned
label={t<string>('Submit Unsigned')}

View File

@ -84,7 +84,7 @@ function Unbond ({ className = '', controllerId, onClose, stakingLedger, stashId
<Modal.Actions onCancel={onClose}>
<TxButton
accountId={controllerId}
icon='sign-out'
icon='unlock'
isDisabled={!maxUnbond?.gtn(0)}
label={t<string>('Unbond')}
onStart={onClose}

View File

@ -0,0 +1,49 @@
// Copyright 2017-2020 @polkadot/app-accounts authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import React from 'react';
import styled from 'styled-components';
import Button from './Button';
interface Props {
children: React.ReactNode;
className?: string;
offset?: number;
onClose: () => void;
position: 'left' | 'right';
}
function Sidebar ({ children, className = '', onClose }: Props): React.ReactElement<Props> {
return (
<div className={`ui--Sidebar ${className}`}>
<Button
className='ui--Sidebar-close'
icon='times'
isBasic
isCircular
onClick={onClose}
/>
{children}
</div>
);
}
export default React.memo(styled(Sidebar)(({ offset = 0, position }: Props) => `
background: #f5f4f3;
bottom: 0;
box-shadow: ${position === 'right' ? '-6px' : '6px'} 0px 20px 0px rgba(0, 0, 0, 0.3);
max-width: 24rem;
position: fixed;
padding: 1rem;
top: 0;
z-index: 999;
${position}: ${offset};
.ui--Sidebar-close {
position: absolute;
right: 0.5rem;
top: 0.5rem;
}
`));

View File

@ -76,6 +76,7 @@ export { default as Popup } from './Popup';
export { default as Progress } from './Progress';
export { default as ProposedAction } from './ProposedAction';
export { default as Row } from './Row';
export { default as Sidebar } from './Sidebar';
export { default as Spinner } from './Spinner';
export { default as StakingBonded } from './StakingBonded';
export { default as StakingRedeemable } from './StakingRedeemable';