Skip to content

Commit

Permalink
Support unit for $
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanchuan committed Sep 7, 2023
1 parent 10ca326 commit 9fd8221
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/generator/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Rules {
}

pick_func(name) {
if (name === '$') name = 'calc';
if (name.startsWith('$')) name = 'calc';
return Func[name] || MathFunc[name];
}

Expand All @@ -114,17 +114,21 @@ class Rules {
});
input = make_array(remove_empty_values(input));
if (typeof _fn === 'function') {
if (fname === '$') {
if (fname.startsWith('$')) {
let group = Object.assign({},
this.custom_properties['host'],
this.custom_properties['container'],
this.custom_properties[coords.count]
);
let context = {};
let unit = '';
for (let [name, key] of Object.entries(group)) {
context[name.substr(2)] = key;
}
return _fn(input, context);
if (fname.length > 1) {
unit = fname.split('$')[1] ?? '';
}
return _fn(input, context) + unit;
}
return _fn(...input);
}
Expand Down

0 comments on commit 9fd8221

Please sign in to comment.