Skip to content

Commit

Permalink
Update BaseStyle.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Sep 24, 2024
1 parent 33ae3a0 commit 7ccad8e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/core/src/base/style/BaseStyle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Theme, dt } from '@primeuix/styled';
import { minifyCSS, resolve } from '@primeuix/utils/object';
import { isNotEmpty, minifyCSS, resolve } from '@primeuix/utils/object';
import { useStyle } from '@primevue/core/usestyle';

const theme = ({ dt }) => `
Expand Down Expand Up @@ -159,13 +159,13 @@ export default {
load(style, options = {}, transform = (cs) => cs) {
const computedStyle = transform(resolve(style, { dt }));

return computedStyle ? useStyle(minifyCSS(computedStyle), { name: this.name, ...options }) : {};
return isNotEmpty(computedStyle) ? useStyle(minifyCSS(computedStyle), { name: this.name, ...options }) : {};
},
loadCSS(options = {}) {
return this.load(this.css, options);
},
loadTheme(options = {}, style = '') {
return this.load(this.theme, options, (computedStyle) => Theme.transformCSS(options.name || this.name, `${computedStyle}${style}`));
return this.load(this.theme, options, (computedStyle = '') => Theme.transformCSS(options.name || this.name, `${computedStyle}${style}`));
},
getCommonTheme(params) {
return Theme.getCommon(this.name, params);
Expand All @@ -184,13 +184,13 @@ export default {
},
getStyleSheet(extendedCSS = '', props = {}) {
if (this.css) {
const _css = resolve(this.css, { dt });
const _css = resolve(this.css, { dt }) || '';
const _style = minifyCSS(`${_css}${extendedCSS}`);
const _props = Object.entries(props)
.reduce((acc, [k, v]) => acc.push(`${k}="${v}"`) && acc, [])
.join(' ');

return `<style type="text/css" data-primevue-style-id="${this.name}" ${_props}>${_style}</style>`;
return isNotEmpty(_style) ? `<style type="text/css" data-primevue-style-id="${this.name}" ${_props}>${_style}</style>` : '';
}

return '';
Expand All @@ -209,7 +209,7 @@ export default {
.reduce((acc, [k, v]) => acc.push(`${k}="${v}"`) && acc, [])
.join(' ');

css.push(`<style type="text/css" data-primevue-style-id="${name}" ${_props}>${_style}</style>`);
isNotEmpty(_style) && css.push(`<style type="text/css" data-primevue-style-id="${name}" ${_props}>${_style}</style>`);
}

return css.join('');
Expand Down

0 comments on commit 7ccad8e

Please sign in to comment.