diff --git a/src/Components/HomePage/Hero/Hero.jsx b/src/Components/HomePage/Hero/Hero.jsx index 5d2471a..57c8594 100644 --- a/src/Components/HomePage/Hero/Hero.jsx +++ b/src/Components/HomePage/Hero/Hero.jsx @@ -4,152 +4,145 @@ import SearchResult from "../SearchResults/SearchResult"; import "./hero.css"; const Hero = () => { - const [query, setQuery] = useState(""); - const [images,setImages] = useState([]); + const [query, setQuery] = useState(""); + const [images, setImages] = useState([]); - const baseurl = `https://api.pexels.com/v1/search?query=${query}&per_page=50`; - - - - const handleSubmit = async (e) => { - e.preventDefault(); - try { - const response = await fetch(baseurl, { - method: "GET", - // mode: "cors", - headers: { - Authorization: process.env.REACT_APP_API_KEY, - "Content-Type": "application/json", - } - }); - const data = await response.json(); - console.log(data.photos) - setImages(data); - } catch (error) { - console.log(error); - } - }; + const handleSubmit = async (e) => { + if (e.target.value) { + const response = await fetch(`https://api.pexels.com/v1/search?query=${query}&per_page=50`, { + method: "GET", + headers: { + Authorization: process.env.REACT_APP_API_KEY, + "Content-Type": "application/json", + } + }); + const data = await response.json(); + setImages(data); + console.log(data.photos) + console.log(images) + } + }; const handleChange = (e) => { - setQuery(e.target.value); - }; + setQuery(e.target.value); + }; - return ( -
-
-
-
-

Image Search

-
Freely-usaable images, Powered by creators worldwide
-
-
-
- - -
-
-
-
- {/* Gallery 01 */} - Gallery 01 -
-
- {/* Gallery 02 */} - Gallery 02 -
-
- {/* Gallery 03 */} - Gallery 03 -
-
- {/* Gallery 04 */} - Gallery 04 -
-
- {/* Gallery 05 */} - Gallery 05 -
-
- {/* Gallery 06 */} - Gallery 06 -
-
- {/* Gallery 07 */} - Gallery 07 -
-
- {/* Gallery 08 */} - Gallery 08 -
-
- {/* Gallery 09 */} - Gallery 09 -
-
- {/* Gallery 10 */} - Gallery 10 -
-
- {/* Gallery 11 */} - Gallery 11 -
-
- {/* Gallery 12 */} - Gallery 12 -
-
- {/* Gallery 13 */} - Gallery 13 -
-
- {/* Gallery 14 */} - Gallery 14 -
- {/* */} -
- {/* Gallery 15 */} - Gallery 15 -
-
- {/* Gallery 16 */} - Gallery 16 -
-
- {/* Gallery 17 */} - Gallery 17 -
-
- {/* Gallery 18 */} - Gallery 18 -
-
- {/* Gallery 19 */} - Gallery 19 -
-
- {/* Gallery 20 */} - Gallery 20 -
-
+ return ( +
+
+
+
+

Image Search

+
Freely-usaable images, Powered by creators worldwide
+
+
+
+ { if (e.key == "Enter") handleSubmit(); }} + className="py-3 px-5 form-control relative flex-auto min-w-0 block w-full text-base font-normal text-gray-700 bg-white bg-clip-padding border border-solid border-gray-300 rounded transition ease-in-out m-0 focus:text-gray-700 focus:bg-white focus:border-cyan-600 focus:outline-none" + placeholder="Search" + aria-label="Search" + aria-describedby="button-addon2" + /> + +
+
+
+
+ {/* Gallery 01 */} + Gallery 01 +
+
+ {/* Gallery 02 */} + Gallery 02 +
+
+ {/* Gallery 03 */} + Gallery 03 +
+
+ {/* Gallery 04 */} + Gallery 04 +
+
+ {/* Gallery 05 */} + Gallery 05 +
+
+ {/* Gallery 06 */} + Gallery 06 +
+
+ {/* Gallery 07 */} + Gallery 07 +
+
+ {/* Gallery 08 */} + Gallery 08 +
+
+ {/* Gallery 09 */} + Gallery 09 +
+
+ {/* Gallery 10 */} + Gallery 10 +
+
+ {/* Gallery 11 */} + Gallery 11 +
+
+ {/* Gallery 12 */} + Gallery 12 +
+
+ {/* Gallery 13 */} + Gallery 13 +
+
+ {/* Gallery 14 */} + Gallery 14 +
+ {/* */} +
+ {/* Gallery 15 */} + Gallery 15 +
+
+ {/* Gallery 16 */} + Gallery 16 +
+
+ {/* Gallery 17 */} + Gallery 17 +
+
+ {/* Gallery 18 */} + Gallery 18 +
+
+ {/* Gallery 19 */} + Gallery 19 +
+
+ {/* Gallery 20 */} + Gallery 20 +
+
- - -
- ) + + +
+ ) } -export default Hero \ No newline at end of file +export default Hero