Skip to content

Commit 2e77b0a

Browse files
committed
Use directory search box component
1 parent 16c22e0 commit 2e77b0a

4 files changed

Lines changed: 67 additions & 16 deletions

File tree

‎src/components/structures/RoomDirectory.js‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ module.exports = React.createClass({
6868
this.filterString = null;
6969
this.filterTimeout = null;
7070
this.scrollPanel = null;
71+
this.searchBox = null;
7172

7273
// dis.dispatch({
7374
// action: 'ui_opacity',
@@ -212,9 +213,7 @@ module.exports = React.createClass({
212213
return this.getMoreRooms();
213214
},
214215

215-
onFilterChange: function(ev) {
216-
const alias = ev.target.value;
217-
216+
onFilterChange: function(alias) {
218217
this.filterString = alias || null;
219218

220219
// don't send the request for a little bit,
@@ -230,10 +229,22 @@ module.exports = React.createClass({
230229
}, 300);
231230
},
232231

233-
onFilterKeyUp: function(ev) {
234-
if (ev.key == "Enter") {
235-
this.showRoomAlias(ev.target.value);
232+
onFilterChange: function() {
233+
this.filterString = null;
234+
235+
if (this.filterTimeout) {
236+
clearTimeout(this.filterTimeout);
236237
}
238+
// update immediately
239+
this.refreshRoomList();
240+
},
241+
242+
onJoinClick: function(alias) {
243+
this.showRoomAlias(alias);
244+
},
245+
246+
collectSearchBox: function(e) {
247+
this.searchBox = e;
237248
},
238249

239250
showRoomAlias: function(alias) {
@@ -393,13 +404,15 @@ module.exports = React.createClass({
393404

394405
const SimpleRoomHeader = sdk.getComponent('rooms.SimpleRoomHeader');
395406
const NetworkDropdown = sdk.getComponent('directory.NetworkDropdown');
407+
const DirectorySearchBox = sdk.getComponent('elements.DirectorySearchBox');
396408
return (
397409
<div className="mx_RoomDirectory">
398410
<SimpleRoomHeader title="Directory" />
399411
<div className="mx_RoomDirectory_list">
400412
<div className="mx_RoomDirectory_listheader">
401-
<input type="text" placeholder="Find a room by keyword or room ID (#foo:matrix.org)"
402-
className="mx_RoomDirectory_input" size="64" onChange={this.onFilterChange} onKeyUp={this.onFilterKeyUp}
413+
<DirectorySearchBox
414+
className="mx_RoomDirectory_searchbox" ref={this.collectSearchBox}
415+
onChange={this.onFilterChange} onClear={this.onFilterClear} onJoinClick={this.onJoinClick}
403416
/>
404417
<NetworkDropdown config={this.props.config} onNetworkChange={this.onNetworkChange} />
405418
</div>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Copyright 2016 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+
.mx_DirectorySearchBox {
18+
position: relative;
19+
border-radius: 3px;
20+
border: 1px solid #c7c7c7;
21+
padding-left: 9px;
22+
padding-right: 25px;
23+
}
24+
25+
.mx_DirectorySearchBox_input {
26+
border: 0;
27+
padding: 0;
28+
font-weight: 300;
29+
font-size: 13px;
30+
}
31+
input[type=text].mx_DirectorySearchBox_input:focus {
32+
border: 0;
33+
}
34+
35+
.mx_DirectorySearchBox_clear {
36+
position: absolute;
37+
right: 0px;
38+
display: inline-block;
39+
top: 10px;
40+
right: 10px;
41+
background: url('img/icon_context_delete.svg');
42+
width: 15px;
43+
height: 15px;
44+
cursor: pointer;
45+
}

‎src/skins/vector/css/vector-web/structures/RoomDirectory.css‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,8 @@ limitations under the License.
5959
border-spacing: 5px;
6060
}
6161

62-
.mx_RoomDirectory_input {
62+
.mx_RoomDirectory_searchbox {
6363
display: table-cell;
64-
border-radius: 3px;
65-
border: 1px solid #c7c7c7;
66-
font-weight: 300;
67-
font-size: 13px;
68-
padding: 9px;
6964
}
7065

7166
.mx_RoomDirectory_listheader .mx_NetworkDropdown {

‎src/skins/vector/css/vector-web/views/directory/NetworkDropdown.css‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ limitations under the License.
2424
border: 1px solid #c7c7c7;
2525
font-weight: 300;
2626
font-size: 13px;
27-
margin-top: 12px;
28-
margin-bottom: 12px;
2927
user-select: none;
3028
}
3129

0 commit comments

Comments
 (0)