From d5d052455d58d7458b8730d843396b5907cd247d Mon Sep 17 00:00:00 2001 From: Yuriy Ivanenko Date: Wed, 12 Jun 2024 10:45:29 -0400 Subject: [PATCH 1/9] Render pigs to the screen in tiles --- src/components/App.js | 2 ++ src/components/HogTile.js | 20 ++++++++++++++++++++ src/index.css | 7 +++---- 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/components/HogTile.js diff --git a/src/components/App.js b/src/components/App.js index 344d48d4..719e292e 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -1,5 +1,6 @@ import React from "react"; import Nav from "./Nav"; +import HogTile from "./HogTile"; import hogs from "../porkers_data"; @@ -7,6 +8,7 @@ function App() { return (
); } diff --git a/src/components/HogTile.js b/src/components/HogTile.js new file mode 100644 index 00000000..cfcb2580 --- /dev/null +++ b/src/components/HogTile.js @@ -0,0 +1,20 @@ +import React from "react"; + +const HogTile = ({ hogs }) => { + return ( +
+
+ {hogs.map(hog => { + return ( +
+

{hog.name}

+ +
+ ) + })} +
+
+ ) +} + +export default HogTile; diff --git a/src/index.css b/src/index.css index a89ad3a1..53b896db 100644 --- a/src/index.css +++ b/src/index.css @@ -114,14 +114,13 @@ ul { .minPigTile { width: 250px; - height: 250px; background-size: cover; } .maxPigTile { background-size: cover; - width: 500px; - height: 500px; + width: 100px; + height: 100px; } .pigTile:hover { @@ -149,4 +148,4 @@ ul { to { transform: rotate(360deg); } -} \ No newline at end of file +} From 51ea6ac48f45b50e0b854c3c9dcd3739c28be65f Mon Sep 17 00:00:00 2001 From: Yuriy Ivanenko Date: Wed, 12 Jun 2024 10:59:44 -0400 Subject: [PATCH 2/9] Show hog details when tile is clicked --- src/components/App.js | 4 ++-- src/components/HogList.js | 16 ++++++++++++++++ src/components/HogTile.js | 31 +++++++++++++++++-------------- 3 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 src/components/HogList.js diff --git a/src/components/App.js b/src/components/App.js index 719e292e..ec313d69 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -1,6 +1,6 @@ import React from "react"; import Nav from "./Nav"; -import HogTile from "./HogTile"; +import HogList from "./HogList"; import hogs from "../porkers_data"; @@ -8,7 +8,7 @@ function App() { return (
); } diff --git a/src/components/HogList.js b/src/components/HogList.js new file mode 100644 index 00000000..9d343602 --- /dev/null +++ b/src/components/HogList.js @@ -0,0 +1,16 @@ +import React from "react"; +import HogTile from "./HogTile"; + +const HogList = ({ hogs }) => { + return ( +
+
+ {hogs.map(hog => { + return + })} +
+
+ ) +} + +export default HogList; diff --git a/src/components/HogTile.js b/src/components/HogTile.js index cfcb2580..8e3457af 100644 --- a/src/components/HogTile.js +++ b/src/components/HogTile.js @@ -1,19 +1,22 @@ -import React from "react"; +import React, { useState } from "react"; -const HogTile = ({ hogs }) => { +const HogTile = ({ hog }) => { + const [showDetails, setShowDetails] = useState(false) + const handleShowDetails = () => setShowDetails(!showDetails) + return ( -
-
- {hogs.map(hog => { - return ( -
-

{hog.name}

- -
- ) - })} -
-
+
+

{hog.name}

+ {showDetails ? + <> +

{hog.specialty}

+

{hog.weight}

+

{hog.greased}

+

{hog["highest medal achieved"]}

+ + : null} + +
) } From 069c5aaf9434caf1554eed3ae2416b8fbf78b54d Mon Sep 17 00:00:00 2001 From: Yuriy Ivanenko Date: Wed, 12 Jun 2024 11:40:04 -0400 Subject: [PATCH 3/9] Allow users to filter for greased pigs --- src/components/App.js | 2 ++ src/components/HogList.js | 59 +++++++++++++++++++++++++++++++++++---- src/components/HogTile.js | 2 +- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/components/App.js b/src/components/App.js index ec313d69..abb5c020 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -5,6 +5,8 @@ import HogList from "./HogList"; import hogs from "../porkers_data"; function App() { + + return (
diff --git a/src/components/App.js b/src/components/App.js index 3041bad4..5606e3c6 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -1,9 +1,11 @@ -import React, { useState } from "react"; -import Nav from "./Nav"; -import HogList from "./HogList"; -import AddHogForm from "./AddHogForm"; +import React, { useState } from "react" + +import hogs from "../porkers_data" + +import Nav from "./Nav" +import HogList from "./HogList" +import AddHogForm from "./AddHogForm" -import hogs from "../porkers_data"; function App() { const [hogsList, setHogsList] = useState(hogs) From b1f18cd124bcc087e44ae52e166d9e9319b731d9 Mon Sep 17 00:00:00 2001 From: Yuriy Ivanenko Date: Thu, 13 Jun 2024 09:08:27 -0400 Subject: [PATCH 9/9] Change styling for cards using semantic ui --- src/components/AddHogForm.js | 1 + src/components/HogTile.js | 31 +++++++++++++++++++------------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/components/AddHogForm.js b/src/components/AddHogForm.js index a2cbf5a3..c2ee4a24 100644 --- a/src/components/AddHogForm.js +++ b/src/components/AddHogForm.js @@ -65,6 +65,7 @@ const AddHogForm = ({ handleNewHog }) => {