Theming API: Added fallback param to inline dt method.

This commit is contained in:
mertsincan 2024-03-28 13:01:28 +00:00
parent c25b2e0559
commit 468106cfb8
3 changed files with 8 additions and 8 deletions

View file

@ -109,7 +109,7 @@ export default {
getVariableName(prefix = '', variable = '') {
return `--${this.toNormalizeVariable(prefix, variable)}`;
},
getVariableValue(value, variable = '', prefix = '', excludedKeyRegexes = []) {
getVariableValue(value, variable = '', prefix = '', excludedKeyRegexes = [], fallback) {
if (this.isString(value)) {
const regex = /{([^}]*)}/g;
const val = value.trim();
@ -119,7 +119,7 @@ export default {
const path = v.replace(/{|}/g, '');
const keys = path.split('.').filter((_v) => !excludedKeyRegexes.some((_r) => this.test(_r, _v)));
return `var(${this.getVariableName(prefix, this.toKebabCase(keys.join('-')))})`;
return `var(${this.getVariableName(prefix, this.toKebabCase(keys.join('-')))}${fallback ? `,${fallback}` : ''})`;
});
const calculationRegex = /(\d+\s+[\+\-\*\/]\s+\d+)/g;