Skip to content

Commit 29abb2a

Browse files
authored
refactor(Theming): fallback to Fiori 3 theme (#1039)
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.
1 parent 3434076 commit 29abb2a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/base/src/asset-registries/Themes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { fetchJsonOnce } from "../util/FetchHelper.js";
33
const themeURLs = new Map();
44
const themeStyles = new Map();
55
const registeredPackages = new Set();
6+
const SUPPORTED_THEMES = ["sap_fiori_3", "sap_fiori_3_dark", "sap_belize", "sap_belize_hcb"];
67

78
const registerThemeProperties = (packageName, themeName, style) => {
89
if (style._) {
@@ -24,6 +25,11 @@ const getThemeProperties = async (packageName, themeName) => {
2425
return style;
2526
}
2627

28+
if (!SUPPORTED_THEMES.includes(themeName)) {
29+
console.warn(`You have requested non-existing theme - falling back to sap_fiori_3. The supported themes are: ${SUPPORTED_THEMES.join(", ")}.`); /* eslint-disable-line */
30+
return themeStyles.get(`${packageName}_sap_fiori_3`);
31+
}
32+
2733
const data = await fetchThemeProperties(packageName, themeName);
2834
themeStyles.set(`${packageName}_${themeName}`, data._);
2935
return data._;

0 commit comments

Comments
 (0)