Skip to content
This repository has been archived by the owner on Oct 8, 2020. It is now read-only.

styling fixes & countdown voting clock #153

Merged
merged 28 commits into from May 13, 2018
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b84a7d5
no message
lazarovicedo May 4, 2018
680e774
no message
lazarovicedo May 4, 2018
3b847b1
Merge branch 'master' of https://github.com/lazarovicedo/wallet-web
lazarovicedo May 4, 2018
00b5ef9
keep footer on the bottom, added loading bar (vertical centered) on t…
lazarovicedo May 5, 2018
c368b55
Merge branch 'master' into master
lazarovicedo May 5, 2018
482ba32
no login captcha file
lazarovicedo May 5, 2018
f793086
On account view, removed view password button for trustness.
lazarovicedo May 5, 2018
6751b83
formatted number of votes for easy reading. Load bar for list of repr…
lazarovicedo May 5, 2018
99e7b56
help info updated on voting page and count clock added (every 6h UTC)
lazarovicedo May 6, 2018
907cde8
fixes and cleanup on votes countdown clock
lazarovicedo May 7, 2018
18c393a
Merge branch 'master' into master
lazarovicedo May 7, 2018
39a3005
Merge branch 'master' into master
lazarovicedo May 7, 2018
92cb6e3
function not needed anymore
lazarovicedo May 7, 2018
319b4e9
Merge branch 'master' of https://github.com/lazarovicedo/wallet-web
lazarovicedo May 7, 2018
9fa1f0c
no message
lazarovicedo May 7, 2018
c059bf0
no message
lazarovicedo May 7, 2018
c484723
removes grey bar on the bottom of the login page.
lazarovicedo May 8, 2018
9779145
Merge branch 'master' into master
lazarovicedo May 9, 2018
01042f2
fixes lost logged-in session when reloading the page
lazarovicedo May 9, 2018
56312d7
no tokens found message instead of an empty table with headers
lazarovicedo May 9, 2018
7047142
Update app.js
lazarovicedo May 11, 2018
b1b52ef
Update app.js
lazarovicedo May 11, 2018
9e76159
Merge branch 'master' into master
lazarovicedo May 11, 2018
4c53489
Update app.js
lazarovicedo May 11, 2018
6f963cf
removed componentDidMount duplicated in login,
lazarovicedo May 12, 2018
d7caab2
no message
lazarovicedo May 12, 2018
6a22a64
added testnet warning on receive , added testnet text n footer, added…
lazarovicedo May 12, 2018
53e282b
added FormattedMessage function for better paragraph formatting.
lazarovicedo May 13, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -51,6 +51,7 @@
"react": "^16.2.0",
"react-async-component": "^2.0.0",
"react-copy-to-clipboard": "^5.0.1",
"react-countdown-now": "^1.3.0",
"react-dev-utils": "^5.0.0",
"react-dom": "^16.2.0",
"react-intl": "^2.4.0",
Expand Down
10 changes: 7 additions & 3 deletions src/components/Footer.js
@@ -1,17 +1,21 @@
import React, {Component} from "react";
import packageJson from '../../package.json';

export default class Footer extends Component {


render() {
return (
<footer className="container text-center pt-3">
<a className="mr-1 text-muted" href="https://github.com/tronprotocol/wallet-web" target="_blank" rel="noopener noreferrer">
return (
<footer className="footer text-center mt-3 mb-2">
<a className="mr-1 text-muted" href={packageJson.bugs.url} target="_blank" rel="noopener noreferrer">
<i className="fab fa-github social mr-2"/>
</a>
<a className="mr-1 text-muted" href="https://twitter.com/tronfoundation" target="_blank" rel="noopener noreferrer">
<i className="fab fa-twitter social ml-2"/>
</a>
<div>
<small>Tron Wallet v.{packageJson.version}</small>
</div>
</footer>
)
}
Expand Down
62 changes: 38 additions & 24 deletions src/components/account/Account.js
Expand Up @@ -80,32 +80,46 @@ class Account extends Component {
);
}

return (
<table className="table border-0 m-0">
<thead>
<tr>
<th>{tu("name")}</th>
<th className="text-right">{tu("balance")}</th>
</tr>
</thead>
<tbody>
{
tokenBalances.map((token, index) => (

(index > 0) && //Hide TRON TRX on this view
<tr key={index}>
<td>{token.name}</td>
<td className="text-right">
<FormattedNumber value={token.balance}/>
</td>
if (tokenBalances.length < 2) {

return (
<h3 className="text-center text-secondary p-3" colspan="2">{tu("no_tokens_found")}</h3>
);

}else{

return (

<table className="table border-0 m-0">
<thead>
<tr>
<th>{tu("name")}</th>
<th className="text-right">{tu("balance")}</th>
</tr>

))
}
</tbody>
</table>
)
}
</thead>
<tbody>
{
tokenBalances.map((token, index) => (

(index > 0) && //Hide TRON TRX on this view
<tr key={index}>
<td>{token.name}</td>
<td className="text-right">
<FormattedNumber value={token.balance}/>
</td>
</tr>

))
}
</tbody>
</table>

);
}
}



requestTrx = async () => {
let {account} = this.props;
Expand Down
14 changes: 13 additions & 1 deletion src/components/account/Login.js
Expand Up @@ -33,6 +33,16 @@ class Login extends Component {
componentDidMount() {
this.generateAccount();
}


componentDidMount() {
document.body.classList.add('bg-dark');
}

componentWillUnmount() {
document.body.classList.remove('bg-dark');
}


generateAccount = () => {

Expand Down Expand Up @@ -210,7 +220,7 @@ class Login extends Component {
}

return (
<main className="container-fluid pt-5 pb-5 bg-dark">
<main className="container-fluid pt-5">
{this.renderTestNetWarning()}
<div className="container">
<div className="row justify-content-center">
Expand Down Expand Up @@ -254,6 +264,8 @@ function mapStateToProps(state) {
};
}



const mapDispatchToProps = {
loginWithPassword,
};
Expand Down
88 changes: 82 additions & 6 deletions src/components/account/Votes.js
Expand Up @@ -10,9 +10,13 @@ import {Sticky, StickyContainer} from "react-sticky";
import MediaQuery from "react-responsive";
import {Alert} from "reactstrap";
import {Redirect} from "react-router-dom";
import {BarLoader} from "../common/loaders";
import {FormattedNumber} from "react-intl";
import Countdown from 'react-countdown-now';
import {ONE_TRX} from "../../constants";



class Votes extends Component {

constructor() {
Expand Down Expand Up @@ -78,7 +82,6 @@ class Votes extends Component {
})
};


filteredWitnesses() {
let {witnesses} = this.props;
let {searchString} = this.state;
Expand Down Expand Up @@ -127,13 +130,50 @@ class Votes extends Component {
votePercentage: (votesSpend / trxBalance) * 100,
};
}

returnVate(){
this.setState({
votesSubmitted: false,
votes: {},
});

}



diffSeconds(){
// Calculation of difference of time (in seconds) between now time in UTC
// and next voting time in UTC

var now = new Date();
var utcHour = now.getUTCHours();
var fromTime = new Date(2000, 1, 1, utcHour, now.getMinutes(), now.getSeconds());

var nextHour = 24;

if (utcHour >= 0 && utcHour < 6) {
var nextHour = 6;
}
if (utcHour >= 6 && utcHour < 12) {
var nextHour = 12;
}
if (utcHour >= 12 && utcHour < 18) {
var nextHour = 18;
}
if (utcHour >= 18 && utcHour < 24) {
var nextHour = 24;
}
var toTime = new Date(2000, 1, 1, nextHour, 0, 0);

var dif = fromTime.getTime() - toTime.getTime();
var secondsDiff = Math.abs(dif);

return secondsDiff;

}




render() {

Expand All @@ -148,7 +188,16 @@ class Votes extends Component {

let witnesses = this.filteredWitnesses();
let voteStatus = this.getVoteStatus();



if (witnesses === null || witnesses.length === 0) {
return (
<div className="loader-center">
<BarLoader />
</div>
);
}

if (votesSubmitted) {
return (
<main className="container pt-5 pb-5">
Expand All @@ -168,6 +217,24 @@ class Votes extends Component {
);
}



const CountingVotes = () => <span className="blink_txt">{tu("counting_votes")}...</span>;

const RendererClock = ({ hours, minutes, seconds, completed }) => {
if (completed) {
return <CountingVotes/>;
}else{
return (
<div>
<small>{tu("countdown_txt")}</small>
<div style={{fontWeight: 'bold'}}>{hours}:{minutes}:{seconds}</div>
</div>
);
}
};


const VoteCard = ({className = ""}) => (
<div className={"card " + className}>
<div className="card-header text-center bg-dark text-white">
Expand All @@ -177,7 +244,7 @@ class Votes extends Component {
{
voteStatus.voteState === 1 &&
<p className="text-center">
{voteStatus.votesAvailable} TRX {tu("remaining")}
<FormattedNumber value={voteStatus.votesAvailable} /> {tu("votes_remaining")}
</p>
}
{
Expand Down Expand Up @@ -211,8 +278,15 @@ class Votes extends Component {
{tu("too_many_votes")}
</button>
}
<p className="mt-3">
<hr/>
<div className="text-center m-3 text-info" style={{fontFamily: 'sans-serif'}}>
<Countdown date={Date.now() + this.diffSeconds()} renderer={RendererClock}>
</Countdown>
</div>
<hr/>
<p className="mt-3 small">
{tu("vote_guide_message")}
{tu("vote_info_link")}&nbsp;<a href='https://medium.com/@Tronfoundation/tron-community-guidelines-ca10c2fcd444'>{tu("sr_guide")} <i className="fas fa-external-link-alt"></i></a>
</p>
</div>
</div>
Expand All @@ -238,7 +312,7 @@ class Votes extends Component {
</div>
<div className="card">
<div className="card-header text-center bg-dark text-white">
{tu("candidates")}
Super Representatives {tu("candidates")}
</div>
<div className="card-body p-0">
<table className="table table-striped bg-white">
Expand All @@ -259,7 +333,9 @@ class Votes extends Component {
{account.address.substr(0, 24)}...<br/>
<small>{account.url}</small>
</td>
<td>{account.votes} TRX</td>
<td className="text-right" style={{fontFamily: 'sans-serif'}}>
<FormattedNumber value={account.votes} />
</td>
<td>
<input onChange={(ev) => this.setVote(account.address, ev.target.value)}
value={votes[account.address]}
Expand Down
6 changes: 3 additions & 3 deletions src/components/network/Representatives.js
Expand Up @@ -19,7 +19,7 @@ class Representatives extends Component {

if (witnesses.length === 0) {
return (
<div className="text-center d-flex justify-content-center p-4">
<div className="loader-center">
<BarLoader />
</div>
);
Expand All @@ -45,11 +45,11 @@ class Representatives extends Component {
<tr key={account.address}>
<td className="text-right">{index + 1}</td>
<td>
<ExternalUrl url={account.url}><span className="text-truncate text-nowrap d-inline-block" style={{maxWidth: 300}}></span></ExternalUrl></td>
<ExternalUrl url={(account.url.length > 50) ? account.url.substr(0, 50)+" ..." : account.url}><span className="text-truncate text-nowrap d-inline-block" style={{maxWidth: 300}}></span></ExternalUrl></td>
<td className="text-right"><FormattedNumber value={account.latestBlockNumber} /></td>
<td className="text-right"><FormattedNumber value={account.producedTotal} /></td>
<td className="text-right"><FormattedNumber value={account.missedTotal} /></td>
<td className="text-right"><FormattedNumber value={account.votes} /> TRX</td>
<td className="text-right"><FormattedNumber value={account.votes} /></td>
</tr>
))
}
Expand Down
21 changes: 15 additions & 6 deletions src/components/tokens/TokensView.js
Expand Up @@ -8,6 +8,7 @@ import {TextField} from "../../utils/formHelper";
import {Client} from "../../services/api";
import MediaQuery from "react-responsive";
import {ONE_TRX} from "../../constants";
import {BarLoader} from "../common/loaders";

const desStyle = {
whiteSpace: "normal",
Expand Down Expand Up @@ -128,9 +129,17 @@ class TokensView extends Component {
renderTable() {
let {tokens, account, searchString} = this.props;
let {amount, confirmedParticipate, loading, participateSuccess} = this.state;

tokens = filter(tokens, t => t.name.toUpperCase().indexOf(searchString) !== -1);
tokens = sortBy(tokens, t => t.name);

if (tokens === null || tokens.length === 0) {
return (
<div className="loader-center">
<BarLoader />
</div>
);
}

return (
<table className="table table-striped">
Expand Down Expand Up @@ -159,12 +168,12 @@ class TokensView extends Component {
<td className="text-right">
<FormattedNumber value={token.totalSupply} />
</td>
<td>
<FormattedDate value={token.startTime}/>&nbsp;
<FormattedTime value={token.startTime}/>&nbsp;
<td className="small text-right">
<FormattedDate value={token.startTime} year='numeric' month='2-digit' day='2-digit'/>&nbsp;
<FormattedTime value={token.startTime} hour='2-digit' minute='2-digit' second='2-digit'/>
<br/>
<FormattedDate value={token.endTime}/>&nbsp;
<FormattedTime value={token.endTime}/>
<FormattedDate value={token.endTime} year='numeric' month='2-digit' day='2-digit'/>&nbsp;
<FormattedTime value={token.endTime} hour='2-digit' minute='2-digit' second='2-digit'/>
</td>
{
account.isLoggedIn && <td className="text-right">
Expand Down
2 changes: 1 addition & 1 deletion src/components/transfer/Send.js
Expand Up @@ -209,7 +209,7 @@ class Send extends React.Component {
value={token}>
{
tokenBalances.map(tokenBalance => (
<SendOption key={tokenBalance.name} name={tokenBalance.name} balance={tokenBalance.balance}/>
<SendOption key={tokenBalance.name} name={(tokenBalance.name.length > 25) ? tokenBalance.name.substr(0, 25)+" ..." : tokenBalance.name} balance={tokenBalance.balance}/>
))
}
</select>
Expand Down
10 changes: 5 additions & 5 deletions src/reducers/app.js
Expand Up @@ -20,11 +20,11 @@ const initialState = {
fr: "Français",
es: "Español" ,
},
activeLanguage: 'en',
account: {
key: undefined,
address: undefined,
isLoggedIn: false,
activeLanguage: (Lockr.get("language") !== undefined ? Lockr.get("language") : 'en'),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locker.get has a second parameter for a default value, this can be simplified to Lockr.get("language", "en")

account: {
key: (Lockr.get("account_key") !== undefined ? Lockr.get("account_key") : undefined),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be simplified to Lockr.get("account_key")

address: (Lockr.get("account_key") !== undefined ? privateKeyToAddress(Lockr.get("account_key")) : undefined),
isLoggedIn: (Lockr.get("account_key") !== undefined ? true : false)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be simplified to Lockr.get("account_key") !== undefined

},
searchString: '',
};
Expand Down