Skip to content

Commit e613382

Browse files
authored
Merge pull request element-hq#3804 from vector-im/dbkr/left_panel_for_newbies_2
Make left panel better for new users (mk II)
2 parents d1db602 + c27f397 commit e613382

7 files changed

Lines changed: 111 additions & 170 deletions

File tree

‎src/components/structures/BottomLeftMenu.js‎

Lines changed: 15 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright 2015, 2016 OpenMarket Ltd
3+
Copyright 2017 Vector Creations Ltd
34
45
Licensed under the Apache License, Version 2.0 (the "License");
56
you may not use this file except in compliance with the License.
@@ -14,13 +15,8 @@ See the License for the specific language governing permissions and
1415
limitations under the License.
1516
*/
1617

17-
'use strict';
18-
19-
var React = require('react');
20-
var ReactDOM = require('react-dom');
21-
var sdk = require('matrix-react-sdk')
22-
var dis = require('matrix-react-sdk/lib/dispatcher');
23-
var AccessibleButton = require('matrix-react-sdk/lib/components/views/elements/AccessibleButton');
18+
import React from 'react';
19+
import sdk from 'matrix-react-sdk';
2420

2521
module.exports = React.createClass({
2622
displayName: 'BottomLeftMenu',
@@ -30,121 +26,28 @@ module.exports = React.createClass({
3026
teamToken: React.PropTypes.string,
3127
},
3228

33-
getInitialState: function() {
34-
return({
35-
directoryHover : false,
36-
roomsHover : false,
37-
homeHover: false,
38-
peopleHover : false,
39-
settingsHover : false,
40-
});
41-
},
42-
43-
// Room events
44-
onDirectoryClick: function() {
45-
dis.dispatch({ action: 'view_room_directory' });
46-
},
47-
48-
onDirectoryMouseEnter: function() {
49-
this.setState({ directoryHover: true });
50-
},
51-
52-
onDirectoryMouseLeave: function() {
53-
this.setState({ directoryHover: false });
54-
},
55-
56-
onRoomsClick: function() {
57-
dis.dispatch({ action: 'view_create_room' });
58-
},
59-
60-
onRoomsMouseEnter: function() {
61-
this.setState({ roomsHover: true });
62-
},
63-
64-
onRoomsMouseLeave: function() {
65-
this.setState({ roomsHover: false });
66-
},
67-
68-
// Home button events
69-
onHomeClick: function() {
70-
dis.dispatch({ action: 'view_home_page' });
71-
},
72-
73-
onHomeMouseEnter: function() {
74-
this.setState({ homeHover: true });
75-
},
76-
77-
onHomeMouseLeave: function() {
78-
this.setState({ homeHover: false });
79-
},
80-
81-
// People events
82-
onPeopleClick: function() {
83-
dis.dispatch({ action: 'view_create_chat' });
84-
},
85-
86-
onPeopleMouseEnter: function() {
87-
this.setState({ peopleHover: true });
88-
},
89-
90-
onPeopleMouseLeave: function() {
91-
this.setState({ peopleHover: false });
92-
},
93-
94-
// Settings events
95-
onSettingsClick: function() {
96-
dis.dispatch({ action: 'view_user_settings' });
97-
},
98-
99-
onSettingsMouseEnter: function() {
100-
this.setState({ settingsHover: true });
101-
},
102-
103-
onSettingsMouseLeave: function() {
104-
this.setState({ settingsHover: false });
105-
},
106-
107-
// Get the label/tooltip to show
108-
getLabel: function(label, show) {
109-
if (show) {
110-
var RoomTooltip = sdk.getComponent("rooms.RoomTooltip");
111-
return <RoomTooltip className="mx_BottomLeftMenu_tooltip" label={label} />;
112-
}
113-
},
114-
11529
render: function() {
116-
var TintableSvg = sdk.getComponent('elements.TintableSvg');
30+
const HomeButton = sdk.getComponent('elements.HomeButton');
31+
const StartChatButton = sdk.getComponent('elements.StartChatButton');
32+
const RoomDirectoryButton = sdk.getComponent('elements.RoomDirectoryButton');
33+
const CreateRoomButton = sdk.getComponent('elements.CreateRoomButton');
34+
const SettingsButton = sdk.getComponent('elements.SettingsButton');
11735

11836
var homeButton;
11937
if (this.props.teamToken) {
120-
homeButton = (
121-
<AccessibleButton className="mx_BottomLeftMenu_homePage" onClick={ this.onHomeClick } onMouseEnter={ this.onHomeMouseEnter } onMouseLeave={ this.onHomeMouseLeave } >
122-
<TintableSvg src="img/icons-home.svg" width="25" height="25" />
123-
{ this.getLabel("Welcome page", this.state.homeHover) }
124-
</AccessibleButton>
125-
);
38+
homeButton = <HomeButton tooltip={true} />;
12639
}
12740

12841
return (
12942
<div className="mx_BottomLeftMenu">
13043
<div className="mx_BottomLeftMenu_options">
13144
{ homeButton }
132-
<AccessibleButton className="mx_BottomLeftMenu_people" onClick={ this.onPeopleClick } onMouseEnter={ this.onPeopleMouseEnter } onMouseLeave={ this.onPeopleMouseLeave } >
133-
<TintableSvg src="img/icons-people.svg" width="25" height="25" />
134-
{ this.getLabel("Start chat", this.state.peopleHover) }
135-
</AccessibleButton>
136-
<AccessibleButton className="mx_BottomLeftMenu_directory" onClick={ this.onDirectoryClick } onMouseEnter={ this.onDirectoryMouseEnter } onMouseLeave={ this.onDirectoryMouseLeave } >
137-
<TintableSvg src="img/icons-directory.svg" width="25" height="25"/>
138-
{ this.getLabel("Room directory", this.state.directoryHover) }
139-
</AccessibleButton>
140-
<AccessibleButton className="mx_BottomLeftMenu_createRoom" onClick={ this.onRoomsClick } onMouseEnter={ this.onRoomsMouseEnter } onMouseLeave={ this.onRoomsMouseLeave } >
141-
<TintableSvg src="img/icons-create-room.svg" width="25" height="25" />
142-
{ this.getLabel("Create new room", this.state.roomsHover) }
143-
</AccessibleButton>
144-
<AccessibleButton className="mx_BottomLeftMenu_settings" onClick={ this.onSettingsClick } onMouseEnter={ this.onSettingsMouseEnter } onMouseLeave={ this.onSettingsMouseLeave } >
145-
<TintableSvg src="img/icons-settings.svg" width="25" height="25" />
146-
{ this.getLabel("Settings", this.state.settingsHover) }
147-
</AccessibleButton>
45+
<StartChatButton tooltip={true} />
46+
<RoomDirectoryButton tooltip={true} />
47+
<CreateRoomButton tooltip={true} />
48+
<span className="mx_BottomLeftMenu_settings">
49+
<SettingsButton tooltip={true} />
50+
</span>
14851
</div>
14952
</div>
15053
);

‎src/components/structures/RoomSubList.js‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
Copyright 2017 Vector Creations Ltd
23
Copyright 2015, 2016 OpenMarket Ltd
34
45
Licensed under the Apache License, Version 2.0 (the "License");
@@ -83,6 +84,8 @@ var RoomSubList = React.createClass({
8384
incomingCall: React.PropTypes.object,
8485
onShowMoreRooms: React.PropTypes.func,
8586
searchFilter: React.PropTypes.string,
87+
emptyContent: React.PropTypes.node, // content shown if the list is empty
88+
headerItems: React.PropTypes.node, // content shown in the sublist header
8689
},
8790

8891
getInitialState: function() {
@@ -469,16 +472,15 @@ var RoomSubList = React.createClass({
469472

470473
render: function() {
471474
var connectDropTarget = this.props.connectDropTarget;
472-
var RoomDropTarget = sdk.getComponent('rooms.RoomDropTarget');
473475
var TruncatedList = sdk.getComponent('elements.TruncatedList');
474476

475477
var label = this.props.collapsed ? null : this.props.label;
476478

477-
//console.log("render: " + JSON.stringify(this.state.sortedList));
478-
479-
var target;
480-
if (this.state.sortedList.length == 0 && this.props.editable) {
481-
target = <RoomDropTarget label={ 'Drop here to ' + this.props.verb }/>;
479+
let content;
480+
if (this.state.sortedList.length == 0) {
481+
content = this.props.emptyContent;
482+
} else {
483+
content = this.makeRoomTiles();
482484
}
483485

484486
var roomCount = this.props.list.length > 0 ? this.props.list.length : '';
@@ -498,8 +500,7 @@ var RoomSubList = React.createClass({
498500
if (!this.state.hidden) {
499501
subList = <TruncatedList className={ classes } truncateAt={this.state.truncateAt}
500502
createOverflowElement={this._createOverflowTile} >
501-
{ target }
502-
{ this.makeRoomTiles() }
503+
{ content }
503504
</TruncatedList>;
504505
}
505506
else {
@@ -521,6 +522,7 @@ var RoomSubList = React.createClass({
521522
roomNotificationCount={ this.roomNotificationCount() }
522523
onClick={ this.onClick }
523524
onHeaderClick={ this.props.onHeaderClick }
525+
headerItems={this.props.headerItems}
524526
/>
525527
{ subList }
526528
</div>
@@ -542,6 +544,7 @@ var RoomSubList = React.createClass({
542544
roomNotificationCount={ this.roomNotificationCount() }
543545
onClick={ this.onClick }
544546
onHeaderClick={ this.props.onHeaderClick }
547+
headerItems={this.props.headerItems}
545548
/>
546549
: undefined }
547550
{ (this.props.showSpinner && !this.state.hidden) ? <Loader /> : undefined }

‎src/components/structures/RoomSubListHeader.js‎

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,11 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
'use strict';
18-
19-
var React = require('react');
20-
var ReactDOM = require('react-dom');
21-
var classNames = require('classnames');
22-
var sdk = require('matrix-react-sdk')
23-
var FormattingUtils = require('matrix-react-sdk/lib/utils/FormattingUtils');
24-
var RoomNotifs = require('matrix-react-sdk/lib/RoomNotifs');
25-
var AccessibleButton = require('matrix-react-sdk/lib/components/views/elements/AccessibleButton');
26-
var ConstantTimeDispatcher = require('matrix-react-sdk/lib/ConstantTimeDispatcher');
17+
import React from 'react';
18+
import classNames from 'classnames';
19+
import sdk from 'matrix-react-sdk';
20+
import { formatCount } from 'matrix-react-sdk/lib/utils/FormattingUtils';
21+
import AccessibleButton from 'matrix-react-sdk/lib/components/views/elements/AccessibleButton';
2722

2823
module.exports = React.createClass({
2924
displayName: 'RoomSubListHeader',
@@ -42,6 +37,7 @@ module.exports = React.createClass({
4237
hidden: React.PropTypes.bool,
4338
onClick: React.PropTypes.func,
4439
onHeaderClick: React.PropTypes.func,
40+
headerItems: React.PropTypes.node, // content shown in the sublist header
4541
},
4642

4743
getDefaultProps: function() {
@@ -63,52 +59,52 @@ module.exports = React.createClass({
6359
// },
6460

6561
render: function() {
66-
var TintableSvg = sdk.getComponent("elements.TintableSvg");
62+
const TintableSvg = sdk.getComponent("elements.TintableSvg");
6763

68-
var subListNotifications = this.props.roomNotificationCount;
69-
var subListNotifCount = subListNotifications[0];
70-
var subListNotifHighlight = subListNotifications[1];
64+
const subListNotifications = this.props.roomNotificationCount;
65+
const subListNotifCount = subListNotifications[0];
66+
const subListNotifHighlight = subListNotifications[1];
7167

72-
var chevronClasses = classNames({
68+
const chevronClasses = classNames({
7369
'mx_RoomSubList_chevron': true,
7470
'mx_RoomSubList_chevronRight': this.props.hidden,
7571
'mx_RoomSubList_chevronDown': !this.props.hidden,
7672
});
7773

78-
var badgeClasses = classNames({
74+
const badgeClasses = classNames({
7975
'mx_RoomSubList_badge': true,
8076
'mx_RoomSubList_badgeHighlight': subListNotifHighlight,
8177
});
8278

83-
var badge;
79+
let badge;
8480
if (subListNotifCount > 0) {
85-
badge = <div className={badgeClasses}>{ FormattingUtils.formatCount(subListNotifCount) }</div>;
86-
}
87-
else if (subListNotifHighlight) {
81+
badge = <div className={badgeClasses}>{ formatCount(subListNotifCount) }</div>;
82+
} else if (subListNotifHighlight) {
8883
badge = <div className={badgeClasses}>!</div>;
8984
}
9085

9186
// When collapsed, allow a long hover on the header to show user
9287
// the full tag name and room count
93-
var title;
94-
var roomCount = this.props.roomCount;
88+
let title;
89+
const roomCount = this.props.roomCount;
9590
if (this.props.collapsed) {
9691
title = this.props.label;
9792
if (roomCount !== '') {
9893
title += " [" + roomCount + "]";
9994
}
10095
}
10196

102-
var incomingCall;
97+
let incomingCall;
10398
if (this.props.isIncomingCallRoom) {
104-
var IncomingCallBox = sdk.getComponent("voip.IncomingCallBox");
99+
const IncomingCallBox = sdk.getComponent("voip.IncomingCallBox");
105100
incomingCall = <IncomingCallBox className="mx_RoomSubList_incomingCall" incomingCall={ this.props.incomingCall }/>;
106101
}
107102

108103
return (
109104
<div className="mx_RoomSubList_labelContainer" title={ title } ref="header">
110105
<AccessibleButton onClick={ this.props.onClick } className="mx_RoomSubList_label" tabIndex="0">
111106
{ this.props.collapsed ? '' : this.props.label }
107+
{this.props.headerItems}
112108
<div className="mx_RoomSubList_roomCount">{ roomCount }</div>
113109
<div className={chevronClasses}></div>
114110
{ badge }

‎src/skins/vector/css/_components.scss‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
@import "./matrix-react-sdk/views/elements/_MemberEventListSummary.scss";
2828
@import "./matrix-react-sdk/views/elements/_ProgressBar.scss";
2929
@import "./matrix-react-sdk/views/elements/_RichText.scss";
30+
@import "./matrix-react-sdk/views/elements/_RoleButton.scss";
3031
@import "./matrix-react-sdk/views/login/_InteractiveAuthEntryComponents.scss";
3132
@import "./matrix-react-sdk/views/login/_ServerConfig.scss";
3233
@import "./matrix-react-sdk/views/messages/_MEmoteBody.scss";
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Copyright 2107 Vector Creations 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+
.mx_RoleButton {
18+
margin-left: 4px;
19+
margin-right: 4px;
20+
cursor: pointer;
21+
display: inline-block;
22+
}
23+
24+
.mx_RoleButton object {
25+
pointer-events: none;
26+
}
27+
28+
.mx_RoleButton_tooltip {
29+
display: inline-block;
30+
position: relative;
31+
top: -25px;
32+
left: 6px;
33+
}

‎src/skins/vector/css/matrix-react-sdk/views/rooms/_RoomList.scss‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright 2015, 2016 OpenMarket Ltd
3+
Copyright 2107 Vector Creations Ltd
34
45
Licensed under the Apache License, Version 2.0 (the "License");
56
you may not use this file except in compliance with the License.
@@ -37,3 +38,25 @@ limitations under the License.
3738
.mx_RoomList_scrollbar .gm-scrollbar.-vertical {
3839
z-index: 6;
3940
}
41+
42+
.mx_RoomList_emptySubListTip {
43+
font-size: 13px;
44+
margin-left: 18px;
45+
margin-right: 18px;
46+
margin-top: 8px;
47+
margin-bottom: 7px;
48+
padding: 5px;
49+
border: 1px dashed $accent-color;
50+
color: $primary-fg-color;
51+
background-color: $droptarget-bg-color;
52+
border-radius: 4px;
53+
}
54+
55+
.mx_RoomList_emptySubListTip .mx_RoleButton {
56+
vertical-align: -3px;
57+
}
58+
59+
.mx_RoomList_headerButtons {
60+
position: absolute;
61+
right: 60px;
62+
}

0 commit comments

Comments
 (0)