hyper/lib/components/notifications.js

88 lines
2.3 KiB
JavaScript
Raw Normal View History

2016-07-13 12:44:24 -08:00
import React from 'react';
2016-07-13 12:44:24 -08:00
import Component from '../component';
import {decorate} from '../utils/plugins';
2016-07-13 12:44:24 -08:00
import Notification_ from './notification';
const Notification = decorate(Notification_);
export default class Notifications extends Component {
template(css) {
return (<div className={css('view')}>
2016-07-13 12:44:24 -08:00
{ this.props.customChildrenBefore }
{
this.props.fontShowing &&
<Notification
key="font"
backgroundColor="rgba(255, 255, 255, .2)"
2016-07-13 12:44:24 -08:00
text={`${this.props.fontSize}px`}
userDismissable={false}
onDismiss={this.props.onDismissFont}
dismissAfter={1000}
/>
2016-07-13 12:44:24 -08:00
}
{
this.props.resizeShowing &&
<Notification
key="resize"
backgroundColor="rgba(255, 255, 255, .2)"
2016-07-13 12:44:24 -08:00
text={`${this.props.cols}x${this.props.rows}`}
userDismissable={false}
onDismiss={this.props.onDismissResize}
dismissAfter={1000}
/>
2016-07-13 12:44:24 -08:00
}
{
this.props.updateShowing &&
<Notification
key="update"
backgroundColor="#7ED321"
text={`Version ${this.props.updateVersion} ready`}
onDismiss={this.props.onDismissUpdate}
userDismissable
>
Version <b>{ this.props.updateVersion}</b> ready.
{ this.props.updateNote && ` ${this.props.updateNote.trim().replace(/\.$/, '')}` }
{ ' ' }
(<a
style={{color: '#fff'}}
onClick={ev => {
window.require('electron').shell.openExternal(ev.target.href);
ev.preventDefault();
}}
href={`https://github.com/zeit/hyperterm/releases/tag/${this.props.updateVersion}`}
>notes</a>).
2016-07-13 12:44:24 -08:00
{ ' ' }
<a
style={{
cursor: 'pointer',
textDecoration: 'underline',
fontWeight: 'bold'
}}
onClick={this.props.onUpdateInstall}
>
2016-07-13 12:44:24 -08:00
Restart
</a>.
2016-07-13 12:44:24 -08:00
{ ' ' }
</Notification>
}
{ this.props.customChildren }
</div>);
2016-07-13 12:44:24 -08:00
}
styles() {
2016-07-13 12:44:24 -08:00
return {
view: {
position: 'fixed',
bottom: '20px',
right: '20px'
}
};
}
}