Skip to content

Commit

Permalink
refactor: move addCustomCSS away from Core (#58)
Browse files Browse the repository at this point in the history
The addCustomCSS method that used to be on the Core moved to Theming.js

BREAKING CHANGE: addCustomCSS is no longer on the Core object. Use Theming instead.
  • Loading branch information
vladitasev authored Feb 15, 2019
1 parent b6d6bbd commit 33152b9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
4 changes: 0 additions & 4 deletions packages/base/src/sap/ui/webcomponents/base/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ const Core = {
return configuration;
},

addCustomCSS: function (tag, theme, css) {
ShadowDOM._addCustomCSS(tag, theme, css);
},

/**
* @deprecated - must be here for compatibility
*/
Expand Down
5 changes: 5 additions & 0 deletions packages/base/src/sap/ui/webcomponents/base/Theming.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import configuration from "./Configuration";
import ShadowDOM from './compatibility/ShadowDOM';

const themeChangeCallbacks = [];

Expand All @@ -16,3 +17,7 @@ export const setTheme = function setTheme(theme) {
configuration._setTheme(theme);
themeChangeCallbacks.forEach(callback => callback(theme));
};

export const addCustomCSS = function (tag, theme, css) {
ShadowDOM._addCustomCSS(tag, theme, css);
};
6 changes: 5 additions & 1 deletion packages/main/bundle.es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import "@ui5/webcomponents-core/dist/sap/ui/thirdparty/es6-other-polyfills";
import "regenerator-runtime/runtime";

import Core from "@ui5/webcomponents-base/src/sap/ui/webcomponents/base/Core";
import * as Theming from "@ui5/webcomponents-base/src/sap/ui/webcomponents/base/Theming";
import "./bundle.esm";

export { Core };
export {
Core,
Theming,
};
6 changes: 4 additions & 2 deletions packages/main/bundle.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ window.sapUiDevice = Device;

// Note: keep in sync with rollup.config value for IIFE
import Core from "@ui5/webcomponents-base/src/sap/ui/webcomponents/base/Core";
import * as Theming from "@ui5/webcomponents-base/src/sap/ui/webcomponents/base/Theming";
window["sap-ui-webcomponents-main-bundle"] = {
Core: Core
}
Core,
Theming,
};
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@
}

// theme change sample
var wcCore = window["sap-ui-webcomponents-main-bundle"].Core;
wcCore.addCustomCSS('ui5-input', 'sap_belize_hcb', inputCSS);
wcCore.addCustomCSS('ui5-icon', 'sap_belize_hcb', iconCSS);
var Theming = window["sap-ui-webcomponents-main-bundle"].Theming;
Theming.addCustomCSS('ui5-input', 'sap_belize_hcb', inputCSS);
Theming.addCustomCSS('ui5-icon', 'sap_belize_hcb', iconCSS);

$('ui5-radiobutton[group="theme"]').on("select", function (event) {
if (event.detail.selected) {
Expand All @@ -157,10 +157,10 @@
} else {
document.body.style.backgroundColor = "white";
}
wcCore.setTheme(theme);
Theming.setTheme(theme);
}
});
});
</script>
</body>
</html>
</html>

0 comments on commit 33152b9

Please sign in to comment.