Skip to content

Commit 1f656c3

Browse files
committed
added clear button on search input + added suggestion
1 parent ebad00b commit 1f656c3

File tree

3 files changed

+75
-17
lines changed

3 files changed

+75
-17
lines changed

src/App.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
background-color: #f8faff !important;
88
}
99

10+
.is-active {
11+
background-color: rgb(241, 238, 238) !important;
12+
}
13+
14+
.navbar-end > a.navbar-item:hover {
15+
color: #6c8eef !important;
16+
background-color: #f8faff !important;
17+
}
18+
1019
/* Hero Section */
1120
.space {
1221
background: linear-gradient(90deg, #f8faff 19px, transparent 1%) center,
@@ -154,6 +163,11 @@ ul ol {
154163
margin-bottom: 4px;
155164
}
156165

166+
/* tag */
167+
.tag:hover {
168+
opacity: 0.8;
169+
}
170+
157171
@media (max-width: 600px) {
158172
.features .feature-card {
159173
flex-direction: column;

src/App.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import ScrollToTopBtn from './components/ScrollToTopBtn';
1010

1111
function App() {
1212
const [searchInput, setSearchInput] = useState('');
13-
const handleInputChange = (e) => {
14-
setSearchInput(e.target.value);
13+
const handleInputChange = (value) => {
14+
// console.log(value);
15+
setSearchInput(value);
1516
};
1617
return (
1718
<div className='App'>

src/components/Category/Resources.js

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
import React from 'react';
2-
import { Search } from 'react-feather';
2+
import { Search, XCircle } from 'react-feather';
33
import { resources } from './resourcesData';
44
import Category from './Category';
55

66
const Resources = ({ searchInput, handleInputChange }) => {
7+
const filters = [
8+
'Design',
9+
'App',
10+
'Project',
11+
'interview',
12+
'web',
13+
'Developer',
14+
'Programmer',
15+
'javascript',
16+
'Resources',
17+
];
718
var filteredResources = [];
19+
React.useEffect(() => {
20+
document.getElementById('clear').addEventListener('click', () => {
21+
handleInputChange('');
22+
});
23+
});
824
if (window.location.pathname === '/resources') {
925
filteredResources =
1026
resources &&
@@ -48,24 +64,51 @@ const Resources = ({ searchInput, handleInputChange }) => {
4864
);
4965
return (
5066
<div className='container' style={{ marginTop: '1rem', width: '100%' }}>
51-
<div className='columns' style={{ margin: 'auto' }}>
52-
<div className='column is-half is-offset-one-quarter'>
53-
<div className='field'>
54-
<p className='control has-icons-right box-shadow-lift'>
55-
<input
56-
className='input'
57-
type='text'
58-
onChange={handleInputChange}
59-
placeholder='search from resources'
60-
value={searchInput}
67+
<div
68+
className='field has-addons has-addons-centered'
69+
style={{ outline: 'none' }}
70+
>
71+
<p className='control has-icons-left box-shadow-lift'>
72+
<input
73+
className='input'
74+
type='text'
75+
onChange={(e) => handleInputChange(e.target.value)}
76+
placeholder='search from resources'
77+
value={searchInput}
78+
/>
79+
<span className='icon is-small is-left'>
80+
<Search />
81+
</span>
82+
</p>
83+
<div class='control' id='clear'>
84+
<div
85+
class='button is-info'
86+
disabled={searchInput.trim() === '' ? true : false}
87+
>
88+
<span className='icon is-small'>
89+
<XCircle
90+
style={searchInput.trim() === '' ? { color: '#fff' } : {}}
6191
/>
62-
<span className='icon is-small is-right'>
63-
<Search />
64-
</span>
65-
</p>
92+
</span>
6693
</div>
6794
</div>
6895
</div>
96+
<div
97+
style={{ display: 'flex', justifyContent: 'center', padding: '10px' }}
98+
>
99+
<div className='tags'>
100+
{filters.map((filter, index) => (
101+
<span
102+
key={index}
103+
className='tag is-primary'
104+
style={{ cursor: 'pointer' }}
105+
onClick={() => handleInputChange(filter)}
106+
>
107+
{filter}
108+
</span>
109+
))}
110+
</div>
111+
</div>
69112
<Category filteredResources={filteredResources} />
70113
</div>
71114
);

0 commit comments

Comments
 (0)