diff --git a/src/components/Dropdown.jsx b/src/components/Dropdown.jsx
index d24c1c3..35b1571 100644
--- a/src/components/Dropdown.jsx
+++ b/src/components/Dropdown.jsx
@@ -1,11 +1,12 @@
import React, { useState } from 'react';
-//use isOpen to keep track of whether the dropdown menu is visible
const Dropdown = ({ label, children }) => {
+ //use isOpen to keep track of whether the dropdown menu is visible
const [isOpen, setIsOpen] = useState(false);
return (
{
}, 1000);
}}
>
-
+
{isOpen && (
-
+ // style below for children
+
{children}
)}
@@ -28,3 +30,5 @@ const Dropdown = ({ label, children }) => {
};
export default Dropdown;
+
+
From 3ec172e382122c389d90d7d7dbf0ef068410c7e3 Mon Sep 17 00:00:00 2001
From: Yi Gu <2962915100@qq.com.com>
Date: Sun, 27 Oct 2024 20:38:55 -0400
Subject: [PATCH 6/9] drop-down-wrapper
---
src/components/Dropdown.jsx | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/components/Dropdown.jsx b/src/components/Dropdown.jsx
index 35b1571..5dd55fd 100644
--- a/src/components/Dropdown.jsx
+++ b/src/components/Dropdown.jsx
@@ -10,13 +10,23 @@ const Dropdown = ({ label, children }) => {
class="absolute inline-block"
//use onMouseEnter and onMouseLeave to track the mouse
//If the mouse is on the menu, turn state to true, otherwise false
- onMouseEnter={() => setIsOpen(true)}
- onMouseLeave={() => {
- // Set a 1-second delay before closing the menu
- timeoutId = setTimeout(() => {
- setIsOpen(false);
- }, 1000);
- }}
+ onClick={() => {
+ if(isOpen) {
+ setIsOpen(false);
+ } else{
+ setIsOpen(true);
+ }
+ }
+ }
+ // if (isOpen ) {
+ // onclick={() => setIsOpen(false)}
+ // // onMouseLeave={() => {
+ // // // Set a 1-second delay before closing the menu
+ // // timeoutId = setTimeout(() => {
+ // // setIsOpen(false);
+ // // }, 1000);
+ // // }}
+ // }
>
{isOpen && (
From 21a28cdc7fbf58f3ac843f8b09a052b10c7aa2d5 Mon Sep 17 00:00:00 2001
From: Yi Gu <2962915100@qq.com.com>
Date: Sun, 27 Oct 2024 20:39:49 -0400
Subject: [PATCH 7/9] drop-down-wrapper
---
src/components/Dropdown.jsx | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/src/components/Dropdown.jsx b/src/components/Dropdown.jsx
index 5dd55fd..323603a 100644
--- a/src/components/Dropdown.jsx
+++ b/src/components/Dropdown.jsx
@@ -8,7 +8,7 @@ const Dropdown = ({ label, children }) => {