bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/modal/simple/component.jsx

71 lines
1.8 KiB
React
Raw Normal View History

import React, { Component } from 'react';
import PropTypes from 'prop-types';
2017-10-11 06:08:51 +08:00
import cx from 'classnames';
import Button from '/imports/ui/components/button/component';
2017-10-11 06:08:51 +08:00
import ModalBase, { withModalState } from '../base/component';
2018-01-08 14:17:18 +08:00
import { styles } from './styles';
const propTypes = {
title: PropTypes.string,
dismiss: PropTypes.shape({
callback: PropTypes.func,
label: PropTypes.string.isRequired,
description: PropTypes.string,
}),
};
const defaultProps = {
2017-04-19 03:06:51 +08:00
shouldCloseOnOverlayClick: true,
overlayClassName: styles.overlay,
dismiss: {
2017-04-19 03:06:51 +08:00
label: 'Cancel',
description: 'Disregards changes and closes the modal',
},
};
class ModalSimple extends Component {
render() {
const {
title,
hideBorder,
dismiss,
2017-04-19 03:06:51 +08:00
className,
modalisOpen,
2019-01-11 06:58:42 +08:00
onRequestClose,
2017-10-11 06:08:51 +08:00
...otherProps
} = this.props;
return (
2017-04-19 03:06:51 +08:00
<ModalBase
isOpen={modalisOpen}
className={cx(className, styles.modal)}
2019-01-11 06:58:42 +08:00
onRequestClose={onRequestClose}
2017-04-19 03:06:51 +08:00
contentLabel={title}
{...otherProps}
>
2018-12-22 02:53:21 +08:00
<header className={hideBorder ? styles.headerNoBorder : styles.header}>
<h1 className={styles.title}>{title}</h1>
2017-04-19 03:06:51 +08:00
<Button
className={styles.dismiss}
label={dismiss.label}
icon="close"
2017-10-11 06:08:51 +08:00
circle
hideLabel
2019-01-11 06:58:42 +08:00
onClick={onRequestClose}
aria-describedby="modalDismissDescription"
2017-10-11 06:08:51 +08:00
/>
2018-12-22 02:53:21 +08:00
</header>
<div className={styles.content}>
{this.props.children}
</div>
2017-07-06 23:32:11 +08:00
<div id="modalDismissDescription" hidden>{confirm.description}</div>
2017-04-19 03:06:51 +08:00
</ModalBase>
);
}
2017-10-11 06:08:51 +08:00
}
ModalSimple.propTypes = propTypes;
ModalSimple.defaultProps = defaultProps;
2017-04-19 03:06:51 +08:00
export default withModalState(ModalSimple);