Skip to content

Commit c8d9d2a

Browse files
authored
Merge pull request #815 from fahad-aot/featute/fwf-5214-search-input
feature/fwf-5214:Added search input component
2 parents f064a89 + 7e351d5 commit c8d9d2a

File tree

3 files changed

+68
-62
lines changed

3 files changed

+68
-62
lines changed
Lines changed: 26 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,34 @@
1-
import React, { FC } from 'react';
2-
import { InputGroup, FormControl } from 'react-bootstrap';
3-
import { ClearIcon } from "../SvgIcons/index";
1+
import React, { FC } from "react";
42
import { useTranslation } from "react-i18next";
53

6-
74
interface CustomSearchProps {
8-
searchLoading?: boolean;
9-
handleClearSearch: () => void;
10-
search: string;
11-
setSearch: (value: string) => void;
12-
handleSearch: () => void;
13-
placeholder?: string;
14-
title?: string;
15-
dataTestId: string;
5+
search: string;
6+
setSearch: (value: string) => void;
7+
handleSearch: () => void;
8+
placeholder?: string;
9+
dataTestId: string;
1610
}
1711

1812
export const CustomSearch: FC<CustomSearchProps> = ({
19-
searchLoading,
20-
handleClearSearch,
21-
search,
22-
setSearch,
23-
handleSearch,
24-
placeholder = "Search...",
25-
title = "Search",
26-
dataTestId
13+
search,
14+
setSearch,
15+
handleSearch,
16+
placeholder = "Search",
17+
dataTestId,
2718
}) => {
28-
const { t } = useTranslation();
29-
const inputClassNames = ` ${searchLoading ? 'is-searching' : search ? 'has-value' : ''
30-
}`;
31-
32-
return (
33-
// <InputGroup className="d-flex align-items-center p-0 search-box input-group">
34-
<div className="input-search">
35-
{/* <div className="form-control-with-icon w-25"> */}
36-
<input
37-
className={inputClassNames}
38-
value={search}
39-
onChange={(e) => setSearch(e.target.value)}
40-
onKeyDown={(e) => (e.key === 'Enter' && handleSearch())}
41-
placeholder={t(placeholder)}
42-
title={t(title)}
43-
data-testid={dataTestId}
44-
aria-label={placeholder}
45-
/>
46-
{search && (
47-
// <span className={`d-flex search-box-icon ${searchLoading ? 'loading' : ''}`} >
48-
<>
49-
{!searchLoading ? (
50-
<button className="icon" onClick={handleClearSearch}>
51-
<ClearIcon
52-
// width={16}
53-
// height={16}
54-
// onClick={handleClearSearch}
55-
data-testid="form-search-clear-button"
56-
/>
57-
</button>
58-
) : (
59-
<div className="search-spinner" data-testid="search-spinner"></div>
60-
)}
61-
62-
</>
63-
)}
64-
{/* </div> */}
65-
</div>
66-
// </InputGroup>
67-
);
19+
const { t } = useTranslation();
20+
return (
21+
<div className="search-input-container">
22+
<input
23+
className="search-input"
24+
onChange={(e) => setSearch(e.target.value)}
25+
onKeyDown={(e) => e.key === "Enter" && handleSearch()}
26+
placeholder={t(placeholder)}
27+
data-testid={dataTestId}
28+
aria-label={placeholder}
29+
value={search}
30+
role="searchbox"
31+
/>
32+
</div>
33+
);
6834
};
69-

forms-flow-theme/scss/index.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@
4040
@import "./external/toastify.scss";
4141
@import "~bootstrap/scss/bootstrap";
4242

43-
//v8 Custom component style override
43+
@import "./v8-scss/search";
4444
@import "./v8-scss/button";
45+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.search-input-container {
2+
position: relative;
3+
display: flex;
4+
align-items: center;
5+
width: 100%;
6+
max-width: 20rem;
7+
8+
&.search-disabled {
9+
opacity: 0.6;
10+
pointer-events: none;
11+
}
12+
13+
.search-input {
14+
width: 100%;
15+
height: 2.5rem;
16+
border-radius: 5px;
17+
padding: 11px 13px;
18+
border: 1px solid #ededed;
19+
background: #fcfcfc;
20+
font-weight: 400;
21+
font-size: 15px;
22+
line-height: 1;
23+
letter-spacing: 0;
24+
outline: none;
25+
transition: border-color 0.2s, box-shadow 0.2s;
26+
27+
&::placeholder {
28+
color: #ededed;
29+
}
30+
&:focus {
31+
color: #4a4a4a;
32+
border-color: #ededed;
33+
background: #fcfcfc;
34+
&::placeholder {
35+
color: #b7b7b8;
36+
}
37+
}
38+
}
39+
}
40+

0 commit comments

Comments
 (0)