diff --git a/src/components/BreadDetail/BreadDetail.tsx b/src/components/BreadDetail/BreadDetail.tsx index 2ea368d..bbb3297 100644 --- a/src/components/BreadDetail/BreadDetail.tsx +++ b/src/components/BreadDetail/BreadDetail.tsx @@ -4,54 +4,122 @@ import { fetchBreadsForCountry } from "../../apiCalls"; import { BreadAttributes } from "../../apiTypes"; const BreadDetail = () => { - const { id: countryName, breadId } = useParams<{ id: string; breadId: string; }>(); - const [breadDetail, setBreadDetail] = useState(null); - const navigate = useNavigate(); - - useEffect(() => { - if (countryName) { - fetchBreadsForCountry(countryName) - .then((data) => { - const bread = data.breads.data.find(bread => bread.attributes.name === breadId); - if (bread) { - setBreadDetail(bread.attributes); - } else { - navigate('/error'); // Redirect to error page - } - }) - .catch((error) => { - navigate('/error'); // Redirect to error page - }); - } - }, [countryName, breadId, navigate]); - - if (!breadDetail) return
Loading...
; - - return ( -
-
-

{breadDetail.name}

-

{breadDetail.description}

- {breadDetail.name} -
-
-
-

Ingredients

-
    - {breadDetail.recipe.ingredients.map((ingredient, index) => ( -
  • {ingredient}
  • - ))} -
-

Instructions

-
    - {breadDetail.recipe.instructions.map((instruction, index) => ( -
  1. {instruction}
  2. - ))} -
-
-
-
- ); + const { id: countryName, breadId } = useParams<{ + id: string; + breadId: string; + }>(); + const [breadDetail, setBreadDetail] = useState(null); + const navigate = useNavigate(); + const [isFlipped, setFlip] = useState(false); + + const handleFlip = (event: React.MouseEvent) => { + event.preventDefault(); + setFlip(!isFlipped); + }; + + useEffect(() => { + if (countryName) { + fetchBreadsForCountry(countryName) + .then((data) => { + const bread = data.breads.data.find( + (bread) => bread.attributes.name === breadId + ); + if (bread) { + setBreadDetail(bread.attributes); + } else { + navigate("/error"); // Redirect to error page + } + }) + .catch((error) => { + navigate("/error"); // Redirect to error page + }); + } + }, [countryName, breadId, navigate]); + + if (!breadDetail) return
Loading...
; + + return ( + //
+ //
+ //

{breadDetail.name}

+ //

{breadDetail.description}

+ // {breadDetail.name} + //
+ //
+ //
+ //

Ingredients

+ //
    + // {breadDetail.recipe.ingredients.map((ingredient, index) => ( + //
  • {ingredient}
  • + // ))} + //
+ //

Instructions

+ //
    + // {breadDetail.recipe.instructions.map((instruction, index) => ( + //
  1. {instruction}
  2. + // ))} + //
+ //
+ //
+ //
+ + //BROKEN ANIMATION ATTEMPT: NO ERRORS / NO RENDERING +
+
+

{breadDetail.name}

+

+ {breadDetail.description} +

+
+ +
+
+
+
+
+ {breadDetail.name} +
+ +
+
+

+ Ingredients +

+
    + {breadDetail.recipe.ingredients.map((ingredient, index) => ( +
  • {ingredient}
  • + ))} +
+

+ Instructions +

+
    + {breadDetail.recipe.instructions.map( + (instruction, index) => ( +
  1. + {instruction} +
  2. + ) + )} +
+
+
+
+
+
+
+
+ ); }; export default BreadDetail; diff --git a/src/components/Main/Main.css b/src/components/Main/Main.css index 3b93546..dc9b32d 100644 --- a/src/components/Main/Main.css +++ b/src/components/Main/Main.css @@ -12,4 +12,27 @@ body, html { .error-container { display: flex; justify-content: center; -} \ No newline at end of file +} + +@layer utilities { + @keyframes wiggle { + 25% { + transform: translateX(-5px); + } + 50% { + transform: translateX(5px); + } + 75% { + transform: translateX(-5px); + } + 100% { + transform: translateX(5px); + } + } + } + + @layer components { + .animate-wiggle { + animation: wiggle 0.5s ease-in-out infinite; + } + } \ No newline at end of file diff --git a/src/components/Main/Main.tsx b/src/components/Main/Main.tsx index 909b007..7ce82ff 100644 --- a/src/components/Main/Main.tsx +++ b/src/components/Main/Main.tsx @@ -7,7 +7,7 @@ const Main = () => { return (
-

Select a country from our world bakery!

+

Select a country from our world bakery!

diff --git a/tailwind.config.js b/tailwind.config.js index d242c38..8848bb4 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -8,6 +8,16 @@ module.exports = { ], theme: { extend: { + keyframes: { + flip: { + '0%, 100%': { transform: 'rotateY(0)' }, + '50%': { transform: 'rotateY(180deg)' }, + }, + }, + animation: { + flip: 'flip 1s ease-in-out', + }, + fontFamily:{ 'abel': ['Abel', 'sans-serif'], satisfy:["Satisfy", "cursive"]