mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-11 01:42:34 +00:00
Change theming implementation - 1/2
This commit is contained in:
parent
6479cad038
commit
43bdf2c3e5
19 changed files with 474 additions and 61 deletions
22
components/lib/themes/utils/dt.js
Normal file
22
components/lib/themes/utils/dt.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
import Theme, { SharedUtils } from 'primevue/themes';
|
||||
|
||||
const EXCLUDED_KEY_REGEX = /^(primitive|semantic|variables|colorscheme|light|dark|common|colors|root|states)$/gi;
|
||||
|
||||
export const $dt = (tokenPath) => {
|
||||
const config = Theme.getPConfig();
|
||||
|
||||
return dt(config?.theme, tokenPath);
|
||||
};
|
||||
|
||||
export const dt = (theme = {}, tokenPath) => {
|
||||
if (tokenPath) {
|
||||
const { prefix, transform } = theme?.options || {};
|
||||
const regex = /{([^}]*)}/g;
|
||||
const token = SharedUtils.object.test(regex, tokenPath) ? tokenPath : `{${tokenPath}}`;
|
||||
const isStrictTransform = transform === 'strict'; // @todo - TRANSFORM: strict | lenient
|
||||
|
||||
return isStrictTransform ? SharedUtils.object.getComputedValue(theme?.preset, token, [EXCLUDED_KEY_REGEX]) : SharedUtils.object.getVariableValue(token, undefined, prefix, [EXCLUDED_KEY_REGEX]);
|
||||
}
|
||||
|
||||
return '';
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue