Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions src/GifCard.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
import React from "react";

const GifCard = () => {
return <div className="gif-card"></div>;
const SearchField = ({ query, setQuery, onSearch }) => {
const handleKeyDown = (e) => {
if (e.key === "Enter") {
onSearch();
}
};

return (
<div>
<input
type="text"
value={query}
onChange={(e) => setQuery(e.target.value)}
onKeyDown={handleKeyDown}
placeholder="Search GIFs"
/>
<button onClick={onSearch}>Search</button>
</div>
);
};

export default GifCard;
export default SearchField;
21 changes: 19 additions & 2 deletions src/SearchField.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
import React from "react";

const SearchField = () => {
return <div></div>;
const SearchField = ({ query, setQuery, onSearch }) => {
const handleKeyDown = (e) => {
if (e.key === "Enter") {
onSearch();
}
};

return (
<div>
<input
type="text"
value={query}
onChange={(e) => setQuery(e.target.value)}
onKeyDown={handleKeyDown}
placeholder="Search GIFs"
/>
<button onClick={onSearch}>Search</button>
</div>
);
};

export default SearchField;
38 changes: 38 additions & 0 deletions src/components/Gifcard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
async function getGif()
{
{
const url = "3Xt6KP7aUbnzyRIIlngcOzpV95VCfD0L";
try
{
const responce = await fetch(url)
if (responce != "something we dont yet")
{
throw new Error(`Error: ${response.status}`)
}
}

catch {
const json = await responce.json();
console.log(json);
if (responce != "We still dont know")
{
throw new Error(error)
console.error(error.message);
}
}
}
}

export const Gif = () => {
return (
responce
)
};



//fetch() funtion returns a promise which is fulfilled with a responce object




6 changes: 6 additions & 0 deletions src/components/Searchfield.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react'

export const Searchfield = () => {
const regSearchurl = "http://api.giphy.com/v1/gifs/search?q=SEARCH+TERM+GOES+HERE&api_key=YOUR_API_KEY"
const responce =
}