Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions frontend/__tests__/unit/components/ScrollToTop.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ describe('ScrollToTop component test', () => {
Object.defineProperty(globalThis, 'scrollY', { value: 400, writable: true })
globalThis.dispatchEvent(new Event('scroll'))

Object.defineProperty(globalThis, 'scrollY', {
value: 500,
writable: true,
})
globalThis.dispatchEvent(new Event('scroll'))

await waitFor(() => {
expect(button).toHaveClass('opacity-100')
expect(button).toHaveClass('pointer-events-auto')
Expand Down
2 changes: 1 addition & 1 deletion frontend/__tests__/unit/pages/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ describe('Header Component', () => {
expect(logoImages.length).toBe(2)

for (const logo of logoImages) {
expect(logo).toHaveAttribute('src', '/img/logo_dark.png')
expect(logo).toHaveAttribute('src', '/img/logo_light.png')
expect(logo).toBeInTheDocument()
}
})
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Button } from '@heroui/button'
import Image from 'next/image'
import Link from 'next/link'
import { usePathname } from 'next/navigation'
import { useTheme } from 'next-themes'
import { useEffect, useState } from 'react'
import {
FaRegHeart,
Expand All @@ -22,7 +23,16 @@ import UserMenu from 'components/UserMenu'

export default function Header({ isGitHubAuthEnabled }: { readonly isGitHubAuthEnabled: boolean }) {
const pathname = usePathname()
const { resolvedTheme } = useTheme()
const [mounted, setMounted] = useState(false)
const [mobileMenuOpen, setMobileMenuOpen] = useState(false)

useEffect(() => {
setMounted(true)
}, [])

const logoSrc = mounted && resolvedTheme === 'dark' ? '/img/logo_dark.png' : '/img/logo_light.png'

const toggleMobileMenu = () => setMobileMenuOpen(!mobileMenuOpen)

useEffect(() => {
Expand Down Expand Up @@ -70,7 +80,7 @@ export default function Header({ isGitHubAuthEnabled }: { readonly isGitHubAuthE
width={64}
height={64}
priority={true}
src={'/img/logo_dark.png'}
src={logoSrc}
className="h-full w-auto object-contain"
alt="OWASP Logo"
/>
Expand Down Expand Up @@ -167,7 +177,7 @@ export default function Header({ isGitHubAuthEnabled }: { readonly isGitHubAuthE
width={64}
height={64}
priority={true}
src={'/img/logo_dark.png'}
src={logoSrc}
className="h-full w-auto object-contain"
alt="OWASP Logo"
/>
Expand Down