forked from matrix/element-web
track RHS collapse state, and implement a basic responsive design
This commit is contained in:
parent
b05f3343e2
commit
9a8a9a4ce4
|
@ -18,13 +18,12 @@ limitations under the License.
|
||||||
|
|
||||||
var React = require('react');
|
var React = require('react');
|
||||||
var sdk = require('matrix-react-sdk')
|
var sdk = require('matrix-react-sdk')
|
||||||
|
var dis = require('matrix-react-sdk/lib/dispatcher');
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'RightPanel',
|
displayName: 'RightPanel',
|
||||||
|
|
||||||
Phase : {
|
Phase : {
|
||||||
Blank: 'Blank',
|
|
||||||
None: 'None',
|
|
||||||
MemberList: 'MemberList',
|
MemberList: 'MemberList',
|
||||||
FileList: 'FileList',
|
FileList: 'FileList',
|
||||||
},
|
},
|
||||||
|
@ -36,11 +35,16 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onMemberListButtonClick: function() {
|
onMemberListButtonClick: function() {
|
||||||
if (this.state.phase == this.Phase.None) {
|
if (this.props.collapsed) {
|
||||||
this.setState({ phase: this.Phase.MemberList });
|
this.setState({ phase: this.Phase.MemberList });
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'show_right_panel',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.setState({ phase: this.Phase.None });
|
dis.dispatch({
|
||||||
|
action: 'hide_right_panel',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -48,6 +52,7 @@ module.exports = React.createClass({
|
||||||
var MemberList = sdk.getComponent('organisms.MemberList');
|
var MemberList = sdk.getComponent('organisms.MemberList');
|
||||||
var buttonGroup;
|
var buttonGroup;
|
||||||
var panel;
|
var panel;
|
||||||
|
|
||||||
if (this.props.roomId) {
|
if (this.props.roomId) {
|
||||||
buttonGroup =
|
buttonGroup =
|
||||||
<div className="mx_RightPanel_headerButtonGroup">
|
<div className="mx_RightPanel_headerButtonGroup">
|
||||||
|
@ -59,13 +64,13 @@ module.exports = React.createClass({
|
||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
|
|
||||||
if (this.state.phase == this.Phase.MemberList) {
|
if (!this.props.collapsed && this.state.phase == this.Phase.MemberList) {
|
||||||
panel = <MemberList roomId={this.props.roomId} key={this.props.roomId} />
|
panel = <MemberList roomId={this.props.roomId} key={this.props.roomId} />
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var classes = "mx_RightPanel";
|
var classes = "mx_RightPanel";
|
||||||
if (this.state.phase === this.Phase.None) {
|
if (this.props.collapsed) {
|
||||||
classes += " collapsed";
|
classes += " collapsed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,43 @@ module.exports = React.createClass({
|
||||||
displayName: 'MatrixChat',
|
displayName: 'MatrixChat',
|
||||||
mixins: [MatrixChatController],
|
mixins: [MatrixChatController],
|
||||||
|
|
||||||
|
getInitialState: function() {
|
||||||
|
return {
|
||||||
|
width: 10000,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
componentDidMount: function() {
|
||||||
|
window.addEventListener('resize', this.handleResize);
|
||||||
|
this.handleResize();
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillUnmount: function() {
|
||||||
|
window.removeEventListener('resize', this.handleResize);
|
||||||
|
},
|
||||||
|
|
||||||
|
handleResize: function(e) {
|
||||||
|
var hideLhsThreshold = 1000;
|
||||||
|
var showLhsThreshold = 1000;
|
||||||
|
var hideRhsThreshold = 820;
|
||||||
|
var showRhsThreshold = 820;
|
||||||
|
|
||||||
|
if (this.state.width > hideLhsThreshold && window.innerWidth <= hideLhsThreshold) {
|
||||||
|
dis.dispatch({ action: 'hide_left_panel' });
|
||||||
|
}
|
||||||
|
if (this.state.width <= showLhsThreshold && window.innerWidth > showLhsThreshold) {
|
||||||
|
dis.dispatch({ action: 'show_left_panel' });
|
||||||
|
}
|
||||||
|
if (this.state.width > hideRhsThreshold && window.innerWidth <= hideRhsThreshold) {
|
||||||
|
dis.dispatch({ action: 'hide_right_panel' });
|
||||||
|
}
|
||||||
|
if (this.state.width <= showRhsThreshold && window.innerWidth > showRhsThreshold) {
|
||||||
|
dis.dispatch({ action: 'show_right_panel' });
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({width: window.innerWidth});
|
||||||
|
},
|
||||||
|
|
||||||
onRoomCreated: function(room_id) {
|
onRoomCreated: function(room_id) {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: "view_room",
|
action: "view_room",
|
||||||
|
@ -57,19 +94,19 @@ module.exports = React.createClass({
|
||||||
switch (this.state.page_type) {
|
switch (this.state.page_type) {
|
||||||
case this.PageTypes.RoomView:
|
case this.PageTypes.RoomView:
|
||||||
page_element = <RoomView roomId={this.state.currentRoom} key={this.state.currentRoom} />
|
page_element = <RoomView roomId={this.state.currentRoom} key={this.state.currentRoom} />
|
||||||
right_panel = <RightPanel roomId={this.state.currentRoom} />
|
right_panel = <RightPanel roomId={this.state.currentRoom} collapsed={this.state.collapse_rhs} />
|
||||||
break;
|
break;
|
||||||
case this.PageTypes.UserSettings:
|
case this.PageTypes.UserSettings:
|
||||||
page_element = <UserSettings />
|
page_element = <UserSettings />
|
||||||
right_panel = <RightPanel/>
|
right_panel = <RightPanel collapsed={this.state.collapse_rhs}/>
|
||||||
break;
|
break;
|
||||||
case this.PageTypes.CreateRoom:
|
case this.PageTypes.CreateRoom:
|
||||||
page_element = <CreateRoom onRoomCreated={this.onRoomCreated}/>
|
page_element = <CreateRoom onRoomCreated={this.onRoomCreated}/>
|
||||||
right_panel = <RightPanel/>
|
right_panel = <RightPanel collapsed={this.state.collapse_rhs}/>
|
||||||
break;
|
break;
|
||||||
case this.PageTypes.RoomDirectory:
|
case this.PageTypes.RoomDirectory:
|
||||||
page_element = <RoomDirectory />
|
page_element = <RoomDirectory />
|
||||||
right_panel = <RightPanel/>
|
right_panel = <RightPanel collapsed={this.state.collapse_rhs}/>
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue