Skip to content

Commit 9a8a9a4

Browse files
committed
track RHS collapse state, and implement a basic responsive design
1 parent b05f334 commit 9a8a9a4

2 files changed

Lines changed: 53 additions & 11 deletions

File tree

‎src/skins/vector/views/organisms/RightPanel.js‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ limitations under the License.
1818

1919
var React = require('react');
2020
var sdk = require('matrix-react-sdk')
21+
var dis = require('matrix-react-sdk/lib/dispatcher');
2122

2223
module.exports = React.createClass({
2324
displayName: 'RightPanel',
2425

2526
Phase : {
26-
Blank: 'Blank',
27-
None: 'None',
2827
MemberList: 'MemberList',
2928
FileList: 'FileList',
3029
},
@@ -36,18 +35,24 @@ module.exports = React.createClass({
3635
},
3736

3837
onMemberListButtonClick: function() {
39-
if (this.state.phase == this.Phase.None) {
40-
this.setState({ phase: this.Phase.MemberList });
38+
if (this.props.collapsed) {
39+
this.setState({ phase: this.Phase.MemberList });
40+
dis.dispatch({
41+
action: 'show_right_panel',
42+
});
4143
}
4244
else {
43-
this.setState({ phase: this.Phase.None });
45+
dis.dispatch({
46+
action: 'hide_right_panel',
47+
});
4448
}
4549
},
4650

4751
render: function() {
4852
var MemberList = sdk.getComponent('organisms.MemberList');
4953
var buttonGroup;
5054
var panel;
55+
5156
if (this.props.roomId) {
5257
buttonGroup =
5358
<div className="mx_RightPanel_headerButtonGroup">
@@ -59,13 +64,13 @@ module.exports = React.createClass({
5964
</div>
6065
</div>;
6166

62-
if (this.state.phase == this.Phase.MemberList) {
67+
if (!this.props.collapsed && this.state.phase == this.Phase.MemberList) {
6368
panel = <MemberList roomId={this.props.roomId} key={this.props.roomId} />
6469
}
6570
}
6671

6772
var classes = "mx_RightPanel";
68-
if (this.state.phase === this.Phase.None) {
73+
if (this.props.collapsed) {
6974
classes += " collapsed";
7075
}
7176

‎src/skins/vector/views/pages/MatrixChat.js‎

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,43 @@ module.exports = React.createClass({
3131
displayName: 'MatrixChat',
3232
mixins: [MatrixChatController],
3333

34+
getInitialState: function() {
35+
return {
36+
width: 10000,
37+
}
38+
},
39+
40+
componentDidMount: function() {
41+
window.addEventListener('resize', this.handleResize);
42+
this.handleResize();
43+
},
44+
45+
componentWillUnmount: function() {
46+
window.removeEventListener('resize', this.handleResize);
47+
},
48+
49+
handleResize: function(e) {
50+
var hideLhsThreshold = 1000;
51+
var showLhsThreshold = 1000;
52+
var hideRhsThreshold = 820;
53+
var showRhsThreshold = 820;
54+
55+
if (this.state.width > hideLhsThreshold && window.innerWidth <= hideLhsThreshold) {
56+
dis.dispatch({ action: 'hide_left_panel' });
57+
}
58+
if (this.state.width <= showLhsThreshold && window.innerWidth > showLhsThreshold) {
59+
dis.dispatch({ action: 'show_left_panel' });
60+
}
61+
if (this.state.width > hideRhsThreshold && window.innerWidth <= hideRhsThreshold) {
62+
dis.dispatch({ action: 'hide_right_panel' });
63+
}
64+
if (this.state.width <= showRhsThreshold && window.innerWidth > showRhsThreshold) {
65+
dis.dispatch({ action: 'show_right_panel' });
66+
}
67+
68+
this.setState({width: window.innerWidth});
69+
},
70+
3471
onRoomCreated: function(room_id) {
3572
dis.dispatch({
3673
action: "view_room",
@@ -57,19 +94,19 @@ module.exports = React.createClass({
5794
switch (this.state.page_type) {
5895
case this.PageTypes.RoomView:
5996
page_element = <RoomView roomId={this.state.currentRoom} key={this.state.currentRoom} />
60-
right_panel = <RightPanel roomId={this.state.currentRoom} />
97+
right_panel = <RightPanel roomId={this.state.currentRoom} collapsed={this.state.collapse_rhs} />
6198
break;
6299
case this.PageTypes.UserSettings:
63100
page_element = <UserSettings />
64-
right_panel = <RightPanel/>
101+
right_panel = <RightPanel collapsed={this.state.collapse_rhs}/>
65102
break;
66103
case this.PageTypes.CreateRoom:
67104
page_element = <CreateRoom onRoomCreated={this.onRoomCreated}/>
68-
right_panel = <RightPanel/>
105+
right_panel = <RightPanel collapsed={this.state.collapse_rhs}/>
69106
break;
70107
case this.PageTypes.RoomDirectory:
71108
page_element = <RoomDirectory />
72-
right_panel = <RightPanel/>
109+
right_panel = <RightPanel collapsed={this.state.collapse_rhs}/>
73110
break;
74111
}
75112

0 commit comments

Comments
 (0)