Browse Source

feature(value): add value component and use it in activity feed

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
9463062912
  1. 23
      app/components/Value/Value.js
  2. 0
      app/components/Value/Value.scss
  3. 3
      app/components/Value/index.js
  4. 23
      app/routes/activity/components/components/Invoice/Invoice.js
  5. 23
      app/routes/activity/components/components/Payment/Payment.js
  6. 23
      app/routes/activity/components/components/Transaction/Transaction.js
  7. 25
      app/routes/activity/components/components/Transaction/Transaction.scss

23
app/components/Value/Value.js

@ -0,0 +1,23 @@
import React from 'react'
import PropTypes from 'prop-types'
import { btc } from 'utils'
const Value = ({ value, currency, currentTicker }) => {
const renderValue = () => {
if (currency === 'btc') {
return btc.satoshisToBtc(value)
}
return 'gang'
}
return (
<i>{renderValue()}</i>
)
}
Value.propTypes = {
}
export default Value

0
app/components/Value/Value.scss

3
app/components/Value/index.js

@ -0,0 +1,3 @@
import Value from './Value'
export default Value

23
app/routes/activity/components/components/Invoice/Invoice.js

@ -5,6 +5,7 @@ import 'moment-timezone'
import Isvg from 'react-inlinesvg'
import { FaBolt } from 'react-icons/lib/fa'
import { btc } from 'utils'
import Value from 'components/Value'
import checkmarkIcon from 'icons/check_circle.svg'
import clockIcon from 'icons/clock.svg'
import styles from '../Activity.scss'
@ -47,20 +48,18 @@ const Invoice = ({
<div className={`${styles.amount} ${invoice.settled ? styles.positive : styles.negative}`}>
<span className='hint--top' data-hint='Invoice amount'>
<i className={styles.plus}>+</i>
{
ticker.currency === 'usd' ?
btc.satoshisToUsd(invoice.value, currentTicker.price_usd)
:
btc.satoshisToBtc(invoice.value)
}
<Value
value={invoice.value}
currency={ticker.currency}
currentTicker={currentTicker}
/>
</span>
<span className='hint--bottom' data-hint='Invoice fee'>
{
ticker.currency === 'usd' ?
btc.satoshisToUsd(invoice.fee, currentTicker.price_usd)
:
btc.satoshisToBtc(invoice.fee)
}
<Value
value={invoice.fee}
currency={ticker.currency}
currentTicker={currentTicker}
/>
</span>
</div>
</div>

23
app/routes/activity/components/components/Payment/Payment.js

@ -5,6 +5,7 @@ import 'moment-timezone'
import Isvg from 'react-inlinesvg'
import { FaBolt } from 'react-icons/lib/fa'
import { btc } from 'utils'
import Value from 'components/Value'
import checkmarkIcon from 'icons/check_circle.svg'
import styles from '../Activity.scss'
@ -39,20 +40,18 @@ const Payment = ({
<div className={styles.amount}>
<span className='hint--top' data-hint='Payment amount'>
<i className={styles.minus}>-</i>
{
ticker.currency === 'usd' ?
btc.satoshisToUsd(payment.value, currentTicker.price_usd)
:
btc.satoshisToBtc(payment.value)
}
<Value
value={payment.value}
currency={ticker.currency}
currentTicker={currentTicker}
/>
</span>
<span className='hint--bottom' data-hint='Payment fee'>
{
ticker.currency === 'usd' ?
btc.satoshisToUsd(payment.fee, currentTicker.price_usd)
:
btc.satoshisToBtc(payment.fee)
}
<Value
value={payment.fee}
currency={ticker.currency}
currentTicker={currentTicker}
/>
</span>
</div>
</div>

23
app/routes/activity/components/components/Transaction/Transaction.js

@ -5,6 +5,7 @@ import 'moment-timezone'
import Isvg from 'react-inlinesvg'
import { FaChain } from 'react-icons/lib/fa'
import { btc } from 'utils'
import Value from 'components/Value'
import checkmarkIcon from 'icons/check_circle.svg'
import styles from '../Activity.scss'
@ -39,20 +40,18 @@ const Transaction = ({
<div className={`${styles.amount} ${transaction.amount > 0 ? styles.positive : styles.negative}`}>
<span className='hint--top' data-hint='Transaction amount'>
<i className={transaction.amount > 0 ? styles.plus : styles.minus}>{ transaction.amount > 0 ? '+' : '-' }</i>
{
ticker.currency === 'usd' ?
btc.satoshisToUsd(transaction.amount, currentTicker.price_usd)
:
btc.satoshisToBtc(transaction.amount)
}
<Value
value={transaction.amount}
currency={ticker.currency}
currentTicker={currentTicker}
/>
</span>
<span className='hint--bottom' data-hint='Transaction fee'>
{
ticker.currency === 'usd' ?
btc.satoshisToUsd(transaction.total_fees, currentTicker.price_usd)
:
btc.satoshisToBtc(transaction.total_fees)
}
<Value
value={transaction.total_fees}
currency={ticker.currency}
currentTicker={currentTicker}
/>
</span>
</div>
</div>

25
app/routes/activity/components/components/Transaction/Transaction.scss

@ -75,27 +75,6 @@
font-weight: 500;
}
section {
display: inline-block;
vertical-align: top;
text-align: right;
font-size: 0;
margin: 0;
padding: 0;
&:nth-child(1) {
width: 20%;
}
&:nth-child(2) {
width: 80%;
}
}
svg {
font-size: 20px;
}
span {
display: block;
@ -106,6 +85,10 @@
&:nth-child(2) {
font-size: 10px;
}
.value {
font-size: 14px;
}
}
}

Loading…
Cancel
Save