From 2e77b0a3c7d1e45e8a800a73b790fd8101e94e7b Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 23 Sep 2016 13:48:44 +0100 Subject: [PATCH] Use directory search box component --- src/components/structures/RoomDirectory.js | 29 ++++++++---- .../views/elements/DirectorySearchBox.css | 45 +++++++++++++++++++ .../vector-web/structures/RoomDirectory.css | 7 +-- .../views/directory/NetworkDropdown.css | 2 - 4 files changed, 67 insertions(+), 16 deletions(-) create mode 100644 src/skins/vector/css/matrix-react-sdk/views/elements/DirectorySearchBox.css diff --git a/src/components/structures/RoomDirectory.js b/src/components/structures/RoomDirectory.js index 95e2f71c5..9f8573f6c 100644 --- a/src/components/structures/RoomDirectory.js +++ b/src/components/structures/RoomDirectory.js @@ -68,6 +68,7 @@ module.exports = React.createClass({ this.filterString = null; this.filterTimeout = null; this.scrollPanel = null; + this.searchBox = null; // dis.dispatch({ // action: 'ui_opacity', @@ -212,9 +213,7 @@ module.exports = React.createClass({ return this.getMoreRooms(); }, - onFilterChange: function(ev) { - const alias = ev.target.value; - + onFilterChange: function(alias) { this.filterString = alias || null; // don't send the request for a little bit, @@ -230,10 +229,22 @@ module.exports = React.createClass({ }, 300); }, - onFilterKeyUp: function(ev) { - if (ev.key == "Enter") { - this.showRoomAlias(ev.target.value); + onFilterChange: function() { + this.filterString = null; + + if (this.filterTimeout) { + clearTimeout(this.filterTimeout); } + // update immediately + this.refreshRoomList(); + }, + + onJoinClick: function(alias) { + this.showRoomAlias(alias); + }, + + collectSearchBox: function(e) { + this.searchBox = e; }, showRoomAlias: function(alias) { @@ -393,13 +404,15 @@ module.exports = React.createClass({ const SimpleRoomHeader = sdk.getComponent('rooms.SimpleRoomHeader'); const NetworkDropdown = sdk.getComponent('directory.NetworkDropdown'); + const DirectorySearchBox = sdk.getComponent('elements.DirectorySearchBox'); return (
-
diff --git a/src/skins/vector/css/matrix-react-sdk/views/elements/DirectorySearchBox.css b/src/skins/vector/css/matrix-react-sdk/views/elements/DirectorySearchBox.css new file mode 100644 index 000000000..9afaa10de --- /dev/null +++ b/src/skins/vector/css/matrix-react-sdk/views/elements/DirectorySearchBox.css @@ -0,0 +1,45 @@ +/* +Copyright 2016 OpenMarket Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +.mx_DirectorySearchBox { + position: relative; + border-radius: 3px; + border: 1px solid #c7c7c7; + padding-left: 9px; + padding-right: 25px; +} + +.mx_DirectorySearchBox_input { + border: 0; + padding: 0; + font-weight: 300; + font-size: 13px; +} +input[type=text].mx_DirectorySearchBox_input:focus { + border: 0; +} + +.mx_DirectorySearchBox_clear { + position: absolute; + right: 0px; + display: inline-block; + top: 10px; + right: 10px; + background: url('img/icon_context_delete.svg'); + width: 15px; + height: 15px; + cursor: pointer; +} diff --git a/src/skins/vector/css/vector-web/structures/RoomDirectory.css b/src/skins/vector/css/vector-web/structures/RoomDirectory.css index 17954e1c9..1417c385d 100644 --- a/src/skins/vector/css/vector-web/structures/RoomDirectory.css +++ b/src/skins/vector/css/vector-web/structures/RoomDirectory.css @@ -59,13 +59,8 @@ limitations under the License. border-spacing: 5px; } -.mx_RoomDirectory_input { +.mx_RoomDirectory_searchbox { display: table-cell; - border-radius: 3px; - border: 1px solid #c7c7c7; - font-weight: 300; - font-size: 13px; - padding: 9px; } .mx_RoomDirectory_listheader .mx_NetworkDropdown { diff --git a/src/skins/vector/css/vector-web/views/directory/NetworkDropdown.css b/src/skins/vector/css/vector-web/views/directory/NetworkDropdown.css index 3bf4bb347..cc1528026 100644 --- a/src/skins/vector/css/vector-web/views/directory/NetworkDropdown.css +++ b/src/skins/vector/css/vector-web/views/directory/NetworkDropdown.css @@ -24,8 +24,6 @@ limitations under the License. border: 1px solid #c7c7c7; font-weight: 300; font-size: 13px; - margin-top: 12px; - margin-bottom: 12px; user-select: none; }