Skip to content

Implemented dark mode in harbor website#703

Open
mythicalyash wants to merge 2 commits intogoharbor:mainfrom
mythicalyash:main
Open

Implemented dark mode in harbor website#703
mythicalyash wants to merge 2 commits intogoharbor:mainfrom
mythicalyash:main

Conversation

@mythicalyash
Copy link

This PR introduces full dark mode support to the Harbor website, including a user-controlled theme toggle, automatic system preference detection, persistent theme selection, and flash-of-unstyled-content (FOUC) prevention. The implementation is accessible, performant, and visually consistent with the existing design system.


🚀 Changes Made

➕ New Files

  • assets/sass/dark-mode.sass
    Complete dark mode styling using CSS custom properties.

  • layouts/partials/theme-toggle.html
    Alpine.js–powered theme toggle component with accessibility support.


✏️ Modified Files

  • layouts/_default/baseof.html

    • Added inline script to prevent FOUC
    • Integrated theme toggle into the navbar
    • Added Alpine.js dependency
  • layouts/partials/navbar.html

    • Integrated theme toggle button into the navbar
  • assets/sass/style.sass

    • Imported dark mode styles

✅ Features Implemented

Theme Toggle Button

  • Sun / moon icon toggle in navbar
  • Smooth transitions between light and dark themes
  • Accessible with proper ARIA labels

System Preference Detection

  • Automatically detects prefers-color-scheme on first visit
  • Respects OS-level theme preference

Persistent Theme Selection

  • Stores user preference in localStorage
  • Maintains selection across sessions and page navigation

FOUC Prevention

  • Inline script applies theme before initial render
  • No flash of incorrect theme on page load

Comprehensive Dark Mode Styling

  • Fully styled components:

    • Navbar, footer, cards
    • Tables, code blocks
    • Buttons, links, forms
  • Proper contrast and visual hierarchy

  • White text on colored buttons for readability


🎨 Visual Overview

Light Mode (unchanged)

  • Clean white backgrounds
  • Blue accents and borders

Dark Mode

  • Dark gray background (#1a1a1a)
  • Pure black sections (#000000) for contrast
  • Light body text (#e0e0e0) with white headings
  • Blue accents preserved for brand consistency
  • Optimized contrast ratios for accessibility

🧪 Testing Performed

  • ✅ Theme toggle works across all pages
  • ✅ System preference detected on first visit
  • ✅ Theme persists across sessions
  • ✅ FOUC prevention verified
  • ✅ Visual inspection of all major components
  • ✅ WCAG-compliant color contrast checks
  • ✅ Responsive behavior in both themes

♿ Accessibility

  • ARIA labels on theme toggle button
  • WCAG AA color contrast compliance
  • Fully keyboard accessible toggle

Screenshot 2026-02-02 at 4 14 59 PM Screenshot 2026-02-02 at 4 24 51 PM Screenshot 2026-02-02 at 4 24 33 PM Screenshot 2026-02-02 at 4 25 11 PM

Signed-off-by: mythicalyash <21yashvardhan22@gmail.com>
@OrlinVasilev
Copy link
Member

Hi @mythicalyash thanks for the contribution! Looks legit to me
Is that AI generated?

Copy link
Member

@OrlinVasilev OrlinVasilev left a comment

Choose a reason for hiding this comment

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

looks OK to me

{{ if $home }}
<script async defer src="https://buttons.github.io/buttons.js"></script>
{{ end }}
<!-- Analytics -->
Copy link
Member

Choose a reason for hiding this comment

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

why do you remove this line?

Copy link
Author

@mythicalyash mythicalyash Feb 2, 2026

Choose a reason for hiding this comment

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

Must be Error
I will restore this
Thanks for pointing it out

@mythicalyash
Copy link
Author

Hi @mythicalyash thanks for the contribution! Looks legit to me Is that AI generated?

Most of work was done by me
and I used AI for reviewing my work (just a bit)

Signed-off-by: Yashvardhan <122466420+mythicalyash@users.noreply.github.com>
@mythicalyash
Copy link
Author

@OrlinVasilev
I restored That comment line

@OrlinVasilev
Copy link
Member

great stuff thanks!

@mythicalyash
Copy link
Author

@OrlinVasilev

great stuff thanks!

welcome
and
I am looking forward to contribute more in this organisation

@mythicalyash
Copy link
Author

@Vad1mo can you review this ?

@OrlinVasilev OrlinVasilev enabled auto-merge (squash) February 3, 2026 15:53
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.

5 participants

Comments