import React from "react"; import { formatCredits, formatFullPrice } from "util/formatCredits"; import lbry from "../lbry.js"; //component/icon.js export class Icon extends React.PureComponent { static propTypes = { icon: React.PropTypes.string.isRequired, className: React.PropTypes.string, fixed: React.PropTypes.bool, }; render() { const { fixed, className } = this.props; const spanClassName = "icon " + ("fixed" in this.props ? "icon-fixed-width " : "") + this.props.icon + " " + (this.props.className || ""); return ; } } export class TruncatedText extends React.PureComponent { static propTypes = { lines: React.PropTypes.number, }; static defaultProps = { lines: null, }; render() { return ( {this.props.children} ); } } export class BusyMessage extends React.PureComponent { static propTypes = { message: React.PropTypes.string, }; render() { return ( {this.props.message} ); } } export class CurrencySymbol extends React.PureComponent { render() { return LBC; } } export class CreditAmount extends React.PureComponent { static propTypes = { amount: React.PropTypes.number.isRequired, precision: React.PropTypes.number, isEstimate: React.PropTypes.bool, label: React.PropTypes.bool, showFree: React.PropTypes.bool, showFullPrice: React.PropTypes.bool, showPlus: React.PropTypes.bool, look: React.PropTypes.oneOf(["indicator", "plain", "fee"]), }; static defaultProps = { precision: 2, label: true, showFree: false, look: "indicator", showFullPrice: false, showPlus: false, }; render() { const minimumRenderableAmount = Math.pow(10, -1 * this.props.precision); const { amount, precision, showFullPrice } = this.props; let formattedAmount; let fullPrice = formatFullPrice(amount, 2); if (showFullPrice) { formattedAmount = fullPrice; } else { formattedAmount = amount > 0 && amount < minimumRenderableAmount ? "<" + minimumRenderableAmount : formatCredits(amount, precision); } let amountText; if (this.props.showFree && parseFloat(this.props.amount) === 0) { amountText = __("free"); } else { if (this.props.label) { amountText = formattedAmount + " " + (parseFloat(amount) == 1 ? __("credit") : __("credits")); } else { amountText = formattedAmount; } if (this.props.showPlus && amount > 0) { amountText = "+" + amountText; } } return ( {amountText} {this.props.isEstimate ? * : null} ); } } let addressStyle = { fontFamily: '"Consolas", "Lucida Console", "Adobe Source Code Pro", monospace', }; export class Address extends React.PureComponent { static propTypes = { address: React.PropTypes.string, }; constructor(props) { super(props); this._inputElem = null; } render() { return (