UI: Replace buttons for HDS in component templates (#23698)

This commit is contained in:
Chelsea Shaw
2023-10-20 09:23:55 -05:00
committed by GitHub
parent 28e3b78e8e
commit 0c59d51e3a
93 changed files with 673 additions and 1004 deletions

View File

@@ -171,6 +171,18 @@ class Transforms {
});
}
filterModifiers() {
const params = [this.builders.string('click')];
this.node.modifiers.forEach((modifier) => {
if (modifier.path === 'action') {
// Replaces {{action "blah"}} with {{on "click" (action "blah")}}
params.push(this.builders.sexpr(modifier.path, modifier.params));
const onClickModifier = this.builders.elementModifier('on', params);
this.modifiers.push(onClickModifier);
}
});
}
textToString(node) {
// filter out escape charaters like \n and whitespace from TextNode and rebuild as StringLiteral
const text = decodeURI(node.chars).trim();
@@ -249,6 +261,7 @@ class Transforms {
} else if (this.hasIcon) {
// if there was an icon node but no text we need to add the @isIconOnly arg
this.addAttr('@isIconOnly', this.builders.mustache(this.builders.boolean(true)));
this.addAttr('@text', 'REPLACE_ME');
}
}
@@ -273,6 +286,7 @@ module.exports = (env) => {
if (transforms.shouldTransform()) {
transforms.childNodesToArgs();
transforms.filterAttributes();
transforms.filterModifiers();
return transforms.buildElement();
}
} catch (error) {