bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/app/component.jsx

174 lines
3.7 KiB
React
Raw Normal View History

2016-04-29 03:02:51 +08:00
import React, { Component, PropTypes } from 'react';
2017-03-17 00:52:43 +08:00
import _ from 'lodash';
import { defineMessages, injectIntl } from 'react-intl';
import NotificationsBarContainer from '../notifications-bar/container';
import AudioNotificationContainer from '../audio-notification/container';
import ChatNotificationContainer from '../chat/notification/container';
2016-07-29 03:48:26 +08:00
import Button from '../button/component';
2016-05-03 06:42:54 +08:00
import styles from './styles';
import cx from 'classnames';
2016-04-29 03:02:51 +08:00
const intlMessages = defineMessages({
userListLabel: {
id: 'app.userlist.Label',
},
chatLabel: {
id: 'app.chat.Label',
},
mediaLabel: {
id: 'app.media.Label',
},
actionsbarLabel: {
id: 'app.actionsBar.Label',
},
});
2016-04-29 03:02:51 +08:00
const propTypes = {
2017-03-10 03:50:21 +08:00
init: PropTypes.func.isRequired,
fontSize: PropTypes.string,
2016-04-29 03:02:51 +08:00
navbar: PropTypes.element,
sidebar: PropTypes.element,
media: PropTypes.element,
actionsbar: PropTypes.element,
modal: PropTypes.element,
};
const defaultProps = {
fontSize: '16px',
2016-04-29 03:02:51 +08:00
};
class App extends Component {
2016-09-15 01:48:50 +08:00
constructor(props) {
super(props);
2017-03-10 03:50:21 +08:00
2016-09-15 01:48:50 +08:00
this.state = {
compactUserList: false, //TODO: Change this on userlist resize (?)
};
2017-03-17 00:52:43 +08:00
props.init.call(this);
}
componentDidMount() {
document.getElementsByTagName('html')[0].style.fontSize = this.props.fontSize;
2016-09-15 01:48:50 +08:00
}
renderNavBar() {
2016-04-29 03:02:51 +08:00
const { navbar } = this.props;
2017-03-17 00:52:43 +08:00
if (!navbar) return null;
2016-04-29 03:02:51 +08:00
2017-03-17 00:52:43 +08:00
return (
<header className={styles.navbar}>
2017-03-17 00:52:43 +08:00
{navbar}
</header>
2017-03-17 00:52:43 +08:00
);
2016-04-29 03:02:51 +08:00
}
renderSidebar() {
const { sidebar } = this.props;
2016-04-29 03:02:51 +08:00
2017-03-17 00:52:43 +08:00
if (!sidebar) return null;
2016-04-29 03:02:51 +08:00
2017-03-17 00:52:43 +08:00
return (
<aside className={styles.sidebar}>
{sidebar}
</aside>
);
2016-04-29 03:02:51 +08:00
}
renderUserList() {
let { userList, intl } = this.props;
2016-09-15 01:48:50 +08:00
const { compactUserList } = this.state;
if (!userList) return;
2016-09-15 01:48:50 +08:00
let userListStyle = {};
userListStyle[styles.compact] = compactUserList;
userList = React.cloneElement(userList, {
compact: compactUserList,
});
return (
<nav
className={cx(styles.userList, userListStyle)}
aria-label={intl.formatMessage(intlMessages.userListLabel)}>
{userList}
</nav>
);
}
renderChat() {
const { chat, intl } = this.props;
2017-03-17 00:52:43 +08:00
if (!chat) return null;
2017-03-17 00:52:43 +08:00
return (
<section
className={styles.chat}
2017-03-28 05:57:05 +08:00
role="region"
aria-label={intl.formatMessage(intlMessages.chatLabel)}>
{chat}
</section>
2017-03-17 00:52:43 +08:00
);
}
2016-04-29 03:02:51 +08:00
renderMedia() {
const { media, intl } = this.props;
2016-04-29 03:02:51 +08:00
2017-03-17 00:52:43 +08:00
if (!media) return null;
2016-04-29 03:02:51 +08:00
2017-03-17 00:52:43 +08:00
return (
<section
className={styles.media}
role="region"
aria-label={intl.formatMessage(intlMessages.mediaLabel)}>
{media}
</section>
2017-03-17 00:52:43 +08:00
);
}
renderActionsBar() {
const { actionsbar, intl } = this.props;
2016-04-29 03:02:51 +08:00
2017-03-17 00:52:43 +08:00
if (!actionsbar) return null;
2016-04-29 03:02:51 +08:00
2016-05-12 04:43:07 +08:00
return (
<section
className={styles.actionsbar}
role="region"
aria-label={intl.formatMessage(intlMessages.actionsbarLabel)}>
{actionsbar}
</section>
2016-05-12 04:43:07 +08:00
);
}
2016-04-29 03:02:51 +08:00
render() {
const { modal, params } = this.props;
2016-04-29 03:02:51 +08:00
return (
2016-05-03 06:42:54 +08:00
<main className={styles.main}>
<AudioNotificationContainer />
<NotificationsBarContainer />
2016-05-03 06:42:54 +08:00
<section className={styles.wrapper}>
{this.renderUserList()}
{this.renderChat()}
2016-05-03 06:42:54 +08:00
<div className={styles.content}>
{this.renderNavBar()}
2016-04-29 03:02:51 +08:00
{this.renderMedia()}
{this.renderActionsBar()}
2016-04-29 03:02:51 +08:00
</div>
{this.renderSidebar()}
2016-04-29 03:02:51 +08:00
</section>
2017-03-17 00:52:43 +08:00
{modal}
<audio id="remote-media" autoPlay="autoplay"></audio>
<ChatNotificationContainer currentChatID={params.chatID} />
2016-04-29 03:02:51 +08:00
</main>
);
}
}
App.propTypes = propTypes;
App.defaultProps = defaultProps;
export default injectIntl(App);