allow markup in instructions

This commit is contained in:
Bruno Windels
2020-12-07 14:35:08 +01:00
parent 732b8a48ff
commit 42994c4474
4 changed files with 28 additions and 7 deletions
+14 -3
View File
@@ -16,7 +16,7 @@ limitations under the License.
import {TemplateView} from "../utils/TemplateView.js";
import {copy} from "../utils/copy.js";
import {text} from "../utils/html.js";
import {text, tag} from "../utils/html.js";
function formatPlatforms(platforms) {
return platforms.reduce((str, p, i, all) => {
@@ -26,6 +26,16 @@ function formatPlatforms(platforms) {
}, "");
}
function renderInstructions(parts) {
return parts.map(p => {
if (p.type === "code") {
return tag.code(p.text);
} else {
return text(p);
}
});
}
export class ClientView extends TemplateView {
render(t, vm) {
@@ -66,7 +76,8 @@ class InstallClientView extends TemplateView {
render(t, vm) {
const children = [];
if (vm.textInstructions) {
const textInstructions = vm.textInstructions;
if (textInstructions) {
const copyButton = t.button({
className: "copy",
onClick: evt => {
@@ -78,7 +89,7 @@ class InstallClientView extends TemplateView {
}
}
});
children.push(t.p({className: "instructions"}, [t.code(vm.textInstructions), copyButton]));
children.push(t.p({className: "instructions"}, renderInstructions(textInstructions).concat(copyButton)));
}
const actions = t.div({className: "actions"}, vm.actions.map(a => {