|
1 | 1 | import React from 'react'; |
2 | | -import { Search } from 'react-feather'; |
| 2 | +import { Search, XCircle } from 'react-feather'; |
3 | 3 | import { resources } from './resourcesData'; |
4 | 4 | import Category from './Category'; |
5 | 5 |
|
6 | 6 | 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 | + ]; |
7 | 18 | var filteredResources = []; |
| 19 | + React.useEffect(() => { |
| 20 | + document.getElementById('clear').addEventListener('click', () => { |
| 21 | + handleInputChange(''); |
| 22 | + }); |
| 23 | + }); |
8 | 24 | if (window.location.pathname === '/resources') { |
9 | 25 | filteredResources = |
10 | 26 | resources && |
@@ -48,24 +64,51 @@ const Resources = ({ searchInput, handleInputChange }) => { |
48 | 64 | ); |
49 | 65 | return ( |
50 | 66 | <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' } : {}} |
61 | 91 | /> |
62 | | - <span className='icon is-small is-right'> |
63 | | - <Search /> |
64 | | - </span> |
65 | | - </p> |
| 92 | + </span> |
66 | 93 | </div> |
67 | 94 | </div> |
68 | 95 | </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> |
69 | 112 | <Category filteredResources={filteredResources} /> |
70 | 113 | </div> |
71 | 114 | ); |
|
0 commit comments