feat: enhance README and TODO documentation, implement mobile menu functionality in Header component

- Updated README.md with project details, quick start instructions, and tech stack.
- Expanded TODO.md to reflect current project status and backlog items, including Linear ticket synchronization.
- Added mobile menu toggle functionality in Header component with corresponding tests for user interactions.
- Configured Next.js for Docker deployment and optimized build settings.
This commit is contained in:
Do Siki
2025-09-05 17:28:52 +02:00
parent 578a85ec1a
commit b0df8dd182
50 changed files with 7758 additions and 67 deletions
+82 -2
View File
@@ -1,7 +1,7 @@
import { render, screen } from '@testing-library/react'
import { render, screen, fireEvent } from '@testing-library/react'
import '@testing-library/jest-dom'
import Header from './Header'
import userEvent from '@testing-library/user-event'
import Header from './Header'
// Mock Next.js Link component
jest.mock('next/link', () => {
@@ -77,4 +77,84 @@ describe('Header', () => {
// Should be sticky positioned
expect(header).toHaveClass('sticky', 'top-0')
})
it('should toggle mobile menu when hamburger button is clicked', async () => {
const user = userEvent.setup()
render(<Header />)
const hamburgerButton = screen.getByRole('button')
// Initially menu should be closed
expect(hamburgerButton).toHaveAttribute('aria-expanded', 'false')
// Click to open menu
await user.click(hamburgerButton)
expect(hamburgerButton).toHaveAttribute('aria-expanded', 'true')
// Click again to close menu
await user.click(hamburgerButton)
expect(hamburgerButton).toHaveAttribute('aria-expanded', 'false')
})
it('should close mobile menu when navigation link is clicked', async () => {
const user = userEvent.setup()
render(<Header />)
const hamburgerButton = screen.getByRole('button')
// Open the mobile menu
await user.click(hamburgerButton)
expect(hamburgerButton).toHaveAttribute('aria-expanded', 'true')
// Find a navigation link in the mobile menu and click it
const mobileNavLinks = screen.getAllByText('Rólunk')
const mobileLink = mobileNavLinks.find(link =>
link.closest('.md\\:hidden') !== null
)
if (mobileLink) {
await user.click(mobileLink)
expect(hamburgerButton).toHaveAttribute('aria-expanded', 'false')
}
})
it('should have correct navigation links with proper hrefs', () => {
render(<Header />)
// Check for home link
const homeLinks = screen.getAllByText('Kezdőlap')
expect(homeLinks.length).toBeGreaterThan(0)
expect(homeLinks[0].closest('a')).toHaveAttribute('href', '/')
// Check for about link
const aboutLinks = screen.getAllByText('Rólunk')
expect(aboutLinks.length).toBeGreaterThan(0)
expect(aboutLinks[0].closest('a')).toHaveAttribute('href', '/rolunk')
// Check for services link
const servicesLinks = screen.getAllByText('Szolgáltatások')
expect(servicesLinks.length).toBeGreaterThan(0)
expect(servicesLinks[0].closest('a')).toHaveAttribute('href', '/szolgaltatasok')
// Check for contact link
const contactLinks = screen.getAllByText('Kapcsolat')
expect(contactLinks.length).toBeGreaterThan(0)
expect(contactLinks[0].closest('a')).toHaveAttribute('href', '/kapcsolat')
})
it('should have proper responsive classes', () => {
const { container } = render(<Header />)
// Desktop menu should be hidden on mobile
const desktopMenu = container.querySelector('.hidden.md\\:block')
expect(desktopMenu).toBeInTheDocument()
// Mobile menu button should be hidden on desktop
const mobileMenuButton = container.querySelector('.md\\:hidden button')
expect(mobileMenuButton).toBeInTheDocument()
// Mobile menu should be positioned correctly
const mobileMenu = container.querySelector('.md\\:hidden.absolute')
expect(mobileMenu).toBeInTheDocument()
})
})
+42 -19
View File
@@ -1,6 +1,15 @@
'use client'
import { siteConfig } from '@/config/site'
import { useState } from 'react'
export default function Header() {
const [isMenuOpen, setIsMenuOpen] = useState(false)
const toggleMenu = () => {
setIsMenuOpen(!isMenuOpen)
}
return (
<header className="bg-white border-b border-gray-200 sticky top-0 z-50">
<nav className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
@@ -36,32 +45,46 @@ export default function Header() {
<div className="md:hidden">
<button
type="button"
onClick={toggleMenu}
className="text-gray-500 hover:text-gray-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-blue-500"
aria-expanded="false"
aria-expanded={isMenuOpen}
>
<span className="sr-only">Open main menu</span>
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h16" />
</svg>
<span className="sr-only">{isMenuOpen ? 'Close main menu' : 'Open main menu'}</span>
{isMenuOpen ? (
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
) : (
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h16" />
</svg>
)}
</button>
</div>
</div>
{/* Mobile Navigation - Hidden by default */}
<div className="md:hidden absolute top-full left-0 right-0 bg-white border-b border-gray-200 shadow-lg opacity-0 invisible transition-all duration-300 ease-in-out">
{/* Mobile Navigation - Dynamic visibility */}
<div className={`md:hidden absolute top-full left-0 right-0 bg-white border-b border-gray-200 shadow-lg transition-all duration-300 ease-in-out ${
isMenuOpen
? 'opacity-100 visible'
: 'opacity-0 invisible'
}`}>
<div className="px-2 pt-2 pb-3 space-y-1">
<a href="/" className="block px-3 py-2 rounded-md text-base font-medium text-gray-900 hover:text-blue-600">
Kezdőlap
</a>
<a href="/rolunk" className="block px-3 py-2 rounded-md text-base font-medium text-gray-900 hover:text-blue-600">
Rólunk
</a>
<a href="/szolgaltatasok" className="block px-3 py-2 rounded-md text-base font-medium text-gray-900 hover:text-blue-600">
Szolgáltatások
</a>
<a href="/kapcsolat" className="block px-3 py-2 rounded-md text-base font-medium bg-blue-600 text-white">
Kapcsolat
</a>
{siteConfig.navigation.main.map((item) => (
<a
key={item.href}
href={item.href}
target={item.external ? '_blank' : undefined}
rel={item.external ? 'noopener noreferrer' : undefined}
onClick={() => setIsMenuOpen(false)}
className={item.label === 'Kapcsolat'
? "block px-3 py-2 rounded-md text-base font-medium bg-blue-600 text-white"
: "block px-3 py-2 rounded-md text-base font-medium text-gray-900 hover:text-blue-600 hover:bg-blue-50"
}
>
{item.label}
</a>
))}
</div>
</div>
</nav>