wallet code + some finer touches on header + nav

This commit is contained in:
Jeremy Kauffman 2016-08-07 20:20:14 -04:00 committed by Alex Liebowitz
parent 0d2775138a
commit a36f0f2691
13 changed files with 132 additions and 79 deletions

View file

@ -61,6 +61,10 @@ var creditAmountStyle = {
color: '#aaa', color: '#aaa',
}; };
var CurrencySymbol = React.createClass({
render: function() { return <span>LBC</span>; }
});
var CreditAmount = React.createClass({ var CreditAmount = React.createClass({
propTypes: { propTypes: {
amount: React.PropTypes.number, amount: React.PropTypes.number,

View file

@ -32,7 +32,7 @@ var Drawer = React.createClass({
<DrawerItem href='/?home' viewingPage={this.props.viewingPage} label="Discover" icon="icon-search" /> <DrawerItem href='/?home' viewingPage={this.props.viewingPage} label="Discover" icon="icon-search" />
<DrawerItem href='/?publish' viewingPage={this.props.viewingPage} label="Publish" icon="icon-upload" /> <DrawerItem href='/?publish' viewingPage={this.props.viewingPage} label="Publish" icon="icon-upload" />
<DrawerItem href='/?files' viewingPage={this.props.viewingPage} label="My Files" icon='icon-cloud-download' /> <DrawerItem href='/?files' viewingPage={this.props.viewingPage} label="My Files" icon='icon-cloud-download' />
<DrawerItem href="/?wallet" viewingPage={this.props.viewingPage} label={ lbry.formatCredits(this.state.balance) } icon="icon-bank" /> <DrawerItem href="/?wallet" viewingPage={this.props.viewingPage} label="My Wallet" badge={lbry.formatCredits(this.state.balance) } icon="icon-bank" />
<DrawerItem href='/?settings' viewingPage={this.props.viewingPage} label="Settings" icon='icon-gear' /> <DrawerItem href='/?settings' viewingPage={this.props.viewingPage} label="Settings" icon='icon-gear' />
<DrawerItem href='/?help' viewingPage={this.props.viewingPage} label="Help" icon='icon-question-circle' /> <DrawerItem href='/?help' viewingPage={this.props.viewingPage} label="Help" icon='icon-question-circle' />
</nav> </nav>

View file

@ -1,7 +1,8 @@
var Header = React.createClass({ var Header = React.createClass({
getInitialState: function() { getInitialState: function() {
return { return {
title: "LBRY" title: "LBRY",
isScrolled: false
}; };
}, },
componentWillMount: function() { componentWillMount: function() {
@ -12,10 +13,21 @@ var Header = React.createClass({
{ subtree: true, characterData: true, childList: true } { subtree: true, characterData: true, childList: true }
); );
}, },
componentDidMount() {
document.addEventListener('scroll', this.handleScroll);
},
componentWillUnmount() {
document.removeEventListener('scroll', this.handleScroll);
},
handleScroll() {
this.setState({
isScrolled: event.srcElement.body.scrollTop > 0
});
},
render: function() { render: function() {
var isLinux = /linux/i.test(navigator.userAgent); // @TODO: find a way to use getVersionInfo() here without messy state management var isLinux = /linux/i.test(navigator.userAgent); // @TODO: find a way to use getVersionInfo() here without messy state management
return ( return (
<header id="header"> <header id="header" className={this.state.isScrolled ? 'header-scrolled' : 'header-unscrolled'}>
<Link onClick={this.props.onOpenDrawer} icon="icon-bars" className="open-drawer-link" /> <Link onClick={this.props.onOpenDrawer} icon="icon-bars" className="open-drawer-link" />
{isLinux ? <Link href="/?start" icon="icon-close" className="close-lbry-link" /> : null} {isLinux ? <Link href="/?start" icon="icon-close" className="close-lbry-link" /> : null}
<h1>{ this.state.title }</h1> <h1>{ this.state.title }</h1>

View file

@ -16,7 +16,8 @@ var Link = React.createClass({
<a className={className ? className : 'button-text'} href={href} style={this.props.style ? this.props.style : {}} <a className={className ? className : 'button-text'} href={href} style={this.props.style ? this.props.style : {}}
title={this.props.title} onClick={this.handleClick}> title={this.props.title} onClick={this.handleClick}>
{this.props.icon ? icon : '' } {this.props.icon ? icon : '' }
{this.props.label} <span className="link-label">{this.props.label}</span>
{this.props.badge ? <span className="badge">{this.props.badge}</span> : '' }
</a> </a>
); );
} }
@ -72,17 +73,6 @@ var ToolTipLink = React.createClass({
} }
}); });
var ReturnLink = React.createClass({
render: function() {
return <div style={ { padding: '24px 0' } }><Link
href={this.props.href ? this.props.href : '/'}
icon="icon-chevron-left"
label={this.props.label ? this.props.label : 'Return'}
/></div>;
}
});
var DownloadLink = React.createClass({ var DownloadLink = React.createClass({
propTypes: { propTypes: {
type: React.PropTypes.string, type: React.PropTypes.string,

View file

@ -1,6 +1,4 @@
var claimCodePageStyle = { var claimCodeContentStyle = {
textAlign: 'center',
}, claimCodeContentStyle = {
display: 'inline-block', display: 'inline-block',
textAlign: 'left', textAlign: 'left',
width: '600px', width: '600px',
@ -72,8 +70,9 @@ var ClaimCodePage = React.createClass({
}, },
render: function() { render: function() {
return ( return (
<main className="page" style={claimCodePageStyle}> <main>
<h1>Claim your beta invitation code</h1> <div className="card">
<h2>Claim your beta invitation code</h2>
<section style={claimCodeContentStyle}> <section style={claimCodeContentStyle}>
<p>Thanks for beta testing LBRY! Enter your invitation code and email address below to receive your initial <p>Thanks for beta testing LBRY! Enter your invitation code and email address below to receive your initial
LBRY credits.</p> LBRY credits.</p>
@ -90,6 +89,7 @@ var ClaimCodePage = React.createClass({
disabled={this.state.submitting} onClick={this.handleSubmit} /> disabled={this.state.submitting} onClick={this.handleSubmit} />
<Link button="alt" label="Skip" disabled={this.state.submitting} onClick={this.handleSkip} /> <Link button="alt" label="Skip" disabled={this.state.submitting} onClick={this.handleSkip} />
</section> </section>
</div>
</main> </main>
); );
} }

View file

@ -191,9 +191,6 @@ var MyFilesPage = React.createClass({
<section> <section>
{content} {content}
</section> </section>
<section>
<ReturnLink />
</section>
</main> </main>
); );
} }

View file

@ -78,13 +78,13 @@ var SettingsPage = React.createClass({
return ( return (
<main> <main>
<section className="card"> <section className="card">
<h3>Run on startup</h3> <h3>Run on Startup</h3>
<label style={settingsCheckBoxOptionStyles}> <label style={settingsCheckBoxOptionStyles}>
<input type="checkbox" onChange={this.onRunOnStartChange} defaultChecked={this.state.settings.run_on_startup} /> Run LBRY automatically when I start my computer <input type="checkbox" onChange={this.onRunOnStartChange} defaultChecked={this.state.settings.run_on_startup} /> Run LBRY automatically when I start my computer
</label> </label>
</section> </section>
<section className="card"> <section className="card">
<h3>Download directory</h3> <h3>Download Directory</h3>
<div className="help">Where would you like the files you download from LBRY to be saved?</div> <div className="help">Where would you like the files you download from LBRY to be saved?</div>
<input style={downloadDirectoryFieldStyles} type="text" name="download_directory" defaultValue={this.state.settings.download_directory} onChange={this.onDownloadDirChange}/> <input style={downloadDirectoryFieldStyles} type="text" name="download_directory" defaultValue={this.state.settings.download_directory} onChange={this.onDownloadDirChange}/>
</section> </section>
@ -108,7 +108,7 @@ var SettingsPage = React.createClass({
</label> </label>
</section> </section>
<section className="card"> <section className="card">
<h3>Share diagnostic data</h3> <h3>Share Diagnostic Data</h3>
<label style={settingsCheckBoxOptionStyles}> <label style={settingsCheckBoxOptionStyles}>
<input type="checkbox" onChange={this.onShareDataChange} defaultChecked={this.state.settings.upload_log} /> Help make LBRY better by contributing diagnostic data about my usage <input type="checkbox" onChange={this.onShareDataChange} defaultChecked={this.state.settings.upload_log} /> Help make LBRY better by contributing diagnostic data about my usage
</label> </label>

View file

@ -142,9 +142,6 @@ var DetailPage = React.createClass({
return ( return (
<main className="page"> <main className="page">
<FormatsSection name={name} claimInfo={claimInfo} amount={amount} /> <FormatsSection name={name} claimInfo={claimInfo} amount={amount} />
<section>
<ReturnLink />
</section>
</main>); </main>);
} }
}); });

View file

@ -13,8 +13,8 @@ var NewAddressSection = React.createClass({
}, },
render: function() { render: function() {
return ( return (
<section> <section className="card">
<h1>Generate New Address</h1> <h3>Generate New Address</h3>
<section><input type="text" size="60" value={this.state.address}></input></section> <section><input type="text" size="60" value={this.state.address}></input></section>
<Link button="primary" label="Generate" onClick={this.generateAddress} /> <Link button="primary" label="Generate" onClick={this.generateAddress} />
</section> </section>
@ -80,35 +80,57 @@ var SendToAddressSection = React.createClass({
}, },
render: function() { render: function() {
return ( return (
<section className="card">
<h3>Send Credits</h3>
<section> <section>
<h1>Send Credits</h1> <label htmlFor="amount">Amount <input id="amount" type="text" size="10" onChange={this.setAmount}></input></label>
<section> <label htmlFor="address">Recipient address <input id="address" type="text" size="60" onChange={this.setAddress}></input></label>
<section><label for="balance">Balance {this.state.balance}</label></section>
<label for="amount">Amount <input id="amount" type="text" size="10" onChange={this.setAmount}></input></label>
<label for="address">Recipient address <input id="address" type="text" size="60" onChange={this.setAddress}></input></label>
<Link button="primary" label="Send" onClick={this.sendToAddress} disabled={!(parseFloat(this.state.amount) > 0.0) || this.state.address == ""} /> <Link button="primary" label="Send" onClick={this.sendToAddress} disabled={!(parseFloat(this.state.amount) > 0.0) || this.state.address == ""} />
</section> </section>
<section className={!this.state.results ? 'hidden' : ''}> {
<h4>Results:</h4> this.state.results ?
<section>
<h4>Results</h4>
{this.state.results} {this.state.results}
</section> </section>
</section> : ''
}
); );
} }
}); });
var WalletPage = React.createClass({ var WalletPage = React.createClass({
componentDidMount: function() {
document.title = "My Wallet";
},
/*
Below should be refactored so that balance is shared all of wallet page. Or even broader?
What is the proper React pattern for sharing a global state like balance?
*/
getInitialState: function() {
return {
balance: "Checking balance...",
}
},
componentWillMount: function() {
lbry.getBalance((results) => {
this.setState({
balance: results,
});
});
},
render: function() { render: function() {
return ( return (
<main className="page"> <main className="page">
<NewAddressSection /> <section className="card">
<SendToAddressSection /> <h3>Balance</h3>
<section> {this.state.balance} <CurrencySymbol />
<h4>Claim invite code</h4>
<Link href="?claim" label="Claim a LBRY beta invite code"/>
</section> </section>
<section> <SendToAddressSection />
<ReturnLink /> <NewAddressSection />
<section className="card">
<h3>Claim Invite Code</h3>
<Link href="?claim" label="Claim a LBRY beta invite code" button="alt" />
</section> </section>
</main> </main>
); );

View file

@ -9,41 +9,54 @@ body
{ {
font-family: 'Source Sans Pro', sans-serif; font-family: 'Source Sans Pro', sans-serif;
line-height: 1.3333; line-height: 1.3333;
min-height: 100%;
position: relative;
} }
#window $drawer-width: 240px;
{
position: relative;
}
#drawer #drawer
{ {
width: 240px; width: $drawer-width;
position: absolute; position: absolute;
min-height: 100vh; min-height: 100vh;
left: 0; left: 0;
top: 0; top: 0;
background: $color-bg;
z-index: 1;
.drawer-item .drawer-item
{ {
display: block; display: block;
padding: $spacing-vertical / 2; padding: $spacing-vertical / 2;
font-size: 1.2em; font-size: 1.2em;
height: $spacing-vertical * 1.5;
.icon .icon
{ {
margin-right: 6px; margin-right: 6px;
} }
.link-label
{
line-height: $spacing-vertical * 1.5;
}
.badge
{
float: right;
background: $color-money;
display: inline-block;
padding: 2px;
color: white;
margin-top: $spacing-vertical * 0.25 - 2;
border-radius: 2px;
}
} }
.drawer-item-selected .drawer-item-selected
{ {
background: $color-canvas; background: $color-canvas;
color: $color-primary;
} }
} }
#drawer-handle #drawer-handle
{ {
padding: $spacing-vertical / 2; padding: $spacing-vertical / 2;
max-height: $header-height; max-height: $header-height - $spacing-vertical;
text-align: center; text-align: center;
} }
@ -53,7 +66,7 @@ body
} }
#window.drawer-open #window.drawer-open
{ {
#main-content { margin-left: 240px; } #main-content { margin-left: $drawer-width; }
.open-drawer-link { display: none; } .open-drawer-link { display: none; }
} }
@ -62,16 +75,26 @@ body
background: $color-primary; background: $color-primary;
color: white; color: white;
height: $header-height; height: $header-height;
padding: $spacing-vertical / 2; padding: $spacing-vertical / 2 $spacing-vertical / 2 $spacing-vertical / 2 $drawer-width + $spacing-vertical / 2;
h1 { font-size: 1.8em; line-height: $header-height; } position: fixed;
top: 0;
left: 0;
width: 100%;
box-sizing: border-box;
h1 { font-size: 1.8em; line-height: $header-height - $spacing-vertical; }
&.header-scrolled
{
box-shadow: $default-box-shadow;
}
} }
#main-content #main-content
{ {
background: $color-canvas; background: $color-canvas;
min-height: 100vh; min-height: calc(100vh - 60px); //should be -$header-height, but I'm dumb I guess? It wouldn't work
main main
{ {
margin-top: $header-height;
padding: $spacing-vertical; padding: $spacing-vertical;
} }
} }
@ -98,6 +121,12 @@ $header-icon-size: 1.5em;
max-width: 800px; max-width: 800px;
padding: $spacing-vertical; padding: $spacing-vertical;
background: $color-bg; background: $color-bg;
box-shadow: $default-box-shadow;
border-radius: 2px;
h2
{
margin-bottom: $spacing-vertical;
}
h3, h4 h3, h4
{ {
margin-bottom: $spacing-vertical / 2; margin-bottom: $spacing-vertical / 2;

View file

@ -17,7 +17,9 @@ $mobile-width-threshold: 801px;
$max-content-width: 1000px; $max-content-width: 1000px;
$max-text-width: 660px; $max-text-width: 660px;
$header-height: $spacing-vertical * 1.5; $header-height: $spacing-vertical * 2.5;
$default-box-shadow: 0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.2),0 1px 5px 0 rgba(0,0,0,.12);
@mixin clearfix() @mixin clearfix()

View file

@ -135,7 +135,7 @@ select {
border: 0 none; border: 0 none;
text-align: center; text-align: center;
border-radius: 2px; border-radius: 2px;
box-shadow: 0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.2),0 1px 5px 0 rgba(0,0,0,.12); box-shadow: $default-box-shadow;
text-transform: uppercase; text-transform: uppercase;
+ .button-block + .button-block
{ {