@@ -8,7 +8,7 @@ import '../App.css';
88import './settings.css' ;
99import PreferencesContext from '../preferences/PreferencesContext' ;
1010import ConfigurationContext from '../configuration/ConfigurationContext' ;
11- import { SUPPORTED_CARDS , APP } from '../Constants'
11+ import { SUPPORTED_CARDS , SUPPORTED_SEARCH_ENGINES , APP } from '../Constants'
1212import {
1313 trackAddLanguage ,
1414 trackRemoveLanguage ,
@@ -21,7 +21,8 @@ import {
2121function SettingsModal ( { showSettings, setShowSettings } ) {
2222 const { supportedTags } = useContext ( ConfigurationContext )
2323 const preferences = useContext ( PreferencesContext )
24- const { dispatcher, cards, userSelectedTags, openLinksNewTab, listingMode, theme } = preferences
24+ const { dispatcher, cards, userSelectedTags, openLinksNewTab, listingMode, theme, searchEngine } =
25+ preferences
2526 const [ selectedCards , setSelectedCards ] = useState ( cards )
2627
2728 const handleCloseModal = ( ) => {
@@ -64,6 +65,10 @@ function SettingsModal({ showSettings, setShowSettings }) {
6465 dispatcher ( { type : 'setCards' , value : newCards } )
6566 }
6667
68+ const onSearchEngineSelectChange = ( value ) => {
69+ dispatcher ( { type : 'setSearchEngine' , value } )
70+ }
71+
6772 const onOpenLinksNewTabChange = ( e ) => {
6873 const checked = e . target . checked
6974 trackOpenLinksNewTab ( checked )
@@ -162,6 +167,27 @@ function SettingsModal({ showSettings, setShowSettings }) {
162167 />
163168 </ div >
164169 </ div >
170+
171+ < div className = "settingRow" >
172+ < p className = "settingTitle" > Favorite search engine</ p >
173+ < div className = "settingContent" >
174+ < Select
175+ options = { SUPPORTED_SEARCH_ENGINES }
176+ value = { SUPPORTED_SEARCH_ENGINES . find ( ( e ) => e . label == searchEngine ) }
177+ isMulti = { false }
178+ isClearable = { false }
179+ isSearchable = { false }
180+ classNamePrefix = { 'hackertab' }
181+ onChange = { onSearchEngineSelectChange }
182+ />
183+ < p className = "settingHint" >
184+ Missing a search engine? create an issue{ ' ' }
185+ < a href = "#" onClick = { ( e ) => window . open ( APP . supportLink , '_blank' ) } >
186+ here
187+ </ a >
188+ </ p >
189+ </ div >
190+ </ div >
165191 </ div >
166192 </ ReactModal >
167193 )
0 commit comments