Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Refactor of enabled content
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc committed Mar 3, 2017
1 parent 9b41d66 commit 6bc57e5
Show file tree
Hide file tree
Showing 7 changed files with 436 additions and 356 deletions.
34 changes: 34 additions & 0 deletions app/common/lib/ledgerUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
'use strict'

const {responseHasContent} = require('./httpUtil')
const moment = require('moment')
moment.locale(navigator.language)

/**
* Is page an actual page being viewed by the user? (not an error page, etc)
Expand Down Expand Up @@ -39,3 +41,35 @@ module.exports.shouldTrackView = (view, responseList) => {
}
return false
}

module.exports.btcToCurrencyString = (btc, ledgerData) => {
const balance = Number(btc || 0)
const currency = ledgerData.get('currency') || 'USD'

if (balance === 0) {
return `0 ${currency}`
}

if (ledgerData.get('btc') && typeof ledgerData.get('amount') === 'number') {
const btcValue = ledgerData.get('btc') / ledgerData.get('amount')
const fiatValue = (balance / btcValue).toFixed(2)
let roundedValue = Math.floor(fiatValue)
const diff = fiatValue - roundedValue

if (diff > 0.74) {
roundedValue += 0.75
} else if (diff > 0.49) {
roundedValue += 0.50
} else if (diff > 0.24) {
roundedValue += 0.25
}

return `${roundedValue.toFixed(2)} ${currency}`
}

return `${balance} BTC`
}

module.exports.formattedTimeFromNow = (timestamp) => {
return moment(new Date(timestamp)).fromNow()
}
25 changes: 15 additions & 10 deletions app/renderer/components/preferences/payment/disabledContent.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

const React = require('react')
const ImmutableComponent = require('../../../../../js/components/immutableComponent')
const globalStyles = require('../../styles/global')
const {StyleSheet, css} = require('aphrodite/no-important')

// icons
const ImmutableComponent = require('../../../../../js/components/immutableComponent')

// style
const globalStyles = require('../../styles/global')
const paymentStyles = require('../../styles/payment')
const PIA = require('../../../../extensions/brave/img/private_internet_access.png')
const PIA2 = require('../../../../extensions/brave/img/private_internet_access_2x.png')
const BitGo = require('../../../../extensions/brave/img/bitgo.png')
Expand Down Expand Up @@ -57,10 +63,14 @@ const styles = StyleSheet.create({
},

textSide: {
fontSize: '12px',
fontSize: paymentStyles.font.regular,
margin: '50px 0 20px 12px'
},

walletBarMargin: {
marginTop: paymentStyles.margin.bar
},

h3: {
fontSize: '18px',
paddingBottom: '0.5em'
Expand All @@ -75,10 +85,6 @@ const styles = StyleSheet.create({
fontWeight: 'bold'
},

walletBarMargin: {
marginTop: '15px'
},

paymentsSidebar: {
opacity: 0.8,
width: '200px',
Expand All @@ -103,8 +109,7 @@ const styles = StyleSheet.create({
},

paymentsSidebarCoinbase: {
backgroundImage: `-webkit-image-set(url(${CoinBase}) 1x,
url(${CoinBase2}) 2x)`,
backgroundImage: `-webkit-image-set(url(${CoinBase}) 1x, url(${CoinBase2}) 2x)`,
width: '100px',
height: '35px',
margin: '0 0 20px 12px',
Expand Down
Loading

0 comments on commit 6bc57e5

Please sign in to comment.