bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/modals/BaseModal.jsx

98 lines
2.5 KiB
React
Raw Normal View History

2016-05-06 05:14:39 +08:00
import React from 'react';
import Modal from 'react-modal';
import Icon from '/imports/ui/components/icon/component';
import Button from '/imports/ui/components/button/component';
2016-05-07 01:46:14 +08:00
import styles from './styles';
import classNames from 'classnames';
2016-05-06 05:14:39 +08:00
const customStyles = {
overlay: {
zIndex: 1000,
},
content: {
top: '50%',
left: '50%',
right: 'auto',
bottom: 'auto',
marginRight: '-50%',
transform: 'translate(-50%, -50%)',
},
};
export default class BaseModal extends React.Component {
constructor(props) {
super(props);
this.state = {
modalIsOpen: false,
title: props.title || 'title',
content: <div>hello</div>,
};
this.openModal = this.openModal.bind(this);
this.closeModal = this.closeModal.bind(this);
this.handleModalCloseRequest = this.handleModalCloseRequest.bind(this);
this.handleSaveClicked = this.handleSaveClicked.bind(this);
this.afterOpenModal = this.afterOpenModal.bind(this);
this.setTitle = this.setTitle.bind(this);
}
setTitle(title) {
this.setState({ title: title });
}
openModal() {
this.setState({ modalIsOpen: true });
}
closeModal() {
this.setState({ modalIsOpen: false });
}
2016-05-07 01:46:14 +08:00
afterOpenModal() {}
2016-05-06 05:14:39 +08:00
handleModalCloseRequest() {
// opportunity to validate something and keep the modal open even if it
// requested to be closed
this.setState({ modalIsOpen: false });
}
handleSaveClicked(e) {
alert('Save button was clicked');
}
getContent() {
return (<div>parent content</div>);
}
render() {
return (
<span>
<Modal
isOpen={this.state.modalIsOpen}
onAfterOpen={this.afterOpenModal}
onRequestClose={this.closeModal}
shouldCloseOnOverlayClick={false}
style={customStyles} >
2016-05-13 00:10:43 +08:00
<span className={classNames(styles.modalHeaderTitle, 'largeFont')}>
{this.state.title}
</span>
2016-05-07 01:46:14 +08:00
<span className={styles.modalHeaderButtonContainer}>
2016-05-13 00:10:43 +08:00
<button className={classNames(styles.modalButton, styles.close)}
onClick={this.closeModal}>
Cancel
</button>
<button className={classNames(styles.modalButton, styles.done)}
onClick={this.closeModal}>
Done
</button>
2016-05-06 05:14:39 +08:00
</span>
2016-05-07 01:46:14 +08:00
<hr className={styles.modalHorizontalRule} />
2016-05-06 05:14:39 +08:00
<div>
{this.getContent()}
</div>
</Modal>
</span>
);
}
};