-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): Implement custom search input (closes #184)
- Loading branch information
1 parent
4bde7b1
commit 108e419
Showing
5 changed files
with
79 additions
and
37 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 |
---|---|---|
|
@@ -91,9 +91,5 @@ | |
.filters-btn { | ||
border-radius: 1.3rem; | ||
} | ||
|
||
.group-by-date-btn { | ||
padding: 0 8px; | ||
} | ||
} | ||
} |
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,37 @@ | ||
import React, { useState } from "react"; | ||
|
||
import Button from "./Button"; | ||
import SearchIcon from "../../icons/SearchIcon"; | ||
|
||
interface IProps { | ||
onSearch: (value: string) => void; | ||
loading?: boolean; | ||
defaultValue: string; | ||
placeholder?: string; | ||
} | ||
|
||
const SearchInput: React.FC<IProps> = ({ onSearch, loading, defaultValue, placeholder }) => { | ||
const [searchValue, setSearchValue] = useState(defaultValue); | ||
|
||
const handleSearch = () => { | ||
onSearch(searchValue); | ||
}; | ||
|
||
return ( | ||
<div className="search-input"> | ||
<input | ||
type="text" | ||
autoComplete="off" | ||
placeholder={placeholder || ""} | ||
value={searchValue} | ||
onChange={(e) => setSearchValue(e.target.value)} | ||
onKeyPress={(e) => { | ||
if (e.key === "Enter") handleSearch(); | ||
}} | ||
/> | ||
<Button icon={<SearchIcon />} className="search-btn" onClick={handleSearch} loading={loading} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SearchInput; |
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,18 @@ | ||
import React from "react"; | ||
|
||
// search-black-24dp | ||
|
||
interface IProps { | ||
className?: string; | ||
} | ||
|
||
const SearchIcon: React.FC<IProps> = ({ className }) => { | ||
return ( | ||
<svg className={"icon search-icon " + className} viewBox="0 0 24 24"> | ||
<path d="M0 0h24v24H0V0z" fill="none" /> | ||
<path d="M15.5 14h-.79l-.28-.27c1.2-1.4 1.82-3.31 1.48-5.34-.47-2.78-2.79-5-5.59-5.34-4.23-.52-7.79 3.04-7.27 7.27.34 2.8 2.56 5.12 5.34 5.59 2.03.34 3.94-.28 5.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" /> | ||
</svg> | ||
); | ||
}; | ||
|
||
export default SearchIcon; |
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