From a2cbac9e0cfadfdf7c07e7ae88a25957785b7cd4 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 6 Jun 2022 11:53:13 +0530 Subject: [PATCH] Move code into method --- src/platform/web/ThemeLoader.ts | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/platform/web/ThemeLoader.ts b/src/platform/web/ThemeLoader.ts index bd53ff30..94310b80 100644 --- a/src/platform/web/ThemeLoader.ts +++ b/src/platform/web/ThemeLoader.ts @@ -66,24 +66,15 @@ export class ThemeLoader { }) .response(); this._populateThemeMap(body); - /* - After build has finished, the source section of each theme manifest - contains `built-assets` which is a mapping from the theme-name to theme - information which includes the location of the CSS file. - (see type ThemeInformation above) - */ - //Add the default-theme as an additional option to the mapping - const defaultThemeId = this.getDefaultTheme(); - if (defaultThemeId) { - const themeDetails = this._findThemeDetailsFromId(defaultThemeId); - if (themeDetails) { - this._themeMapping["Default"] = { id: "default", cssLocation: themeDetails.cssLocation }; - } - } } } private _populateThemeMap(manifest) { + /* + After build has finished, the source section of each theme manifest + contains `built-assets` which is a mapping from the theme-id to + cssLocation of theme + */ const builtAssets: Record = manifest.source?.["built-assets"]; const themeName = manifest.name; let defaultDarkVariant: any = {}, defaultLightVariant: any = {}; @@ -130,6 +121,14 @@ export class ThemeLoader { const variant = defaultDarkVariant.id ? defaultDarkVariant : defaultLightVariant; this._themeMapping[`${themeName} ${variant.variantName}`] = { id: variant.id, cssLocation: variant.cssLocation }; } + //Add the default-theme as an additional option to the mapping + const defaultThemeId = this.getDefaultTheme(); + if (defaultThemeId) { + const themeDetails = this._findThemeDetailsFromId(defaultThemeId); + if (themeDetails) { + this._themeMapping["Default"] = { id: "default", cssLocation: themeDetails.cssLocation }; + } + } } setTheme(themeName: string, themeVariant: "light" | "dark" | "default", log?: ILogItem) {