feat(core): theme service refactor (#DS-3003) - #1856
Conversation
|
Visit the preview URL for this PR (updated for commit c59aa1e): https://koobiq-next--prs-1856-jmotwjcq.web.app (expires Sun, 16 Aug 2026 07:12:11 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: c9e37e518febda70d0317d07e8ceb35ac43c534c |
There was a problem hiding this comment.
Pull request overview
This PR refactors the core ThemeService (DS-3003) into a signal-based KbqThemeService. It introduces a built-in auto mode that follows the OS color scheme via matchMedia, adds out-of-the-box mode persistence through a swappable KBQ_THEME_STORE (default KbqThemeLocalStorageStore), and DI-based configuration via kbqThemeProvider()/KBQ_THEME_CONFIG. Backward compatibility is preserved: ThemeService remains as a deprecated alias, and current, KbqTheme.selected, setTheme()/getTheme() still work. Consumers across the docs app and docs-examples are migrated to the signal API, and the docs navbar's hand-rolled matchMedia/localStorage wiring is removed.
Changes:
- New signal-based
KbqThemeService(mode,resolvedMode,currentTheme,themes) withsetAuto()/toggle()/setMode(), internal OS-scheme handling, and DI config (kbqThemeProvider,KBQ_THEME_CONFIG,KBQ_THEME_STORE,KbqThemeLocalStorageStore). - Deprecated back-compat surface kept (
ThemeServicealias,current,selected,setTheme/getTheme); public API snapshot approved. - Migrated all consumers (navbar, welcome, docsearch, tokens-overview, theme-toggle, 7 docs-examples) to the signal API; added
theme.service.spec.tsand migration docs.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
packages/components/core/services/theme.service.ts |
New KbqThemeService, config/store tokens, deprecated ThemeService alias. |
packages/components/core/services/theme.service.spec.ts |
New unit tests for auto/mode/custom themes/persistence/SSR/deprecated shims. |
tools/public_api_guard/components/core.api.md |
Approved public API changes for the new/renamed symbols. |
apps/docs/src/app/config.ts |
Wires kbqThemeProvider({ storageKey: 'docs_theme' }) (see comment — format mismatch). |
apps/docs/src/app/components/navbar/navbar.component.ts / navbar.template.html |
Removes hand-rolled matchMedia/storage; drives dropdown off mode()/setMode(). |
apps/docs/src/app/components/welcome/welcome.component.ts |
Uses resolvedMode() computed instead of current observable. |
apps/docs/src/app/components/docsearch/docsearch.directive.ts |
Uses toObservable(resolvedMode) for the search theme. |
apps/docs/src/app/components/design-tokens-viewers/tokens-overview.ts / .spec.ts |
Recalculates via effect on resolvedMode(); test mocks matchMedia. |
packages/components-dev/theme-toggle.ts |
Dev toggle rewired to resolvedMode()/setMode() via effect. |
packages/docs-examples/** (7 files) |
Switched currentTheme to resolvedMode() computed; dropped unused rxjs imports. |
docs/guides/migration.en.md / migration.ru.md |
Adds a "13. Theme service review" migration section. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Summary
Refactors
ThemeService(DS-3003) into a signal-basedKbqThemeService: a closedmode: 'auto' | 'light' | 'dark'signal resolved against the OS color scheme and a registeredthemes()set, replacing index/name-based selection withcolorScheme-driven resolution.ThemeServiceis kept as a deprecated facade for backward compatibility.Notable changes
KbqThemeService— signalsmode,themes,currentTheme,colorScheme;toggle()flips light/dark; persists via a swappableKBQ_THEME_STORE(KbqThemeLocalStorageStoreby default,KbqThemeCookieStorefor live SSR)KbqThemeConfig(name,className, requiredcolorScheme) replacingKbqThemefor registered themes, plusKbqDefaultThemes/KbqThemeSelector/KbqThemeNamesfor the built-in light/dark setkbqThemeProvider(config)/KBQ_THEME_CONFIGfor DI-based setup (custom themes, initial mode, storage key)ThemeService,KbqTheme,current/setTheme()/getTheme()as deprecated shims backed byKbqThemeServicetheme.service.spec.tsandcore.api.mdWhat should reviewers focus on
mode/colorSchemeas the final shape, replacing the earlierselection/autoLight/autoDarkdraft