• Stars
    star
    3,725
  • Rank 11,846 (Top 0.3 %)
  • Language
    TypeScript
  • License
    GNU General Publi...
  • Created over 4 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generate responsive pages and apps on HTML, Tailwind, Flutter and SwiftUI.

Figma to Code

Figma to Code

Twitter

Most design to code plugins are bad, some are even paid. This project aims to raise the bar by generating responsive layouts in Tailwind, Flutter and SwiftUI. The plan is to eventually add support for Jetpack Compose and possibly standard HTML or other frameworks like React Native, Bootstrap or Fluent. Feedback, ideas and partnerships are appreciated!

Gif showing the conversion

How it works

This plugin takes an unconventional approach to improve code quality: it optimizes the layout before the conversion to code even begins. The standard Figma Nodes (what represents each layer) is a joy to work with, but it can't modify a layer without modifying the user project. For this reason, I decided to virtualize it, remaking the official implementation and naming them AltNodes. During the process of converting a Node into an AltNode, the plugin does the following:

Conversion Workflow

That process can also be seen as an Intermediate Representation and might allow this plugin to, one day, live outside Figma.

Hard cases

When finding the unknown (a Group or Frame with more than one child and no vertical or horizontal alignment), Tailwind mode uses insets for best cases and left, top from standard CSS for the worst cases. Flutter mode uses Stack and Positioned.fill. Both are usually not recommended and can easily defeat the responsiveness. In many scenarios, just wrapping some elements in a Group or Frame can solve:

Conversion Workflow

Tip: Instead of selecting the whole page, you can also select individual items. This can be useful for both debugging and componentization. For example: you can use the plugin to generate the code of a single element and then replicate it using a for-loop.

Todo

  • Vectors (tricky in HTML, unsupported in Flutter)
  • Images (they are local, how to support them?)
  • Line/Star/Polygon (todo. Rectangle and Ellipse were prioritized and are more common)
  • The source code is fully commented and there are more than 30 "todo"s there

Tailwind limitations

  • Width: Tailwind has a maximum width of 384px. If an item passes this, the width will be set to w-full (unless it is already relative like w-1/2, w-1/3, etc). This is usually a feature, but be careful: if most layers in your project are larger than 384px, the plugin's result might be less than optimal.

Flutter limits and ideas

  • Stack: in some simpler cases, a Stack could be replaced with a Container and a BoxDecoration. Discover those cases and optimize them.
  • Material Styles: text could be matched to existing Material styles (like outputting Headline6 when text size is 20).
  • Identify Buttons: the plugin could identify specific buttons and output them instead of always using Container or Material.

How to build the project

The project is configured to be built with Webpack or Rollup. The author couldn't find a way to correctly configure Svelte in Webpack, so Rollup was added. But Rollup is a lot less stable than Webpack and crashes regularly in watch mode when editing Typescript files. So, if you are going to work with Typescript only, I recommend sticking with Webpack. If you are going to make changes in the UI, you need to use Rollup for now.

Issues

The Figma file for this README and icon is also open and welcome to changes! Check it here.

I took decisions thinking about how it would benefit the majority of people, but I can (and probably will!) be wrong many times. Found a bug? Have an idea for an improvement? Feel free to add an issue or email me. Pull requests are also more than welcome.

More Repositories

1

GradleKotlinConverter

Convert from Groovy to Kotlin DSL for Gradle, focused on Android.
TypeScript
916
star
2

ChangeDetection

Automatically track websites changes on Android in background.
Kotlin
704
star
3

EmojiSlider

🀯 A slider widget rich in emoji and highly customisable.
Kotlin
600
star
4

color-studio

It is too hard to build coherent and accessible themes with the right colors. This should help.
Dart
418
star
5

SDKMonitor

App to display and monitor the targetSDK from installed apps.
Kotlin
131
star
6

CashBalancer

It is too hard to balance money across different assets and accounts.
Dart
79
star
7

RandomColorScheme

Flutter plugin to help experiment with different Color Schemes without pain.
Dart
77
star
8

ColorBlindnessFlutter

Simulate color blindness in color themes.
Dart
59
star
9

hsluv-dart

Dart port of HSLuv, a human-friendly alternative to HSL based on human experiments.
Dart
51
star
10

FastDarkTheme

Experiment with dark themes based on popular apps.
Dart
48
star
11

SafeChangeLog

Make sure your changelogs are safe in all devices.
Rust
40
star
12

CarouselGifViewer

Efficiently display a list of GIFs in a carousel (RecyclerView).
Kotlin
36
star
13

FlutterResourceRanker

Find underused colors, overused magical numbers and the largest classes in any Flutter project.
Kotlin
23
star
14

non_uniform_border

Provides a border class for Flutter that allows different widths for each side with a single color.
Dart
22
star
15

current-setup

My current terminal config, .zshrc file and brew apps list.
Shell
5
star
16

RegexLearner

A journey through the world with regular expressions. Swift Student Challenge (WWDC20) winner.
Swift
3
star
17

material-color-utilities-mojo

Dart
3
star
18

MultiModule

Temporary project
Kotlin
1
star
19

covid19-br

JavaScript
1
star
20

bernaferrari.github.io

A quick showcase of my projects (that were compiled for the web).
JavaScript
1
star