diff --git a/src/App.jsx b/src/App.jsx index 467dcaf..b68cc71 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,14 +1,32 @@ -import React from "react"; +import React, {useEffect, useState}from "react"; +import axios from "axios"; import { createRoot } from "react-dom/client"; // import axios from "axios"; // Maybe we'll need axios? 🤔 import "./style.css"; +import SearchField from "./SearchField"; +import GifCard from "./GifCard"; -// const GIPHY_API_KEY = "YOUR_API_KEY"; +const GIPHY_API_KEY = "3uPYTPfMF80n8U1q1PLoIu75lKpbeFzk"; const App = () => { + const [data, setData] = useState([]); + + const fetchData = async (searchValue) => { + const response = await axios.get(`http://api.giphy.com/v1/gifs/search?q=${searchValue}&api_key=${GIPHY_API_KEY}`) + setData(response.data.data); + // console.log("This is data-->", response.data) + // console.log("This is Search Value-->", searchValue) + }; + // console.log("this is Data-->", data) + + useEffect(() => { + fetchData(); + }, []) return (

Let's Make Some API Requests!

+ +
); }; diff --git a/src/GifCard.css b/src/GifCard.css new file mode 100644 index 0000000..2354978 --- /dev/null +++ b/src/GifCard.css @@ -0,0 +1,10 @@ +.gif-card-container { + display: grid; + grid-template-columns: 1fr 1fr 1fr; + background-color: white; +} + +.cards { + border: solid; + border-color: black; +} \ No newline at end of file diff --git a/src/GifCard.jsx b/src/GifCard.jsx index 24d000d..11f3915 100644 --- a/src/GifCard.jsx +++ b/src/GifCard.jsx @@ -1,7 +1,25 @@ import React from "react"; +import './GifCard.css' -const GifCard = () => { - return
; +const GifCard = ({data}) => { + console.log("this is data-->", data[0]?.title) + return ( +
+
{}
+
ghdgh
+
dfghdh
+
dfghd
+
+
+
+
+
+
hdgh
+
+
+ +
+ ) }; export default GifCard; diff --git a/src/SearchField.css b/src/SearchField.css new file mode 100644 index 0000000..33d55e0 --- /dev/null +++ b/src/SearchField.css @@ -0,0 +1,5 @@ +.search-box { + width: 400px; + height: 50px; + text-align: center; +} \ No newline at end of file diff --git a/src/SearchField.jsx b/src/SearchField.jsx index 3afa0a7..70fc328 100644 --- a/src/SearchField.jsx +++ b/src/SearchField.jsx @@ -1,7 +1,30 @@ -import React from "react"; +import React ,{useState}from "react"; +import './SearchField.css' -const SearchField = () => { - return
; +const SearchField = ({fetchData}) => { + const [searchValue, setSearchValue] = useState() + + const handleInput = (event) => { + setSearchValue(event.target.value) + } + + const handleSubmit = () => { + fetchData(searchValue) + } + return ( +
+
+ +
+ +
+ ); }; +// 3uPYTPfMF80n8U1q1PLoIu75lKpbeFzk export default SearchField;