-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from medyo/develop
[WIP] New Version #Minor
- Loading branch information
Showing
18 changed files
with
294 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
"source.organizeImports": "explicit" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 14 additions & 7 deletions
21
src/components/Elements/SearchBarWithLogo/SearchBarWithLogo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { useState } from 'react' | ||
import { isValidURL } from 'src/utils/UrlUtils' | ||
|
||
import { TiPlus } from 'react-icons/ti' | ||
import { useUserPreferences } from 'src/stores/preferences' | ||
|
||
export const AddSearchEngine = () => { | ||
const { addSearchEngine, searchEngines } = useUserPreferences() | ||
const [searchEngineUrl, setSearchEngineUrl] = useState<string | undefined>() | ||
const [RssInputFeedback, setRssInputFeedback] = useState<string | undefined>() | ||
|
||
const onAddSearchEngine = async () => { | ||
if (!searchEngineUrl) { | ||
setRssInputFeedback('Please provide a valid Search engine URL') | ||
return | ||
} | ||
|
||
if (!isValidURL(searchEngineUrl)) { | ||
setRssInputFeedback('Invalid Search Engine URL. Please check and try again') | ||
return | ||
} | ||
|
||
if (searchEngines.some((se) => se.url === searchEngineUrl)) { | ||
setRssInputFeedback('Search Engine already exists') | ||
return | ||
} | ||
|
||
// Get label from url | ||
const url = new URL(searchEngineUrl) | ||
const label = url.hostname.replace('www.', '').split('.')[0] | ||
|
||
addSearchEngine({ label: label, url: searchEngineUrl, default: false }) | ||
setRssInputFeedback('Search Engine added successfully') | ||
} | ||
|
||
return ( | ||
<div className="settingRow"> | ||
<p className="settingTitle">Search Engine URL</p> | ||
<div className="settingContent"> | ||
<div className="form"> | ||
<input | ||
type="text" | ||
value={searchEngineUrl || ''} | ||
onChange={(e) => setSearchEngineUrl(e.target.value)} | ||
placeholder="https://google.com?q=" | ||
/> | ||
<div> | ||
<button onClick={onAddSearchEngine}> | ||
<TiPlus /> Add | ||
</button> | ||
</div> | ||
</div> | ||
{RssInputFeedback && ( | ||
<div className="settingHint"> | ||
<p>{RssInputFeedback}</p> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.