-
Notifications
You must be signed in to change notification settings - Fork 91
/
MiniModal.js
49 lines (43 loc) · 1.28 KB
/
MiniModal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React, { Component } from 'react';
import Modal from './index';
import { withRouter } from 'react-router-dom';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import './mini-modal.scss';
export class MiniModal extends Component {
static propTypes = {
closeRoute: PropTypes.string,
onClose: PropTypes.func,
children: PropTypes.node.isRequired,
title: PropTypes.string.isRequired,
centered: PropTypes.bool,
wide: PropTypes.bool,
};
onClose = () => {
if (this.props.onClose)
return this.props.onClose();
this.props.closeRoute
? this.props.history.push(this.props.closeRoute)
: this.props.history.goBack();
};
render() {
const names = classnames('mini-modal', {
'mini-modal--centered': this.props.centered,
'mini-modal--wide': this.props.wide,
});
return (
<Modal className={names} onClose={this.onClose}>
<div className="mini-modal__header">
<div className="mini-modal__title">
{this.props.title}
</div>
<div className="mini-modal__close" onClick={this.onClose} />
</div>
<div className="mini-modal__content">
{this.props.children}
</div>
</Modal>
)
}
}
export default withRouter(MiniModal);