MCPcopy
hub / github.com/DevCloudFE/ng-devui / initializeTheme

Method initializeTheme

devui/theme/theme-service.ts:52–80  ·  view source on GitHub ↗
(specificThemeId?: string, allowDynamicTheme?: boolean)

Source from the content-addressed store, hash-verified

50 }
51
52 initializeTheme(specificThemeId?: string, allowDynamicTheme?: boolean) {
53 const themeId = specificThemeId
54 || this.storage.tryGetLocalStorage(THEME_KEY.userLastPreferTheme)
55 || this.context.getDataFromNameSpace(THEME_KEY.currentTheme);
56 let theme;
57
58 if (themeId) {
59 const themes = this.context.getDataFromNameSpace(THEME_KEY.themeCollection);
60 if (themes && Object.keys(themes).length > 0) {
61 theme = themes[themeId];
62 if (!theme) {
63 const key = Object.keys(themes).find(t => themes[t].id === themeId);
64 theme = themes[key];
65 }
66 }
67 }
68 this.currentTheme = theme || {
69 id: 'empty-theme',
70 name: '',
71 data: {},
72 isDark: false
73 };
74 this.createColorTransition();
75 if (!theme && allowDynamicTheme) {
76 document.body.setAttribute(THEME_KEY.uiThemeAttributeName, 'empty-theme');
77 return;
78 }
79 this.applyTheme(this.currentTheme);
80 }
81
82 formatCSSVariables(themeData: Theme['data']) {
83 return Object.keys(themeData).map(

Callers 1

ThemeServiceInitFunction · 0.95

Calls 4

createColorTransitionMethod · 0.95
applyThemeMethod · 0.95
tryGetLocalStorageMethod · 0.65
getDataFromNameSpaceMethod · 0.65

Tested by

no test coverage detected