Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/icona79/sketch-plugin-utilities
Sketch plugin development reusable functions
https://github.com/icona79/sketch-plugin-utilities
Last synced: about 1 month ago
JSON representation
Sketch plugin development reusable functions
- Host: GitHub
- URL: https://github.com/icona79/sketch-plugin-utilities
- Owner: icona79
- Created: 2021-03-21T07:55:54.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-04-22T09:03:31.000Z (over 3 years ago)
- Last Synced: 2024-05-01T22:39:48.242Z (8 months ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Sketch plugin utilities
Useful functions for Sketch plugins. Provides functions to be reused into your plugins.
## Installation
```bash
npm i @icona79/sketch-plugin-utilities
```## Usage
You can import all the functions in once via
```javascript
var SketchUtilities = require("@icona79/sketch-plugin-utilities");
```or select every single function you need:
```javascript
import { functionNameA, functionNameB } from "@icona79/sketch-plugin-utilities";
```### Smart Layout options
#### Set Constraint (Pinning properties)
Set the Pinning Properties and Size properties for the selected artefact
```javascript
import { setResizingConstraint } from "@icona79/sketch-plugin-utilities";// set fix size both horizontally and vertically
setResizingConstraint(myItem, [false, false, false, false], [true, true]);
// set all the pinning properties to automatically resize the item based on its container size
setResizingConstraint(myItem, [true, true, true, true], [false, false]);
```Note: in case of all the same direction parameters are true (which will cause a Sketch error) the pin properties wins over the size contraint properties
#### Set Smart Layout
Set the Smart Layout properties for the selected artefact (Symbol or Group only)
```javascript
import { setSmartLayout } from "@icona79/sketch-plugin-utilities";// set the item's smart layout to be resized horzontally from the center
setSmartLayout(myItem, "HorizontallyCenter"));
```