Skip to content

feat(adminpanel): add an automatic theme which follows the system color scheme - #1540

Merged
sven-n merged 2 commits into
MUnique:masterfrom
icheat2win:feat/admin-panel-dark-mode
Nov 17, 2026
Merged

sven-n merged 2 commits into
MUnique:masterfrom
icheat2win:feat/admin-panel-dark-mode

Conversation

@icheat2win

@icheat2win icheat2win commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1275 (the admin panel refresh). This one only touches the existing
ThemeSelector, on top of Bootstrap's own color modes (data-bs-theme), as
asked there. No new packages, no new override layer.

What changes

  • The sun/moon button is now a small menu: Light, Dark and
    Auto (system). The current choice is checked.
  • Auto follows prefers-color-scheme of the OS/browser, also while the
    page is open (switching the OS to dark mode switches the panel right away).
    It's the default when no theme cookie exists yet, so new users get the theme
    their system uses. Users who already picked light or dark keep it.
  • Picking a theme is applied instantly on the client and stored in the
    existing OpenMU.Theme cookie. The page is no longer reloaded, so
    unsaved input in an edit form isn't lost anymore.
  • A tiny js/theme.js is loaded in <head> before the stylesheets. For
    "auto" it sets data-bs-theme before the first paint, so there's no light
    flash for dark-mode users. The server renders data-theme-preference with
    the cookie value.
  • ThemeController knows auto now (and still works as a fallback if the JS
    module can't be loaded). The fallback URL is relative now, so it also works
    when the panel is hosted under a path base.
  • Texts: SwitchToDarkMode/SwitchToLightMode replaced by Theme,
    ThemeLight, ThemeDark, ThemeAuto (en, de, pt-BR, zh-CN).
  • Docs: the theme selector line in docs-website/docs/admin-panel/overview.md.

Screenshots

Before / after (dark):

theme-selector-before-after

Light:

theme-menu-light

Tests

  • New ThemeControllerTests (normalizing, server-side bootstrap theme) and
    bUnit ThemeSelectorTests (menu shows three themes with the current one
    checked; selecting stores the theme via JS, closes the menu and doesn't
    navigate).
  • dotnet test tests/MUnique.OpenMU.Web.Tests: 721 passed. 1 failure in
    MapControllerTests.ControllerCreatedAfterDisposalIsDisposedAsync, which is
    unrelated and timing dependent (passes when run alone, 3 of 3).
  • Checked by hand with Playwright on the demo server: OS dark + no cookie ->
    dark; picking Light switches without reload and survives a reload; Auto
    follows an OS switch live; Esc and clicking outside close the menu; no
    console errors.

…or scheme

The theme selector is now a small menu with light, dark and auto. Auto follows
prefers-color-scheme of the operating system, also while the page is open, and
is the default when no theme was chosen yet. The selection is applied
immediately on the client and stored in the existing theme cookie, so the page
isn't reloaded anymore and unsaved form input is kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011xNc76fa7jSQsMehuCbYQr
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T04:50:26.311204Z 8c170f8 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codacy-production

codacy-production Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 15 complexity · 0 duplication

Metric Results
Complexity 15
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a13617c79

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Web/AdminPanel/Components/App.razor Resolved
The shared project excludes wwwroot/js from its content, so js/theme.js was
missing in published builds and the theme didn't change there. Move it to
the wwwroot root and use the IIFE style Codacy expects.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011xNc76fa7jSQsMehuCbYQr
@sven-n
sven-n merged commit 434898c into MUnique:master Nov 17, 2026
2 checks passed
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.

2 participants