fix: add hover effect to search dropdown, custom support etc

This commit is contained in:
David Ralph
2021-08-26 19:48:20 +01:00
parent e5f8cf3e66
commit de4ffbcb0a
3 changed files with 20 additions and 4 deletions

View File

@@ -45,7 +45,7 @@ export default class KeybindSettings extends PureComponent {
} }
reset(type) { reset(type) {
let keybinds = this.state.keybinds; const keybinds = this.state.keybinds;
keybinds[type] = ''; keybinds[type] = '';
localStorage.setItem('keybinds', JSON.stringify(keybinds)); localStorage.setItem('keybinds', JSON.stringify(keybinds));
this.setState({ this.setState({

View File

@@ -130,7 +130,7 @@ export default class Search extends PureComponent {
} }
} }
setSearch(name) { setSearch(name, custom) {
let url; let url;
let query = 'q'; let query = 'q';
const info = searchEngines.find((i) => i.name === name); const info = searchEngines.find((i) => i.name === name);
@@ -142,6 +142,10 @@ export default class Search extends PureComponent {
} }
} }
if (custom) {
url = localStorage.getItem('customSearchEngine');
}
this.setState({ this.setState({
url: url, url: url,
query: query, query: query,
@@ -165,23 +169,27 @@ export default class Search extends PureComponent {
} }
render() { render() {
const customText = window.language.modals.main.settings.sections.search.custom.split(' ')[0];
return ( return (
<form onSubmit={this.searchButton} className='searchBar'> <form onSubmit={this.searchButton} className='searchBar'>
{localStorage.getItem('searchDropdown') === 'true' ? {localStorage.getItem('searchDropdown') === 'true' ?
<div className='searchDropdown'> <div className='searchDropdown'>
<span className='searchSelected' onClick={() => this.toggleDropdown()}>{this.state.currentSearch}</span> <span className='searchSelected' onClick={() => this.toggleDropdown()}>{this.state.currentSearch}</span>
<div className='searchOptions' style={{ display: this.state.searchDropdown }}> <div style={{ display: this.state.searchDropdown }}>
{searchEngines.map((engine) => { {searchEngines.map((engine) => {
if (engine.name === this.state.currentSearch) { if (engine.name === this.state.currentSearch) {
return null; return null;
} }
return ( return (
<> <>
<span className='searchSelected' onClick={() => this.setSearch(engine.name)}>{engine.name}</span> <span className='searchDropdownList' onClick={() => this.setSearch(engine.name)}>{engine.name}</span>
<br/> <br/>
</> </>
); );
})} })}
{this.state.currentSearch !== customText ? <span className='searchDropdownList' onClick={() => this.setSearch(customText, 'custom')}>{customText}</span> : null}
</div> </div>
</div> : null} </div> : null}
{this.state.microphone} {this.state.microphone}

View File

@@ -56,6 +56,14 @@
.searchSelected { .searchSelected {
cursor: pointer; cursor: pointer;
} }
.searchDropdownList {
cursor: pointer;
&:hover {
color: rgb(211, 211, 211);
}
}
} }
.micIcon { .micIcon {