Created
December 12, 2016 16:30
-
-
Save andrewliebchen/c1a98a158806f2d66a036b77269e922b to your computer and use it in GitHub Desktop.
Creating multiple layers in Framer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. IMPORT FROM SKETCH | |
sketch = Framer.Importer.load("imported/boxes@1x") | |
# 2. INDIVIDUAL LAYERS | |
box1 = new Layer | |
size: 100 | |
backgroundColor: 'blue' | |
# ...More layers... | |
box10 = new Layer | |
size: 100 | |
backgroundColor: 'magenta' | |
# 3. LOOP | |
boxColors = ['blue', ..., 'magenta'] | |
for i in [0..9] | |
box = new Layer | |
size: 100 | |
name: "box#{i}" | |
backgroundColor: boxColors[i] | |
# 4. CLASS | |
class Box extends Layer | |
constructor: (options) -> | |
super _.defaults options, | |
size: 100 | |
box1 = new Box | |
backgroundColor: 'blue' | |
# ...More layers... | |
box10 = new Box | |
backgroundColor: 'magenta' | |
# 5. OBJECT | |
boxes = [ | |
{ | |
name: 'box1' | |
backgroundColor: 'blue' | |
}, ... { | |
name: 'box2' | |
backgroundColor: 'magenta' | |
} | |
] | |
for element, index in boxes | |
box = new Layer | |
size: 100 | |
backgroundColor: element.backgroundColor | |
name: element.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment