From 1a404b76cacd7384162a865bee298c680da0475f Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 24 Jun 2019 17:40:32 +0200 Subject: [PATCH] Additional styled componentn adjustments (#1337) --- packages/app-accounts/src/modals/Transfer.tsx | 61 ++++---- packages/app-contracts/src/ABI.tsx | 64 ++++----- .../app-staking/src/Actions/Account/index.tsx | 135 +++++++++--------- packages/app-sudo/src/SetKey.tsx | 24 ++-- packages/app-toolbox/src/Sign.tsx | 69 +++++---- 5 files changed, 172 insertions(+), 181 deletions(-) diff --git a/packages/app-accounts/src/modals/Transfer.tsx b/packages/app-accounts/src/modals/Transfer.tsx index 9b76e1bf51..5612d2fb24 100644 --- a/packages/app-accounts/src/modals/Transfer.tsx +++ b/packages/app-accounts/src/modals/Transfer.tsx @@ -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 { state: State; @@ -157,13 +131,13 @@ class Transfer extends React.PureComponent { } 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 = {t('available ')}; return ( - +
{ isSendable onChange={this.onChangeFees} /> - +
); } @@ -259,7 +233,32 @@ class Transfer extends React.PureComponent { } 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( diff --git a/packages/app-contracts/src/ABI.tsx b/packages/app-contracts/src/ABI.tsx index ce0b8bd5fa..270e97b1f8 100644 --- a/packages/app-contracts/src/ABI.tsx +++ b/packages/app-contracts/src/ABI.tsx @@ -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 { state: State = { contractAbi: null, @@ -48,7 +45,6 @@ class ABI extends React.PureComponent { super(props); const { contractAbi, isError, isRequired } = this.props; - const isAbiValid = !!contractAbi; this.state = { @@ -76,19 +72,26 @@ class ABI extends React.PureComponent { } render () { + const { className } = this.props; const { contractAbi, isAbiValid } = this.state; - return (contractAbi && isAbiValid) - ? this.renderMessages() - : this.renderInputFile(); + return ( +
+ { + (contractAbi && isAbiValid) + ? this.renderMessages() + : this.renderInputFile() + } +
+ ); } 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 ( - +
{ : t('click to select or drag and drop a JSON ABI file') } /> - +
); } @@ -109,30 +112,18 @@ class ABI extends React.PureComponent { const { help, isDisabled, label, onRemove } = this.props; const { contractAbi } = this.state; - const messages = ( - - ); - - if (label) { - return ( - - - {messages} - - - ); - } return ( - - {messages} - + + + ); } @@ -151,6 +142,7 @@ class ABI extends React.PureComponent { }, () => onChange(json, contractAbi)); } catch (error) { console.error(error); + this.setState({ isAbiValid: false, isEmpty: false, @@ -176,4 +168,6 @@ class ABI extends React.PureComponent { } } -export default translate(ABI); +export default translate(styled(ABI)` + min-height: 4rem; +`); diff --git a/packages/app-staking/src/Actions/Account/index.tsx b/packages/app-staking/src/Actions/Account/index.tsx index 2783634279..caa0b2ffca 100644 --- a/packages/app-staking/src/Actions/Account/index.tsx +++ b/packages/app-staking/src/Actions/Account/index.tsx @@ -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 { } 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 { {this.renderSetSessionAccount()} {this.renderUnbond()} {this.renderValidate()} - +
{this.renderControllerAccount()} {this.renderSessionAccount()} @@ -211,7 +151,7 @@ class Account extends React.PureComponent {
{this.renderNominee()}
-
+ ); } @@ -633,9 +573,70 @@ class Account extends React.PureComponent { } } -export default translate( +export default withMulti( + styled(Account as React.ComponentClass)` + 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( ['derive.staking.info', { paramName: 'accountId' }], ['derive.balances.all', { paramName: 'accountId' }] - )(Account) + ) ); diff --git a/packages/app-sudo/src/SetKey.tsx b/packages/app-sudo/src/SetKey.tsx index e1c778a669..b41247fb5f 100644 --- a/packages/app-sudo/src/SetKey.tsx +++ b/packages/app-sudo/src/SetKey.tsx @@ -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 { } render () { - const { isMine, sudoKey, t } = this.props; + const { className, isMine, sudoKey, t } = this.props; const { selected } = this.state; return (
- +
{isMine ? ( <> { )} - +
{this.willLose() && (
@@ -115,4 +106,11 @@ class SetKey extends React.PureComponent { } } -export default translate(SetKey); +export default translate(styled(SetKey)` + align-items: flex-end; + justify-content: center; + + .summary { + text-align: center; + } +`); diff --git a/packages/app-toolbox/src/Sign.tsx b/packages/app-toolbox/src/Sign.tsx index b3a2782c49..17d8b7e4f7 100644 --- a/packages/app-toolbox/src/Sign.tsx +++ b/packages/app-toolbox/src/Sign.tsx @@ -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 { state: State; @@ -75,19 +45,19 @@ class Sign extends React.PureComponent { } render () { - const { isLocked } = this.state; + const { className, isLocked } = this.state; return (
{this.renderAccount()} - +
{this.renderInput()} {this.renderSignature()} {this.renderUnlock()} - +
); } @@ -249,4 +219,33 @@ class Sign extends React.PureComponent { } } -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; + } + } +`);