Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/app-accounts/src/Vanity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class VanityApp extends TxComponent<Props, State> {
return;
}

setTimeout((): void => {
setImmediate((): void => {
if (this._isActive) {
if (this.results.length === 25) {
this.checkMatches();
Expand All @@ -257,7 +257,7 @@ class VanityApp extends TxComponent<Props, State> {

this.executeGeneration();
}
}, 0);
});
}

private onCreateToggle = (createSeed: string): void => {
Expand Down
88 changes: 48 additions & 40 deletions packages/app-council/src/Overview/Vote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import React from 'react';
import styled from 'styled-components';
import { createType } from '@polkadot/types';
import { withCalls, withMulti } from '@polkadot/react-api';
import { AddressRow, Button, Toggle } from '@polkadot/react-components';
import { AddressMini, Button, Toggle } from '@polkadot/react-components';
import TxModal, { TxModalState, TxModalProps } from '@polkadot/react-components/TxModal';

import translate from '../translate';
import VoteValue from './VoteValue';

type VoteType = 'member' | 'runnerup' | 'candidate';

interface Props extends ApiProps, ComponentProps, TxModalProps {
voterPositions?: DerivedVoterPositions;
}
Expand Down Expand Up @@ -46,37 +48,47 @@ interface State extends TxModalState {
const Candidates = styled.div`
display: flex;
flex-wrap: wrap;
`;
justify-content: center;

.candidate {
border: 1px solid #eee;
border-radius: 0.25rem;
margin: 0.25rem;
padding-bottom: 0.25rem;
padding-right: 0.5rem;
position: relative;

&::after {
content: '';
position: absolute;
top: 0;
right: 0;
border-color: transparent;
border-style: solid;
border-radius: 0.25em;
border-width: 0.25em;
}

const Candidate = styled.div`
cursor: pointer;
width: 25rem;
min-width: calc(50% - 1rem);
border-radius: 0.5rem;
border: 1px solid #eee;
padding: 0.75rem 0.5rem 0.25rem;
margin: 0.25rem;
transition: all 0.2s;

b {
min-width: 5rem;
}
&.isAye {
background: #fff;
border-color: #ccc;
}

&.aye {
background-color: rgba(0, 255, 0, 0.05);
&.member::after {
border-color: green;
}

b {
color: green;
&.runnerup::after {
border-color: steelblue;
}
}

&.nay {
background-color: rgba(0, 0, 0, 0.05);
}
.ui--AddressMini-icon {
z-index: 1;
}

.ui--Row-children {
text-align: right;
width: 100%;
.candidate-right {
text-align: right;
}
}
`;

Expand Down Expand Up @@ -164,11 +176,11 @@ class Vote extends TxModal<Props, State> {
protected renderContent = (): React.ReactNode => {
const { api, electionsInfo: { candidates, members, runnersUp }, t } = this.props;
const { accountId, votes } = this.state;
const _candidates = candidates.map((accountId): [AccountId, boolean] => [accountId, false]);
const _candidates = candidates.map((accountId): [AccountId, VoteType] => [accountId, 'candidate']);
const available = api.tx.electionsPhragmen
? members
.map(([accountId]): [AccountId, boolean] => [accountId, true])
.concat(runnersUp.map(([accountId]): [AccountId, boolean] => [accountId, false]))
.map(([accountId]): [AccountId, VoteType] => [accountId, 'member'])
.concat(runnersUp.map(([accountId]): [AccountId, VoteType] => [accountId, 'runnerup']))
.concat(_candidates)
: _candidates;

Expand Down Expand Up @@ -200,21 +212,17 @@ class Vote extends TxModal<Props, State> {
</AlreadyVoted>
)} */}
<Candidates>
{available.map(([accountId, isMember]): React.ReactNode => {
{available.map(([accountId, type]): React.ReactNode => {
const key = accountId.toString();
const isAye = votes[key] || false;

return (
<Candidate
className={isAye ? 'aye' : 'nay'}
<AddressMini
className={`candidate ${isAye ? 'isAye' : 'isNay'} ${type}`}
key={key}
value={key}
>
<AddressRow
defaultName={isMember ? t('member') : t('candidate')}
isInline
value={accountId}
withIndexOrAddress
>
<div className='candidate-right'>
<Toggle
label={
isAye
Expand All @@ -224,8 +232,8 @@ class Vote extends TxModal<Props, State> {
onChange={this.onChangeVote(key)}
value={isAye}
/>
</AddressRow>
</Candidate>
</div>
</AddressMini>
);
})}
</Candidates>
Expand Down
4 changes: 2 additions & 2 deletions packages/react-api/src/with/call.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ export default function withCall<P extends ApiProps> (endpoint: string, {

// The attachment takes time when a lot is available, set a timeout
// to first handle the current queue before subscribing
setTimeout((): void => {
setImmediate((): void => {
this
.subscribe(this.getParams(this.props))
.then(NOOP)
.catch(NOOP);
}, 0);
});
}

public componentWillUnmount (): void {
Expand Down