Additional styled componentn adjustments (#1337)

This commit is contained in:
Jaco Greeff 2019-06-24 17:40:32 +02:00 committed by kwingram25
parent f21cfe0506
commit 1a404b76ca
5 changed files with 172 additions and 181 deletions

View File

@ -21,6 +21,7 @@ import translate from '../translate';
type Props = ApiProps & I18nProps & {
balances_fees?: DerivedFees,
className?: string,
onClose: () => void,
recipientId?: string,
senderId?: string,
@ -38,33 +39,6 @@ type State = {
const ZERO = new BN(0);
const Wrapper = styled.div`
article.padded {
box-shadow: none;
}
.balance {
margin-bottom: 0.5rem;
text-align: right;
padding-right: 1rem;
.label {
opacity: 0.7;
}
}
${media.DESKTOP`
article.padded {
margin: .75rem 0 0.75rem 15rem;
padding: 0.25rem 1rem;
}
`}
label.with-help {
flex-basis: 10rem;
}
`;
class Transfer extends React.PureComponent<Props> {
state: State;
@ -157,13 +131,13 @@ class Transfer extends React.PureComponent<Props> {
}
private renderContent () {
const { recipientId: propRecipientId, senderId: propSenderId, t } = this.props;
const { className, recipientId: propRecipientId, senderId: propSenderId, t } = this.props;
const { extrinsic, hasAvailable, maxBalance, recipientId, senderId } = this.state;
const available = <span className='label'>{t('available ')}</span>;
return (
<Modal.Content>
<Wrapper>
<div className={className}>
<InputAddress
defaultValue={propSenderId}
help={t('The account you will send funds from.')}
@ -196,7 +170,7 @@ class Transfer extends React.PureComponent<Props> {
isSendable
onChange={this.onChangeFees}
/>
</Wrapper>
</div>
</Modal.Content>
);
}
@ -259,7 +233,32 @@ class Transfer extends React.PureComponent<Props> {
}
export default withMulti(
Transfer,
styled(Transfer)`
article.padded {
box-shadow: none;
}
.balance {
margin-bottom: 0.5rem;
text-align: right;
padding-right: 1rem;
.label {
opacity: 0.7;
}
}
${media.DESKTOP`
article.padded {
margin: .75rem 0 0.75rem 15rem;
padding: 0.25rem 1rem;
}
`}
label.with-help {
flex-basis: 10rem;
}
`,
translate,
withApi,
withCalls<Props>(

View File

@ -13,6 +13,7 @@ import { u8aToString } from '@polkadot/util';
import translate from './translate';
type Props = I18nProps & {
className?: string,
contractAbi?: Abi | null,
help?: React.ReactNode,
isError?: boolean,
@ -32,10 +33,6 @@ type State = {
isError: boolean
};
const Normalize = styled.div`
min-height: 4rem;
`;
class ABI extends React.PureComponent<Props, State> {
state: State = {
contractAbi: null,
@ -48,7 +45,6 @@ class ABI extends React.PureComponent<Props, State> {
super(props);
const { contractAbi, isError, isRequired } = this.props;
const isAbiValid = !!contractAbi;
this.state = {
@ -76,19 +72,26 @@ class ABI extends React.PureComponent<Props, State> {
}
render () {
const { className } = this.props;
const { contractAbi, isAbiValid } = this.state;
return (contractAbi && isAbiValid)
? this.renderMessages()
: this.renderInputFile();
return (
<div className={className}>
{
(contractAbi && isAbiValid)
? this.renderMessages()
: this.renderInputFile()
}
</div>
);
}
private renderInputFile () {
const { help, isDisabled, isRequired, label, t } = this.props;
const { className, help, isDisabled, isRequired, label, t } = this.props;
const { isAbiValid, isEmpty, isError } = this.state;
return (
<Normalize>
<div className={className}>
<InputFile
help={help}
isDisabled={isDisabled}
@ -101,7 +104,7 @@ class ABI extends React.PureComponent<Props, State> {
: t('click to select or drag and drop a JSON ABI file')
}
/>
</Normalize>
</div>
);
}
@ -109,30 +112,18 @@ class ABI extends React.PureComponent<Props, State> {
const { help, isDisabled, label, onRemove } = this.props;
const { contractAbi } = this.state;
const messages = (
<Messages
contractAbi={contractAbi!}
onRemove={onRemove || this.onRemove}
isRemovable={!isDisabled}
/>
);
if (label) {
return (
<Normalize>
<Labelled
label={label}
help={help}
>
{messages}
</Labelled>
</Normalize>
);
}
return (
<Normalize>
{messages}
</Normalize>
<Labelled
label={label}
help={help}
withLabel={!!label}
>
<Messages
contractAbi={contractAbi!}
onRemove={onRemove || this.onRemove}
isRemovable={!isDisabled}
/>
</Labelled>
);
}
@ -151,6 +142,7 @@ class ABI extends React.PureComponent<Props, State> {
}, () => onChange(json, contractAbi));
} catch (error) {
console.error(error);
this.setState({
isAbiValid: false,
isEmpty: false,
@ -176,4 +168,6 @@ class ABI extends React.PureComponent<Props, State> {
}
}
export default translate(ABI);
export default translate(styled(ABI)`
min-height: 4rem;
`);

View File

@ -13,7 +13,7 @@ import { Popup } from 'semantic-ui-react';
import React from 'react';
import styled from 'styled-components';
import { AddressCard, AddressInfo, AddressMini, AddressRow, Button, Menu, RecentlyOffline, TxButton } from '@polkadot/ui-app';
import { withCalls } from '@polkadot/ui-api';
import { withCalls, withMulti } from '@polkadot/ui-api';
import BondExtra from './BondExtra';
import Nominate from './Nominate';
@ -26,6 +26,7 @@ import Validate from './Validate';
type Props = ApiProps & I18nProps & {
accountId: string,
className?: string,
recentlyOffline: RecentlyOfflineMap,
balances_all?: DerivedBalances,
staking_info?: DerivedStaking,
@ -54,67 +55,6 @@ type State = {
validatorPrefs?: ValidatorPrefs
};
const Wrapper = styled.div`
display: flex;
.staking--Accounts {
flex: 1;
display: flex;
flex-direction: column
}
.staking--Account-detail.actions{
display: inline-block;
vertical-align: top;
margin-top: .5rem;
margin-bottom: 1.5rem;
&:last-child {
margin: 0;
}
}
.staking--Infos {
flex: 1;
display: flex;
flex-direction: column;
.staking--balances {
div {
justify-content: flex-end;
}
.column {
flex:0;
}
}
.staking--Account-Nominee {
display: flex;
flex-direction: column;
justify-content: flex-end;
padding-top: 1em;
flex: 1;
}
}
.staking--Account-Nominee {
text-align: right;
.staking--label {
margin: 0 2.25rem -.75rem 0;
}
}
.ui--Row-buttons .ui--Button-Group {
margin-right: .25rem;
.ui.tiny.icon.button {
visibility: visible;
}
}
`;
function toIdString (id?: AccountId | null): string | null {
return id
? id.toString()
@ -165,7 +105,7 @@ class Account extends React.PureComponent<Props, State> {
}
render () {
const { t } = this.props;
const { className, t } = this.props;
const { isActiveStash, stashId } = this.state;
if (!isActiveStash || !stashId) {
@ -200,7 +140,7 @@ class Account extends React.PureComponent<Props, State> {
{this.renderSetSessionAccount()}
{this.renderUnbond()}
{this.renderValidate()}
<Wrapper>
<div className={className}>
<div className='staking--Accounts'>
{this.renderControllerAccount()}
{this.renderSessionAccount()}
@ -211,7 +151,7 @@ class Account extends React.PureComponent<Props, State> {
</div>
{this.renderNominee()}
</div>
</Wrapper>
</div>
</AddressCard>
);
}
@ -633,9 +573,70 @@ class Account extends React.PureComponent<Props, State> {
}
}
export default translate(
export default withMulti(
styled(Account as React.ComponentClass<Props>)`
display: flex;
.staking--Accounts {
flex: 1;
display: flex;
flex-direction: column
}
.staking--Account-detail.actions{
display: inline-block;
vertical-align: top;
margin-top: .5rem;
margin-bottom: 1.5rem;
&:last-child {
margin: 0;
}
}
.staking--Infos {
flex: 1;
display: flex;
flex-direction: column;
.staking--balances {
div {
justify-content: flex-end;
}
.column {
flex:0;
}
}
.staking--Account-Nominee {
display: flex;
flex-direction: column;
justify-content: flex-end;
padding-top: 1em;
flex: 1;
}
}
.staking--Account-Nominee {
text-align: right;
.staking--label {
margin: 0 2.25rem -.75rem 0;
}
}
.ui--Row-buttons .ui--Button-Group {
margin-right: .25rem;
.ui.tiny.icon.button {
visibility: visible;
}
}
`,
translate,
withCalls<Props>(
['derive.staking.info', { paramName: 'accountId' }],
['derive.balances.all', { paramName: 'accountId' }]
)(Account)
)
);

View File

@ -17,15 +17,6 @@ type State = {
selected?: string
};
const Wrapper = styled.section`
align-items: flex-end;
justify-content: center;
.summary {
text-align: center;
}
`;
const SudoInputAddress = styled(InputAddress)`
margin: -0.25rem 0.5rem -0.25rem 0;
`;
@ -52,12 +43,12 @@ class SetKey extends React.PureComponent<Props, State> {
}
render () {
const { isMine, sudoKey, t } = this.props;
const { className, isMine, sudoKey, t } = this.props;
const { selected } = this.state;
return (
<section>
<Wrapper className='ui--row'>
<section className={`${className} ui--row`}>
{isMine ? (
<>
<SudoInputAddress
@ -85,7 +76,7 @@ class SetKey extends React.PureComponent<Props, State> {
<AddressMini value={sudoKey} />
</SudoLabelled>
)}
</Wrapper>
</section>
{this.willLose() && (
<article className='warning padded'>
<div>
@ -115,4 +106,11 @@ class SetKey extends React.PureComponent<Props, State> {
}
}
export default translate(SetKey);
export default translate(styled(SetKey)`
align-items: flex-end;
justify-content: center;
.summary {
text-align: center;
}
`);

View File

@ -14,6 +14,7 @@ import translate from './translate';
import Unlock from './Unlock';
type State = {
className?: string,
currentPair: KeyringPair | null,
data: string,
isHexData: boolean,
@ -22,37 +23,6 @@ type State = {
signature: string
};
const Wrapper = styled.div`
position: relative;
width: 100%;
height: 100%;
.unlock-overlay {
position: absolute;
width: 100%;
height: 100%;
top:0;
left:0;
background-color: #0f0e0e7a;
}
.unlock-overlay-warning {
display: flex;
align-items: center;
justify-content: center;
height:100%;
}
.unlock-overlay-content {
color:#fff;
text-align:center;
.ui--Button-Group {
text-align: center;
}
}
`;
class Sign extends React.PureComponent<Props, State> {
state: State;
@ -75,19 +45,19 @@ class Sign extends React.PureComponent<Props, State> {
}
render () {
const { isLocked } = this.state;
const { className, isLocked } = this.state;
return (
<div className='toolbox--Sign'>
{this.renderAccount()}
<Wrapper>
<div className={className}>
{this.renderInput()}
{this.renderSignature()}
<div className='unlock-overlay' hidden={!isLocked}>
{this.renderUnlockWarning()}
</div>
{this.renderUnlock()}
</Wrapper>
</div>
</div>
);
}
@ -249,4 +219,33 @@ class Sign extends React.PureComponent<Props, State> {
}
}
export default translate(Sign);
export default translate(styled(Sign)`
position: relative;
width: 100%;
height: 100%;
.unlock-overlay {
position: absolute;
width: 100%;
height: 100%;
top:0;
left:0;
background-color: #0f0e0e7a;
}
.unlock-overlay-warning {
display: flex;
align-items: center;
justify-content: center;
height:100%;
}
.unlock-overlay-content {
color:#fff;
text-align:center;
.ui--Button-Group {
text-align: center;
}
}
`);