0.8.26 • Published 1 year ago

convertiv-motiv v0.8.26

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

Handoff

Handoff is a toolchain for extracting design tokens from the Figma REST API and building frontend developer documentation from that figma file.

Handoff works by extracts design foundation and component data from well formed Figma libraries, storing them as JSON, and then transforms them into design tokens. Those design tokens are published as SASS and CSS variables.

Once Handoff extracts design tokens and variables, it builds a staticly generated NextJS application that can be published to the web. This asset can be hosted on on an static webhost (nginx, s3/cloudfront, cloudflare pages etc).

This pipeline from Figma to Documentation Web app can be automated via CI/CD to provide automatic, up to date, easily readable developer documentation.

Beta Release

Handoff is currently in beta release. We want you to use it, and we think it works very well within the constraints listed below. We're working hard to harden the current feature set, and to expand the use cases.

We'd love feature ideas and bug reports, either as github issues or email to handoff@convertiv.com.

This project is sponsered and built by Convertiv

Requirements

  • Node 16
  • NPM 8

Quick Start

  • Run npx handoff-app create
  • Enter a project name at the prompt
  • Optionally enter a figma file id and developer token
    • You can leave these two blank and add them manually via a .env file, or an env variable
    • See the .env.example that is created
  • A folder will be created with the project name in the current directory
  • cd project-name
  • Edit the .env file if and provide a figma file id and developer token
  • Start the project npm run start

What Next

Ok, now that you have it running locally, what should you do next?

Publishing Package

You can publish the build static site. Use the build command baked into the generated code.

npm run build

This will fetch everything from figma, and publish a built artifact to the public directory. You can take the contents of that folder and run it on any static web host.

Running Fetch Only

If you run npm run fetch, this will fetch down and run the transformers to get all the token data from figma, but will not generate the static site. The contents of the fetch and transform will be exported to the exported directory.

  • tokens.json - A json representation of all the tokens extracted from figma
  • changelog.json - A changelog indicating changes since the last run
  • preview.json - A json representation of the iframable preview components
  • variables - A folder containing the css and sass variables for each component

Customizing Handoff

Basic Configuration

config.js contains all the basic configuration options for the site. This file is heavily commented, and strictly typed to make it easy to know what options you have. This config will let you set things like sort order and page text

Preview Templates

The templates directory contains starter code and instructions for the component previews in the static site. These templates default to Bootstrap 5 components. In this folder you can customize the component markup, the styles of the previews, and add javascript that will be executed in the preview frame.

Assets

You can customize any of the static assets published to the site. These assets are stored either in an assets file for prebuilt components (svgs) or in the public directory for things like a favicon. Simply place the asset in the directory and it will get built into the project on build.

Philosophy and Limitations

Handoff is designed to reduce the friction between design and frontend development by creating a set of developer focused tools. These tools are designed to extract data and then transform it into reusable components.

Handoff is highly opinionated. This is partially because extraction of tokens from Figma is difficult, and partially because imposing a highly opinionated structure on design produces better engineering results. Handoff comes from a belief that the foundations and components of a web application should be designed with a high degree of rigour, and then expressive designs can be built on top of that foundation. The expressive design will be better in every facet, if the foundational objects are well built.

The toolchain is designed to be fully modular, allowing you to use only the portions you need, and to extend the framework as desired. The toolchain consists of the following pieces

  • Figma REST Extractor
    • Foundations (Colors, Typogoraphy, Logos, Icons)
    • Components
  • SASS Variable Token Transformer
  • CSS Variable Token Transformer
  • Boostrap Preview generator
  • Static Site Generator

Figma Limitations

Extracting tokens reliably from Figma is difficult, and this toolchain is an ongoing and evolving project. At present, we can extract only with a fairly well structured Figma library. We have published a starter library for you to copy and clone. Using this as a baseline will ensure high quality token export.

TODO: Insert published figma file here.

Token Limitations

At present, we support the following components and structures.

  • Foundations
    • Colors
    • Typography
    • Logos (SVG)
    • Icons (SVG)
  • Components
    • Alerts
    • Buttons
    • Checkbox
    • Input
    • Modal
    • Pagination
    • Radio
    • Select
    • Switch
    • Tooltips
  • Component Groups
    • Type
    • State
    • Theme
    • Active
    • Horizontal (activation)
    • Vertical (activation)
  • General Properties (varies by component)
    • Background Color (solid)
    • Border Color (solid)
    • Border Radius (4 corners)
    • Border Width
    • Padding (left, right, top, bottom)
    • Box Shadows
    • Component text
    • Font weight
    • Font Spacing
    • Label spacing
    • Component spacing

General Limitations (things we're working on)

  • Figma naming needs to be pretty consistant with our figma starter
  • Gradient colors don't work TODO: List further limitations

Working directly with this repo

If you want to work directly with the source code, you can check this repo out directly. The code is all in typescript, and the project is broadly seperated into three parts -

  • Next JS Site generator
  • Figma Exporter and transformers
  • Supporting assets (build, installer, resources)

You must compile from typescript when you run the project. The NextJS code has automatic TS compilation, but the figma exporter must be compiled prior to each run. Here are the main commands you can run:

npm run build:lib

Builds the figma-exporter fetch source code found in figma-exporter.

npm run fetch

Fetch the latest from the figma project specified in the .env file. The user token must have access to the specified project.

npm run dev

Runs the app in the development mode.\ Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.\ You will also see any lint errors in the console.

npm run build:static

Builds the app for production to the out folder.\ It correctly bundles React in production mode and optimizes the build for the best performance. The build is minified and the filenames include the hashes. Your app is ready to be deployed!

0.8.23

1 year ago

0.8.22

1 year ago

0.8.25

1 year ago

0.8.24

1 year ago

0.8.20

1 year ago

0.8.26

1 year ago

0.8.19

1 year ago

0.8.16

1 year ago

0.8.15

1 year ago

0.8.18

1 year ago

0.8.17

1 year ago

0.8.9

1 year ago

0.8.8

1 year ago

0.8.5

1 year ago

0.8.7

1 year ago

0.8.6

1 year ago

0.8.1

1 year ago

0.8.0

1 year ago

0.8.3

1 year ago

0.8.2

1 year ago

0.8.12

1 year ago

0.8.11

1 year ago

0.8.14

1 year ago

0.8.13

1 year ago

0.8.10

1 year ago

0.7.19

1 year ago

0.7.11

1 year ago

0.7.10

1 year ago

0.7.13

1 year ago

0.7.12

1 year ago

0.7.18

1 year ago

0.7.15

1 year ago

0.7.14

1 year ago

0.7.17

1 year ago

0.7.16

1 year ago

0.7.2

1 year ago

0.7.1

1 year ago

0.7.4

1 year ago

0.7.3

1 year ago

0.7.9

1 year ago

0.7.6

1 year ago

0.7.5

1 year ago

0.7.8

1 year ago

0.7.7

1 year ago

0.5.0-0

1 year ago

0.3.0-0

1 year ago

0.6.0-0

1 year ago

0.2.0-0

1 year ago

0.4.0-0

1 year ago

0.5.1

1 year ago

0.1.0-0

2 years ago

0.0.91

2 years ago

0.0.84

2 years ago

0.0.85

2 years ago

0.0.86

2 years ago

0.0.88

2 years ago

0.0.89

2 years ago

0.0.80

2 years ago

0.0.81

2 years ago

0.0.82

2 years ago

0.0.83

2 years ago

0.0.78

2 years ago

0.0.79

2 years ago

0.0.90

2 years ago

0.0.77

2 years ago

0.0.76

2 years ago

0.0.75

2 years ago

0.0.74

2 years ago

0.0.73

2 years ago

0.0.72

2 years ago

0.0.71

2 years ago

0.0.70

2 years ago

0.0.69

2 years ago

0.0.68

2 years ago

0.0.67

2 years ago

0.0.66

2 years ago

0.0.65

2 years ago

0.0.64

2 years ago

0.0.63

2 years ago

0.0.62

2 years ago

0.0.61

2 years ago

0.0.60

2 years ago

0.0.59

2 years ago

0.0.58

2 years ago

0.0.57

2 years ago

0.0.56

2 years ago

0.0.55

2 years ago

0.0.54

2 years ago

0.0.53

2 years ago

0.0.52

2 years ago

0.0.51

2 years ago

0.0.50

2 years ago

0.0.48

2 years ago

0.0.47

2 years ago

0.0.46

2 years ago

0.0.45

2 years ago

0.0.44

2 years ago

0.0.43

2 years ago

0.0.41

2 years ago

0.0.40

2 years ago

0.0.39

2 years ago

0.0.38

2 years ago

0.0.37

2 years ago

0.0.36

2 years ago

0.0.35

2 years ago

0.0.34

2 years ago

0.0.33

2 years ago

0.0.32

2 years ago

0.0.31

2 years ago

0.0.30

2 years ago

0.0.29

2 years ago

0.0.28

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago