1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-14 14:21:23 +00:00

12.0 remove glamor (#6256)

* remove glamor

* change toaster style
This commit is contained in:
Michael An
2024-06-25 16:46:29 +08:00
committed by GitHub
parent 544ebe7fe6
commit 939c85d3c1
7 changed files with 183 additions and 398 deletions

View File

@@ -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>
);
}
}