2016-08-07 22:10:44 +02:00
|
|
|
var Header = React.createClass({
|
2016-08-08 00:13:17 +02:00
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
2016-08-08 02:20:14 +02:00
|
|
|
title: "LBRY",
|
|
|
|
isScrolled: false
|
2016-08-08 00:13:17 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
componentWillMount: function() {
|
|
|
|
new MutationObserver(function(mutations) {
|
|
|
|
this.setState({ title: mutations[0].target.innerHTML });
|
|
|
|
}.bind(this)).observe(
|
|
|
|
document.querySelector('title'),
|
|
|
|
{ subtree: true, characterData: true, childList: true }
|
|
|
|
);
|
|
|
|
},
|
2016-08-08 02:20:14 +02:00
|
|
|
componentDidMount() {
|
|
|
|
document.addEventListener('scroll', this.handleScroll);
|
|
|
|
},
|
|
|
|
componentWillUnmount() {
|
|
|
|
document.removeEventListener('scroll', this.handleScroll);
|
|
|
|
},
|
|
|
|
handleScroll() {
|
|
|
|
this.setState({
|
|
|
|
isScrolled: event.srcElement.body.scrollTop > 0
|
|
|
|
});
|
|
|
|
},
|
2016-08-07 22:10:44 +02:00
|
|
|
render: function() {
|
2016-08-08 00:25:29 +02:00
|
|
|
var isLinux = /linux/i.test(navigator.userAgent); // @TODO: find a way to use getVersionInfo() here without messy state management
|
2016-08-07 22:10:44 +02:00
|
|
|
return (
|
2016-08-08 02:20:14 +02:00
|
|
|
<header id="header" className={this.state.isScrolled ? 'header-scrolled' : 'header-unscrolled'}>
|
2016-08-07 22:10:44 +02:00
|
|
|
<Link onClick={this.props.onOpenDrawer} icon="icon-bars" className="open-drawer-link" />
|
2016-08-08 00:25:29 +02:00
|
|
|
{isLinux ? <Link href="/?start" icon="icon-close" className="close-lbry-link" /> : null}
|
2016-08-08 00:13:17 +02:00
|
|
|
<h1>{ this.state.title }</h1>
|
2016-08-07 22:10:44 +02:00
|
|
|
</header>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|