Theming API: Refactor
parent
00d5192737
commit
0b6013a978
|
@ -7,19 +7,8 @@ export default {
|
||||||
selector: ':root',
|
selector: ':root',
|
||||||
excludedKeyRegex: /^(primitive|semantic|variables|colorscheme|light|dark|common|colors|root|states|components|directives)$/gi
|
excludedKeyRegex: /^(primitive|semantic|variables|colorscheme|light|dark|common|colors|root|states|components|directives)$/gi
|
||||||
},
|
},
|
||||||
colorScheme: {
|
darkModeSelector: '.p-dark',
|
||||||
light: {
|
cssLayer: {
|
||||||
class: '',
|
|
||||||
rule: ':root{[CSS]}',
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
dark: {
|
|
||||||
class: 'p-dark',
|
|
||||||
rule: '.p-dark{[CSS]}',
|
|
||||||
default: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
layer: {
|
|
||||||
name: 'primevue',
|
name: 'primevue',
|
||||||
order: 'primevue'
|
order: 'primevue'
|
||||||
}
|
}
|
||||||
|
@ -32,10 +21,9 @@ export default {
|
||||||
_tokens: {},
|
_tokens: {},
|
||||||
init() {
|
init() {
|
||||||
if (!this._initialized) {
|
if (!this._initialized) {
|
||||||
this.applyColorScheme();
|
this._tokens = ThemeUtils.createTokens(this.preset, this.getCurrentColorScheme(), this.defaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._tokens = ThemeUtils.createTokens(this.preset, this.getCurrentColorScheme(), this.defaults);
|
|
||||||
this._initialized = true;
|
this._initialized = true;
|
||||||
},
|
},
|
||||||
get theme() {
|
get theme() {
|
||||||
|
@ -50,9 +38,6 @@ export default {
|
||||||
get options() {
|
get options() {
|
||||||
return this.theme?.options || {};
|
return this.theme?.options || {};
|
||||||
},
|
},
|
||||||
get extend() {
|
|
||||||
return this.theme?.extend || {};
|
|
||||||
},
|
|
||||||
get tokens() {
|
get tokens() {
|
||||||
return this._tokens;
|
return this._tokens;
|
||||||
},
|
},
|
||||||
|
@ -81,13 +66,6 @@ export default {
|
||||||
setLayerNames(layerName) {
|
setLayerNames(layerName) {
|
||||||
this._layerNames?.add(layerName);
|
this._layerNames?.add(layerName);
|
||||||
},
|
},
|
||||||
applyColorScheme() {
|
|
||||||
const newColorScheme = ThemeUtils.applyColorScheme(this.options, this.getCurrentColorScheme(), this.defaults);
|
|
||||||
|
|
||||||
this.setCurrentColorScheme(newColorScheme);
|
|
||||||
|
|
||||||
return newColorScheme;
|
|
||||||
},
|
|
||||||
toggleColorScheme() {
|
toggleColorScheme() {
|
||||||
const newColorScheme = ThemeUtils.toggleColorScheme(this.options, this.getCurrentColorScheme(), this.defaults);
|
const newColorScheme = ThemeUtils.toggleColorScheme(this.options, this.getCurrentColorScheme(), this.defaults);
|
||||||
|
|
||||||
|
@ -115,7 +93,7 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getLayerOrderCSS(name = '') {
|
getLayerOrderCSS(name = '') {
|
||||||
return ThemeUtils.getLayerOrder(name, this.options, { names: this.getLayerNames() });
|
return ThemeUtils.getLayerOrder(name, this.options, { names: this.getLayerNames() }, this.defaults);
|
||||||
},
|
},
|
||||||
getCommonStyleSheet(name = '', theme, params, props = {}) {
|
getCommonStyleSheet(name = '', theme, params, props = {}) {
|
||||||
return ThemeUtils.getCommonStyleSheet({ name, theme, params, props, defaults: this.defaults, set: { layerNames: this.setLayerNames.bind(this) } });
|
return ThemeUtils.getCommonStyleSheet({ name, theme, params, props, defaults: this.defaults, set: { layerNames: this.setLayerNames.bind(this) } });
|
||||||
|
|
Loading…
Reference in New Issue