Move top bar into its own component

This commit is contained in:
Alex Liebowitz 2016-03-27 01:41:36 -04:00
parent 29f8018cef
commit d6a432fe75

View file

@ -69,12 +69,6 @@ var creditAmountStyle = {
}, estimateStyle = { }, estimateStyle = {
marginLeft : '5px', marginLeft : '5px',
color: '#aaa', color: '#aaa',
}, menuStyle = {
position: 'relative',
top: '3px',
marginLeft: '2px'
}, menuItemStyle = {
marginLeft: '3px'
}; };
var CreditAmount = React.createClass({ var CreditAmount = React.createClass({
@ -84,20 +78,14 @@ var CreditAmount = React.createClass({
render: function() { render: function() {
var formattedAmount = lbry.formatCredits(this.props.amount); var formattedAmount = lbry.formatCredits(this.props.amount);
return ( return (
<span className='top-bar'>
<span className="credit-amount"> <span className="credit-amount">
<span style={creditAmountStyle}>{formattedAmount}</span> <span style={creditAmountStyle}>{formattedAmount}</span>
{ this.props.isEstimate ? <span style={estimateStyle}>(est)</span> : null } { this.props.isEstimate ? <span style={estimateStyle}>(est)</span> : null }
</span> </span>
<span className='menu' style={menuStyle}>
<Link href='#' icon="icon-gear" fadeIn={true} style={menuItemStyle} />
</span>
</span>
); );
} }
}); });
//component/header.js //component/header.js
var logoStyle = { var logoStyle = {
padding: '48px 12px', padding: '48px 12px',
@ -105,7 +93,7 @@ var logoStyle = {
maxHeight: '80px', maxHeight: '80px',
}, },
balanceStyle = { balanceStyle = {
float: 'right', // float: 'right',
marginTop: '3px' marginTop: '3px'
}, },
imgStyle = { //@TODO: remove this, img should be properly scaled once size is settled imgStyle = { //@TODO: remove this, img should be properly scaled once size is settled
@ -113,6 +101,32 @@ var logoStyle = {
}; };
var Header = React.createClass({ var Header = React.createClass({
render: function() {
return (
<header>
<TopBar />
<div style={logoStyle}>
<img src="./img/lbry-dark-1600x528.png" style={imgStyle}/>
</div>
</header>
);
}
});
var topBarStyle = {
'float': 'right'
};
var menuStyle = {
position: 'relative',
top: '3px',
marginLeft: '2px'
}, menuItemStyle = {
marginLeft: '3px'
};
var TopBar = React.createClass({
getInitialState: function() { getInitialState: function() {
return { return {
balance: 0 balance: 0
@ -125,20 +139,23 @@ var Header = React.createClass({
}); });
}.bind(this)); }.bind(this));
}, },
render: function() { render: function() {
return ( return (
<header> <span className='top-bar' style={topBarStyle}>
<span style={balanceStyle}> <span style={balanceStyle}>
<CreditAmount amount={this.state.balance}/> <CreditAmount amount={this.state.balance}/>
</span> </span>
<div style={logoStyle}> <span className='menu' style={menuStyle}>
<img src="./img/lbry-dark-1600x528.png" style={imgStyle}/> <Link href='#' icon="icon-gear" fadeIn={true} style={menuItemStyle} />
</div> </span>
</header> </span>
); );
} }
}); });
//component/discover.js //component/discover.js
var searchInputStyle = { var searchInputStyle = {