Last active
November 2, 2018 17:22
-
-
Save peterflynn/9485214cbe904e118141c00adecc1959 to your computer and use it in GitHub Desktop.
XD Plugin UI Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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