/
githubmirror
/
components
Обзор
Документация
Войти
/
githubmirror
/
components
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/src/app/shared/theme-picker/theme-storage/theme-storage.ts
46 строк
1019 B
Kristiyan Kostadinov
build: switch docs to service decorator
25 апр 2026, 23:10
25 апр 2026, 23:10
7ac0542
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {Service, EventEmitter} from '@angular/core'; export interface DocsSiteTheme { name: string; displayName?: string; color: string; background: string; isDefault?: boolean; } @Service() export class ThemeStorage { static storageKey = 'docs-theme-storage-current-name'; onThemeUpdate: EventEmitter<DocsSiteTheme> = new EventEmitter<DocsSiteTheme>(); storeTheme(theme: DocsSiteTheme) { try { window.localStorage[ThemeStorage.storageKey] = theme.name; } catch {} this.onThemeUpdate.emit(theme); } getStoredThemeName(): string | null { try { return window.localStorage[ThemeStorage.storageKey] || null; } catch { return null; } } clearStorage() { try { window.localStorage.removeItem(ThemeStorage.storageKey); } catch {} } }