diff --git a/src/components/App.js b/src/components/App.js
index 6b15d49f8..9cc785165 100644
--- a/src/components/App.js
+++ b/src/components/App.js
@@ -1,18 +1,27 @@
-import React from "react";
+import React, { useState } from "react";
import ShoppingList from "./ShoppingList";
import itemData from "../data/items";
function App() {
+ // Create a state variable to track whether dark mode is enabled
+ const [isDarkMode, setIsDarkMode] = useState(false);
- // replace 'false' with a state variable that can be toggled between true and false
- // this will be used for the Dark Mode Toggle feature
- const appClass = false ? "App dark" : "App light"
+ // Toggle dark mode
+ const toggleDarkMode = () => {
+ setIsDarkMode(!isDarkMode);
+ };
+
+ // Define the CSS class based on the state variable
+ const appClass = isDarkMode ? "App dark" : "App light";
+
+ // Define the button text based on the state variable
+ const buttonText = isDarkMode ? "Toggle Light Mode" : "Toggle Dark Mode";
return (
Shopster
-
+
diff --git a/src/components/Item.js b/src/components/Item.js
index b833ecf8e..d375320b9 100644
--- a/src/components/Item.js
+++ b/src/components/Item.js
@@ -1,11 +1,17 @@
-import React from "react";
+import React, { useState } from "react";
function Item({ name, category }) {
+ const [isInCart, setIsInCart] = useState(false); // Initialize with false
+ const toggleCartStatus = () => {
+ setIsInCart(!isInCart); // Toggle the cart status
+ };
return (
-
+
{name}{category}
-
+
);
}
diff --git a/src/components/ShoppingList.js b/src/components/ShoppingList.js
index a48d82615..67a6f43c2 100644
--- a/src/components/ShoppingList.js
+++ b/src/components/ShoppingList.js
@@ -1,11 +1,29 @@
-import React from "react";
+import React, { useState } from "react";
import Item from "./Item";
function ShoppingList({ items }) {
+ // Create a state variable for the selected category and initialize it to "All"
+ const [selectedCategory, setSelectedCategory] = useState("All");
+
+ // Function to handle changes in the