Code Monkey home page Code Monkey logo

sketch-framer's Introduction

This plugin is no longer maintained, since Framer Studio now imports from Sketch natively

The code and the rest of the README are left here for historical reasons


Sketch Framer

A plugin to export Sketch.app documents into FramerJS to make interactive prototypes.

Common questions

  • Only works with Sketch Beta right now because the App Store version is sandboxed. Download Sketch Beta here.
  • Make sure you copy both files as specified below.

Sketch 3 Support

We're hard at work updating the plugin for Sketch 3! You can use the plugin with a few caveats:

  • Artboards aren't supported yet. Please ungroup your artboard and have elements directly on the canvas. We suggest you group everything at top level, and move the parent group to 0,0 position.
  • Symbols aren't supported. We suggest making a copy of your file, going to Manage Symbols and deleting the symbols, which will effectively detach all the symbol layers from the symbol (but keep them on the canvas).

Installation

  1. Download the repository using this link
  2. Grab these files from the ZIP: Export to Framer.sketchplugin, sandbox.js and sketch-framer-config.js
  3. In Sketch 3, select Plugins > Reveal Plugins Folder... from the menu bar, and put those files in this folder.

This is what your plugins folder should look like after you copy them:

Directory structure

Then you'll see the plugin in the plugins menu:

Plugins menu

Usage

  1. Create your layered Sketch file, and save it somewhere
  2. Run the plugin from the plugins menu
  3. The framer prototype will be generated in a folder right next to where the Sketch file is saved

Exported files

Tips

  • Don't use artboards (Known bug, trying to fix it)
  • Group everything in your document in a main "Phone" group, and align it to (0,0)
  • Use unique names for each group in your document to avoid conflicts
  • Every group in your document will become a Framer view

Special operations

  • Flatten To have a group flattened so its child groups don't export individually, append * to its name. Example: Card*. Flattening complex groups will improve performance.
  • Shape/text layers To export a shape or a text layer as a view, put it in a group, or append + to its name. Otherwise they will export as a background image.
  • Ignore To ignore a layer, append - to its name. Example: Ignored-
  • Hidden layers Hidden layers in Sketch will be exported as hidden layers in Framer. To show the layer in framer, try view.visible = true
  • Masks Native masks now work! You can also use Scroll in the name of a group that includes a mask to make that group scrollable.

Configuration

You can customize the exported files (index.html, app.js) by tweaking sketch-framer-config.js. The most common thing you might want to do is import a library file and include it in all your projects.

Known bugs

  • Very complicated files may cause the plugin to crash, or result in a sluggish Framer mockup. Flatten groups (by appending * to their names or using Sketch 3's Layer > Flatten Selection to Bitmap command) where you don't need to access the contents individually.
  • Only rectangular masks work. If you're masking with an odd shape, try flattening the group (by appending * to its name)
  • Effects that expand beyond the boundaries of a layer (eg. drop shadows, outside borders) cause minor positioning bugs. Try flattening these layers to bitmaps.
  • Avoid background blur, it causes bugs in positioning.

Help us improve Sketch Framer

To propose changes, fork the repository and submit a pull request!

Questions?

Reach out to @bomberstudios or @gem_ray on Twitter!

sketch-framer's People

Contributors

bomberstudios avatar cemre avatar jenbennings avatar jmwhittaker avatar nickstamas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sketch-framer's Issues

Multiple windows of sketch open causes "Multiple Pages" error

If I have a multiple windows of Sketch open, the importer fails and says "Sketch Framer found some errors". I have to close all other windows in sketch for it to work properly. Ideally, I could leave any number of windows open and only import the active one, which is how the photoshop importer works. I'm also not sure why the error message talks about "Pages", when the "Windows" are what appear to be the issue here.

screen shot 2014-08-17 at 2 11 46 pm

Support Mulitiple Pages

I suggest that this supports exporting pages and artboards in pages. So, you could either export pages each in their own folder, with all artboards contained in the framer js file export. See below as my example of what the export could be:

  • Filename.sketch
  • Filename (folder)
    • Page 1 Name (folder)
      • framer (folder)
      • images (folder)
    • Page 2 Name
      • framer (folder)
      • images (folder)

Border set to 'outside' bubbles up to parent group

Took me a while to figure out what was going on here. Basically, a border set to 'outside' on a child group (or element) is resulting in erroneous width/height on the parent group. This is only visible in the .png output. Here's an example:

The pink view is 640px × 1136px. However since I have a child group with an outside border thickness of 50px, it has exported out as 740px × 1236px (an extra 50px on each side).

Not quite sure if this is something to do with Sketch, Sketch Framer, or me!

Problem Exporting Using Sketch Beta

Hi guys-

This morning—I think this morning—I got a dialogue box to update to the latest version of Sketch3 beta. After that, when I go to export using the Sketch Export plugin, the /framer and /images directories are created, but no files are added. In the Sketch app, the top-most folder (including its layers) is duplicated. If I attempt to re-export, the top-most folder is duplicated a third then fourth time.

framer.js missing on initial load of index.html

The first time I run Export to Framer on a new project, the launched index.html file can't find framer.js, even though the file exists in the directory:

Fortunately this fixes itself on refresh—which leads me think that perhaps the open task is being fired too soon. Not a big deal, but thought I'd mention it here anyway.

FYI this only appears to have started happening since upgrading to the latest version of Sketch Framer. I'm on Version 2.4.3 (5347) of Sketch.

2.4

Hey!

This doesn't quite work on 2.4 or 2.4.2. Just wanted to give y'all a heads up.

I'm super pumped this exists and really wish someone would update it. Hell, I'd throw down 5-10 to support. Are there any updates down the line?

export bitmaps at original resolution and resize in code?

what if bitmaps were exported at at their original resolution and resized in framer so we can scale them up/down without loss of quality. this would be similar to how Sketch itself handles bitmaps.

downsides: larger exports and potential problems with the scaling algoritms?

Fix offset calculation

Right now the offset calculation code assumes that effects are symmetrical in both axes, and will fail miserably for effects that aren't (your typical drop shadow, or a basic reflection, for example).

Extra Padding around Group

Setup:
padding

The "Screen" group contains all other layer groups. Nothing exceeds 640 x 1136.
When targeting Screen within Framer:

padding2

What's causing this extra padding? Masking makes no difference. Including / removing Artboards doesn't either.

Sketch File: http://cl.ly/X8bJ
Framer File: http://cl.ly/X8lw

Symbols with mask crop child layers

If you import these to framer the kermit in the ContainerA will be the right unchopped size and the other one will be as high as ContainerB (flattened).

image

Asterisk in layer names.

Because the Sketch-to-Framer is pretty shaky, I've been liberally flattening layers by appending a * to the Sketch layer name. The problem is that when I want to use the flattened layers, I have to say myLayers['flattened_'] because myLayers.flattened_ throws and error obviously.

Does it make sense to strip out the asterisk? I can see arguments against stripping, but I thought I'd let you know it's an issue I've run up against.

And I've been using this loop to fix it:

/*Because Framer currently includes the * for flattened layers, we need to remove them*/
for(var i in myLayers) {
    if(i.slice(-1) == "*") {
        var newName = i.slice(0, i.length-1);
        window[newName] = myLayers[i];   #in keeping with using framer shortcuts which move all layers to the global namespace.
    }
}

Outside borders and shadows make parent elements to incorrectly grow or shift

I was trying to debug a weird alignment bug that I was losing sleep over, and found the bottom of it. Basically any external border or shadow causes every parent element in the document to shift by that amount. Also the immediate parent will grow by that amount as well, even if the borders don't mess with its boundaries. This is probably caused by a bug in calculate_real_position_for?

@bomberstudios

Example

Without borders, everything is fine. Phone is at (0,0) and Feed_scroll is 640px wide. Card is 600px wide and starts at x=20.
align
screen shot 2014-02-23 at 3 36 46 pm


With a 8px outside border, Phone shifts to (-8, -8), an Feed_scroll grew to 656px, even though the border actually didn't cause the container to grow. Card is 616px wide (correct) and starts at x=12 (correct).

align
screen shot 2014-02-23 at 3 37 03 pm


Here's the file:
https://dl.dropboxusercontent.com/u/811105/prototypes/sketch-framer-border-bug.zip

Blurred Layers

Set-up:
blur-layers

Framer Studio result:
blur

It clips layers at the selection of the original rectangle. Not too big of a deal, but I thought I'd share anyway. (As flattening layers should prevent this)

After exporting, new tab opens on Chrome

Every time I export to Framer, Chrome opens a new tab with the prototype.

Is there a way to reuse the same tab? Or maybe only open the browser the first time a prototype is generated, and not subsequent times.

Opaque group png issue

In this file, a group with no contents (view), just folders that contain layers, exports as a opaque png that is too high and therefor offsets vertical alignment.

Zip here: http://cl.ly/X3ut

screen shot 2014-08-15 at 17 37 43

Compatibility issues with Sketch 3 beta

Firstly Sketch 3 is very much beta and they are releasing updates at an incredible rate so this is more a ticket to be aware of the new release.

SketchFramer running inside Sketch 3 beta exports blank images. I've looked at the code and not got to the reason for the blank export yet.

Retina Canvas Support

Is it possible to exports everything in 2x if I uses retina canvas? As frame set image using background-image, I think the result is that we can achieve a retina-friendly prototype.

Problem with Multiple Versions of Sketch Installed

Even if just Sketch Version 3.0.4 (8053) is installed and open, if I have a beta version or other older versions of sketch, the importer seems to try to boot them up and use them, and then the importer fails. If I remove the other versions from my machine and empty the trash, then reopen framer studio and reopen sketch, it seems to start working correctly again.

Usability issue: missing feedback on export

As a first time user it can be hard to know what's happening when you hit the "export to framer" button. Sketch offers a non-obstrusive way to implement messages to the toolbar. It might be a good idea to add something like "Export finished! Project located at: /xxx/my project"

Images not exported correctly

When exporting, I get the set of correctly sized images in the /images folder, but all are blank transparent pngs. It's correctly doing everything else. :-)

Include framer templates in project

Would be nice you could choose to export a project using Tisho's framer templates instead of having to manually add them from the github repo :)

Plugin doesn't work with last Sketch 3 Beta release

I just updated Sketch 3 Beta and Framer stopped working. It does nothing when selecting "Export to Framer". I tried removing and adding again the plugin files.

Just in case this takes time, is there a way to return to the previous beta?
Thanx! : )

Views not defined?

Not sure if it's the new Sketch Beta 3.0.2 or changes here but when I call layer group names in app.js they're showing up as undefined in the error console. Any tips?

support for sketch 3

I just grabbed sketch 3 and I'm trying to run the plugin and I'm getting this error in the console:

4/18/14 9:18:25.956 AM Sketch[15084]: Sketch-Scripting Error on Line 589 (/Users/jga/Library/Containers/com.bohemiancoding.sketch3/Data/Library/Application Support/com.bohemiancoding.sketch3/Plugins/Export to Framer.sketchplugin): TypeError: 'undefined' is not a function (evaluating 'filename. stringByDeletingLastPathComponent()')

Is this because I'm using the app store version?

Z-order isn't respected relative to non-imported elements

Currently, if a user imports a Sketch file with layers sketchdoc["Layer1"] and sketchdoc["Layer2"], and assigns them z: 1 and z: 10, respectively, then creates a new layer called layer3 with z:5, sketchdoc["Layer2"] will not be visible over layer3, despite having a larger z-order.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.