import React, { Component, PropTypes } from 'react'; import { FormattedMessage } from 'react-intl'; 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'; import Button from '../button/component'; import styles from './styles'; import cx from 'classnames'; const intlMessages = defineMessages({ userListLabel: { id: 'app.userlist.Label', }, chatLabel: { id: 'app.chat.Label', }, mediaLabel: { id: 'app.media.Label', }, actionsbarLabel: { id: 'app.actionsBar.Label', }, }); const propTypes = { init: PropTypes.func.isRequired, fontSize: PropTypes.string, navbar: PropTypes.element, sidebar: PropTypes.element, media: PropTypes.element, actionsbar: PropTypes.element, modal: PropTypes.element, }; const defaultProps = { fontSize: '16px', }; class App extends Component { constructor(props) { super(props); this.state = { compactUserList: false, //TODO: Change this on userlist resize (?) }; props.init.call(this); } componentDidMount() { document.getElementsByTagName('html')[0].style.fontSize = this.props.fontSize; } renderNavBar() { const { navbar } = this.props; if (!navbar) return null; return ( {navbar} ); } renderSidebar() { const { sidebar } = this.props; if (!sidebar) return null; return ( ); } renderUserList() { let { userList, intl } = this.props; const { compactUserList } = this.state; if (!userList) return; let userListStyle = {}; userListStyle[styles.compact] = compactUserList; userList = React.cloneElement(userList, { compact: compactUserList, }); return ( {userList} ); } renderChat() { const { chat, intl } = this.props; if (!chat) return null; return ( {chat} ); } renderMedia() { const { media, intl } = this.props; if (!media) return null; return ( {media} ); } renderActionsBar() { const { actionsbar, intl } = this.props; if (!actionsbar) return null; return ( {actionsbar} ); } render() { const { modal, params } = this.props; return ( {this.renderUserList()} {this.renderChat()} {this.renderNavBar()} {this.renderMedia()} {this.renderActionsBar()} {this.renderSidebar()} {modal} ); } } App.propTypes = propTypes; App.defaultProps = defaultProps; export default injectIntl(App);