Skip to content

Commit

Permalink
MM-005: Add header with hamburger button
Browse files Browse the repository at this point in the history
  • Loading branch information
Anum1608 committed Jul 30, 2024
1 parent 5a1238a commit cfef2ec
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react';
import logo from './logo.svg';
import './App.scss';
import Header from './header';

function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
{/* <img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
Expand All @@ -17,7 +18,10 @@ function App() {
rel="noopener noreferrer"
>
Learn React
</a>
</a> */}

<Header/>

</header>
</div>
);
Expand Down
18 changes: 18 additions & 0 deletions src/Hamburgerbutton.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.hamburger {
display: flex;
flex-direction: column;
justify-content: space-around;
width: 30px;
height: 30px;
background: transparent;
border: none;
cursor: pointer;
}

.line {
width: 100%;
height: 3px;
background-color: black;
transition: all 0.3s ease;
}

24 changes: 24 additions & 0 deletions src/Hamburgerbutton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import './Hamburgerbutton.scss'; // styling for the hmauburger button icon

interface HamburgerProps {
onClick: () => void;
}

const Hamburger: React.FC<HamburgerProps> = ({ onClick }) => {

const handleClick = () => {
onClick();
};

return (
<button onClick={handleClick} className="hamburger">
{/* draw the 3 lines which make up the hmburger */}
<div className="line" />
<div className="line" />
<div className="line" />
</button>
);
};

export default Hamburger;
16 changes: 16 additions & 0 deletions src/header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import Hamburger from './Hamburgerbutton';

const Header: React.FC = () => {
const handleHamburgerClick = () => {
console.log('Hamburger menu clicked!');
};

return (
<div className="App">
<Hamburger onClick={handleHamburgerClick} />
</div>
);
};

export default Header;

0 comments on commit cfef2ec

Please sign in to comment.