-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mm 005 header v2 #7
Changes from 10 commits
cfef2ec
333fd03
e0fe437
5123b30
ee7f67e
154dea0
2e6bd7e
27def32
a1a8d64
d68c747
bd1ca07
6f2a0c7
0b557f0
09955b6
2477c36
234e24b
16f11b9
8ebf9d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import App from './App'; | ||
import "@testing-library/jest-dom"; | ||
import Hamburger from './Hamburgerbutton'; | ||
|
||
|
||
// remove this test when real tests are added | ||
test('renders header', () => { | ||
render(<App />); | ||
const header = screen.getAllByText(/MarsioKart/i); | ||
expect(header[0]).toBeInTheDocument(); | ||
}); | ||
const header = screen.getByText(/MarsioKart/i); | ||
expect(header).toBeInTheDocument(); | ||
}); | ||
|
||
test('calls onClick when Hamburger button is clicked', () => { | ||
const handleClick = jest.fn(); | ||
render(<Hamburger onClick={handleClick} label="Click Me" />); | ||
|
||
const button = screen.getByText('Click Me'); | ||
fireEvent.click(button); | ||
|
||
expect(handleClick).toHaveBeenCalledTimes(1); | ||
}); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is looking great and is nice and clear - in order to prevent the src folder from being too full of separate files (and therefore harder to read through) please can you create a Hamburgerbutton folder and put this file and Hamburgerbusston.tsx in it |
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; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import './Hamburgerbutton.scss'; // styling for the hmauburger button icon | ||
|
||
interface HamburgerProps { | ||
onClick: () => void; | ||
label: string; | ||
|
||
} | ||
|
||
const Hamburger: React.FC<HamburgerProps> = ({ onClick , label}) => { | ||
|
||
const handleClick = () => { | ||
onClick(); | ||
}; | ||
|
||
return ( | ||
<button onClick={handleClick} className="hamburger"> | ||
{/* draw the 3 lines which make up the hmburger */} | ||
{label} | ||
<div className="line" /> | ||
<div className="line" /> | ||
<div className="line" /> | ||
</button> | ||
); | ||
}; | ||
|
||
export default Hamburger; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above - please can you also create a Header folder and put this file in it |
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} label={""}/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Header; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you remove the
<div>
s from this line and just have<Header/>
it will be easier for a screen reader to see what is happening and translate it - please can you do that?