2016-04-29 03:02:51 +08:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
2017-03-28 03:49:46 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2016-09-01 21:56:41 +08:00
|
|
|
|
2017-03-17 00:52:43 +08:00
|
|
|
import _ from 'lodash';
|
2016-09-01 21:56:41 +08:00
|
|
|
|
2017-04-19 03:06:51 +08:00
|
|
|
import ModalContainer from '../modal/container';
|
2017-04-29 00:15:29 +08:00
|
|
|
|
2016-08-10 00:28:16 +08:00
|
|
|
import NotificationsBarContainer from '../notifications-bar/container';
|
2017-03-25 00:38:49 +08:00
|
|
|
import AudioNotificationContainer from '../audio/audio-notification/container';
|
2017-03-28 04:40:44 +08:00
|
|
|
import AudioContainer from '../audio/container';
|
2017-03-17 03:57:45 +08:00
|
|
|
import ChatNotificationContainer from '../chat/notification/container';
|
2016-08-10 00:28:16 +08:00
|
|
|
|
2016-05-03 06:42:54 +08:00
|
|
|
import styles from './styles';
|
2016-08-25 02:56:06 +08:00
|
|
|
import cx from 'classnames';
|
2016-04-29 03:02:51 +08:00
|
|
|
|
2017-03-28 03:49:46 +08:00
|
|
|
const intlMessages = defineMessages({
|
|
|
|
userListLabel: {
|
|
|
|
id: 'app.userlist.Label',
|
2017-04-10 23:50:03 +08:00
|
|
|
description: 'Aria-label for Userlist Nav',
|
2017-03-28 03:49:46 +08:00
|
|
|
},
|
|
|
|
chatLabel: {
|
|
|
|
id: 'app.chat.Label',
|
2017-04-19 03:42:55 +08:00
|
|
|
description: 'Aria-label for Chat Section',
|
2017-03-28 03:49:46 +08:00
|
|
|
},
|
|
|
|
mediaLabel: {
|
|
|
|
id: 'app.media.Label',
|
2017-04-19 03:42:55 +08:00
|
|
|
description: 'Aria-label for Media Section',
|
2017-03-28 03:49:46 +08:00
|
|
|
},
|
|
|
|
actionsbarLabel: {
|
|
|
|
id: 'app.actionsBar.Label',
|
2017-04-19 03:42:55 +08:00
|
|
|
description: 'Aria-label for ActionsBar Section',
|
2017-03-28 03:49:46 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2016-04-29 03:02:51 +08:00
|
|
|
const propTypes = {
|
2017-03-17 03:57:45 +08:00
|
|
|
fontSize: PropTypes.string,
|
2016-04-29 03:02:51 +08:00
|
|
|
navbar: PropTypes.element,
|
|
|
|
sidebar: PropTypes.element,
|
|
|
|
media: PropTypes.element,
|
|
|
|
actionsbar: PropTypes.element,
|
2017-03-17 03:57:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
fontSize: '16px',
|
2016-04-29 03:02:51 +08:00
|
|
|
};
|
|
|
|
|
2017-03-28 03:49:46 +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-02-25 04:19:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
2017-03-17 03:57:45 +08:00
|
|
|
document.getElementsByTagName('html')[0].style.fontSize = this.props.fontSize;
|
2016-09-15 01:48:50 +08:00
|
|
|
}
|
|
|
|
|
2016-05-04 22:48:53 +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}>
|
|
|
|
{navbar}
|
|
|
|
</header>
|
|
|
|
);
|
2016-04-29 03:02:51 +08:00
|
|
|
}
|
|
|
|
|
2016-05-04 04:40:46 +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
|
|
|
}
|
|
|
|
|
2016-05-04 04:40:46 +08:00
|
|
|
renderUserList() {
|
2017-03-28 03:49:46 +08:00
|
|
|
let { userList, intl } = this.props;
|
2016-09-15 01:48:50 +08:00
|
|
|
const { compactUserList } = this.state;
|
2016-08-25 02:56:06 +08:00
|
|
|
|
2017-03-17 03:57:45 +08:00
|
|
|
if (!userList) return;
|
|
|
|
|
2016-09-15 01:48:50 +08:00
|
|
|
let userListStyle = {};
|
|
|
|
userListStyle[styles.compact] = compactUserList;
|
2017-03-17 03:57:45 +08:00
|
|
|
userList = React.cloneElement(userList, {
|
|
|
|
compact: compactUserList,
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
2017-03-28 03:49:46 +08:00
|
|
|
<nav
|
|
|
|
className={cx(styles.userList, userListStyle)}
|
|
|
|
aria-label={intl.formatMessage(intlMessages.userListLabel)}>
|
|
|
|
{userList}
|
2017-03-17 03:57:45 +08:00
|
|
|
</nav>
|
|
|
|
);
|
2016-05-04 04:40:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
renderChat() {
|
2017-03-28 03:49:46 +08:00
|
|
|
const { chat, intl } = this.props;
|
2016-05-04 04:40:46 +08:00
|
|
|
|
2017-03-17 00:52:43 +08:00
|
|
|
if (!chat) return null;
|
2016-05-04 04:40:46 +08:00
|
|
|
|
2017-03-17 00:52:43 +08:00
|
|
|
return (
|
2017-03-28 03:49:46 +08:00
|
|
|
<section
|
|
|
|
className={styles.chat}
|
2017-03-28 05:57:05 +08:00
|
|
|
role="region"
|
2017-03-28 03:49:46 +08:00
|
|
|
aria-label={intl.formatMessage(intlMessages.chatLabel)}>
|
|
|
|
{chat}
|
2017-03-17 00:52:43 +08:00
|
|
|
</section>
|
|
|
|
);
|
2016-05-04 04:40:46 +08:00
|
|
|
}
|
|
|
|
|
2016-04-29 03:02:51 +08:00
|
|
|
renderMedia() {
|
2017-03-28 03:49:46 +08:00
|
|
|
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 (
|
2017-03-28 03:49:46 +08:00
|
|
|
<section
|
|
|
|
className={styles.media}
|
|
|
|
role="region"
|
|
|
|
aria-label={intl.formatMessage(intlMessages.mediaLabel)}>
|
|
|
|
{media}
|
2017-03-17 00:52:43 +08:00
|
|
|
</section>
|
|
|
|
);
|
2016-07-23 08:12:31 +08:00
|
|
|
}
|
|
|
|
|
2016-05-04 22:48:53 +08:00
|
|
|
renderActionsBar() {
|
2017-03-28 03:49:46 +08:00
|
|
|
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 (
|
2017-03-28 03:49:46 +08:00
|
|
|
<section
|
|
|
|
className={styles.actionsbar}
|
|
|
|
role="region"
|
|
|
|
aria-label={intl.formatMessage(intlMessages.actionsbarLabel)}>
|
|
|
|
{actionsbar}
|
2017-03-17 00:52:43 +08:00
|
|
|
</section>
|
2016-05-12 04:43:07 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-01-14 07:57:29 +08:00
|
|
|
render() {
|
2017-03-17 03:57:45 +08:00
|
|
|
const { modal, params } = this.props;
|
2016-07-29 03:48:26 +08:00
|
|
|
|
2016-04-29 03:02:51 +08:00
|
|
|
return (
|
2016-05-03 06:42:54 +08:00
|
|
|
<main className={styles.main}>
|
2017-01-26 03:52:17 +08:00
|
|
|
<AudioNotificationContainer />
|
2016-08-10 00:28:16 +08:00
|
|
|
<NotificationsBarContainer />
|
2016-05-03 06:42:54 +08:00
|
|
|
<section className={styles.wrapper}>
|
2016-05-04 04:40:46 +08:00
|
|
|
{this.renderUserList()}
|
|
|
|
{this.renderChat()}
|
2016-05-03 06:42:54 +08:00
|
|
|
<div className={styles.content}>
|
2016-05-04 22:48:53 +08:00
|
|
|
{this.renderNavBar()}
|
2016-04-29 03:02:51 +08:00
|
|
|
{this.renderMedia()}
|
2016-05-04 22:48:53 +08:00
|
|
|
{this.renderActionsBar()}
|
2016-04-29 03:02:51 +08:00
|
|
|
</div>
|
2016-05-04 04:40:46 +08:00
|
|
|
{this.renderSidebar()}
|
2016-04-29 03:02:51 +08:00
|
|
|
</section>
|
2017-04-19 03:06:51 +08:00
|
|
|
<ModalContainer />
|
2017-03-28 04:40:44 +08:00
|
|
|
<AudioContainer />
|
2017-03-17 03:57:45 +08:00
|
|
|
<ChatNotificationContainer currentChatID={params.chatID} />
|
2016-04-29 03:02:51 +08:00
|
|
|
</main>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
App.propTypes = propTypes;
|
2017-03-17 03:57:45 +08:00
|
|
|
App.defaultProps = defaultProps;
|
2017-03-28 03:49:46 +08:00
|
|
|
export default injectIntl(App);
|