Skip to content

Commit 4ea672e

Browse files
authored
fix: improve preview screen
1 parent dd05606 commit 4ea672e

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

editor.html

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</div>
2020
<div class="wds-editor__content" id="content">
2121
<div id="editor" class="wds-editor__editor"></div>
22-
<div id="playground" class="wds-editor__playground"></div>
22+
<div id="playground" class="wds-editor__playground hidden"></div>
2323
</div>
2424
<div class="wds-editor__console" id="console"></div>
2525
</div>
@@ -59,23 +59,10 @@
5959
method: "POST",
6060
});
6161

62-
output.innerText = await encode(await req.json());
62+
output.innerText = 'Done.'
6363
updatePreview();
6464
};
6565

66-
const addPreview = async (title, html) => {
67-
const frame = document.createElement("iframe");
68-
const heading = document.createElement("h2");
69-
heading.innerText = title;
70-
heading.className = "wds-editor__snippet";
71-
playground.appendChild(heading);
72-
playground.appendChild(frame);
73-
74-
const fbody = frame.contentDocument.body;
75-
fbody.innerHTML =
76-
`<link rel="stylesheet" href="/assets/${presetName}.css" />` + html;
77-
};
78-
7966
const updatePreview = async () => {
8067
const snippets = (await decode(editor.getValue())).snippets;
8168

@@ -87,9 +74,14 @@
8774
playground.innerHTML = "";
8875
togglePlayground(false);
8976

90-
Object.entries(snippets).forEach(([key, value]) =>
91-
addPreview(key, value)
92-
);
77+
const frame = document.createElement("iframe");
78+
const heading = document.createElement("h2");
79+
playground.appendChild(frame);
80+
81+
const fbody = frame.contentDocument.body;
82+
fbody.innerHTML =
83+
`<link rel="stylesheet" href="/assets/${presetName}.css" />` +
84+
Object.entries(snippets).map(([key, value]) => `<div style="font-weight: bold">${key}</div>${value}`).join('');
9385
};
9486

9587
const actions = {

0 commit comments

Comments
 (0)