From d5b8f0ffbbde5fb8d41c3abb4b0969b962746b52 Mon Sep 17 00:00:00 2001 From: jloup Date: Sun, 13 May 2018 23:04:56 +0200 Subject: JS factorization + clean. --- cmd/web/js/account.jsx | 23 +---------------------- cmd/web/js/balance.jsx | 13 ++++++------- cmd/web/js/panel.jsx | 25 +++++++++++++++++++++++++ cmd/web/js/poloniex.jsx | 20 +------------------- 4 files changed, 33 insertions(+), 48 deletions(-) create mode 100644 cmd/web/js/panel.jsx (limited to 'cmd/web/js') diff --git a/cmd/web/js/account.jsx b/cmd/web/js/account.jsx index 3dc8afd..988d840 100644 --- a/cmd/web/js/account.jsx +++ b/cmd/web/js/account.jsx @@ -1,27 +1,6 @@ import Api from './api.js'; import React from 'react'; -import classnames from 'classnames'; - -class Panel extends React.Component { - render = () => { - if (this.props.component === null) { - return
; - } - - var className = classnames('row', this.props.topClassName); - - return ( -
-
-
-
{this.props.title}
-
-
- {this.props.component} -
-
); - } -} +import Panel from './panel.js'; class AccountInformation extends React.Component { constructor(props) { diff --git a/cmd/web/js/balance.jsx b/cmd/web/js/balance.jsx index d141aa8..515a7ed 100644 --- a/cmd/web/js/balance.jsx +++ b/cmd/web/js/balance.jsx @@ -1,14 +1,13 @@ import React from 'react'; import moment from 'moment'; +import classnames from 'classnames'; class CurrencyLogo extends React.Component { render = () => { - return
- {this.props.currency} -
; + var className = classnames('cc', this.props.currency, 'currency-logo'); + return ; } } @@ -42,7 +41,7 @@ class CurrencyRate extends React.Component { render = () => { return
-
{this.props.currency}
+
{this.props.currency}
{this.props.positionType}
{this.props.quantity}
{this.props.BTCValue}
diff --git a/cmd/web/js/panel.jsx b/cmd/web/js/panel.jsx new file mode 100644 index 0000000..c293e9a --- /dev/null +++ b/cmd/web/js/panel.jsx @@ -0,0 +1,25 @@ +import React from 'react'; +import classnames from 'classnames'; + +class Panel extends React.Component { + render = () => { + if (this.props.component === null) { + return
; + } + + var className = classnames('row', this.props.topClassName); + + return ( +
+
+
+
{this.props.title}
+
+
+ {this.props.component} +
+
); + } +} + +export default Panel; diff --git a/cmd/web/js/poloniex.jsx b/cmd/web/js/poloniex.jsx index b28bc26..5c374c3 100644 --- a/cmd/web/js/poloniex.jsx +++ b/cmd/web/js/poloniex.jsx @@ -1,6 +1,7 @@ import Api from './api.js'; import React from 'react'; import {PFBalance, Assets} from './balance.js'; +import Panel from './panel.js'; class PoloniexController extends React.Component { constructor(props) { @@ -74,25 +75,6 @@ class PoloniexController extends React.Component { } } -class Panel extends React.Component { - render = () => { - if (this.props.component === null) { - return
; - } - - return ( -
-
-
-
{this.props.title}
-
-
- {this.props.component} -
-
); - } -} - class PoloniexBalance extends React.Component { render = () => { -- cgit v1.2.3