Browse Source

feature(activity): style LN payment and request components

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
b77c1f5b73
  1. 5
      app/routes/activity/components/Activity.js
  2. 117
      app/routes/activity/components/components/Activity.scss
  3. 60
      app/routes/activity/components/components/Invoice/Invoice.js
  4. 59
      app/routes/activity/components/components/Payment/Payment.js
  5. 12
      app/routes/activity/components/components/Transaction/Transaction.js

5
app/routes/activity/components/Activity.js

@ -37,10 +37,11 @@ class Activity extends Component {
return <Transaction transaction={activity} ticker={ticker} currentTicker={currentTicker} />
} else if (activity.hasOwnProperty('payment_request')) {
// activity is an LN invoice
return <Invoice invoice={activity} />
console.log('activity: ', activity)
return <Invoice invoice={activity} ticker={ticker} currentTicker={currentTicker} />
} else {
// activity is an LN payment
return <Payment payment={activity} />
return <Payment payment={activity} ticker={ticker} currentTicker={currentTicker} />
}
}

117
app/routes/activity/components/components/Activity.scss

@ -0,0 +1,117 @@
@import '../../../../variables.scss';
.container {
display: flex;
flex-direction: row;
cursor: pointer;
max-width: 960px;
margin: 0 auto;
height: 76px;
align-items: center;
border-bottom: 1px solid $grey;
font-size: 14px;
transition: background-color .1s linear;
transition-delay: .1s;
color: $darkestgrey;
position: relative;
}
.label {
position: absolute;
top: 0;
left: -25%;
}
.icon {
display: block;
margin-right: 20px;
flex: none;
position: relative;
width: 36px;
height: 36px;
border: 1px solid $darkestgrey;
border-radius: 50%;
svg {
color: $main;
font-size: 16px;
vertical-align: middle;
display: flex;
top: 0;
left: 50%;
height: 100%;
margin: 0 auto;
}
}
.data {
display: flex;
flex-direction: row;
flex: 6 0;
.title {
flex: 8 0;
}
.subtitle {
padding-left: 20px;
flex: 2 0;
}
}
.subtitle, .date {
text-align: center;
}
.date {
padding-left: 20px;
flex: 1 0;
}
.amount {
flex: 1 0;
padding-left: 20px;
&.negative {
font-weight: 200;
}
&.positive {
color: $main;
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;
&:nth-child(1) {
font-size: 14px;
}
&:nth-child(2) {
font-size: 10px;
}
}
}

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

@ -1,10 +1,62 @@
import React from 'react'
import PropTypes from 'prop-types'
import styles from './Invoice.scss'
import Moment from 'react-moment'
import 'moment-timezone'
import { FaBolt } from 'react-icons/lib/fa'
import { btc } from '../../../../../utils'
import CurrencyIcon from '../../../../../components/CurrencyIcon'
import styles from '../Activity.scss'
const Invoice = () => (
<div>
Invoice
const Invoice = ({ invoice, ticker, currentTicker }) => (
<div className={styles.container}>
<i className={`${styles.icon} hint--top`} data-hint='Lightning Network transaction'>
<FaBolt />
</i>
<div className={styles.data}>
<div className={styles.title}>
{invoice.r_hash.toString('hex')}
</div>
<div className={styles.subtitle}>
{invoice.memo}
</div>
</div>
<div className={styles.date}>
<Moment format='MMM Do'>
{
invoice.settled ?
invoice.settle_date * 1000
:
invoice.creation_date * 1000
}
</Moment>
</div>
<div className={`${styles.amount} ${invoice.settled ? styles.positive : styles.negative}`}>
<section>
<CurrencyIcon
currency={ticker.currency}
crypto={ticker.crypto}
styles={{ verticalAlign: 'top', width: '24px' }}
/>
</section>
<section>
<span className='hint--top' data-hint='Invoice amount'>
{
ticker.currency === 'usd' ?
btc.satoshisToUsd(invoice.value, currentTicker.price_usd)
:
btc.satoshisToBtc(invoice.value)
}
</span>
<span className='hint--bottom' data-hint='Invoice fee'>
{
ticker.currency === 'usd' ?
btc.satoshisToUsd(invoice.fee, currentTicker.price_usd)
:
btc.satoshisToBtc(invoice.fee)
}
</span>
</section>
</div>
</div>
)

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

@ -1,10 +1,61 @@
import React from 'react'
import PropTypes from 'prop-types'
import styles from './Payment.scss'
import Moment from 'react-moment'
import 'moment-timezone'
import { FaBolt } from 'react-icons/lib/fa'
import { btc } from '../../../../../utils'
import CurrencyIcon from '../../../../../components/CurrencyIcon'
import styles from '../Activity.scss'
const Payment = () => (
<div>
Payment
const Payment = ({ payment, ticker, currentTicker }) => (
<div className={styles.container}>
<i className={`${styles.icon} hint--top`} data-hint='Lightning Network transaction'>
<FaBolt />
</i>
<div className={styles.data}>
<div className={styles.title}>
{payment.payment_hash}
</div>
<div className={styles.subtitle}>
{
payment.path.length > 1 ?
`${payment.path.length} hops`
:
'Directly routed'
}
</div>
</div>
<div className={styles.date}>
<Moment format='MMM Do'>{payment.creation_date * 1000}</Moment>
</div>
<div className={styles.amount}>
<section>
<CurrencyIcon
currency={ticker.currency}
crypto={ticker.crypto}
styles={{ verticalAlign: 'top', width: '24px' }}
/>
</section>
<section>
<span className='hint--top' data-hint='Payment amount'>
-
{
ticker.currency === 'usd' ?
btc.satoshisToUsd(payment.value, currentTicker.price_usd)
:
btc.satoshisToBtc(payment.value)
}
</span>
<span className='hint--bottom' data-hint='Payment fee'>
{
ticker.currency === 'usd' ?
btc.satoshisToUsd(payment.fee, currentTicker.price_usd)
:
btc.satoshisToBtc(payment.fee)
}
</span>
</section>
</div>
</div>
)

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

@ -5,10 +5,20 @@ import 'moment-timezone'
import { FaChain } from 'react-icons/lib/fa'
import { btc } from '../../../../../utils'
import CurrencyIcon from '../../../../../components/CurrencyIcon'
import styles from './Transaction.scss'
import styles from '../Activity.scss'
const Transaction = ({ transaction, ticker, currentTicker }) => (
<div className={styles.container}>
<div className={styles.label}>
<h3>
{
transaction.amount < 0 ?
'Sent'
:
'Received'
}
</h3>
</div>
<i className={`${styles.icon} hint--top`} data-hint='On-chain transaction'>
<FaChain />
</i>

Loading…
Cancel
Save