Created
October 15, 2018 01:20
-
-
Save peterflynn/5eb77db4b5d4a626bf8087a0498c94ce to your computer and use it in GitHub Desktop.
This file contains hidden or 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 fs = require("uxp").storage.localFileSystem; | |
function loadStyleguideFile(selection) { | |
return fs.getFileForOpening() | |
.then(function (file) { | |
console.log("User chose file: " + file); | |
return file.read(); | |
}) | |
.then(function (text) { | |
var json = JSON.parse(text); | |
createFrame(selection, json.padding.vertical, json.padding.horizontal); | |
}); | |
} |
This file contains hidden or 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
{ | |
"padding": { | |
"horizontal": 10, | |
"vertical": 10 | |
} | |
} |
This file contains hidden or 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 fs = require("uxp").storage.localFileSystem; | |
async function loadStyleguideFile(selection) { | |
var file = await fs.getFileForOpening(); | |
console.log("User chose file: " + file); | |
var text = await file.read(); | |
var json = JSON.parse(text); | |
createRectangle(selection, json.padding.vertical, json.padding.horizontal); | |
} |
This file contains hidden or 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 fs = require("uxp").storage.localFileSystem; | |
async function loadStyleguideFile(selection) { | |
var file = await fs.getFileForOpening(); | |
if (!file) { | |
return; // picker was canceled | |
} | |
console.log("User chose file: " + file); | |
var text = await file.read(); | |
var json = JSON.parse(text); | |
createRectangle(selection, json.padding.vertical, json.padding.horizontal); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment