-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
persist the chat embed throughout site navigation
Closes #212
- Loading branch information
Showing
18 changed files
with
257 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import React from 'react'; | ||
import { Router } from 'react-router-dom'; | ||
import PropTypes from 'prop-types'; | ||
import { compose } from 'redux'; | ||
import { connect } from 'react-redux'; | ||
import history from '../history'; | ||
import Routes from '../routes'; | ||
import ChatEmbed from './ChatEmbed'; | ||
import Resizeable from './Resizeable'; | ||
import idx from 'idx'; | ||
|
||
import Header from './Header'; | ||
import Footer from './Footer'; | ||
|
||
import '../css/Stream'; | ||
|
||
import { | ||
setChatSize, | ||
showChat, | ||
} from '../actions'; | ||
|
||
export const RoutesWithChat = ({showHeader, showFooter, setChatSize, showLeftChat=false, chatClosed, chatSize}) => | ||
{ | ||
let left = ( | ||
<div className='flex-shrink-0 stream-embed' style={{ width: chatClosed ? '100%' : `calc(100% - ${chatSize}px)` , display: 'flex', flexDirection: 'column'}}> | ||
<Routes /> | ||
{showFooter ? <Footer /> : null} | ||
</div> | ||
); | ||
let right = chatClosed ? null : ( | ||
<div className='chat-embed' style={{ width: chatSize, height: "inherit"}}> | ||
<ChatEmbed onClose={() => showChat(false)} /> | ||
</div> | ||
); | ||
|
||
|
||
if (showLeftChat) { | ||
const temp = left; | ||
left = right; | ||
right = temp; | ||
} | ||
|
||
return ( | ||
<div style={{height: "100%"}}> | ||
<Router history={history}> | ||
<div style={{height: "100%", display: 'flex', flexDirection: 'column'}}> | ||
{showHeader ? <Header history={history} /> : null} | ||
<Resizeable | ||
className='flex-grow-1 flex-column flex-lg-row' | ||
onResize={e => { | ||
let newChatSize; | ||
if (showLeftChat) { | ||
newChatSize = e.pageX; | ||
} | ||
else { | ||
newChatSize = window.innerWidth - e.pageX; | ||
} | ||
setChatSize(newChatSize); | ||
}}> | ||
{left} | ||
{right} | ||
</Resizeable> | ||
</div> | ||
</Router> | ||
</div> | ||
); | ||
}; | ||
|
||
RoutesWithChat.propTypes = { | ||
showHeader: PropTypes.bool, | ||
showFooter: PropTypes.bool, | ||
showLeftChat: PropTypes.bool, | ||
chatClosed: PropTypes.bool, | ||
|
||
chatSize: PropTypes.number.isRequired, | ||
|
||
setChatSize: PropTypes.func.isRequired, | ||
showChat: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default compose( | ||
connect( | ||
state => ({ | ||
showHeader: state.ui.showHeader, | ||
showFooter: state.ui.showFooter, | ||
chatSize: state.ui.chatSize, | ||
showLeftChat: idx(state, _ => _.self.profile.data.left_chat), | ||
chatClosed: !state.ui.showChat, | ||
}), | ||
{ | ||
setChatSize, | ||
showChat, | ||
}, | ||
), | ||
)(RoutesWithChat); |
Oops, something went wrong.