Skip to content

Commit 85aa390

Browse files
authored
Merge pull request element-hq#4023 from vector-im/luke/new-guest-access-left-panel
Make left panel better for new users (mk III)
2 parents 36ec156 + 9d28c8f commit 85aa390

6 files changed

Lines changed: 159 additions & 61 deletions

File tree

‎src/components/structures/BottomLeftMenu.js‎

Lines changed: 81 additions & 27 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,15 @@ See the License for the specific language governing permissions and
1415
limitations under the License.
1516
*/
1617

17-
'use strict';
18+
import React from 'react';
19+
import ReactDOM from 'react-dom';
20+
import sdk from 'matrix-react-sdk';
21+
import dis from 'matrix-react-sdk/lib/dispatcher';
22+
import AccessibleButton from 'matrix-react-sdk/lib/components/views/elements/AccessibleButton';
23+
import Velocity from 'velocity-vector';
24+
import 'velocity-vector/velocity.ui';
1825

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');
26+
const CALLOUT_ANIM_DURATION = 1000;
2427

2528
module.exports = React.createClass({
2629
displayName: 'BottomLeftMenu',
@@ -39,6 +42,18 @@ module.exports = React.createClass({
3942
});
4043
},
4144

45+
componentWillMount: function() {
46+
this._dispatcherRef = dis.register(this.onAction);
47+
this._peopleButton = null;
48+
this._directoryButton = null;
49+
this._createRoomButton = null;
50+
this._lastCallouts = {};
51+
},
52+
53+
componentWillUnmount: function() {
54+
dis.unregister(this._dispatcherRef);
55+
},
56+
4257
// Room events
4358
onDirectoryClick: function() {
4459
dis.dispatch({ action: 'view_room_directory' });
@@ -103,6 +118,30 @@ module.exports = React.createClass({
103118
this.setState({ settingsHover: false });
104119
},
105120

121+
onAction: function(payload) {
122+
let calloutElement;
123+
switch (payload.action) {
124+
// Incoming instruction: dance!
125+
case 'callout_start_chat':
126+
calloutElement = this._peopleButton;
127+
break;
128+
case 'callout_room_directory':
129+
calloutElement = this._directoryButton;
130+
break;
131+
case 'callout_create_room':
132+
calloutElement = this._createRoomButton;
133+
break;
134+
}
135+
if (calloutElement) {
136+
const lastCallout = this._lastCallouts[payload.action];
137+
const now = Date.now();
138+
if (lastCallout == undefined || lastCallout < now - CALLOUT_ANIM_DURATION) {
139+
this._lastCallouts[payload.action] = now;
140+
Velocity(ReactDOM.findDOMNode(calloutElement), "callout.bounce", CALLOUT_ANIM_DURATION);
141+
}
142+
}
143+
},
144+
106145
// Get the label/tooltip to show
107146
getLabel: function(label, show) {
108147
if (show) {
@@ -111,31 +150,46 @@ module.exports = React.createClass({
111150
}
112151
},
113152

153+
_collectPeopleButton: function(e) {
154+
this._peopleButton = e;
155+
},
156+
157+
_collectDirectoryButton: function(e) {
158+
this._directoryButton = e;
159+
},
160+
161+
_collectCreateRoomButton: function(e) {
162+
this._createRoomButton = e;
163+
},
164+
114165
render: function() {
115-
var TintableSvg = sdk.getComponent('elements.TintableSvg');
166+
const HomeButton = sdk.getComponent('elements.HomeButton');
167+
const StartChatButton = sdk.getComponent('elements.StartChatButton');
168+
const RoomDirectoryButton = sdk.getComponent('elements.RoomDirectoryButton');
169+
const CreateRoomButton = sdk.getComponent('elements.CreateRoomButton');
170+
const SettingsButton = sdk.getComponent('elements.SettingsButton');
171+
172+
var homeButton;
173+
if (this.props.teamToken) {
174+
homeButton = <HomeButton tooltip={true} />;
175+
}
176+
116177
return (
117178
<div className="mx_BottomLeftMenu">
118179
<div className="mx_BottomLeftMenu_options">
119-
<AccessibleButton className="mx_BottomLeftMenu_homePage" onClick={ this.onHomeClick } onMouseEnter={ this.onHomeMouseEnter } onMouseLeave={ this.onHomeMouseLeave } >
120-
<TintableSvg src="img/icons-home.svg" width="25" height="25" />
121-
{ this.getLabel("Welcome page", this.state.homeHover) }
122-
</AccessibleButton>
123-
<AccessibleButton className="mx_BottomLeftMenu_people" onClick={ this.onPeopleClick } onMouseEnter={ this.onPeopleMouseEnter } onMouseLeave={ this.onPeopleMouseLeave } >
124-
<TintableSvg src="img/icons-people.svg" width="25" height="25" />
125-
{ this.getLabel("Start chat", this.state.peopleHover) }
126-
</AccessibleButton>
127-
<AccessibleButton className="mx_BottomLeftMenu_directory" onClick={ this.onDirectoryClick } onMouseEnter={ this.onDirectoryMouseEnter } onMouseLeave={ this.onDirectoryMouseLeave } >
128-
<TintableSvg src="img/icons-directory.svg" width="25" height="25"/>
129-
{ this.getLabel("Room directory", this.state.directoryHover) }
130-
</AccessibleButton>
131-
<AccessibleButton className="mx_BottomLeftMenu_createRoom" onClick={ this.onRoomsClick } onMouseEnter={ this.onRoomsMouseEnter } onMouseLeave={ this.onRoomsMouseLeave } >
132-
<TintableSvg src="img/icons-create-room.svg" width="25" height="25" />
133-
{ this.getLabel("Create new room", this.state.roomsHover) }
134-
</AccessibleButton>
135-
<AccessibleButton className="mx_BottomLeftMenu_settings" onClick={ this.onSettingsClick } onMouseEnter={ this.onSettingsMouseEnter } onMouseLeave={ this.onSettingsMouseLeave } >
136-
<TintableSvg src="img/icons-settings.svg" width="25" height="25" />
137-
{ this.getLabel("Settings", this.state.settingsHover) }
138-
</AccessibleButton>
180+
{ homeButton }
181+
<div ref={this._collectPeopleButton}>
182+
<StartChatButton tooltip={true} />
183+
</div>
184+
<div ref={this._collectDirectoryButton}>
185+
<RoomDirectoryButton tooltip={true} />
186+
</div>
187+
<div ref={this._collectCreateRoomButton}>
188+
<CreateRoomButton tooltip={true} />
189+
</div>
190+
<span className="mx_BottomLeftMenu_settings">
191+
<SettingsButton tooltip={true} />
192+
</span>
139193
</div>
140194
</div>
141195
);

‎src/components/structures/RoomSubList.js‎

Lines changed: 9 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() {
@@ -521,16 +524,15 @@ var RoomSubList = React.createClass({
521524

522525
render: function() {
523526
var connectDropTarget = this.props.connectDropTarget;
524-
var RoomDropTarget = sdk.getComponent('rooms.RoomDropTarget');
525527
var TruncatedList = sdk.getComponent('elements.TruncatedList');
526528

527529
var label = this.props.collapsed ? null : this.props.label;
528530

529-
//console.log("render: " + JSON.stringify(this.state.sortedList));
530-
531-
var target;
532-
if (this.state.sortedList.length == 0 && this.props.editable) {
533-
target = <RoomDropTarget label={ 'Drop here to ' + this.props.verb }/>;
531+
let content;
532+
if (this.state.sortedList.length == 0) {
533+
content = this.props.emptyContent;
534+
} else {
535+
content = this.makeRoomTiles();
534536
}
535537

536538
if (this.state.sortedList.length > 0 || this.props.editable) {
@@ -540,8 +542,7 @@ var RoomSubList = React.createClass({
540542
if (!this.state.hidden) {
541543
subList = <TruncatedList className={ classes } truncateAt={this.state.truncateAt}
542544
createOverflowElement={this._createOverflowTile} >
543-
{ target }
544-
{ this.makeRoomTiles() }
545+
{ content }
545546
</TruncatedList>;
546547
}
547548
else {

‎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+
}

‎src/skins/vector/css/vector-web/structures/_LeftPanel.scss‎

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -64,43 +64,29 @@ limitations under the License.
6464
pointer-events: none;
6565
}
6666

67-
.mx_LeftPanel .mx_BottomLeftMenu_homePage,
68-
.mx_LeftPanel .mx_BottomLeftMenu_directory,
69-
.mx_LeftPanel .mx_BottomLeftMenu_createRoom,
70-
.mx_LeftPanel .mx_BottomLeftMenu_people,
71-
.mx_LeftPanel .mx_BottomLeftMenu_settings {
72-
display: inline-block;
73-
cursor: pointer;
74-
}
75-
76-
.collapsed .mx_BottomLeftMenu_homePage,
77-
.collapsed .mx_BottomLeftMenu_directory,
78-
.collapsed .mx_BottomLeftMenu_createRoom,
79-
.collapsed .mx_BottomLeftMenu_people,
80-
.collapsed .mx_BottomLeftMenu_settings {
67+
.collapsed .mx_RoleButton {
8168
margin-right: 0px ! important;
8269
padding-top: 3px ! important;
8370
padding-bottom: 3px ! important;
8471
}
8572

86-
.mx_LeftPanel .mx_BottomLeftMenu_homePage,
87-
.mx_LeftPanel .mx_BottomLeftMenu_directory,
88-
.mx_LeftPanel .mx_BottomLeftMenu_createRoom,
89-
.mx_LeftPanel .mx_BottomLeftMenu_people {
73+
.mx_BottomLeftMenu_options > div {
74+
display: inline-block;
75+
}
76+
77+
.mx_BottomLeftMenu_options .mx_RoleButton {
78+
margin-left: 0px;
9079
margin-right: 10px;
9180
}
9281

93-
.mx_LeftPanel .mx_BottomLeftMenu_settings {
82+
.mx_BottomLeftMenu_options .mx_BottomLeftMenu_settings {
9483
float: right;
9584
}
9685

97-
.mx_LeftPanel.collapsed .mx_BottomLeftMenu_settings {
98-
float: none;
86+
.mx_BottomLeftMenu_options .mx_BottomLeftMenu_settings .mx_RoleButton {
87+
margin-right: 0px;
9988
}
10089

101-
.mx_LeftPanel .mx_BottomLeftMenu_tooltip {
102-
display: inline-block;
103-
position: relative;
104-
top: -25px;
105-
left: 6px;
90+
.mx_LeftPanel.collapsed .mx_BottomLeftMenu_settings {
91+
float: none;
10692
}

0 commit comments

Comments
 (0)