Skip to content

feat(core): theme service refactor (#DS-3003) - #1856

Open
NikGurev wants to merge 3 commits into
mainfrom
feat/DS-3003
Open

feat(core): theme service refactor (#DS-3003)#1856
NikGurev wants to merge 3 commits into
mainfrom
feat/DS-3003

Conversation

@NikGurev

@NikGurev NikGurev commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Refactors ThemeService (DS-3003): moves it to signals, adds a built-in auto mode that follows the OS color scheme, and persists the selected mode to localStorage out of the box. ThemeService is kept as a deprecated alias so existing consumers don't break, and the new KbqThemeService is fully DI-configurable via kbqThemeProvider().

List of notable changes

  • added KbqThemeService — signal-based (mode, resolvedMode, currentTheme, themes) replacement for ThemeService, with setAuto()/toggle(), internal matchMedia handling for auto mode, and localStorage persistence via a new swappable KBQ_THEME_STORE/KbqThemeLocalStorageStore (same pattern as KBQ_ACCORDION_STATE_STORE)
  • added kbqThemeProvider(config) / KBQ_THEME_CONFIG for DI-based setup (themes, mode, storageKey, autoLight, autoDark) instead of imperative setThemes()/setTheme() calls
  • added autoLight/autoDark config so auto mode resolves correctly against fully custom theme sets, not just the built-in light/dark names
  • kept ThemeService (deprecated alias of KbqThemeService), KbqTheme.selected (deprecated, still synced), and current/setTheme()/getTheme() (deprecated, still functional) for backward compatibility — no ng update schematic needed for the rename
  • removed the docs app's hand-rolled matchMedia listener and localStorage wiring in navbar.component.ts/navbar-property.ts — now just calls setAuto()/setMode(); configured with kbqThemeProvider({ storageKey: 'docs_theme' }) in apps/docs/src/app/config.ts to preserve existing users' saved preference under the old key
  • updated all other ThemeService consumers (theme-toggle.ts, welcome.component.ts, tokens-overview.ts, docsearch.directive.ts, 7 docs-examples) to the signal API
  • added theme.service.spec.ts — unit tests for auto resolution, mode selection, custom themes, persistence, SSR-safety, and the deprecated shims
  • updated docs/guides/migration.en.md / migration.ru.md with a new "13. Theme service review (20.3.0)" section, and approved the core.api.md public API snapshot

What should reviewers focus on?

  • Whether the deprecated back-compat surface (ThemeService, current, selected, setTheme/getTheme) is worth keeping vs. a cleaner break
  • autoLight/autoDark as the mechanism for custom themes to opt into auto mode — reasonable default, or should it be required when custom themes are registered?

@NikGurev
NikGurev requested a review from artembelik August 7, 2026 10:18
@NikGurev NikGurev self-assigned this Aug 7, 2026
@NikGurev NikGurev added the enhancement New feature or request label Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 7211a09):

https://koobiq-next--prs-1856-jmotwjcq.web.app

(expires Mon, 10 Aug 2026 10:38:40 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: c9e37e518febda70d0317d07e8ceb35ac43c534c

@NikGurev
NikGurev marked this pull request as ready for review August 7, 2026 10:42
@NikGurev
NikGurev requested a review from lskramarov as a code owner August 7, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant