Skip to content

Instantly share code, notes, and snippets.

@peterflynn
Last active November 2, 2018 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterflynn/9485214cbe904e118141c00adecc1959 to your computer and use it in GitHub Desktop.
Save peterflynn/9485214cbe904e118141c00adecc1959 to your computer and use it in GitHub Desktop.
XD Plugin UI Examples
var dialog;
function createDialog() {
dialog = document.createElement("dialog");
dialog.innerHTML = `
<form method="dialog">
<h1>Hello, world!</h1>
<hr>
<footer>
<!-- Ok button is special: it will automatically close the dialog for us -->
<button id="ok" type="submit" uxp-variant="cta">OK</button>
</footer>
</form>`;
document.appendChild(dialog);
}
function showDialog(selection) {
if (!dialog) createDialog();
return dialog.showModal().then(function () {
console.log("Dialog closed");
});
}
dialog.innerHTML = `
<style>
.row {
display: flex;
}
</style>
<form method="dialog">
<h1>Create Button Frame</h1>
<hr>
<div class="row">
<input type="text" uxp-quiet="true" id="txtV" placeholder="V padding" />
<input type="text" uxp-quiet="true" id="txtH" placeholder="H padding" />
</div>
<footer>
<!-- Ok button is special: it will automatically close the dialog for us -->
<button id="ok" type="submit" uxp-variant="cta">OK</button>
</footer>
</form>`;
// .....................................................................................
var valueV = dialog.querySelector("#txtV").value;
var valueH = dialog.querySelector("#txtH").value;
console.log(valueV, valueH);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment