Skip to content

Commit

Permalink
1.0.5 - update some wording and lets you choose a library
Browse files Browse the repository at this point in the history
  • Loading branch information
robintindale committed Feb 27, 2018
1 parent ba81c0d commit 1b64020
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
10 changes: 5 additions & 5 deletions library-styles-sync.sketchplugin/Contents/Sketch/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Library Styles Sync",
"identifier": "com.zeroheight.library-styles-sync",
"version": "1.0.4",
"version": "1.0.5",
"description": "sync shared styles with a Library document",
"authorEmail": "[email protected]",
"author": "zeroheight team",
Expand All @@ -25,19 +25,19 @@
"script": "script.js",
"handler": "syncJSON",
"shortcut": "",
"name": "JSON - Sync",
"name": "Sync from JSON",
"identifier": "com.zeroheight.library-styles-sync.json-sync"
},{
"script": "script.js",
"handler": "setColor",
"shortcut": "",
"name": "JSON - Set color URL",
"name": "Set color URL",
"identifier": "com.zeroheight.library-styles-sync.json-color"
},{
"script": "script.js",
"handler": "setTypo",
"shortcut": "",
"name": "JSON - Set typography URL",
"name": "Set typography URL",
"identifier": "com.zeroheight.library-styles-sync.json-typo"
}],
"menu": {
Expand All @@ -49,7 +49,7 @@
"com.zeroheight.library-styles-sync.sync-with",
]
},{
"title": "JSON Sync (experimental)",
"title": "JSON(experimental)",
"items": [
"com.zeroheight.library-styles-sync.json-sync",
"com.zeroheight.library-styles-sync.json-color",
Expand Down
20 changes: 9 additions & 11 deletions library-styles-sync.sketchplugin/Contents/Sketch/script.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
var syncStylesWith = function (context) {

var doc = context.document.documentData();
var lookups = {
layer: createLookup(doc.layerStyles()),
text: createLookup(doc.layerTextStyles())
};

var options = [];
AppController.sharedInstance().librariesController().libraries().forEach(function(lib){
AppController.sharedInstance().librariesController().libraries().forEach(function (lib) {
options.push(lib.name());
});

var alert = COSAlertWindow.new();
alert.setMessageText('Choose library for sync:');

var select = NSComboBox.alloc().initWithFrame(NSMakeRect(0,0,200,25));
var select = NSComboBox.alloc().initWithFrame(NSMakeRect(0, 0, 200, 25));
select.i18nObjectValues = options;
select.setEditable(false);
select.addItemsWithObjectValues(options);
select.selectItemAtIndex(0);
alert.addAccessoryView(select);

alert.addButtonWithTitle('Sync');
alert.addButtonWithTitle('Cancel');
alert.addButtonWithTitle('Cancel');

if(alert.runModal() == NSAlertFirstButtonReturn)
{
if (alert.runModal() == NSAlertFirstButtonReturn) {
var chosenLibrary = alert.viewAtIndex(0).stringValue();
AppController.sharedInstance().librariesController().libraries().forEach(function(lib){
if(lib.name() == chosenLibrary){
AppController.sharedInstance().librariesController().libraries().forEach(function (lib) {
if (lib.name() == chosenLibrary) {
syncLibraryStyles(lib.document().layerStyles(), doc.layerStyles(), lookups.layer);
syncLibraryStyles(lib.document().layerTextStyles(), doc.layerTextStyles(), lookups.text);
context.document.showMessage('Synced styles with ' + chosenLibrary);
context.document.showMessage('Synced styles from ' + chosenLibrary);
}
});
}
}
};

var syncStyles = function (context) {
var doc = context.document.documentData();
Expand Down Expand Up @@ -65,7 +63,7 @@ var syncStyles = function (context) {
context.document.reloadInspector();

var objects = (validLibraries === 1) ? 'library' : 'libraries';
context.document.showMessage('Synced styles with ' + validLibraries + ' ' + objects);
context.document.showMessage('Synced styles from ' + validLibraries + ' ' + objects);
};

var getUserDefaults = function () {
Expand Down

0 comments on commit 1b64020

Please sign in to comment.