Skip to content

Commit b05f334

Browse files
committed
tooltipize BottomLeftMenu too for consistency
1 parent ae506b5 commit b05f334

7 files changed

Lines changed: 98 additions & 31 deletions

File tree

‎src/skins/vector/img/hide.png‎

-70 Bytes
Loading

‎src/skins/vector/skindex.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ skin['atoms.MessageTimestamp'] = require('./views/atoms/MessageTimestamp');
3535
skin['atoms.RoomAvatar'] = require('./views/atoms/RoomAvatar');
3636
skin['atoms.voip.VideoFeed'] = require('./views/atoms/voip/VideoFeed');
3737
skin['molecules.BottomLeftMenu'] = require('./views/molecules/BottomLeftMenu');
38+
skin['molecules.BottomLeftMenuTile'] = require('./views/molecules/BottomLeftMenuTile');
3839
skin['molecules.ChangeAvatar'] = require('./views/molecules/ChangeAvatar');
3940
skin['molecules.ChangeDisplayName'] = require('./views/molecules/ChangeDisplayName');
4041
skin['molecules.ChangePassword'] = require('./views/molecules/ChangePassword');

‎src/skins/vector/views/molecules/BottomLeftMenu.js‎

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
'use strict';
1818

1919
var React = require('react');
20-
20+
var sdk = require('matrix-react-sdk')
2121
var dis = require('matrix-react-sdk/lib/dispatcher');
2222

2323
module.exports = React.createClass({
@@ -35,28 +35,24 @@ module.exports = React.createClass({
3535
dis.dispatch({action: 'view_create_room'});
3636
},
3737

38+
getLabel: function(name) {
39+
if (!this.props.collapsed) {
40+
return <div className="mx_RoomTile_name">{name}</div>
41+
}
42+
else if (this.state.hover) {
43+
var RoomTooltip = sdk.getComponent("molecules.RoomTooltip");
44+
return <RoomTooltip name={name}/>;
45+
}
46+
},
47+
3848
render: function() {
49+
var BottomLeftMenuTile = sdk.getComponent('molecules.BottomLeftMenuTile');
3950
return (
4051
<div className="mx_BottomLeftMenu">
4152
<div className="mx_BottomLeftMenu_options">
42-
<div className="mx_RoomTile" onClick={this.onCreateRoomClick}>
43-
<div className="mx_RoomTile_avatar">
44-
<img src="img/create-big.png" alt="Create new room" title="Create new room" width="36" height="36"/>
45-
</div>
46-
<div className="mx_RoomTile_name">Create new room</div>
47-
</div>
48-
<div className="mx_RoomTile" onClick={this.onRoomDirectoryClick}>
49-
<div className="mx_RoomTile_avatar">
50-
<img src="img/directory-big.png" alt="Directory" title="Directory" width="36" height="36"/>
51-
</div>
52-
<div className="mx_RoomTile_name">Directory</div>
53-
</div>
54-
<div className="mx_RoomTile" onClick={this.onSettingsClick}>
55-
<div className="mx_RoomTile_avatar">
56-
<img src="img/settings-big.png" alt="Settings" title="Settings" width="36" height="36"/>
57-
</div>
58-
<div className="mx_RoomTile_name">Settings</div>
59-
</div>
53+
<BottomLeftMenuTile collapsed={ this.props.collapsed } img="img/create-big.png" label="Create new room" onClick={ this.onCreateRoomClick }/>
54+
<BottomLeftMenuTile collapsed={ this.props.collapsed } img="img/directory-big.png" label="Directory" onClick={ this.onRoomDirectoryClick }/>
55+
<BottomLeftMenuTile collapsed={ this.props.collapsed } img="img/settings-big.png" label="Settings" onClick={ this.onSettingsClick }/>
6056
</div>
6157
</div>
6258
);
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
Copyright 2015 OpenMarket Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
var React = require('react');
20+
var classNames = require('classnames');
21+
22+
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
23+
24+
var sdk = require('matrix-react-sdk')
25+
26+
module.exports = React.createClass({
27+
displayName: 'BottomLeftMenuTile',
28+
29+
getInitialState: function() {
30+
return( { hover : false });
31+
},
32+
33+
onMouseEnter: function() {
34+
this.setState( { hover : true });
35+
},
36+
37+
onMouseLeave: function() {
38+
this.setState( { hover : false });
39+
},
40+
41+
render: function() {
42+
var label;
43+
if (!this.props.collapsed) {
44+
label = <div className="mx_RoomTile_name">{ this.props.label }</div>;
45+
}
46+
else if (this.state.hover) {
47+
var RoomTooltip = sdk.getComponent("molecules.RoomTooltip");
48+
label = <RoomTooltip bottom={ true } label={ this.props.label }/>;
49+
}
50+
51+
return (
52+
<div className="mx_RoomTile" onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave} onClick={this.props.onClick}>
53+
<div className="mx_RoomTile_avatar">
54+
<img src={ this.props.img } width="36" height="36"/>
55+
</div>
56+
{ label }
57+
</div>
58+
);
59+
}
60+
});

‎src/skins/vector/views/molecules/RoomTile.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ module.exports = React.createClass({
7777
}
7878
else if (this.state.hover) {
7979
var RoomTooltip = sdk.getComponent("molecules.RoomTooltip");
80-
label = <RoomTooltip room={this.props.room} ref="roomTooltip"/>;
80+
label = <RoomTooltip room={this.props.room}/>;
8181
}
8282

8383
var RoomAvatar = sdk.getComponent('atoms.RoomAvatar');

‎src/skins/vector/views/molecules/RoomTooltip.js‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,35 @@ module.exports = React.createClass({
2828
displayName: 'RoomTooltip',
2929

3030
componentDidMount: function() {
31-
// tell the roomlist about us
32-
dis.dispatch({
33-
action: 'view_tooltip',
34-
tooltip: this.getDOMNode(),
35-
});
31+
if (!this.props.bottom) {
32+
// tell the roomlist about us so it can position us
33+
dis.dispatch({
34+
action: 'view_tooltip',
35+
tooltip: this.getDOMNode(),
36+
});
37+
}
38+
else {
39+
var tooltip = this.getDOMNode();
40+
tooltip.style.top = tooltip.parentElement.getBoundingClientRect().top + "px";
41+
tooltip.style.display = "block";
42+
}
3643
},
3744

3845
componentDidUnmount: function() {
39-
dis.dispatch({
40-
action: 'view_tooltip',
41-
tooltip: null,
42-
});
46+
if (!this.props.bottom) {
47+
dis.dispatch({
48+
action: 'view_tooltip',
49+
tooltip: null,
50+
});
51+
}
4352
},
4453

4554
render: function() {
55+
var label = this.props.room ? this.props.room.name : this.props.label;
4656
return (
4757
<div className="mx_RoomTooltip">
4858
<img className="mx_RoomTooltip_chevron" src="img/chevron-left.png" width="9" height="16"/>
49-
{ this.props.room.name }
59+
{ label }
5060
</div>
5161
);
5262
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module.exports = React.createClass({
4848
{ collapseButton }
4949
<IncomingCallBox />
5050
<RoomList selectedRoom={this.props.selectedRoom} collapsed={this.props.collapsed}/>
51-
<BottomLeftMenu />
51+
<BottomLeftMenu collapsed={this.props.collapsed}/>
5252
</aside>
5353
);
5454
}

0 commit comments

Comments
 (0)