From bc3c3935b479060edb04153bca388656af797e79 Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Sun, 16 Jul 2023 09:50:55 +0530 Subject: [PATCH] notifications and style-sheet > function component --- lib/components/notifications.tsx | 224 +++++++++++++++---------------- lib/components/style-sheet.tsx | 40 +++--- 2 files changed, 131 insertions(+), 133 deletions(-) diff --git a/lib/components/notifications.tsx b/lib/components/notifications.tsx index da63a70e..f9e71de7 100644 --- a/lib/components/notifications.tsx +++ b/lib/components/notifications.tsx @@ -7,126 +7,124 @@ import type {NotificationsProps} from '../hyper'; const Notification = decorate(Notification_, 'Notification'); -export default class Notifications extends React.PureComponent { - render() { - return ( -
- {this.props.customChildrenBefore} - {this.props.fontShowing && ( - - )} +const Notifications: React.FC = (props) => { + return ( +
+ {props.customChildrenBefore} + {props.fontShowing && ( + + )} - {this.props.resizeShowing && ( - - )} + {props.resizeShowing && ( + + )} - {this.props.messageShowing && ( - - {this.props.messageURL - ? [ - this.props.messageText, - ' (', - { - void window.require('electron').shell.openExternal(ev.currentTarget.href); - ev.preventDefault(); - }} - href={this.props.messageURL} - > - more - , - ') ' - ] - : null} - - )} - - {this.props.updateShowing && ( - - Version {this.props.updateVersion} ready. - {this.props.updateNote && ` ${this.props.updateNote.trim().replace(/\.$/, '')}`} ( - { - void window.require('electron').shell.openExternal(ev.currentTarget.href); - ev.preventDefault(); - }} - href={`https://github.com/vercel/hyper/releases/tag/${this.props.updateVersion}`} - > - notes - - ).{' '} - {this.props.updateCanInstall ? ( + {props.messageShowing && ( + + {props.messageURL ? ( + <> + {props.messageText} ( - Restart - - ) : ( - { void window.require('electron').shell.openExternal(ev.currentTarget.href); ev.preventDefault(); }} - href={this.props.updateReleaseUrl!} + href={props.messageURL} > - Download + more - )} - .{' '} - - )} - {this.props.customChildren} + ) + + ) : null} + + )} - -
- ); - } -} + {props.updateShowing && ( + + Version {props.updateVersion} ready. + {props.updateNote && ` ${props.updateNote.trim().replace(/\.$/, '')}`} ( + { + void window.require('electron').shell.openExternal(ev.currentTarget.href); + ev.preventDefault(); + }} + href={`https://github.com/vercel/hyper/releases/tag/${props.updateVersion}`} + > + notes + + ).{' '} + {props.updateCanInstall ? ( + + Restart + + ) : ( + { + void window.require('electron').shell.openExternal(ev.currentTarget.href); + ev.preventDefault(); + }} + href={props.updateReleaseUrl!} + > + Download + + )} + .{' '} + + )} + {props.customChildren} + + +
+ ); +}; + +export default Notifications; diff --git a/lib/components/style-sheet.tsx b/lib/components/style-sheet.tsx index 4cb0fdd3..f8079740 100644 --- a/lib/components/style-sheet.tsx +++ b/lib/components/style-sheet.tsx @@ -1,24 +1,24 @@ import React from 'react'; import type {StyleSheetProps} from '../hyper'; -export default class StyleSheet extends React.PureComponent { - render() { - const {borderColor} = this.props; +const StyleSheet: React.FC = (props) => { + const {borderColor} = props; - return ( - - ); - } -} + return ( + + ); +}; + +export default StyleSheet;