This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d2a6c0
commit 5e1e88c
Showing
31 changed files
with
442 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions
17
Logodrop.sketchplugin/Contents/Resources/asset-manifest.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"main.css": "static/css/main.e55939ff.css", | ||
"main.css.map": "static/css/main.e55939ff.css.map", | ||
"main.js": "static/js/main.4a03090d.js", | ||
"main.js.map": "static/js/main.4a03090d.js.map", | ||
"static\\media\\Lato-Black.ttf": "static/media/Lato-Black.77d35374.ttf", | ||
"static\\media\\Lato-BlackItalic.ttf": "static/media/Lato-BlackItalic.6c522f09.ttf", | ||
"static\\media\\Lato-Bold.ttf": "static/media/Lato-Bold.44dfe8cc.ttf", | ||
"static\\media\\Lato-BoldItalic.ttf": "static/media/Lato-BoldItalic.1ba4767e.ttf", | ||
"static\\media\\Lato-Hairline.ttf": "static/media/Lato-Hairline.db15ac79.ttf", | ||
"static\\media\\Lato-HairlineItalic.ttf": "static/media/Lato-HairlineItalic.a567f4a8.ttf", | ||
"static\\media\\Lato-Italic.ttf": "static/media/Lato-Italic.56c4cb26.ttf", | ||
"static\\media\\Lato-Light.ttf": "static/media/Lato-Light.5b761f2d.ttf", | ||
"static\\media\\Lato-LightItalic.ttf": "static/media/Lato-LightItalic.3d747d8b.ttf", | ||
"static\\media\\Lato-Regular.ttf": "static/media/Lato-Regular.7f690e50.ttf", | ||
"static\\media\\no-results.svg": "static/media/no-results.e43118a5.svg" | ||
} |
16 changes: 16 additions & 0 deletions
16
Logodrop.sketchplugin/Contents/Resources/common/PlatformAPI.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
var app = app || {}; | ||
|
||
app.performAction = (action, data) => { | ||
window.data = JSON.stringify(data); | ||
window.location.hash = action; | ||
window.location.hash = '#'; | ||
} | ||
|
||
app.insertLogo = (logo) => { | ||
app.performAction('INSERT_LOGO', logo); | ||
} | ||
|
||
app.showError = (error) => { | ||
console.log(error); | ||
alert("Error while fetching response from Internet. Please try again!"); | ||
} |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="./manifest.json"><link rel="shortcut icon" href="./favicon.ico"><title>React App</title><script type="text/javascript" src="./common/PlatformAPI.js"></script><script type="text/javascript">document.addEventListener('contextmenu', event => event.preventDefault());</script><link href="./static/css/main.e55939ff.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script type="text/javascript" src="./static/js/main.4a03090d.js"></script></body></html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"short_name": "React App", | ||
"name": "Create React App Sample", | ||
"icons": [ | ||
{ | ||
"src": "favicon.ico", | ||
"sizes": "192x192", | ||
"type": "image/png" | ||
} | ||
], | ||
"start_url": "./index.html", | ||
"display": "standalone", | ||
"theme_color": "#000000", | ||
"background_color": "#ffffff" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
Logodrop.sketchplugin/Contents/Resources/static/css/main.e55939ff.css
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
Logodrop.sketchplugin/Contents/Resources/static/css/main.e55939ff.css.map
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
Logodrop.sketchplugin/Contents/Resources/static/js/main.4a03090d.js
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
Logodrop.sketchplugin/Contents/Resources/static/js/main.4a03090d.js.map
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+112 KB
Logodrop.sketchplugin/Contents/Resources/static/media/Lato-Black.77d35374.ttf
Binary file not shown.
Binary file added
BIN
+109 KB
Logodrop.sketchplugin/Contents/Resources/static/media/Lato-BlackItalic.6c522f09.ttf
Binary file not shown.
Binary file added
BIN
+119 KB
Logodrop.sketchplugin/Contents/Resources/static/media/Lato-Bold.44dfe8cc.ttf
Binary file not shown.
Binary file added
BIN
+117 KB
Logodrop.sketchplugin/Contents/Resources/static/media/Lato-BoldItalic.1ba4767e.ttf
Binary file not shown.
Binary file added
BIN
+113 KB
Logodrop.sketchplugin/Contents/Resources/static/media/Lato-Hairline.db15ac79.ttf
Binary file not shown.
Binary file added
BIN
+89.3 KB
Logodrop.sketchplugin/Contents/Resources/static/media/Lato-HairlineItalic.a567f4a8.ttf
Binary file not shown.
Binary file added
BIN
+116 KB
Logodrop.sketchplugin/Contents/Resources/static/media/Lato-Italic.56c4cb26.ttf
Binary file not shown.
Binary file added
BIN
+120 KB
Logodrop.sketchplugin/Contents/Resources/static/media/Lato-Light.5b761f2d.ttf
Binary file not shown.
Binary file added
BIN
+89.5 KB
Logodrop.sketchplugin/Contents/Resources/static/media/Lato-LightItalic.3d747d8b.ttf
Binary file not shown.
Binary file added
BIN
+117 KB
Logodrop.sketchplugin/Contents/Resources/static/media/Lato-Regular.7f690e50.ttf
Binary file not shown.
19 changes: 19 additions & 0 deletions
19
Logodrop.sketchplugin/Contents/Resources/static/media/no-results.e43118a5.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<rss xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"> | ||
<channel> | ||
<title>Nudged</title> | ||
<link>https://raw.githubusercontent.com/Iconscout/sketch-logos/master/appcast.xml</link> | ||
<description>A Sketch plugin to easily edit your nudge distance settings.</description> | ||
<language>en</language> | ||
<item> | ||
<title>2.0</title> | ||
<description> | ||
<![CDATA[ | ||
<ul> | ||
<li>Changed Plugin Shortcut to Ctrl + Alt + n</li> | ||
<li>Added Custom Nudge input</li> | ||
<li>Added smarter UI with a number of usability enhancements</li> | ||
<li>Added 'Reset' button to settings window</li> | ||
<li>Added Quick Reset Shortcut Ctrl + Alt + 0</li> | ||
<li>Added integration with Sketch App's Update System</li> | ||
</ul> | ||
]]> | ||
</description> | ||
<pubDate>Sat, Jun 3 2017 11:54:08 +0100</pubDate> | ||
<enclosure url="https://github.com/KevinWoodhouse/sketch-nudged/archive/v2.0.zip" type="application/octet-stream" sparkle:version="2.0"/> | ||
</item> | ||
<item> | ||
<title>1.0.1</title> | ||
<description> | ||
<![CDATA[ | ||
<ul> | ||
<li>Added integration with Sketch Runner</li> | ||
</ul> | ||
]]> | ||
</description> | ||
<pubDate>Fri, 17 Mar 2017 12:02:53 +0000</pubDate> | ||
<enclosure url="https://github.com/KevinWoodhouse/sketch-nudged/archive/v1.0.1.zip" type="application/octet-stream" sparkle:version="1.0.1"/> | ||
</item> | ||
<item> | ||
<title>1.0</title> | ||
<description> | ||
<![CDATA[ | ||
<ul> | ||
<li>First release of Sketch Nudged</li> | ||
</ul> | ||
]]> | ||
</description> | ||
<pubDate>Mon, 9 Jan 2017 12:10:42 +0000</pubDate> | ||
<enclosure url="https://github.com/KevinWoodhouse/sketch-nudged/archive/v1.0.zip" type="application/octet-stream" sparkle:version="1.0"/> | ||
</item> | ||
</channel> | ||
</rss> |
80 changes: 80 additions & 0 deletions
80
Logodrop.sketchplugin/Contents/Sketch/common/MochaJSDelegate.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// | ||
// MochaJSDelegate.js | ||
// MochaJSDelegate | ||
// | ||
// Created by Matt Curtis | ||
// Copyright (c) 2015. All rights reserved. | ||
// | ||
|
||
var MochaJSDelegate = function(selectorHandlerDict){ | ||
var uniqueClassName = "MochaJSDelegate_DynamicClass_" + NSUUID.UUID().UUIDString(); | ||
|
||
var delegateClassDesc = MOClassDescription.allocateDescriptionForClassWithName_superclass_(uniqueClassName, NSObject); | ||
|
||
delegateClassDesc.registerClass(); | ||
|
||
// Handler storage | ||
|
||
var handlers = {}; | ||
|
||
// Define interface | ||
|
||
this.setHandlerForSelector = function(selectorString, func){ | ||
var handlerHasBeenSet = (selectorString in handlers); | ||
var selector = NSSelectorFromString(selectorString); | ||
|
||
handlers[selectorString] = func; | ||
|
||
if(!handlerHasBeenSet){ | ||
/* | ||
For some reason, Mocha acts weird about arguments: | ||
https://github.com/logancollins/Mocha/issues/28 | ||
We have to basically create a dynamic handler with a likewise dynamic number of predefined arguments. | ||
*/ | ||
|
||
var dynamicHandler = function(){ | ||
var functionToCall = handlers[selectorString]; | ||
|
||
if(!functionToCall) return; | ||
|
||
return functionToCall.apply(delegateClassDesc, arguments); | ||
}; | ||
|
||
var args = [], regex = /:/g; | ||
while(match = regex.exec(selectorString)) args.push("arg"+args.length); | ||
|
||
dynamicFunction = eval("(function("+args.join(",")+"){ return dynamicHandler.apply(this, arguments); })"); | ||
|
||
delegateClassDesc.addInstanceMethodWithSelector_function_(selector, dynamicFunction); | ||
} | ||
}; | ||
|
||
this.removeHandlerForSelector = function(selectorString){ | ||
delete handlers[selectorString]; | ||
}; | ||
|
||
this.getHandlerForSelector = function(selectorString){ | ||
return handlers[selectorString]; | ||
}; | ||
|
||
this.getAllHandlers = function(){ | ||
return handlers; | ||
}; | ||
|
||
this.getClass = function(){ | ||
return NSClassFromString(uniqueClassName); | ||
}; | ||
|
||
this.getClassInstance = function(){ | ||
return NSClassFromString(uniqueClassName).new(); | ||
}; | ||
|
||
// Conveience | ||
|
||
if(typeof selectorHandlerDict == "object"){ | ||
for(var selectorString in selectorHandlerDict){ | ||
this.setHandlerForSelector(selectorString, selectorHandlerDict[selectorString]); | ||
} | ||
} | ||
}; |
69 changes: 69 additions & 0 deletions
69
Logodrop.sketchplugin/Contents/Sketch/common/Panel.cocoascript
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
function showPanel(options) { | ||
var context = options.context; | ||
var webviewResource = options.webviewResource; | ||
var panelSettings = options.panelSettings; | ||
var delegateListeners = options.delegateListeners; | ||
|
||
try { | ||
var resourcePath = context.plugin.urlForResourceNamed(webviewResource).path(); | ||
var timestamp = Date.now(); | ||
var url = encodeURI('file://' + resourcePath + '#' + timestamp); | ||
|
||
// Main window | ||
var title = "Logodrop by Iconscout"; | ||
var identifier = "com.iconscout.logodrop"; | ||
var threadDictionary = NSThread.mainThread().threadDictionary(); | ||
|
||
if (threadDictionary[identifier]) { | ||
return; | ||
} | ||
|
||
var frame = NSMakeRect(0, 0, panelSettings.width, panelSettings.height); | ||
|
||
var panel = NSPanel.alloc().init(); | ||
panel.setTitle(title); | ||
panel.setTitlebarAppearsTransparent(true); | ||
|
||
panel.standardWindowButton(NSWindowCloseButton).setHidden(false); | ||
panel.standardWindowButton(NSWindowMiniaturizeButton).setHidden(true); | ||
panel.standardWindowButton(NSWindowZoomButton).setHidden(true); | ||
|
||
panel.setFrame_display(frame, false); | ||
panel.setStyleMask(NSTexturedBackgroundWindowMask | NSTitledWindowMask | NSClosableWindowMask); | ||
panel.setBackgroundColor(panelSettings.backgroundColor); | ||
|
||
threadDictionary[identifier] = panel; | ||
COScript.currentCOScript().setShouldKeepAround_(true); | ||
|
||
var contentView = panel.contentView(); | ||
var webView = WebView.alloc().initWithFrame(NSMakeRect(0, 0, panelSettings.width, panelSettings.height)); | ||
|
||
var delegate = new MochaJSDelegate(delegateListeners); | ||
|
||
contentView.setWantsLayer(true); | ||
contentView.layer().setFrame( contentView.frame() ); | ||
contentView.layer().setMasksToBounds(true); | ||
|
||
webView.setBackgroundColor(panelSettings.backgroundColor); | ||
webView.setFrameLoadDelegate_(delegate.getClassInstance()); | ||
webView.setMainFrameURL_(url); | ||
|
||
contentView.addSubview(webView); | ||
|
||
var closeButton = panel.standardWindowButton(NSWindowCloseButton); | ||
closeButton.setCOSJSTargetFunction(function(sender) { | ||
COScript.currentCOScript().setShouldKeepAround(false); | ||
threadDictionary.removeObjectForKey(identifier); | ||
panel.close(); | ||
}); | ||
closeButton.setAction("callAction:"); | ||
|
||
panel.becomeKeyWindow(); | ||
panel.setLevel(NSFloatingWindowLevel); | ||
panel.center(); | ||
panel.makeKeyAndOrderFront(nil); | ||
|
||
} catch(e) { | ||
log(e); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
function placeLogo(logo, context) { | ||
var logoUrl = logo.svg_file; | ||
var selection = context.selection; | ||
var selectedShape = [selection objectAtIndex:0]; | ||
var doc = context.document; | ||
var selectedFrame = selectedShape.frame(); | ||
var svgImporter = MSSVGImporter.svgImporter(); | ||
|
||
var fileURL = NSURL.URLWithString(logoUrl); | ||
svgImporter.prepareToImportFromURL(fileURL); | ||
var importedSVGLayer = svgImporter.importAsLayer(); | ||
importedSVGLayer.name = logo.name; | ||
|
||
// Scale SVG to selection frame | ||
var svgFrame = importedSVGLayer.frame(); | ||
var ratio = svgFrame.width() / svgFrame.height(); | ||
var newWidth = selectedFrame.width(); | ||
var newHeight = newWidth / ratio; | ||
if (newHeight > selectedFrame.height()) { | ||
newHeight = selectedFrame.height(); | ||
newWidth = newHeight * ratio; | ||
} | ||
|
||
// Center in selection frame | ||
[svgFrame setX:selectedFrame.x() + selectedFrame.width() / 2 - newWidth / 2]; | ||
[svgFrame setY:selectedFrame.y() + selectedFrame.height() / 2 - newHeight / 2]; | ||
[svgFrame setWidth:newWidth]; | ||
[svgFrame setHeight:newHeight]; | ||
|
||
// Add label layer | ||
var page = doc.currentPage(); | ||
var canvas = page.currentArtboard() || page; | ||
canvas.addLayers([importedSVGLayer]); | ||
|
||
// Remove selection frame | ||
selectedShape.removeFromParent(); | ||
} |
16 changes: 16 additions & 0 deletions
16
Logodrop.sketchplugin/Contents/Sketch/common/SelectedShape.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function selectedShape(context) { | ||
var selection = context.selection; | ||
var doc = context.document; | ||
|
||
if (selection.count() != 1) { | ||
[doc showMessage:'Please select a layer with a single shape']; | ||
} | ||
|
||
var selectedShape = [selection objectAtIndex:0]; | ||
if (! [selectedShape isKindOfClass:[MSShapeGroup class]]) { | ||
[doc showMessage:'Selected layer is not a shape layer']; | ||
return; | ||
} | ||
|
||
return selectedShape; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@import 'common/MochaJSDelegate.js'; | ||
@import 'common/Panel.cocoascript'; | ||
@import 'common/PlaceLogo.js'; | ||
@import 'common/SelectedShape.js'; | ||
|
||
function searchLogos(context) { | ||
var webviewResource = 'index.html'; | ||
var panelSettings = { | ||
width: 390, | ||
height: 498, | ||
backgroundColor: NSColor.whiteColor() | ||
}; | ||
|
||
var delegateListeners = { | ||
"webView:didChangeLocationWithinPageForFrame:": function(webView, webFrame) { | ||
var panel = webView.superview().window(); | ||
var windowObject = webView.windowScriptObject(); | ||
var request = NSURL.URLWithString(webView.mainFrameURL()).fragment(); | ||
|
||
var data = windowObject.valueForKey("data"); | ||
|
||
var logo = JSON.parse(data); | ||
|
||
placeLogo(logo, context); | ||
|
||
log(data); | ||
} | ||
} | ||
|
||
showPanel({ | ||
context: context, | ||
webviewResource: webviewResource, | ||
panelSettings: panelSettings, | ||
delegateListeners: delegateListeners | ||
}); | ||
} |
Oops, something went wrong.