2017-12-11 17:44:53 +00:00
|
|
|
import { NormalizedBityRate } from 'reducers/swap/types';
|
2017-09-25 02:06:28 +00:00
|
|
|
import bityLogoWhite from 'assets/images/logo-bity-white.svg';
|
|
|
|
import Spinner from 'components/ui/Spinner';
|
|
|
|
import { bityReferralURL } from 'config/data';
|
2017-06-19 05:39:07 +00:00
|
|
|
import React, { Component } from 'react';
|
2017-06-12 01:02:39 +00:00
|
|
|
import translate from 'translations';
|
2017-06-24 18:17:09 +00:00
|
|
|
import { toFixedIfLarger } from 'utils/formatters';
|
2017-09-25 02:06:28 +00:00
|
|
|
import './CurrentRates.scss';
|
2017-06-12 01:02:39 +00:00
|
|
|
|
2017-12-11 17:44:53 +00:00
|
|
|
interface Props {
|
|
|
|
[id: string]: NormalizedBityRate;
|
|
|
|
}
|
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
interface State {
|
|
|
|
ETHBTCAmount: number;
|
|
|
|
ETHREPAmount: number;
|
|
|
|
BTCETHAmount: number;
|
|
|
|
BTCREPAmount: number;
|
|
|
|
}
|
2017-12-11 17:44:53 +00:00
|
|
|
|
|
|
|
export default class CurrentRates extends Component<Props, State> {
|
2017-09-25 02:06:28 +00:00
|
|
|
public state = {
|
2017-07-22 21:24:03 +00:00
|
|
|
ETHBTCAmount: 1,
|
|
|
|
ETHREPAmount: 1,
|
|
|
|
BTCETHAmount: 1,
|
|
|
|
BTCREPAmount: 1
|
2017-06-19 05:39:07 +00:00
|
|
|
};
|
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
public onChange = (event: any) => {
|
|
|
|
const { value } = event.target;
|
|
|
|
const { name } = event.target;
|
2017-06-19 05:39:07 +00:00
|
|
|
this.setState({
|
|
|
|
[name]: value
|
|
|
|
});
|
|
|
|
};
|
2017-06-12 01:02:39 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
public buildPairRate = (origin: string, destination: string) => {
|
2017-08-31 15:56:49 +00:00
|
|
|
const pair = origin + destination;
|
2017-12-19 22:46:34 +00:00
|
|
|
const statePair = this.state[(pair + 'Amount') as keyof State];
|
2017-12-11 17:44:53 +00:00
|
|
|
const propsPair = this.props[pair] ? this.props[pair].rate : null;
|
v3 Style Import (#151)
* Convert bootstrap to sass instead of checked in and less
* Darken body, adjust header.
* First pass at tab styles, each tab will need a lot of individual love tho.
* Update footer to main site content, improve responsiveness.
* Missing key added.
* Fix dropdowns.
* Convert GenerateWallet HTML over, still needs styling.
* Send form.
* Current rates styled.
* CurrencySwap form styles.
* SwapInfoHeader styled.
* Finish up swap restyling, minor usability improvements for mobile.
* Fix up notifications / alert customizations
* Import v3 variables.
* Fix notification spacing.
* Align input height base with buttons.
* Revert height base, add additional bootstrap overrides.
* Grid overrides.
* Move overrides to their own folder. Adjust naming.
* Fix inconsistencies.
* Style generate wallet pt 1.
* Style generate wallet pt 2
* Style generate wallet pt 3
* Fix swap
* Added some missing overries, fixed the fallout.
* Remove header text, indicate alpha version.
* Fix radio / checkbox weights.
* Bind => arrow
* Convert simpledropdown to proper form select, instead of weirdly implemented nonfuncitoning dropdown.
* Fix token balances buttons, footr icons.
2017-09-05 19:52:01 +00:00
|
|
|
return (
|
|
|
|
<div className="SwapRates-panel-rate">
|
2017-09-25 03:29:49 +00:00
|
|
|
{propsPair ? (
|
|
|
|
<div>
|
|
|
|
<input
|
|
|
|
className="SwapRates-panel-rate-input"
|
|
|
|
onChange={this.onChange}
|
|
|
|
value={statePair}
|
|
|
|
name={pair + 'Amount'}
|
|
|
|
/>
|
|
|
|
<span className="SwapRates-panel-rate-amount">
|
2017-12-11 17:44:53 +00:00
|
|
|
{` ${origin} = ${toFixedIfLarger(statePair * propsPair, 6)} ${destination}`}
|
2017-09-25 03:29:49 +00:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
) : (
|
2017-11-15 03:44:55 +00:00
|
|
|
<Spinner size="x1" light={true} />
|
2017-09-25 03:29:49 +00:00
|
|
|
)}
|
v3 Style Import (#151)
* Convert bootstrap to sass instead of checked in and less
* Darken body, adjust header.
* First pass at tab styles, each tab will need a lot of individual love tho.
* Update footer to main site content, improve responsiveness.
* Missing key added.
* Fix dropdowns.
* Convert GenerateWallet HTML over, still needs styling.
* Send form.
* Current rates styled.
* CurrencySwap form styles.
* SwapInfoHeader styled.
* Finish up swap restyling, minor usability improvements for mobile.
* Fix up notifications / alert customizations
* Import v3 variables.
* Fix notification spacing.
* Align input height base with buttons.
* Revert height base, add additional bootstrap overrides.
* Grid overrides.
* Move overrides to their own folder. Adjust naming.
* Fix inconsistencies.
* Style generate wallet pt 1.
* Style generate wallet pt 2
* Style generate wallet pt 3
* Fix swap
* Added some missing overries, fixed the fallout.
* Remove header text, indicate alpha version.
* Fix radio / checkbox weights.
* Bind => arrow
* Convert simpledropdown to proper form select, instead of weirdly implemented nonfuncitoning dropdown.
* Fix token balances buttons, footr icons.
2017-09-05 19:52:01 +00:00
|
|
|
</div>
|
|
|
|
);
|
2017-08-31 15:56:49 +00:00
|
|
|
};
|
2017-07-22 21:24:03 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
public render() {
|
2017-06-19 05:39:07 +00:00
|
|
|
return (
|
v3 Style Import (#151)
* Convert bootstrap to sass instead of checked in and less
* Darken body, adjust header.
* First pass at tab styles, each tab will need a lot of individual love tho.
* Update footer to main site content, improve responsiveness.
* Missing key added.
* Fix dropdowns.
* Convert GenerateWallet HTML over, still needs styling.
* Send form.
* Current rates styled.
* CurrencySwap form styles.
* SwapInfoHeader styled.
* Finish up swap restyling, minor usability improvements for mobile.
* Fix up notifications / alert customizations
* Import v3 variables.
* Fix notification spacing.
* Align input height base with buttons.
* Revert height base, add additional bootstrap overrides.
* Grid overrides.
* Move overrides to their own folder. Adjust naming.
* Fix inconsistencies.
* Style generate wallet pt 1.
* Style generate wallet pt 2
* Style generate wallet pt 3
* Fix swap
* Added some missing overries, fixed the fallout.
* Remove header text, indicate alpha version.
* Fix radio / checkbox weights.
* Bind => arrow
* Convert simpledropdown to proper form select, instead of weirdly implemented nonfuncitoning dropdown.
* Fix token balances buttons, footr icons.
2017-09-05 19:52:01 +00:00
|
|
|
<article className="SwapRates">
|
2017-09-25 03:29:49 +00:00
|
|
|
<h3 className="SwapRates-title">{translate('SWAP_rates')}</h3>
|
v3 Style Import (#151)
* Convert bootstrap to sass instead of checked in and less
* Darken body, adjust header.
* First pass at tab styles, each tab will need a lot of individual love tho.
* Update footer to main site content, improve responsiveness.
* Missing key added.
* Fix dropdowns.
* Convert GenerateWallet HTML over, still needs styling.
* Send form.
* Current rates styled.
* CurrencySwap form styles.
* SwapInfoHeader styled.
* Finish up swap restyling, minor usability improvements for mobile.
* Fix up notifications / alert customizations
* Import v3 variables.
* Fix notification spacing.
* Align input height base with buttons.
* Revert height base, add additional bootstrap overrides.
* Grid overrides.
* Move overrides to their own folder. Adjust naming.
* Fix inconsistencies.
* Style generate wallet pt 1.
* Style generate wallet pt 2
* Style generate wallet pt 3
* Fix swap
* Added some missing overries, fixed the fallout.
* Remove header text, indicate alpha version.
* Fix radio / checkbox weights.
* Bind => arrow
* Convert simpledropdown to proper form select, instead of weirdly implemented nonfuncitoning dropdown.
* Fix token balances buttons, footr icons.
2017-09-05 19:52:01 +00:00
|
|
|
|
|
|
|
<section className="SwapRates-panel row">
|
|
|
|
<div className="SwapRates-panel-side col-sm-6">
|
|
|
|
{this.buildPairRate('ETH', 'BTC')}
|
|
|
|
{this.buildPairRate('ETH', 'REP')}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="SwapRates-panel-side col-sm-6">
|
|
|
|
{this.buildPairRate('BTC', 'ETH')}
|
|
|
|
{this.buildPairRate('BTC', 'REP')}
|
|
|
|
</div>
|
2017-12-11 17:44:53 +00:00
|
|
|
<a className="SwapRates-panel-logo" href={bityReferralURL} target="_blank">
|
2017-07-22 21:24:03 +00:00
|
|
|
<img src={bityLogoWhite} width={120} height={49} />
|
2017-06-19 05:39:07 +00:00
|
|
|
</a>
|
|
|
|
</section>
|
|
|
|
</article>
|
|
|
|
);
|
|
|
|
}
|
2017-06-12 01:02:39 +00:00
|
|
|
}
|