Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using stylesync for code generation and Sketch interoperability #24

Closed
dylanslewis opened this issue Nov 27, 2017 · 2 comments
Closed

Comments

@dylanslewis
Copy link

The problem

A key planned feature of Lona is the ability to generate styling code for multiple platforms and languages, including React Native and Swift. From my understanding of the plans, there are a few issues with the suggested approach:

  • offering a single style of generated code for a platform makes Lona difficult to customise for any project that has specific requirements for their styling code, e.g. accessibility considerations;
  • if a component's name is changed in the Lona project, and therefore the generated code, all references to the component in the generated code's project will need to be manually updated;
  • if a style is removed from the Lona project, and therefore the generated code, it will need to be manually re-added to the generated file to ensure the code project can still compile.

stylesync

stylesync is an open source Swift command line tool and library that is currently able to extract text and colour styles from a Sketch file, and export to code for any language or platform through the use of templates. It is intended to sit on a CI and a generate a Pull Request with updated styling code in response to design system changes; it also handles any style reference updates or deprecations that are needed to keep the project compiling.

The near future planned updates to stylesync include:

Proposal

Since stylesync already exists as a Swift tool and library that inputs design system components and outputs code, I believe it would be a good candidate for handling code generation on Lona. The app could still offer default generated file styles, for languages such as React Native and Swift, but would also allow the user to have complete control over the generated files for their project.

Whilst stylesync is not intended to handle the generation of view hierarchy code, it could be used to export shared styles to Sketch. Furthermore, since stylesync already has a good parser for Sketch files, once it can export to Lona .component files, it could be used for importing styles from Sketch to Lona.

Questions

  • What are the bounds of Lona’s responsibility? Whilst generating one-off style code could be useful for prototyping, it doesn't help to manage a large project due to the aforementioned reasons. Should it update a project based on changes in the design system, or should that be left to stylesync on a CI?
  • Do you have specifications for the .component and expected generated files? If so, I can set stylesync up to make some demo exports to have a look at.

@dabbott I really love the look of Lona as an app and have noticed a similarity between the features both our projects have, or plan, to offer. If you agree that stylesync could be a good fit for certain features, I'd love to get more involved and prioritise the development of stylesync's features to better foster collaboration. I'm also happy to answer and questions or concerns you may have.

@dabbott
Copy link
Member

dabbott commented Nov 28, 2017

I think the problems you describe are accurate. Can you explain how stylesync solves each of them?

What are the bounds of Lona’s responsibility?

Code generation will be part of CI. Lona Studio will eventually support simple git operations, e.g. pull requests, for making changes to the design system. After changes are merged, Lona Compiler will be responsible for generating code on CI. This could delegate to stylesync for outputting style code.

Do you have specifications for the .component and expected generated files?

The docs are pretty incomplete and some of the stuff isn't 100% accurate, but here's my start of a spec: https://github.com/airbnb/Lona/blob/master/docs/file-formats/README.md. I don't have any generated files in the public repo yet... but coming shortly! I'm updating the compiler this week.

@dylanslewis
Copy link
Author

As discussed, whilst stylesync does solve the problems described, the focus for Lona right now is not related to custom code exports or project maintenance. Will close this for now

Sent with GitHawk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants