Skip to content

Commit

Permalink
Merge pull request #21 from JumboCode/DropDownWrapper
Browse files Browse the repository at this point in the history
Drop down wrapper
  • Loading branch information
myix765 authored Nov 2, 2024
2 parents 5c0bcc2 + 05f91fd commit 7aeb08d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import NavBar from '@/components/NavBar/NavBar'
import PageRoutes from '@/components/PageRoutes'
import "./i18n.js";

function App() {
const App = () => {
return (
<>
<NavBar />
Expand Down
36 changes: 35 additions & 1 deletion src/components/Dropdown.jsx
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
// TODO (Togzhan & Yi & Aryaa): Create a dropdown component
import React, { useState } from 'react';

const Dropdown = ({ label, children }) => {
//use isOpen to keep track of whether the dropdown menu is visible
const [isOpen, setIsOpen] = useState(false);

return (
<div
// style below for menu
className="absolute inline-block"

//If the mouse is on the menu, turn state to true, otherwise false
onClick={() => {
if(isOpen) {
setIsOpen(false);
} else{
setIsOpen(true);
}
}
}
>
<button className="dropdown-button text-right">{label}</button>
{isOpen && (
// style below for children
<div className="absolute text-right flex flex-col">
{children}
</div>
)}
</div>
);
};

export default Dropdown;


0 comments on commit 7aeb08d

Please sign in to comment.