Change `palette` method

pull/5507/head
mertsincan 2024-03-08 12:07:16 +00:00
parent 7b3908908a
commit 9d84a9f92c
3 changed files with 16 additions and 8 deletions

View File

@ -281,6 +281,9 @@ export default {
$globalThemeOptions() {
return this.$globalTheme?.options;
},
$globalThemeExtend() {
return this.$globalTheme?.extend;
},
$globalBaseTheme() {
return ObjectUtils.getItemValue(this.$globalTheme?.base);
},
@ -329,7 +332,8 @@ export default {
globalTheme: {
base: { ...this.$globalBaseTheme },
preset: { ...this.$globalPresetTheme },
options: { ...this.$globalThemeOptions }
options: { ...this.$globalThemeOptions },
extend: { ...this.$globalThemeExtend }
}
};
},

View File

@ -1,11 +1,14 @@
import shade from './shade';
import tint from './tint';
export default (color) =>
typeof color === 'string'
? Array.from({ length: 10 }).reduce((acc, _, i) => {
i <= 5 ? (acc[i === 0 ? '50' : `${i * 100}`] = tint(color, (5 - i) * 19)) : (acc[`${i * 100}`] = shade(color, (i - 5) * 15));
const scales = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
return acc;
}, {})
: color;
export default (color) => {
if (/{([^}]*)}/g.test(color)) {
const token = color.replace(/{|}/g, '');
return scales.reduce((acc, scale) => ((acc[scale] = `{${token}.${scale}}`), acc), {});
}
return typeof color === 'string' ? scales.reduce((acc, scale, i) => ((acc[scale] = i <= 5 ? tint(color, (5 - i) * 19) : shade(color, (i - 5) * 15)), acc), {}) : color;
};

View File

@ -260,6 +260,7 @@ const THEME_ALIAS = {
'primevue/themes/primeone/aura': path.resolve(__dirname, './components/lib/themes/primeone/aura/index.js'),
'primevue/themes/primeone': path.resolve(__dirname, './components/lib/themes/primeone/index.js'),
'primevue/themes/config': path.resolve(__dirname, './components/lib/themes/config/index.js'),
'primevue/themes/utils': path.resolve(__dirname, './components/lib/themes/utils/index.js'),
'primevue/themes': path.resolve(__dirname, './components/lib/themes/index.js')
};