the-dataface / figma2html

Export Figma frames as responsive HTML and CSS
https://www.figma.com/community/plugin/1109185297790825980/figma2html
MIT License
48 stars 8 forks source link
ai2html data-journalism figma figma-plugin illustrator

figma2html in action

figma2html

Export Figma frames to responsive HTML and CSS. A Figma version of ai2html, with additional features. Created by The DataFace.

Install the plugin on Figma.

Table of Contents

Instructions

  1. Create your artwork
    • Size frames according to the desired breakpoints. (note: breakpoints are based on width and not height).
    • Name frames using the following format: #[width]px (e.g. #640px).
    • If you're using a Google Font that's built in to Figma, you'll have the option to automatically include the appropriate Google Fonts tag in your exported HTML. Otherwise, you can add your webfonts to your project yourself or include a custom script or link any custom CSS in the Page settings panel.'
  2. Run the plugin and configure your settings
    • In the plugin dialog, you can you load your preconfigured settings from a YAML text node named f2h-settings on the current page in your Figma doc, or you can write your current settings to a YAML text node.
  3. Click Export and voila, you can save your exported images and HTML file as a zipped folder.

Check out this demo Figma file if you need a reference to get started!

How it Works

Options + Features

File settings

Image settings

Page settings

Text settings

Variable Text

Variable text is supported for exportable frames (frames prefixed with #). Variables can be added in the UI under the Variables panel. All variables values are strings and can be used in any text node in your Figma file.

To use a variable, edit any desired visible text node's name to be the key (e.g. hed) in double curly brackets (e.g. {{hed}}) in a visible text node. The exported files with replace the key with the appropriate value (e.g. {{hed}} -> figma2html).

This replacement occurs on the exported files and on Figma itself everytime a key or value changes.

Contributing + Feedback

We welcome feedback, bug reports and feature requests in the form of Issues or PRs. Alternatively, comments can be left on the Figma plugin community page.

Further information on contributing can be found in CONTRIBUTING.md.

Acknowledgements

Figma2html is not possible without ai2html, created by Archie Tse at The New York Times. Figma2html sprung from the same codebase, modified in time to add additional features specific to the Figma API. The plugin was inspired by Thomas Lowry's Figma Plugin DS Svelte library.

The core team from The DataFace features Sam Vickars, Sawyer Click, and Michael Hester.

License

MIT