Theming API: Refactor on global.style implementation
parent
88b1c191b6
commit
4677385e6d
|
@ -203,7 +203,7 @@ export default {
|
||||||
let css = [Theme.getStyleSheet(this.name, params, props)];
|
let css = [Theme.getStyleSheet(this.name, params, props)];
|
||||||
|
|
||||||
if (this.theme) {
|
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 _css = ObjectUtils.getItemValue(this.theme, { dt });
|
||||||
const _style = ObjectUtils.minifyCSS(Theme.transformCSS(name, _css));
|
const _style = ObjectUtils.minifyCSS(Theme.transformCSS(name, _css));
|
||||||
const _props = Object.entries(props)
|
const _props = Object.entries(props)
|
||||||
|
|
|
@ -151,12 +151,13 @@ export default {
|
||||||
.join('');
|
.join('');
|
||||||
},
|
},
|
||||||
getStyleSheet({ name = '', theme = {}, params, props = {}, set, defaults }) {
|
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)
|
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 presetC_css ? `<style type="text/css" data-primevue-style-id="${name}-variables" ${_props}>${SharedUtils.object.minifyCSS(presetC_css)}</style>` : '';
|
return preset_css ? `<style type="text/css" data-primevue-style-id="${name}-variables" ${_props}>${SharedUtils.object.minifyCSS(preset_css)}</style>` : '';
|
||||||
},
|
},
|
||||||
createTokens(obj = {}, defaults, parentKey = '', parentPath = '', tokens = {}) {
|
createTokens(obj = {}, defaults, parentKey = '', parentPath = '', tokens = {}) {
|
||||||
Object.entries(obj).forEach(([key, value]) => {
|
Object.entries(obj).forEach(([key, value]) => {
|
||||||
|
|
Loading…
Reference in New Issue