From 6db81edf6c0df0b20f0ebcdbcc6dde2ade61ba47 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 5 Nov 2018 09:35:44 +0100 Subject: [PATCH] restyle SearchBox & make it more reusable as we can reuse it in the room header --- res/css/structures/_SearchBox.scss | 55 +++----------------------- src/components/structures/LeftPanel.js | 8 +++- src/components/structures/SearchBox.js | 54 +++++++++++-------------- 3 files changed, 34 insertions(+), 83 deletions(-) diff --git a/res/css/structures/_SearchBox.scss b/res/css/structures/_SearchBox.scss index 6f08fd47b2..35b0853321 100644 --- a/res/css/structures/_SearchBox.scss +++ b/res/css/structures/_SearchBox.scss @@ -9,60 +9,15 @@ You may obtain a copy of the License at 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. +widows: THOUT 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_SearchBox { - height: 24px; - margin-left: 16px; - margin-right: 16px; - padding-top: 24px; - padding-bottom: 22px; - - border-bottom: 1px solid $panel-divider-color; - - display: flex; -} - -.mx_SearchBox_searchButton { - margin-right: 10px; - margin-top: 5px; - pointer-events: none; -} - .mx_SearchBox_closeButton { cursor: pointer; - margin-top: -5px; -} - -.mx_SearchBox_search { - flex: 1 1 auto; - width: 0px; - font-family: $font-family; - font-size: 12px; - margin-top: -2px; - height: 24px; - border: 0px ! important; - /* border-bottom: 1px solid rgba(0, 0, 0, 0.1) ! important; */ - border: 0px; -} - -.mx_SearchBox_minimise, -.mx_SearchBox_maximise { - margin-top: 3px; - cursor: pointer; -} - -.mx_SearchBox_minimise { - margin-left: 10px; -} - -.mx_SearchBox_maximise { - margin-left: 9px; -} - -.mx_SearchBox object { - pointer-events: none; + background-image: url('../../img/icons-close.svg'); + background-repeat: no-repeat; + width: 16px; + height: 16px; } diff --git a/src/components/structures/LeftPanel.js b/src/components/structures/LeftPanel.js index 84642a12a6..fc5b5eea5e 100644 --- a/src/components/structures/LeftPanel.js +++ b/src/components/structures/LeftPanel.js @@ -171,6 +171,12 @@ const LeftPanel = React.createClass({ this.setState({ searchFilter: term }); }, + onSearchCleared: function(source) { + if (source === "keyboard") { + dis.dispatch({action: 'focus_composer'}); + } + }, + collectRoomList: function(ref) { this._roomList = ref; }, @@ -195,7 +201,7 @@ const LeftPanel = React.createClass({ ); const searchBox = !this.props.collapsed ? - : + : undefined; return ( diff --git a/src/components/structures/SearchBox.js b/src/components/structures/SearchBox.js index 40a0803024..4df3e837c7 100644 --- a/src/components/structures/SearchBox.js +++ b/src/components/structures/SearchBox.js @@ -29,6 +29,7 @@ module.exports = React.createClass({ propTypes: { onSearch: React.PropTypes.func, + onCleared: React.PropTypes.func, }, getInitialState: function() { @@ -77,52 +78,41 @@ module.exports = React.createClass({ _onKeyDown: function(ev) { switch (ev.keyCode) { case KeyCode.ESCAPE: - this._clearSearch(); - dis.dispatch({action: 'focus_composer'}); + this._clearSearch("keyboard"); break; } }, - _clearSearch: function() { + _clearSearch: function(source) { this.refs.search.value = ""; this.onChange(); + if (this.props.onCleared) { + this.props.onCleared(source); + } }, render: function() { const TintableSvg = sdk.getComponent('elements.TintableSvg'); - const searchControls = [ - this.state.searchTerm.length > 0 ? - 0 ? + ({ this._clearSearch(); } }> - - - : - , - , - ]; + onClick={ () => {this._clearSearch("button")} }> + ) : undefined; - const self = this; return ( -
- { searchControls } +
+ + { clearButton }
); },