mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 17:56:01 +03:00
restyle SearchBox & make it more reusable
as we can reuse it in the room header
This commit is contained in:
parent
064662380f
commit
6db81edf6c
3 changed files with 34 additions and 83 deletions
|
@ -9,60 +9,15 @@ You may obtain a copy of the License at
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
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 {
|
.mx_SearchBox_closeButton {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
margin-top: -5px;
|
background-image: url('../../img/icons-close.svg');
|
||||||
}
|
background-repeat: no-repeat;
|
||||||
|
width: 16px;
|
||||||
.mx_SearchBox_search {
|
height: 16px;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,6 +171,12 @@ const LeftPanel = React.createClass({
|
||||||
this.setState({ searchFilter: term });
|
this.setState({ searchFilter: term });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onSearchCleared: function(source) {
|
||||||
|
if (source === "keyboard") {
|
||||||
|
dis.dispatch({action: 'focus_composer'});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
collectRoomList: function(ref) {
|
collectRoomList: function(ref) {
|
||||||
this._roomList = ref;
|
this._roomList = ref;
|
||||||
},
|
},
|
||||||
|
@ -195,7 +201,7 @@ const LeftPanel = React.createClass({
|
||||||
);
|
);
|
||||||
|
|
||||||
const searchBox = !this.props.collapsed ?
|
const searchBox = !this.props.collapsed ?
|
||||||
<SearchBox onSearch={ this.onSearch } /> :
|
<SearchBox onSearch={ this.onSearch } onCleared={ this.onSearchCleared } /> :
|
||||||
undefined;
|
undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -29,6 +29,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
onSearch: React.PropTypes.func,
|
onSearch: React.PropTypes.func,
|
||||||
|
onCleared: React.PropTypes.func,
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
|
@ -77,52 +78,41 @@ module.exports = React.createClass({
|
||||||
_onKeyDown: function(ev) {
|
_onKeyDown: function(ev) {
|
||||||
switch (ev.keyCode) {
|
switch (ev.keyCode) {
|
||||||
case KeyCode.ESCAPE:
|
case KeyCode.ESCAPE:
|
||||||
this._clearSearch();
|
this._clearSearch("keyboard");
|
||||||
dis.dispatch({action: 'focus_composer'});
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_clearSearch: function() {
|
_clearSearch: function(source) {
|
||||||
this.refs.search.value = "";
|
this.refs.search.value = "";
|
||||||
this.onChange();
|
this.onChange();
|
||||||
|
if (this.props.onCleared) {
|
||||||
|
this.props.onCleared(source);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
const TintableSvg = sdk.getComponent('elements.TintableSvg');
|
const TintableSvg = sdk.getComponent('elements.TintableSvg');
|
||||||
|
|
||||||
const searchControls = [
|
const clearButton = this.state.searchTerm.length > 0 ?
|
||||||
this.state.searchTerm.length > 0 ?
|
(<AccessibleButton key="button"
|
||||||
<AccessibleButton key="button"
|
|
||||||
className="mx_SearchBox_closeButton"
|
className="mx_SearchBox_closeButton"
|
||||||
onClick={ ()=>{ this._clearSearch(); } }>
|
onClick={ () => {this._clearSearch("button")} }>
|
||||||
<TintableSvg
|
</AccessibleButton>) : undefined;
|
||||||
className="mx_SearchBox_searchButton"
|
|
||||||
src="img/icons-close.svg" width="24" height="24"
|
|
||||||
/>
|
|
||||||
</AccessibleButton>
|
|
||||||
:
|
|
||||||
<TintableSvg
|
|
||||||
key="button"
|
|
||||||
className="mx_SearchBox_searchButton"
|
|
||||||
src="img/icons-search-copy.svg" width="13" height="13"
|
|
||||||
/>,
|
|
||||||
<input
|
|
||||||
key="searchfield"
|
|
||||||
type="text"
|
|
||||||
ref="search"
|
|
||||||
className="mx_SearchBox_search"
|
|
||||||
value={ this.state.searchTerm }
|
|
||||||
onChange={ this.onChange }
|
|
||||||
onKeyDown={ this._onKeyDown }
|
|
||||||
placeholder={ _t('Filter room names') }
|
|
||||||
/>,
|
|
||||||
];
|
|
||||||
|
|
||||||
const self = this;
|
|
||||||
return (
|
return (
|
||||||
<div className="mx_SearchBox">
|
<div className="mx_SearchBox mx_textinput">
|
||||||
{ searchControls }
|
<input
|
||||||
|
key="searchfield"
|
||||||
|
type="text"
|
||||||
|
ref="search"
|
||||||
|
className="mx_textinput_icon mx_textinput_search"
|
||||||
|
value={ this.state.searchTerm }
|
||||||
|
onChange={ this.onChange }
|
||||||
|
onKeyDown={ this._onKeyDown }
|
||||||
|
placeholder={ _t('Filter room names') }
|
||||||
|
/>
|
||||||
|
{ clearButton }
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue