forked from AOT-Technologies/forms-flow-ai
-
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.
Merge pull request #3 from Bonymol-aot/feature/FWF-3534-custom-search…
…-component FWF-3534 [Feature] Added style for added seacrch component replaced s…
- Loading branch information
Showing
3 changed files
with
108 additions
and
112 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from 'react'; | ||
import { InputGroup, FormControl, Spinner } from 'react-bootstrap'; | ||
|
||
const customSearch = ({ | ||
searchFormLoading, | ||
handleClearSearch, | ||
search, | ||
setSearch, | ||
handleSearch, | ||
placeholder, | ||
title | ||
}) => { | ||
const inputClassNames = `d-flex align-items-center bg-white out-line search-box-input ${ | ||
searchFormLoading ? 'is-searching' : search ? 'has-value' : '' | ||
}`; | ||
|
||
return ( | ||
<InputGroup className="d-flex align-items-center p-0 search-box input-group"> | ||
<div className="form-control-with-icon"> | ||
<FormControl | ||
className={inputClassNames} | ||
value={search} | ||
onChange={(e) => { | ||
setSearch(e.target.value); | ||
}} | ||
onKeyDown={(e) => (e.keyCode === 13 ? handleSearch() : "")} | ||
placeholder={placeholder} | ||
title={title} | ||
data-testid="form-search-input-box" | ||
aria-label={placeholder} | ||
/> | ||
{search && searchFormLoading ? ( | ||
<span className="d-flex search-box-icon loading"> | ||
<Spinner animation="border" size="sm" /> | ||
</span> | ||
) : ( | ||
search && !searchFormLoading ? ( | ||
<span | ||
className="search-box-icon clear" | ||
onClick={handleClearSearch} | ||
data-testid="form-search-clear-button" | ||
> | ||
<i className="fa fa-times"></i> | ||
</span> | ||
) : null | ||
)} | ||
</div> | ||
</InputGroup> | ||
); | ||
}; | ||
|
||
|
||
customSearch.defaultProps = { | ||
placeholder: "Search...", | ||
title: "Search" | ||
}; | ||
|
||
export default customSearch; |
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 was deleted.
Oops, something went wrong.