Theming API: Refactor on definePreset action

pull/5507/head
mertsincan 2024-03-30 12:29:27 +00:00
parent d80a18c052
commit a7c3bf15e3
1 changed files with 3 additions and 8 deletions

View File

@ -1,13 +1,8 @@
import Theme from 'primevue/themes';
import Theme, { SharedUtils } from 'primevue/themes';
export default (preset1, preset2) => {
const [{ primitive: p1, semantic: s1, components: c1, directives: d1 }, { primitive: p2, semantic: s2, components: c2, directives: d2 }] = [preset1, preset2];
const newPreset = {
primitive: { ...p1, ...p2 },
semantic: { ...s1, ...s2 },
components: { ...c1, ...c2 },
directives: { ...d1, ...d2 }
};
const VARIABLE = Theme.defaults.variable;
const newPreset = SharedUtils.object.mergeKeysByRegex(preset1, preset2, VARIABLE.excludedKeyRegex);
Theme.setPreset(newPreset);