mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Added close handling for popup notification with icon
no issue - Adds close handling for popup notification with close icon
This commit is contained in:
parent
9936dd19ae
commit
a061771138
1 changed files with 19 additions and 8 deletions
|
@ -72,12 +72,12 @@ export const PopupNotificationStyles = `
|
|||
}
|
||||
`;
|
||||
|
||||
const CloseButton = ({hide = false}) => {
|
||||
const CloseButton = ({hide = false, onClose}) => {
|
||||
if (hide) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<CloseIcon className='closeicon' alt='Close' />
|
||||
<CloseIcon className='closeicon' alt='Close' onClick={onClose}/>
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -121,6 +121,12 @@ export default class PopupNotification extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
closeNotification(e) {
|
||||
this.setState({
|
||||
className: 'slideout'
|
||||
});
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
const {popupNotification} = this.context;
|
||||
if (popupNotification.count !== this.state.count) {
|
||||
|
@ -133,9 +139,14 @@ export default class PopupNotification extends React.Component {
|
|||
if (popupNotification.autoHide) {
|
||||
const {duration = 2400} = popupNotification;
|
||||
this.timeoutId = setTimeout(() => {
|
||||
this.setState({
|
||||
className: 'slideout',
|
||||
notificationCount: popupNotification.count
|
||||
this.setState((state) => {
|
||||
if (state.className !== 'slideout') {
|
||||
return {
|
||||
className: 'slideout',
|
||||
notificationCount: popupNotification.count
|
||||
}
|
||||
}
|
||||
return {};
|
||||
});
|
||||
}, duration);
|
||||
} else {
|
||||
|
@ -164,7 +175,7 @@ export default class PopupNotification extends React.Component {
|
|||
return (
|
||||
<div className={`gh-portal-popupnotification${statusClass}${slideClass}`} onAnimationEnd={e => this.onAnimationEnd(e)}>
|
||||
<NotificationText type={type} status={status} />
|
||||
<CloseButton hide={!closeable} />
|
||||
<CloseButton hide={!closeable} onClose={e => this.closeNotification(e)}/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue