GithubHelp home page GithubHelp logo

macintoshhelper / react-xd Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 2.0 1.33 MB

Render React components to Adobe XD. Build design systems and libraries from your code.

License: MIT License

JavaScript 100.00%
react-renderer react adobe-xd adobe-xd-plugin xd-plugin

react-xd's Introduction

React XD

Render React components to Adobe XD. This can be used for React cross-platform UI libraries and for creating design systems. The (incomplete) API is based off React Native/react-primitives

This is a proof of concept for testing and feedback purposes. Please do not use in production systems.

npm npm

Inspired by react-sketchapp

Screenshot Preview

Getting Started

Requirements

Dependency Installation

Please refer to examples/colors for reference.

  1. Initialise a repository or folder
mkdir design-system && cd $_
npm init -y
  1. npm install your developer dependencies
npm install --save-dev @adobe/xdpm @babel/cli @babel/core @babel/plugin-proposal-class-properties @babel/preset-env @babel/preset-flow @babel/preset-react babel-loader webpack webpack-cli
  1. Install react-xd and the required external dependencies
npm install --save react-xd [email protected]

Code Setup

  1. Refer to examples/colors for the webpack setup. You need a manifest.json and main.js entry point for the Adobe XD plugin. You need a build system such as webpack to compile the jsx with Babel into main.js

src/main.js example:

import { render, Document, View, Text } from 'react-xd';

const App = () => (
  <Document>
    <Artboard
      name="Artboard"
      style={{
        height: 640,
        width: 360,
        flexDirection: 'row',
      }}
    >
      <View
        style={{
          width: 360,
          height: 100,
          backgroundColor: 'purple',
          justifyContent: 'center',
          alignItems: 'center',
        }}
      >
        <Text style={{ color: 'white' }}>
          Hello World!!!
        </Text>
      </View>
    </Artboard>
  </Document>
);

function renderToXd(selection, documentRoot) {
  documentRoot.removeAllChildren(); // Resets document

  return render(<App />, { selection, documentRoot });
}


export const commands = {
  render: renderToXd,
  test: () => {}, // Hack to make XD show a menu with the render option instead of a single button
};

Credit

  • react-sketchapp โ€“ inspired this project, and some bits of code are borrowed from it.
    • MIT License
    • Copyright (c) 2018 Airbnb

Contributing

Please post an issue offering any feedback or help! Thanks!

react-xd's People

Contributors

dependabot[bot] avatar macintoshhelper avatar

Stargazers

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

Watchers

 avatar  avatar

Forkers

drewcovi kziemski

react-xd's Issues

React XD | Feature Roadmap [WIP]

This is currently a proof of concept project. It can be used for some simple features, but has a lot of work to be done to make it useful as a React Primitives/React Native app target.

A maintainable CSS to Adobe XD API abstraction layer is needed, and a better layout solution. yoga-layout will not run in Adobe XD's JavaScript execution environment due to nbind's use of eval issue, so I have resorted to using the unmaintained css-layout library for now.

There are some issues with Text flexbox layout.

TODO (WIP issue)...

React Reconciler architecture discussion

A more scalable way of architecting this project could be to use react-reconciler to build a JSON tree, which is then passed through to a walk function which renders to XD outside of the React cycle.

The JSON tree generation could even be parallelised in a separate process to speed up rendering, and would then allow for using yoga-layout, etc.

Group nesting not working

This is more an issue with Adobe XD, but group nesting is broken. This is blocking development on the View component system, which is an integral part of this repo.

The Adobe XD scenegraph doesn't let you create a new group with children, but requires you to add the children to the document root, select them with commands, then create a group, but this doesn't appear to work when one of the children is a group.

I'd love to know if this is just a limitation in the Adobe XD platform API, or if there is a way around this.

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.