A tool to generate code from Sketch designs
npm install- In the project directory, copy
config.js.templatetoconfig.jsand set theprojectRoot. npm run watch
For more, read Using skpm
- Open a Sketch file.
- In Sketch, go to
Plugin -> Scribe -> Generate Component. - All component files will be generated in the project directory's
public/componentsfolder. To preview the components, runnpm run servein a separate terminal window and browse tolocalhost:3000.
Scribe uses the following naming conventions to process specific Sketch layers:
SCBackground: Specifies that a rectangle is the background of the component.svg: If a single shape or a layer group has an extension of.svg(e.g.SomeShapeGroup.svg), the tool will generate the imageSCList: Use to denote a list. A name can be given to a list by wrapping the list inside of a group. Items insideSCListshould only be groups named with a prefix ofSCRow. Anything else will be ignored.SCRow: Used to denote a row inside a list. You can give the row a name by appending it likeSCRow_myRow. The position of the row inside the list determines the index of the row.
Shapes that don’t follow the rules above will be ignored.
In addition, anything that’s prefixed with a double underscore (e.g. __ignoreBg) will be ignored.
During development, you'll want to communicate with Sketch APIs. Since Sketch is an Objective-c app, we can retrieve header files for all of their classes. Use this as reference to find the APIs that you need. Sketch class-dump.
Any class that as a MS prefix is a Sketch object ex. MSArtboard. Any object that's prefixed as NS and CG are Apple objects. Ex. NSDocument and CGRect. Google Apple classes to find relevant documentation for them.
To view output for debugging, open the system console by going to Applications -> Utilities -> Console and observe the logs generated by Sketch.