From 4677385e6d93579c36438f4843c1858e5fd57ab8 Mon Sep 17 00:00:00 2001 From: Mert Sincan Date: Fri, 24 May 2024 18:09:26 +0100 Subject: [PATCH] Theming API: Refactor on global.style implementation --- components/lib/base/style/BaseStyle.js | 2 +- components/lib/themes/utils/themeUtils.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/lib/base/style/BaseStyle.js b/components/lib/base/style/BaseStyle.js index 2ce05f8cd..49dd8ede4 100644 --- a/components/lib/base/style/BaseStyle.js +++ b/components/lib/base/style/BaseStyle.js @@ -203,7 +203,7 @@ export default { let css = [Theme.getStyleSheet(this.name, params, props)]; if (this.theme) { - const name = `${this.name}-style`; + const name = this.name === 'base' ? 'global-style' : `${this.name}-style`; const _css = ObjectUtils.getItemValue(this.theme, { dt }); const _style = ObjectUtils.minifyCSS(Theme.transformCSS(name, _css)); const _props = Object.entries(props) diff --git a/components/lib/themes/utils/themeUtils.js b/components/lib/themes/utils/themeUtils.js index 9a3251aeb..001f2f31c 100644 --- a/components/lib/themes/utils/themeUtils.js +++ b/components/lib/themes/utils/themeUtils.js @@ -151,12 +151,13 @@ export default { .join(''); }, getStyleSheet({ name = '', theme = {}, params, props = {}, set, defaults }) { - const presetC_css = this.getPresetC({ name, theme, params, set, defaults })?.css; + const options = { name, theme, params, set, defaults }; + const preset_css = (name.includes('-directive') ? this.getPresetD(options) : this.getPresetC(options))?.css; const _props = Object.entries(props) .reduce((acc, [k, v]) => acc.push(`${k}="${v}"`) && acc, []) .join(' '); - return presetC_css ? `` : ''; + return preset_css ? `` : ''; }, createTokens(obj = {}, defaults, parentKey = '', parentPath = '', tokens = {}) { Object.entries(obj).forEach(([key, value]) => {