mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-14 14:21:23 +00:00
@@ -1,20 +1,7 @@
|
||||
import React from 'react';
|
||||
import { css } from 'glamor';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import Toast from './toast';
|
||||
|
||||
const wrapperClass = css({
|
||||
maxWidth: 560,
|
||||
margin: '0 auto',
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
position: 'fixed',
|
||||
zIndex: 999999,
|
||||
});
|
||||
|
||||
|
||||
const hasCustomId = settings => Object.hasOwnProperty.call(settings, 'id');
|
||||
|
||||
export default class ToastManager extends React.PureComponent {
|
||||
@@ -83,12 +70,22 @@ export default class ToastManager extends React.PureComponent {
|
||||
const uniqueId = ++ToastManager.idCounter;
|
||||
const id = hasCustomId(settings) ? `${settings.id}-${uniqueId}` : uniqueId;
|
||||
|
||||
let hasCloseButton = settings.hasCloseButton || true;
|
||||
let duration = settings.duration || 2;
|
||||
if (settings.hasCloseButton !== undefined) {
|
||||
hasCloseButton = settings.hasCloseButton;
|
||||
}
|
||||
|
||||
if (settings.duration !== undefined) {
|
||||
duration = settings.duration;
|
||||
}
|
||||
|
||||
return {
|
||||
id,
|
||||
title,
|
||||
description: settings.description,
|
||||
hasCloseButton: settings.hasCloseButton || true,
|
||||
duration: settings.duration || 2,
|
||||
hasCloseButton: hasCloseButton,
|
||||
duration: duration,
|
||||
close: () => this.closeToast(id),
|
||||
intent: settings.intent
|
||||
};
|
||||
@@ -124,7 +121,7 @@ export default class ToastManager extends React.PureComponent {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<span className={wrapperClass}>
|
||||
<div className="seahub-toast-manager">
|
||||
{this.state.toasts.map(({ id, description, ...props }) => {
|
||||
return (
|
||||
<Toast key={id} onRemove={() => this.removeToast(id)} {...props}>
|
||||
@@ -132,7 +129,7 @@ export default class ToastManager extends React.PureComponent {
|
||||
</Toast>
|
||||
);
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user