Feature/Move theme system from core to client-side ThemeProvider (#4108)

**Add approved & assigned issue number here:** 

Resolves #2549

## Description:

Themes are purely for the client's rendering, and the server doesn't
need context on them. This PR moves `Theme.ts` from
`src/core/configuration` to `src/client/theme` and moves affiliation
colors to `render-settings.json`.

This is to support the ability to add additional themes more quickly,
such as colorblind-friendly themes. No visible changes occur from this
refactor.

## Please complete the following:

- [X] I have added screenshots for all UI updates
- [X] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [X] I have added relevant tests to the test directory

## Please put your Discord username so you can be contacted if a bug or
regression is found:

jetaviz

---------

Co-authored-by: Josh Harris <josh@wickedsick.com>
This commit is contained in:
noahschmal
2026-06-02 02:32:08 -07:00
committed by GitHub
parent d8c127a462
commit 2c8a66625c
23 changed files with 150 additions and 88 deletions
+32
View File
@@ -0,0 +1,32 @@
import { UserSettings } from "../../core/game/UserSettings";
import { PastelTheme } from "./PastelTheme";
import { PastelThemeDark } from "./PastelThemeDark";
import { Theme } from "./Theme";
/**
* Client-side source of truth for the active theme. Themes were moved out of
* `src/core` (the simulation never reads colors); this singleton replaces the
* old `Config.theme()` accessor.
*/
class ThemeProvider {
private readonly userSettings = new UserSettings();
private light = new PastelTheme();
private dark = new PastelThemeDark();
/** The active theme, selected from the user's dark-mode preference. */
current(): Theme {
return this.userSettings.darkMode() ? this.dark : this.light;
}
/**
* Recreate the themes so their colour allocators start empty. Call once per
* game — matches the previous per-`Config` theme lifecycle and prevents
* colour-pool depletion across games in a single session.
*/
reset(): void {
this.light = new PastelTheme();
this.dark = new PastelThemeDark();
}
}
export const themeProvider = new ThemeProvider();