Skip to content

feat: enhance dark theme support in search and navigation components#5471

Open
hasithasandunlakshan wants to merge 3 commits into
asyncapi:website-uifrom
hasithasandunlakshan:feature/dark-theme-search-bar
Open

feat: enhance dark theme support in search and navigation components#5471
hasithasandunlakshan wants to merge 3 commits into
asyncapi:website-uifrom
hasithasandunlakshan:feature/dark-theme-search-bar

Conversation

@hasithasandunlakshan
Copy link
Copy Markdown

@hasithasandunlakshan hasithasandunlakshan commented May 24, 2026

Description

  • Updated the mobile docs search button to support dark theme using existing theme classes.
  • Added data-theme="dark" alongside the existing dark class so Algolia DocSearch uses its dark theme.
  • Wrapped the DocSearch modal with existing dark text styling to keep no-results text readable in dark mode.

New behaviour

Screen.Recording.2026-05-25.at.00.16.56.mov

Related issue(s)

Fixes #5470

Summary by CodeRabbit

  • Style

    • Enhanced dark mode styling consistency across search modal, mobile navigation, and theme components.
  • Bug Fixes

    • Improved dark mode theme synchronization to ensure proper styling persistence and visual consistency.

Review Change Stack

@netlify
Copy link
Copy Markdown

netlify Bot commented May 24, 2026

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 5c8e38b
🔍 Latest deploy log https://app.netlify.com/projects/asyncapi-website/deploys/6a13d0b6c61ac200075b282b
😎 Deploy Preview https://deploy-preview-5471--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 81198e43-237e-4ea3-98fc-daf404080f4e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ 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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (2158aed) to head (5c8e38b).
⚠️ Report is 2 commits behind head on website-ui.

Additional details and impacted files
@@             Coverage Diff              @@
##           website-ui     #5471   +/-   ##
============================================
  Coverage      100.00%   100.00%           
============================================
  Files              22        22           
  Lines             906       906           
  Branches          171       171           
============================================
  Hits              906       906           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@princerajpoot20
Copy link
Copy Markdown
Member

@hasithasandunlakshan Have a look at sonar issues in your PR

@hasithasandunlakshan
Copy link
Copy Markdown
Author

@hasithasandunlakshan Have a look at sonar issues in your PR

Done.

Comment thread pages/_document.tsx Outdated
Comment on lines +32 to +33
document.documentElement.classList.add('dark');
document.documentElement.dataset.theme = 'dark';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why we need this additional variable? can't we use the one present above

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Here The theme variable only stores the value read from localStorage; CSS cannot access that JavaScript variable directly.

  • classList.add('dark') is used by Tailwind dark mode.
  • dataset.theme = 'dark' adds data-theme="dark", which is required by Algolia DocSearch’s built-in dark theme selector: html[data-theme=dark].

But here i tested by removing that line it is working correctly. because , DarkModeToggle.tsx also sets document.documentElement.dataset.theme = 'dark' after React mounts. Since DocSearch is opened after the app has mounted, that may be enough.I removed it.

Comment thread components/DarkModeToggle.tsx Outdated
Comment on lines +48 to +64
if (shouldUseDark) {
document.documentElement.dataset.theme = 'dark';
} else {
delete document.documentElement.dataset.theme;
}
setIsDark(shouldUseDark);
}, []);

const toggleDarkMode = () => {
const newTheme = !isDark;

document.documentElement.classList.toggle('dark', newTheme);
if (newTheme) {
document.documentElement.dataset.theme = 'dark';
} else {
delete document.documentElement.dataset.theme;
}
Copy link
Copy Markdown
Member

@princerajpoot20 princerajpoot20 May 25, 2026

Choose a reason for hiding this comment

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

@hasithasandunlakshan too many if else statement, is there a way to make it clean and simple

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

  • we can use reusable function like this
function applyTheme(isDark: boolean) {
  document.documentElement.classList.toggle('dark', isDark);

  if (isDark) {
    document.documentElement.dataset.theme = 'dark';

    return;
  }

  delete document.documentElement.dataset.theme;
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@princerajpoot20 , One thing , since this is very small and tightly coupled to the toggle’s behavior, I kept it inside DarkModeToggle.tsx. If you prefer, I can move it to a separate helper file like theme.ts.

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.

🧹 Nitpick comments (1)
components/navigation/DocsMobileMenu.tsx (1)

50-50: ⚡ Quick win

Consider adding dark mode hover background.

The button includes hover:bg-secondary-100 which applies in both light and dark modes. In dark mode, secondary-100 (likely a light color) may create low contrast or visual inconsistency when hovering over the dark card background. Consider adding dark:hover:bg-dark-background or a similar dark-appropriate hover background color to ensure consistent appearance.

🎨 Suggested addition
-className='flex w-full items-center space-x-3 rounded-md border border-gray-300 bg-white px-3 py-1.5 text-left text-sm text-gray-700 shadow-sm transition-all duration-500 ease-in-out dark:border-dark-text dark:bg-dark-card dark:text-dark-text dark:hover:border-secondary-500 dark:hover:text-secondary-500 hover:border-secondary-500 hover:bg-secondary-100 hover:text-secondary-500'
+className='flex w-full items-center space-x-3 rounded-md border border-gray-300 bg-white px-3 py-1.5 text-left text-sm text-gray-700 shadow-sm transition-all duration-500 ease-in-out dark:border-dark-text dark:bg-dark-card dark:text-dark-text dark:hover:border-secondary-500 dark:hover:bg-dark-background dark:hover:text-secondary-500 hover:border-secondary-500 hover:bg-secondary-100 hover:text-secondary-500'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@components/navigation/DocsMobileMenu.tsx` at line 50, The hover background is
only set for light mode via the CSS class in the className on the interactive
element in DocsMobileMenu (the button/container with className='...
hover:bg-secondary-100 ...'); update that class list to include a dark-mode
hover background (e.g., add dark:hover:bg-dark-background or
dark:hover:bg-dark-card-hover) so hovering in dark theme uses an appropriate
dark color; keep the existing light hover class (hover:bg-secondary-100) and add
the dark:hover:... token to the same className on the element in
DocsMobileMenu.tsx.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@components/navigation/DocsMobileMenu.tsx`:
- Line 50: The hover background is only set for light mode via the CSS class in
the className on the interactive element in DocsMobileMenu (the button/container
with className='... hover:bg-secondary-100 ...'); update that class list to
include a dark-mode hover background (e.g., add dark:hover:bg-dark-background or
dark:hover:bg-dark-card-hover) so hovering in dark theme uses an appropriate
dark color; keep the existing light hover class (hover:bg-secondary-100) and add
the dark:hover:... token to the same className on the element in
DocsMobileMenu.tsx.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4b0e51c0-2c52-4e02-8b64-dabcf750e36a

📥 Commits

Reviewing files that changed from the base of the PR and between 2158aed and b10a08a.

📒 Files selected for processing (4)
  • components/AlgoliaSearch.tsx
  • components/DarkModeToggle.tsx
  • components/navigation/DocsMobileMenu.tsx
  • pages/_document.tsx

…readability and maintainability

style(DocsMobileMenu): update search button hover background for better dark theme compatibility
fix(_document): remove redundant dataset assignment for dark theme
fix(package-lock): mark dependencies as peer
@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

Status: To Be Triaged

Development

Successfully merging this pull request may close these issues.

2 participants