| Download | Features | Usage | Customization | Changelog | Next | Contribute | Credits | Donate | |---|---|---|---|---|---|---|---|---|---|
(Formerly ShareableColorPalette)
Creates a beautiful artboard with all the colors in your 'Document Colors' with its respective color label in a variety of formats. (Sketch 41)
IMPORTANT! Version 1.0.2 Works only on versions of Sketch 41 and higher If you're using Sketch 39 or 40, look for the 1.0.1 release.
* Beautiful color palette generation. * Automatic color naming. * Fully customizable. * Export as code in a variety of formats (CSS, SASS variables, Swift, etc). * Color renaming (Alias). * Rebuilt from the ground up using `Coffeescript` and love. 1. Install plugin. 2. Add your colors to your *Document Colors*. 3. Run command **[ctrl cmd c]**. 4. Voilà!
To change the color alias, just change the text on the Name layer. If you want the default color name, just delete the text on that same layer.
- Select the colors you want to export (optional)
- Click Export Selected Colors [ctrl cmd s] or Export All Colors [ctrl cmd e]
- Select the format to export.
- Save your color code file or copy the colors to clipboard.
ColorFormatter.coffee This is where the format is registered
# This is were formats are registered, the ID must be unique, the name is a human readable mini description, the format is used to use a custom file extension when saving colors to a file
FORMATS: [
{ id: "HEX", name: "HEX CSS", format: "colors.css" }
{ id: "RGBA_CSS", name: "RGBA CSS", format: "colors.css" }
{ id: "SASS", name: "SASS variables", format: "_colors.scss" }
{ id: "UICOLOR_SWIFT", name: "UIColor (Swift)", format: "colors.swift" }
{ id: "UICOLOR_OBJC", name: "UIColor (Objective-C)", format: "colors.m" }
{ id: "ANDROID", name: "Android ARGB Color", format: "colors.java" }
]
Then implement it in the same file
###
HERE is when you have to do the implementation of the new format you want to add.
all these methods must be prefixed with "format_" and then the format ID specified in the FORMATS array
The commented flag is used to add comments (like when we export colors)
or removing them (like when we are populating the cell layers with color data)
the color variable that is passed is a dictionary with all the information you need:
name: the default name of the color or the alias if it exists
hex: color's hex value without the leading '#'
red: color's red value from 0 to 1
blue: color's blue value from 0 to 1
green: color's green value from 0 to 1
alpha: color's alpha value from 0 to 1
###
format_RGBA_CSS: (color, commented) ->
alpha = if color.alpha < 1
color.alpha.toFixed(2)
else
color.alpha
formattedColor = "rgba(#{Math.round(color.red * 255)},#{Math.round(color.green * 255)},#{Math.round(color.blue * 255)},#{alpha});"
if commented
"#{formattedColor} /* #{color.name} */"
else
formattedColor
You can have as many text layers for formats as you want. Also, layers can be locked or invisible as long as they conform to this restrictions.
If you wanna dive deeper on this process, you should check out the Cell.coffee
and Template.coffee
files.
I have included a compile.sh
file that automatically compiles all the files inside the src/ folder into the build/ folder, however, if you add new files you must import them in the right order inside the Prism.cocoascript
file.
You can run the compile.sh file by typing this in the terminal inside the Prism.sketchplugin/Content/Sketch folder:
./compile.sh
This will compile your files as soon as they are saved, as long as the process is running. To stop the process just Ctrl-C
out of it ;)