Skip to content

Commit

Permalink
refactor(Theming): fallback to Fiori 3 theme (#1039)
Browse files Browse the repository at this point in the history
We used to throw an error with the recommendation to import @ui5/webcomponents/dist/json-imports/Themes, when the requested theme is not even existing.

Now, if the requested theme is not existing, we will output a warning and fallback to sap_fiori_3, and never fetch the requested (non-existing) theme.
  • Loading branch information
ilhan007 committed Dec 11, 2019
1 parent 3434076 commit 29abb2a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/base/src/asset-registries/Themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { fetchJsonOnce } from "../util/FetchHelper.js";
const themeURLs = new Map();
const themeStyles = new Map();
const registeredPackages = new Set();
const SUPPORTED_THEMES = ["sap_fiori_3", "sap_fiori_3_dark", "sap_belize", "sap_belize_hcb"];

const registerThemeProperties = (packageName, themeName, style) => {
if (style._) {
Expand All @@ -24,6 +25,11 @@ const getThemeProperties = async (packageName, themeName) => {
return style;
}

if (!SUPPORTED_THEMES.includes(themeName)) {
console.warn(`You have requested non-existing theme - falling back to sap_fiori_3. The supported themes are: ${SUPPORTED_THEMES.join(", ")}.`); /* eslint-disable-line */
return themeStyles.get(`${packageName}_sap_fiori_3`);
}

const data = await fetchThemeProperties(packageName, themeName);
themeStyles.set(`${packageName}_${themeName}`, data._);
return data._;
Expand Down

0 comments on commit 29abb2a

Please sign in to comment.