diff --git a/ui/js/component/header.js b/ui/js/component/header.js index fb64e9ece..6e186cc44 100644 --- a/ui/js/component/header.js +++ b/ui/js/component/header.js @@ -1,5 +1,6 @@ import React from 'react'; import {Link} from './link.js'; +import NotificationBar from './notification-bar.js'; var Header = React.createClass({ getInitialState: function() { @@ -61,6 +62,7 @@ var Header = React.createClass({ : '' } + ); } diff --git a/ui/js/component/notice.js b/ui/js/component/notice.js index 2e5812c21..a09238294 100644 --- a/ui/js/component/notice.js +++ b/ui/js/component/notice.js @@ -15,7 +15,7 @@ export const Notice = React.createClass({ }, render: function() { return ( -
+
{this.props.children}
); diff --git a/ui/js/component/notification-bar.js b/ui/js/component/notification-bar.js new file mode 100644 index 000000000..f6662b552 --- /dev/null +++ b/ui/js/component/notification-bar.js @@ -0,0 +1,53 @@ +import React from 'react'; +import lbry from '../lbry.js'; +import Notice from '../component/notice.js'; + +export const NotificationBar = React.createClass({ + _displayTime: 8, // in seconds + + _hideTimeout: null, + + getInitialState: function() { + return { + message: null, + isError: null, + } + }, + handleNoticeReceived: function(event) { + if (this._hideTimeout) { + clearTimeout(this._hideTimeout); + } + + const {detail: {message, isError}} = event; + this.setState({ + message: message, + isError: isError, + }); + + this._hideTimeout = setTimeout(() => { + this.setState({ + message: null, + isError: null, + }); + }, this._displayTime * 1000); + }, + componentWillMount: function() { + document.addEventListener('globalNotice', this.handleNoticeReceived); + }, + componentWillUnmount: function() { + document.removeEventListener('globalNotice', this.handleNoticeReceived); + }, + render: function() { + if (!this.state.message) { + return null; + } + + return ( + + {this.state.message} + + ); + }, +}); + +export default NotificationBar; \ No newline at end of file diff --git a/ui/scss/all.scss b/ui/scss/all.scss index 126ad742c..89d84058a 100644 --- a/ui/scss/all.scss +++ b/ui/scss/all.scss @@ -13,6 +13,7 @@ @import "component/_channel-indicator.scss"; @import "component/_notice.scss"; @import "component/_modal-page.scss"; +@import "component/_notification-bar.scss"; @import "page/_developer.scss"; @import "page/_watch.scss"; @import "page/_reward.scss"; diff --git a/ui/scss/component/_notice.scss b/ui/scss/component/_notice.scss index 2ae4f403e..b77ba2a5a 100644 --- a/ui/scss/component/_notice.scss +++ b/ui/scss/component/_notice.scss @@ -5,6 +5,10 @@ border: 1px solid #000; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); border-radius: 5px; + + color: #468847; + background-color: #dff0d8; + border-color: #d6e9c6; } .notice--error { diff --git a/ui/scss/component/_notification-bar.scss b/ui/scss/component/_notification-bar.scss new file mode 100644 index 000000000..2f9959f94 --- /dev/null +++ b/ui/scss/component/_notification-bar.scss @@ -0,0 +1,6 @@ +@import "../global"; + +.notification-bar { + margin-top: 5px; + margin-right: 10px; +}