Artboard viewport preset support [Feature Request]
macintoshhelper opened this issue · 1 comments
I am...
| -------------------------------------------------------------------------------------------------
Requesting a new feature |
---|
Proposal/Feature-request:
Support passing through a custom viewport preset to artboards from React props.
Sketch has an Artboard preset feature which lets you choose from a predefined or custom viewport for an artboard. This is essential to allow scrolling in prototypes, especially for mobile prototypes.
This should be fairly straight forward, I've made the changes locally and am able to open a PR with them. Here are instructions for how I did the patch locally:
- In
src/renderers/ArtboardRenderer.js
, you can add this code to the return object (after and including...(props.viewport
):
-
return { _class: 'artboard', /* frame, props, etc here... */ hasBackgroundColor: color !== undefined, ...(props.viewport && { presetDictionary: { allowResizedMatching: 0, offersLandscapeVariant: 1, ...props.viewport } }) };
- Pass this prop to
<Artboard>
in your React app:
-
const viewport = { name: 'Android', width: 360, height: 640 }; <Artboard viewport={viewport}>
Should I go ahead and open a PR, or are there any drawbacks to my proposed method for doing this?
It sounds good! Happy to look at a PR