Skip to content

Sketch API JS bindings for development of Sketch Plugin using PureScript

License

Notifications You must be signed in to change notification settings

iarthstar/purescript-sketch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

purescript-sketch

Build Status

Sketch Javascript API wrapper for development of Sketch Plugin using PureScript

Add purescript-sketch to your existing plugin projects

bower i purescript-sketch

Code Snippet

main :: Effect Unit
main = do
    Dom.selectedLayers >>= case _ of
        Left err -> UI.message "Something went wrong..."
        Right layers -> do
            if length layers == 0
                then UI.alert "No Selection" "Please select a layer and try again..."
                else logShow $ foldl (\a b -> a <> b) "" $ mapWithIndex parseLayers layers
    where
        parseLayers :: Int -> Layer -> String
        parseLayers index layer = do
            let name = case layer of
                    Text (TextLayer tl) -> tl.name
                    Image (ImageLayer il) -> il.name
                    Shape (ShapeLayer sl) -> sl.name
                    Group (GroupLayer gl) -> gl.name
                    Artboard (ArtboardLayer gl) -> gl.name
            show index <> ". " <> name

Example Plugins

Want to Develop Plugin

About

Sketch API JS bindings for development of Sketch Plugin using PureScript

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published