This commit is contained in:
Kovács Rudolf committed 2026-11-19 10:41:05 +01:00
1 parent bdac48678b
commit 65dafdd4c0
2 files changed
+24 -3

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@ function Cocktail({cocktail}) {
<div class="bg-white rounded-xl shadow-md overflow-hidden border border-orange-100 transform hover:scale-105 transition-transform duration-300"> <div class="bg-white rounded-xl shadow-md overflow-hidden border border-orange-100 transform hover:scale-105 transition-transform duration-300">
{/*<!-- Kép helye -->*/} {/*<!-- Kép helye -->*/}
<div class="h-48 bg-orange-200 flex items-center justify-center relative"> <div class="h-48 bg-orange-200 flex items-center justify-center relative">
<img src={cocktail.strImageSource} alt="" class="w-full h-full object-cover absolute inset-0" id="cocktail-image"/> <img src={cocktail.strDrinkThumb} alt="" class="w-full h-full object-cover absolute inset-0" id="cocktail-image"/>
<div class="absolute inset-0 bg-black opacity-20"></div> <div class="absolute inset-0 bg-black opacity-20"></div>
<span class="relative z-10 text-white font-bold text-lg px-3 py-1 bg-orange-600 rounded-full"> <span class="relative z-10 text-white font-bold text-lg px-3 py-1 bg-orange-600 rounded-full">
Koktél Koktél
+23 -2
View File
@@ -1,5 +1,5 @@
import { useState } from "react"; import { useState } from "react";
import Cocktail from "./Cocktail";
function SearchName() { function SearchName() {
@@ -7,6 +7,13 @@ function SearchName() {
const [cocktails,setCocktails]=useState([]); const [cocktails,setCocktails]=useState([]);
const [cocktailName,setCocktailName]=useState(""); const [cocktailName,setCocktailName]=useState("");
const getCocktails=(cocktail)=>{
fetch(`https://www.thecocktaildb.com/api/json/v1/1/search.php?s=${cocktail}`)
.then(res=>res.json())
.then(adat=>setCocktails(adat.drinks))
.catch(err=>alert(err));
}
return ( return (
<main class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-12"> <main class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
{/* komment*/} {/* komment*/}
@@ -29,7 +36,7 @@ function SearchName() {
id="cocktail-name-input"/> id="cocktail-name-input"/>
</div> </div>
<div class="flex space-x-4"> <div class="flex space-x-4">
<button type="submit" class="flex-1 bg-orange-500 hover:bg-orange-600 text-white font-bold py-3 px-4 rounded-lg transition-colors duration-300 shadow-md"> <button type="button" onClick={()=>getCocktails(cocktailName)} class="flex-1 bg-orange-500 hover:bg-orange-600 text-white font-bold py-3 px-4 rounded-lg transition-colors duration-300 shadow-md">
Keresés Keresés
</button> </button>
<button type="button" class="flex-1 bg-white border border-orange-300 hover:bg-orange-50 text-orange-700 font-bold py-3 px-4 rounded-lg transition-colors duration-300"> <button type="button" class="flex-1 bg-white border border-orange-300 hover:bg-orange-50 text-orange-700 font-bold py-3 px-4 rounded-lg transition-colors duration-300">
@@ -45,6 +52,20 @@ function SearchName() {
<p class="col-span-full text-center text-gray-500 py-12 text-lg"> <p class="col-span-full text-center text-gray-500 py-12 text-lg">
Írj be egy koktél nevet a keresőbe, hogy megjelenjen az eredmény! Írj be egy koktél nevet a keresőbe, hogy megjelenjen az eredmény!
</p> </p>
{
(cocktails && cocktails.length>0) ?
<>
{
cocktails.map((cocktail)=>(<Cocktail key={cocktail.idDrink} cocktail={cocktail} />))
}
</>
:
<>
<p class="col-span-full text-center text-gray-500 py-12 text-lg">
Nincs ilyen koktél!
</p>
</>
}
</div> </div>