├── .gitignore ├── CopyColor.sketchplugin └── Contents │ └── Sketch │ ├── copy-color.js │ └── manifest.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /CopyColor.sketchplugin/Contents/Sketch/copy-color.js: -------------------------------------------------------------------------------- 1 | function copyFillColor(context) { 2 | var doc = context.document; 3 | var selected = context.selection; 4 | if (selected.count() > 0) { 5 | var layerFill = selected.firstObject().style().fills().firstObject().color().immutableModelObject().hexValue().toString(); 6 | var pasteBoard = NSPasteboard.generalPasteboard(); 7 | pasteBoard.clearContents() 8 | pasteBoard.writeObjects([layerFill]); 9 | doc.showMessage("Copied layer fill color value: " + layerFill + " to your clipboard"); 10 | } else { 11 | doc.showMessage("Please select a layer"); 12 | } 13 | }; 14 | 15 | function copyTextColor(context) { 16 | var doc = context.document; 17 | var selected = context.selection; 18 | if (selected.count() > 0) { 19 | var textFill = selected.firstObject().textColor().immutableModelObject().hexValue().toString(); 20 | var pasteBoard = NSPasteboard.generalPasteboard(); 21 | pasteBoard.clearContents() 22 | pasteBoard.writeObjects([textFill]); 23 | doc.showMessage("Copied text color value: " + textFill + " to your clipboard"); 24 | } else { 25 | doc.showMessage("Please select a text layer"); 26 | } 27 | }; 28 | 29 | function copyBorderColor(context) { 30 | var doc = context.document; 31 | var selected = context.selection; 32 | if (selected.count() > 0) { 33 | var borderColor = selected.firstObject().style().borders().firstObject().color().immutableModelObject().hexValue().toString(); 34 | var pasteBoard = NSPasteboard.generalPasteboard(); 35 | pasteBoard.clearContents() 36 | pasteBoard.writeObjects([borderColor]); 37 | doc.showMessage("Copied border color value: " + borderColor + " to your clipboard"); 38 | } else { 39 | doc.showMessage("Please select a layer"); 40 | } 41 | }; 42 | -------------------------------------------------------------------------------- /CopyColor.sketchplugin/Contents/Sketch/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Copy Color", 3 | "identifier" : "com.sketchapp.examples.copy-color", 4 | "version" : "2.1", 5 | "description" : "provides shortcuts to copy a layer's fill or border color as well as text color hex value.", 6 | "authorEmail" : "poyi.design@gmail.com", 7 | "author" : "Poyi Chen", 8 | "commands" : [ 9 | { 10 | "script" : "copy-color.js", 11 | "handler" : "copyFillColor", 12 | "shortcut" : "shift cmd f", 13 | "name" : "Copy Fill Color", 14 | "identifier" : "copy-fill" 15 | }, 16 | { 17 | "script" : "copy-color.js", 18 | "handler" : "copyTextColor", 19 | "shortcut" : "shift cmd x", 20 | "name" : "Copy Text Color", 21 | "identifier" : "copy-text" 22 | }, 23 | { 24 | "script" : "copy-color.js", 25 | "handler" : "copyBorderColor", 26 | "shortcut" : "shift cmd b", 27 | "name" : "Copy Border Color", 28 | "identifier" : "copy-border" 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Copy Color Sketch Plugin

2 | This is a Sketch 4 (http://bohemiancoding.com/sketch/) Plugin that provides shortcut for copying a layer's fill color (with shift + command + f) or border's fill color (with shift + command + b) to clipboard. If you need to quickly grab the hex code of either the layer fill color or border color within Sketch and paste it somewhere else, then this plugin may save you some time. 3 | 4 |

Installation

5 | 6 | 1. Download this Plugin 7 | 2. Double clicking the plugin file to automatically install 8 | 3. The shortcut should now be available under the Plugin's menu in Sketch 9 | 10 |

Using the Plugin

11 | 12 | Copy Layer Fill Color 13 | 14 | Select a layer with fill color and press Shift + Command + f. The hex code should now be copied to your clipboard and ready to be pasted. 15 | 16 | Copy Border Fill Color 17 | 18 | Select a layer with border color and press Shift + Command + b. Paste anywhere you see fit. 19 | 20 | Note that the Shift + Command + f overwrites the Sketch default enter full screen shortcut, you can set your own shortcut by editing the plugin file at the top to avoid conflict. e.g. (shift cmd f) -> (shift cmd o) 21 | 22 | Copy Text Color 23 | 24 | Select a text object and press Shift + Command + x. Paste away! 25 | 26 | [![Install PLUGIN NAME with Sketchpacks](http://sketchpacks-com.s3.amazonaws.com/assets/badges/sketchpacks-badge-install.png "Install PLUGIN NAME with Sketchpacks")](https://sketchpacks.com/YOUR_NAME/PLUGIN_NAME/install) 27 | --------------------------------------------------------------------------------