hyper/lib/components/notifications.tsx

133 lines
4 KiB
TypeScript
Raw Normal View History

2016-07-13 12:44:24 -08:00
import React from 'react';
import {decorate} from '../utils/plugins';
2016-07-13 12:44:24 -08:00
import Notification_ from './notification';
2020-03-17 11:05:05 -08:00
import {NotificationsProps} from '../hyper';
2016-07-13 12:44:24 -08:00
const Notification = decorate(Notification_, 'Notification');
2016-07-13 12:44:24 -08:00
2020-03-17 11:05:05 -08:00
export default class Notifications extends React.PureComponent<NotificationsProps> {
render() {
return (
<div className="notifications_view">
{this.props.customChildrenBefore}
{this.props.fontShowing && (
2016-07-13 12:44:24 -08:00
<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 && (
2016-07-13 12:44:24 -08:00
<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.messageShowing && (
<Notification
key="message"
backgroundColor="#FE354E"
text={this.props.messageText}
onDismiss={this.props.onDismissMessage}
userDismissable={this.props.messageDismissable}
userDismissColor="#AA2D3C"
>
2017-11-01 05:44:43 -08:00
{this.props.messageURL
? [
this.props.messageText,
' (',
<a
key="link"
style={{color: '#fff'}}
onClick={ev => {
2020-03-17 11:05:05 -08:00
window.require('electron').shell.openExternal(ev.currentTarget.href);
2017-11-01 05:44:43 -08:00
ev.preventDefault();
}}
href={this.props.messageURL}
>
more
</a>,
')'
]
: null}
</Notification>
)}
{this.props.updateShowing && (
2016-07-13 12:44:24 -08:00
<Notification
key="update"
backgroundColor="#18E179"
color="#000"
text={`Version ${this.props.updateVersion} ready`}
onDismiss={this.props.onDismissUpdate}
userDismissable
>
2016-10-04 11:44:10 -08:00
Version <b>{this.props.updateVersion}</b> ready.
{this.props.updateNote && ` ${this.props.updateNote.trim().replace(/\.$/, '')}`} (
<a
style={{color: '#000'}}
onClick={ev => {
2020-03-17 11:05:05 -08:00
window.require('electron').shell.openExternal(ev.currentTarget.href);
ev.preventDefault();
}}
href={`https://github.com/zeit/hyper/releases/tag/${this.props.updateVersion}`}
>
notes
</a>
).{' '}
{this.props.updateCanInstall ? (
<a
style={{
cursor: 'pointer',
textDecoration: 'underline',
fontWeight: 'bold'
}}
onClick={this.props.onUpdateInstall}
>
Restart
</a>
) : (
<a
style={{
color: '#000',
cursor: 'pointer',
textDecoration: 'underline',
fontWeight: 'bold'
}}
onClick={ev => {
2020-03-17 11:05:05 -08:00
window.require('electron').shell.openExternal(ev.currentTarget.href);
ev.preventDefault();
}}
2020-03-17 11:05:05 -08:00
href={this.props.updateReleaseUrl!}
>
Download
</a>
)}
.{' '}
2016-07-13 12:44:24 -08:00
</Notification>
)}
{this.props.customChildren}
<style jsx>{`
.notifications_view {
position: fixed;
bottom: 20px;
right: 20px;
}
`}</style>
</div>
);
2016-07-13 12:44:24 -08:00
}
}