1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-03 07:55:36 +00:00

Prop type check repair (#2919)

* repair intent check wraning

* change doublequote to singlequote, add semicolon

* optimized code

* modify type-check wraning
This commit is contained in:
杨顺强
2019-01-31 17:37:02 +08:00
committed by Daniel Pan
parent 06f25f05f2
commit e57701fa38
74 changed files with 714 additions and 700 deletions

View File

@@ -71,14 +71,14 @@ class Alert extends React.PureComponent {
getContainerStyle(intent) {
switch (intent) {
case 'success':
return { borderStyle: this.containerBorderSuccess, iconColor: css({color: 'rgb(71, 184, 129)'}), iconClass: 'fa fa-check-circle' };
case 'warning':
return { borderStyle: this.containerBorderWarn, iconColor: css({color: 'rgb(217, 130, 43)'}) , iconClass: 'fa fa-exclamation-triangle' };
case 'none':
return { borderStyle: this.containerBorderNotify, iconColor: css({color: 'rgb(16, 112, 202)'}), iconClass: 'fa fa-exclamation-circle' };
case 'danger':
return { borderStyle: this.containerBorderDanger, iconColor: css({color: 'rgb(236, 76, 71)'}), iconClass: 'fa fa-exclamation-circle' };
case 'success':
return { borderStyle: this.containerBorderSuccess, iconColor: css({color: 'rgb(71, 184, 129)'}), iconClass: 'fa fa-check-circle' };
case 'warning':
return { borderStyle: this.containerBorderWarn, iconColor: css({color: 'rgb(217, 130, 43)'}) , iconClass: 'fa fa-exclamation-triangle' };
case 'none':
return { borderStyle: this.containerBorderNotify, iconColor: css({color: 'rgb(16, 112, 202)'}), iconClass: 'fa fa-exclamation-circle' };
case 'danger':
return { borderStyle: this.containerBorderDanger, iconColor: css({color: 'rgb(236, 76, 71)'}), iconClass: 'fa fa-exclamation-circle' };
}
}

View File

@@ -40,9 +40,7 @@ const animationStyles = css({
height: 0,
transition: `all ${ANIMATION_DURATION}ms ${animationEasing.deceleration}`,
'&[data-state="entering"], &[data-state="entered"]': {
animation: `${openAnimation} ${ANIMATION_DURATION}ms ${
animationEasing.spring
} both`
animation: `${openAnimation} ${ANIMATION_DURATION}ms ${animationEasing.spring} both`
},
'&[data-state="exiting"]': {
animation: `${closeAnimation} 120ms ${animationEasing.acceleration} both`
@@ -51,45 +49,44 @@ const animationStyles = css({
export default class Toast extends React.PureComponent {
static propTypes = {
/**
* The z-index of the toast.
*/
/**
* The z-index of the toast.
*/
zIndex: PropTypes.number,
/**
* Duration of the toast.
*/
/**
* Duration of the toast.
*/
duration: PropTypes.number,
/**
* Function called when the toast is all the way closed.
*/
/**
* Function called when the toast is all the way closed.
*/
onRemove: PropTypes.func,
/**
* The type of the alert.
*/
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger'])
.isRequired,
/**
* The type of the alert.
*/
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger']).isRequired,
/**
* The title of the alert.
*/
/**
* The title of the alert.
*/
title: PropTypes.node,
/**
* Description of the alert.
*/
/**
* Description of the alert.
*/
children: PropTypes.node,
/**
* When true, show a close icon button inside of the toast.
*/
/**
* When true, show a close icon button inside of the toast.
*/
hasCloseButton: PropTypes.bool,
/**
* When false, will close the Toast and call onRemove when finished.
*/
/**
* When false, will close the Toast and call onRemove when finished.
*/
isShown: PropTypes.bool
}
@@ -104,7 +101,7 @@ export default class Toast extends React.PureComponent {
componentDidUpdate(prevProps) {
if (prevProps.isShown !== this.props.isShown) {
// eslint-disable-next-line react/no-did-update-set-state
// eslint-disable-next-line react/no-did-update-set-state
this.setState({
isShown: this.props.isShown
});
@@ -162,23 +159,23 @@ export default class Toast extends React.PureComponent {
render() {
return (
<Transition
appear
unmountOnExit
timeout={ANIMATION_DURATION}
in={this.state.isShown}
onExited={this.props.onRemove}
appear
unmountOnExit
timeout={ANIMATION_DURATION}
in={this.state.isShown}
onExited={this.props.onRemove}
>
{state => (
<div
data-state={state}
className={animationStyles}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
style={{
height: this.state.height,
zIndex: this.props.zIndex,
marginBottom: this.state.isShown ? 0 : -this.state.height
}}
data-state={state}
className={animationStyles}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
style={{
height: this.state.height,
zIndex: this.props.zIndex,
marginBottom: this.state.isShown ? 0 : -this.state.height
}}
>
<div ref={this.onRef} style={{ padding: 8 }}>
<Alert
@@ -190,7 +187,7 @@ export default class Toast extends React.PureComponent {
/>
</div>
</div>
)}
)}
</Transition>
);
}

View File

@@ -19,19 +19,19 @@ const hasCustomId = settings => Object.hasOwnProperty.call(settings, 'id');
export default class ToastManager extends React.PureComponent {
static propTypes = {
/**
* Function called with the `this.notify` function.
*/
/**
* Function called with the `this.notify` function.
*/
bindNotify: PropTypes.func.isRequired,
/**
* Function called with the `this.getToasts` function.
*/
/**
* Function called with the `this.getToasts` function.
*/
bindGetToasts: PropTypes.func.isRequired,
/**
* Function called with the `this.closeAll` function.
*/
/**
* Function called with the `this.closeAll` function.
*/
bindCloseAll: PropTypes.func.isRequired
}
@@ -58,10 +58,10 @@ export default class ToastManager extends React.PureComponent {
}
notify = (title, settings) => {
// If there's a custom toast ID passed, close existing toasts with the same custom ID
// If there's a custom toast ID passed, close existing toasts with the same custom ID
if (hasCustomId(settings)) {
for (const toast of this.state.toasts) {
// Since unique ID is still appended to a custom ID, skip the unique ID and check only prefix
// Since unique ID is still appended to a custom ID, skip the unique ID and check only prefix
if (String(toast.id).startsWith(settings.id)) {
this.closeToast(toast.id);
}
@@ -94,10 +94,10 @@ export default class ToastManager extends React.PureComponent {
};
}
/**
* This will set isShown on the Toast which will close the toast.
* It won't remove the toast until onExited triggers onRemove.
*/
/**
* This will set isShown on the Toast which will close the toast.
* It won't remove the toast until onExited triggers onRemove.
*/
closeToast = id => {
this.setState(previousState => {
return {

View File

@@ -19,9 +19,9 @@ export default class Toaster {
ReactDOM.render(
<ToastManager
bindNotify={this._bindNotify}
bindGetToasts={this._bindGetToasts}
bindCloseAll={this._bindCloseAll}
bindNotify={this._bindNotify}
bindGetToasts={this._bindGetToasts}
bindCloseAll={this._bindCloseAll}
/>,
container
);