Update BaseStyle.js
parent
33ae3a015c
commit
7ccad8ed3d
|
@ -1,5 +1,5 @@
|
||||||
import { Theme, dt } from '@primeuix/styled';
|
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';
|
import { useStyle } from '@primevue/core/usestyle';
|
||||||
|
|
||||||
const theme = ({ dt }) => `
|
const theme = ({ dt }) => `
|
||||||
|
@ -159,13 +159,13 @@ export default {
|
||||||
load(style, options = {}, transform = (cs) => cs) {
|
load(style, options = {}, transform = (cs) => cs) {
|
||||||
const computedStyle = transform(resolve(style, { dt }));
|
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 = {}) {
|
loadCSS(options = {}) {
|
||||||
return this.load(this.css, options);
|
return this.load(this.css, options);
|
||||||
},
|
},
|
||||||
loadTheme(options = {}, style = '') {
|
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) {
|
getCommonTheme(params) {
|
||||||
return Theme.getCommon(this.name, params);
|
return Theme.getCommon(this.name, params);
|
||||||
|
@ -184,13 +184,13 @@ export default {
|
||||||
},
|
},
|
||||||
getStyleSheet(extendedCSS = '', props = {}) {
|
getStyleSheet(extendedCSS = '', props = {}) {
|
||||||
if (this.css) {
|
if (this.css) {
|
||||||
const _css = resolve(this.css, { dt });
|
const _css = resolve(this.css, { dt }) || '';
|
||||||
const _style = minifyCSS(`${_css}${extendedCSS}`);
|
const _style = minifyCSS(`${_css}${extendedCSS}`);
|
||||||
const _props = Object.entries(props)
|
const _props = Object.entries(props)
|
||||||
.reduce((acc, [k, v]) => acc.push(`${k}="${v}"`) && acc, [])
|
.reduce((acc, [k, v]) => acc.push(`${k}="${v}"`) && acc, [])
|
||||||
.join(' ');
|
.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 '';
|
return '';
|
||||||
|
@ -209,7 +209,7 @@ export default {
|
||||||
.reduce((acc, [k, v]) => acc.push(`${k}="${v}"`) && acc, [])
|
.reduce((acc, [k, v]) => acc.push(`${k}="${v}"`) && acc, [])
|
||||||
.join(' ');
|
.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('');
|
return css.join('');
|
||||||
|
|
Loading…
Reference in New Issue