Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 16, 2025

Adds user-controllable theme switching that cycles between System (follows OS), Light, and Dark modes. Preference persists via cookies.

Implementation

  • ThemeService: Manages theme state with three modes, cookie persistence, and event-driven updates
  • MainLayout.razor: Icon button in app bar cycles through modes with contextual tooltips
  • WellKnownCookieValues: Extended with theme preference helpers
  • DI Registration: ThemeService registered as scoped service

Usage

// ThemeService exposes current state and handles transitions
public interface IThemeService
{
    ThemePreference CurrentPreference { get; }  // System | Light | Dark
    bool IsDarkMode { get; }  // Computed from preference + OS setting
    event EventHandler? ThemeChanged;
    Task CycleThemeAsync();  // System → Light → Dark → System
}

Icon reflects current mode: Brightness4 (System) → LightMode → DarkMode. Tooltip shows current mode and next action.

Testing

14 unit tests cover initialization, mode transitions, cookie persistence, event propagation, and system preference updates.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add light/dark theme toggle</issue_title>
<issue_description>MudBlazor supports toggling between light and dark theme.
The default behavior should be to follow the system setting, but allow the user to manually toggle between light and dark.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add light/dark theme toggle functionality Add light/dark theme toggle with system preference support Nov 16, 2025
Copilot AI requested a review from Keboo November 16, 2025 18:10
Copilot finished work on behalf of Keboo November 16, 2025 18:10
Copilot AI and others added 4 commits November 17, 2025 22:16
Refines the theme preference cycling logic to only allow switching between Light and Dark modes directly. The "System" preference is no longer part of the user-facing cycle, although system preference detection continues to determine the active theme when "System" is the selected preference.

Updates associated UI elements (icons, tooltips) and removes outdated tests to reflect this change.

Also updates the `launchSettings.json` for a more streamlined development experience.
@Keboo Keboo force-pushed the copilot/add-theme-toggle-feature branch from 988e24c to 75b2189 Compare November 18, 2025 06:31
@Keboo Keboo marked this pull request as ready for review November 18, 2025 06:31
@Keboo Keboo enabled auto-merge (squash) November 18, 2025 06:31
@Keboo Keboo merged commit 6b34529 into main Nov 18, 2025
3 checks passed
@Keboo Keboo deleted the copilot/add-theme-toggle-feature branch November 18, 2025 06:32
@github-actions
Copy link

Summary - Code Coverage

Summary
Generated on: 11/18/2025 - 06:32:47
Coverage date: 11/18/2025 - 06:32:38 - 11/18/2025 - 06:32:43
Parser: MultiReport (3x Cobertura)
Assemblies: 3
Classes: 26
Files: 24
Line coverage: 60.1% (424 of 705)
Covered lines: 424
Uncovered lines: 281
Coverable lines: 705
Total lines: 1683
Branch coverage: 48.5% (173 of 356)
Covered branches: 173
Total branches: 356
Method coverage: Feature is only available for sponsors
Tag: 961_19456551077

Coverage

PointerStar.Client - 46.3%
Name Line Branch
PointerStar.Client 46.3% 41.4%
PointerStar.Client.Components.ComponentBase`1 0%
PointerStar.Client.Components.QRCode 0% 0%
PointerStar.Client.Components.UserDialog 0% 0%
PointerStar.Client.Cookies.Cookie 0% 0%
PointerStar.Client.Cookies.WellKnownCookieValues 100% 100%
PointerStar.Client.Pages.Index 0%
PointerStar.Client.Pages.Room 0% 0%
PointerStar.Client.Services.ThemeService 96.9% 90.9%
PointerStar.Client.Shared.MainLayout 0% 0%
PointerStar.Client.ViewModels.ClipboardService 0%
PointerStar.Client.ViewModels.RoomViewModel 98.1% 88.5%
PointerStar.Client.ViewModels.UserDialogViewModel 93.7% 100%
PointerStar.Client.ViewModels.ViewModelBase 100%
Program 0%
PointerStar.Server - 83.1%
Name Line Branch
PointerStar.Server 83.1% 66.6%
AspNetCoreGeneratedDocument.Pages_Error 0% 0%
PointerStar.Server.Controllers.RoomController 100%
PointerStar.Server.Hubs.RoomHub 0% 0%
PointerStar.Server.Pages.ErrorModel 0% 0%
PointerStar.Server.Room.InMemoryRoomManager 99.4% 98.5%
Program 94.1% 50%
PointerStar.Shared - 48.1%
Name Line Branch
PointerStar.Shared 48.1% 37.5%
PointerStar.Shared.Role 78.5% 50%
PointerStar.Shared.RoomHubConnection 0% 0%
PointerStar.Shared.RoomOptions 100%
PointerStar.Shared.RoomState 100%
PointerStar.Shared.User 100%
PointerStar.Shared.UserOptions 100%

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.

Add light/dark theme toggle

2 participants