Skip to content

Made OWASP Nest logo dynamically toggle in dark and light theme#4370

Open
harshita8120 wants to merge 3 commits intoOWASP:mainfrom
harshita8120:fix/navbar-logo-visibility-light-theme
Open

Made OWASP Nest logo dynamically toggle in dark and light theme#4370
harshita8120 wants to merge 3 commits intoOWASP:mainfrom
harshita8120:fix/navbar-logo-visibility-light-theme

Conversation

@harshita8120
Copy link
Copy Markdown
Contributor

Resolves #4318 Navbar logo does not adapt to light/dark theme, causing poor visibility in light mode

Proposed change

The changes were made in the frontend/src/components/Header.tsx file. When the theme was selected dark, the logo image "logo_dark" is loaded and when the theme is light, the logo image "logo_light" is loaded. Thus, while switching themes, the logos changes dynamically improving the visual contrast.

Checklist

  • Required: I followed the contributing workflow
  • Required: I verified that my code works as intended and resolves the issue as described
  • Required: I ran make check-test locally: all warnings addressed, tests passed
  • I used AI for code, documentation, tests, or communication related to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 607b5b64-fe3e-415d-ba3c-b3d05a59ab5b

📥 Commits

Reviewing files that changed from the base of the PR and between d85c4aa and 5f8aec2.

📒 Files selected for processing (1)
  • frontend/src/components/Header.tsx

Summary by CodeRabbit

  • Improvements
    • Header logo now adapts to the selected theme, automatically switching between light and dark variants.
    • Both desktop and mobile headers use the theme-aware logo and will display the appropriate variant once the page finishes mounting.

Walkthrough

Header now chooses the navbar logo at runtime based on the resolved theme using useTheme and a mounted flag; both desktop and mobile logo Image components use the computed logoSrc.

Changes

Cohort / File(s) Summary
Theme-aware logo rendering
frontend/src/components/Header.tsx
Added useTheme usage and a mounted state, compute logoSrc based on resolvedTheme, updated desktop and mobile <Image> components to use src={logoSrc}, added useEffect to set mounted on mount.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • Update OWASP Nest logo #2828: Modifies frontend/src/components/Header.tsx logo handling; touches same logo-rendering area and may conflict or overlap.

Suggested labels

frontend

Suggested reviewers

  • arkid15r
  • kasya
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: making the OWASP Nest logo dynamically toggle between dark and light themes, which is the primary objective of the pull request.
Description check ✅ Passed The description is directly related to the changeset, explaining the issue resolution, the specific file modified, the implementation approach, and verification steps taken.
Linked Issues check ✅ Passed The PR successfully implements the core requirement from issue #4318: making the navbar logo dynamically switch between light and dark variants based on the active theme using useTheme hook and mounted state.
Out of Scope Changes check ✅ Passed All changes are focused on the navbar logo theme switching requirement. The PR does not include the suggested follow-up improvements mentioned in the issue regarding navbar background or interactive element styling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file

Confidence score: 4/5

  • This PR is likely safe to merge with minimal risk: the top issue is moderate (5/10) and appears limited to initial theme rendering behavior rather than core functionality.
  • In frontend/src/components/Header.tsx, deriving the logo source in a post-render effect from a light default can cause a visible light-logo flash in dark mode and makes non-'dark' theme handling more fragile.
  • Also in frontend/src/components/Header.tsx, leftover debug console logging in the header effect will run on each theme change, creating minor production noise/perf overhead.
  • Pay close attention to frontend/src/components/Header.tsx - theme-driven logo initialization and cleanup of debug logging.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="frontend/src/components/Header.tsx">

<violation number="1" location="frontend/src/components/Header.tsx:30">
P2: Logo source is derived via post-render effect from a light default, causing incorrect initial render (light logo flash) in dark theme and brittle handling of non-`'dark'` theme states.</violation>

<violation number="2" location="frontend/src/components/Header.tsx:32">
P3: Debug console logging was left in a production header effect and will run on each theme change.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/src/components/Header.tsx (1)

179-183: Remove extra blank line; logo usage is correct.

The dynamic logoSrc is correctly applied to the mobile menu logo. However, line 183 introduces an unnecessary blank line inside the JSX structure.

🧹 Minor cleanup
                   src={logoSrc}
                   className="h-full w-auto object-contain"
                   alt="OWASP Logo"
                 />
-
               </div>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/components/Header.tsx` around lines 179 - 183, Remove the stray
blank line inside the JSX image element in Header.tsx so the <img> element using
logoSrc has no extra empty line between its attributes/closing bracket and
surrounding JSX; locate the <img ... src={logoSrc} className="h-full w-auto
object-contain" alt="OWASP Logo" /> in the Header component and delete the empty
line to keep the JSX compact and properly formatted.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend/src/components/Header.tsx`:
- Around line 29-36: Remove the debug console.log and avoid SSR/hydration
mismatches by deferring theme-dependent logo selection until the component is
mounted: remove the console.log in the useEffect that references useTheme(), add
a mounted flag (e.g., isMounted via useState/useEffect) and only set or render
logoSrc after isMounted is true (or use useTheme().resolvedTheme instead of
theme) so initial server render matches the client; update the useEffect and the
initial useState('/img/logo_light.png') initialization to rely on the mounted
state or resolvedTheme and ensure all references to useTheme(), logoSrc, and the
effect are adjusted accordingly.

---

Nitpick comments:
In `@frontend/src/components/Header.tsx`:
- Around line 179-183: Remove the stray blank line inside the JSX image element
in Header.tsx so the <img> element using logoSrc has no extra empty line between
its attributes/closing bracket and surrounding JSX; locate the <img ...
src={logoSrc} className="h-full w-auto object-contain" alt="OWASP Logo" /> in
the Header component and delete the empty line to keep the JSX compact and
properly formatted.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0b3a2680-0ca2-4f2c-bc76-70bd2b0644f8

📥 Commits

Reviewing files that changed from the base of the PR and between 28d4f48 and 4422c10.

📒 Files selected for processing (1)
  • frontend/src/components/Header.tsx

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 25, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="frontend/src/components/Header.tsx">

<violation number="1" location="frontend/src/components/Header.tsx:29">
P2: Incorrect destructuring of `useTheme()` uses `Theme` instead of `theme`, causing light-mode logo switching to fail.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Navbar logo does not adapt to light/dark theme, causing poor visibility in light mode

1 participant