mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-01 09:45:10 +00:00
Added new component form for price, also only tipping form is shown when
clicked.
This commit is contained in:
parent
b8b3a6ffd2
commit
ba6d093d1c
4 changed files with 87 additions and 23 deletions
|
@ -14,6 +14,7 @@ class FileActions extends React.PureComponent {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
forceShowActions: false,
|
forceShowActions: false,
|
||||||
|
showTipBox: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +59,18 @@ class FileActions extends React.PureComponent {
|
||||||
this.props.loadVideo(this.props.uri);
|
this.props.loadVideo(this.props.uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleTipShow() {
|
||||||
|
this.setState({
|
||||||
|
showTipBox: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
handleTipHide() {
|
||||||
|
this.setState({
|
||||||
|
showTipBox: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
fileInfo,
|
fileInfo,
|
||||||
|
@ -76,6 +89,8 @@ class FileActions extends React.PureComponent {
|
||||||
claimIsMine,
|
claimIsMine,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
const { showTipBox } = this.state;
|
||||||
|
|
||||||
const metadata = fileInfo ? fileInfo.metadata : null,
|
const metadata = fileInfo ? fileInfo.metadata : null,
|
||||||
openInFolderMessage = platform.startsWith("Mac")
|
openInFolderMessage = platform.startsWith("Mac")
|
||||||
? __("Open in Finder")
|
? __("Open in Finder")
|
||||||
|
@ -166,8 +181,14 @@ class FileActions extends React.PureComponent {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="file-actions">
|
<section className="file-actions">
|
||||||
{content}
|
{showTipBox ? "" : content}
|
||||||
{showMenu
|
<TipLink
|
||||||
|
onTipShow={this.handleTipShow.bind(this)}
|
||||||
|
onTipHide={this.handleTipHide.bind(this)}
|
||||||
|
showTipBox={showTipBox}
|
||||||
|
claim={this.props.claim}
|
||||||
|
/>
|
||||||
|
{showMenu && !showTipBox
|
||||||
? <DropDownMenu>
|
? <DropDownMenu>
|
||||||
<DropDownMenuItem
|
<DropDownMenuItem
|
||||||
key={0}
|
key={0}
|
||||||
|
@ -181,7 +202,6 @@ class FileActions extends React.PureComponent {
|
||||||
/>
|
/>
|
||||||
</DropDownMenu>
|
</DropDownMenu>
|
||||||
: ""}
|
: ""}
|
||||||
<TipLink claim={this.props.claim} />
|
|
||||||
<Modal
|
<Modal
|
||||||
type="confirm"
|
type="confirm"
|
||||||
isOpen={modal == "affirmPurchase"}
|
isOpen={modal == "affirmPurchase"}
|
||||||
|
|
5
ui/js/component/priceForm/index.js
Normal file
5
ui/js/component/priceForm/index.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import React from "react";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
import PriceForm from "./view";
|
||||||
|
|
||||||
|
export default connect(null, null)(PriceForm);
|
39
ui/js/component/priceForm/view.jsx
Normal file
39
ui/js/component/priceForm/view.jsx
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
import React from "react";
|
||||||
|
import { FormField } from "component/form";
|
||||||
|
|
||||||
|
const PriceForm = props => {
|
||||||
|
const {
|
||||||
|
onFeeChange,
|
||||||
|
onCurrencyChange,
|
||||||
|
defaultFeeValue,
|
||||||
|
defaultCurrencyValue,
|
||||||
|
placeholder,
|
||||||
|
min,
|
||||||
|
step,
|
||||||
|
} = props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span>
|
||||||
|
<FormField
|
||||||
|
type="number"
|
||||||
|
min={min}
|
||||||
|
placeholder={placeholder || null}
|
||||||
|
step={step}
|
||||||
|
onChange={onFeeChange}
|
||||||
|
defaultValue={defaultFeeValue}
|
||||||
|
className="form-field__input--inline"
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
type="select"
|
||||||
|
onChange={onCurrencyChange}
|
||||||
|
defaultValue={defaultCurrencyValue}
|
||||||
|
className="form-field__input--inline"
|
||||||
|
>
|
||||||
|
<option value="LBC">{__("LBRY credits")}</option>
|
||||||
|
<option value="USD">{__("US Dollars")}</option>
|
||||||
|
</FormField>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PriceForm;
|
|
@ -1,21 +1,20 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import Link from "component/link";
|
import Link from "component/link";
|
||||||
import { FormField } from "component/form";
|
import { FormField } from "component/form";
|
||||||
|
import PriceForm from "component/priceForm";
|
||||||
|
|
||||||
class TipLink extends React.PureComponent {
|
class TipLink extends React.PureComponent {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
showTipBox: false,
|
|
||||||
feeAmount: "1.00",
|
feeAmount: "1.00",
|
||||||
|
currency: "LBC",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTipPublisherButtonClicked() {
|
handleTipPublisherButtonClicked() {
|
||||||
this.setState({
|
this.props.onTipShow();
|
||||||
showTipBox: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTipButtonClicked() {
|
handleTipButtonClicked() {
|
||||||
|
@ -26,15 +25,11 @@ class TipLink extends React.PureComponent {
|
||||||
this.props.setAmount(amount);
|
this.props.setAmount(amount);
|
||||||
this.props.sendToAddress();
|
this.props.sendToAddress();
|
||||||
|
|
||||||
this.setState({
|
this.props.onTipHide();
|
||||||
showTipBox: false,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTipCancelButtonClicked() {
|
handleTipCancelButtonClicked() {
|
||||||
this.setState({
|
this.props.onTipHide();
|
||||||
showTipBox: false,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleFeeAmountChange(event) {
|
handleFeeAmountChange(event) {
|
||||||
|
@ -43,12 +38,18 @@ class TipLink extends React.PureComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleCurrencyChange(event) {
|
||||||
|
this.setState({
|
||||||
|
currency: event.target.value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { showTipBox } = this.state;
|
const { showTipBox } = this.props;
|
||||||
|
|
||||||
let tipLink = (
|
let tipLink = (
|
||||||
<Link
|
<Link
|
||||||
label={__("Tip Publisher")}
|
label={__("Tip")}
|
||||||
button="text"
|
button="text"
|
||||||
icon="icon-gift"
|
icon="icon-gift"
|
||||||
onClick={this.handleTipPublisherButtonClicked.bind(this)}
|
onClick={this.handleTipPublisherButtonClicked.bind(this)}
|
||||||
|
@ -57,15 +58,14 @@ class TipLink extends React.PureComponent {
|
||||||
|
|
||||||
let tipBox = (
|
let tipBox = (
|
||||||
<span>
|
<span>
|
||||||
<FormField
|
<PriceForm
|
||||||
type="number"
|
|
||||||
className="form-field__input--inline"
|
|
||||||
step="0.1"
|
|
||||||
placeholder="1.00"
|
|
||||||
defaultValue="1.00"
|
|
||||||
min="0.01"
|
min="0.01"
|
||||||
postfix={__("LBC")}
|
placeholder="1.00"
|
||||||
onChange={event => this.handleFeeAmountChange(event)}
|
step="0.1"
|
||||||
|
onFeeChange={event => this.handleFeeAmountChange(event)}
|
||||||
|
defaultFeeValue="1.00"
|
||||||
|
onCurrencyChange={event => this.handleCurrencyChange(event)}
|
||||||
|
defaultCurrencyValue="LBC"
|
||||||
/>
|
/>
|
||||||
{__(" ")}
|
{__(" ")}
|
||||||
<Link
|
<Link
|
||||||
|
|
Loading…
Add table
Reference in a new issue