3.0.0-rc.49 • Published 11 months ago

@opendesign/octopus-fig v3.0.0-rc.49

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
11 months ago

Octopus Converter for Figma

Figma HTTP API format to Octopus 3 converter.

Install

yarn add @opendesign/octopus-fig

.env variables

If missing .env file, make a copy of .env.example and rename it to .env and fill correct info.

VariableTypeDescription
NODE_ENVproduction / development / debugNode environment
LOG_LEVELfatal / error / warn / info / debug / trace / silentLog level

Usage

There are three main processing steps:

  • reading source data (using readers)
  • conversion (using converter with EventEmitter instance produced by reader)
  • exporting (using exporters)

Readers used in other Octopus converters return SourceDesign instance, which, actually, is object with static values inside. In case of Figma, we have slightly different approach because of it's asynchronous origin (requesting values using HTTP). So, to provide source data as fast as possible to the converter we use EventEmitter inside of Figma Reader's SourceDesign instance. This makes it possible to process data almost as fast as it's downloaded from Figma's API.

Although you can define the way of reading assets or exporting results yourself (create your own reader/exporter class), you can also choose between existing ones:

Check examples/node/convert-api-local.ts for example usage in automated runs.

Check examples/node/convert-api-debug.ts for example usage in custom manual runs.

Check examples/web/ for more details about usage in web browser.

Check src/services/exporters/ for more details about exporters.

Check src/services/readers/ for more details about readers


Demo: Example Node

Converts your Figma designs from API into Octopus3+ format. Before you start you need to add your Figma API token into .env file. Then you need to find FIGMA_DESIGN_HASH for the design you want to convert. You can find it in the URL of the design: https://www.figma.com/file/__HERE__/...

.env demo variables

ENV variables for our demo scripts located in /examples/node/*

VariableTypeDescription
API_TOKENstringFigma API token
SHOULD_RENDERbooleanif true will trigger ODE rendering when octopus3.json is ready
ODE_RENDERER_CMDstringpath to ODE renderer command (e.g. ode-renderer-cli)
ODE_IGNORE_VALIDATIONbooleanignores the ODE rendering validation
FONTS_PATHstringpath to directory with fonts

yarn convert:debug

Designed for manual runs.

yarn
yarn convert:debug FIGMA_DESIGN_HASH

yarn convert:local

Designed for running in automated runs.

yarn
yarn convert:local FIGMA_DESIGN_HASH

Demo: Example Web

Run yarn bundle and then open examples/web/index.html in live server Look for Result: in console output.


TypeDoc

Command yarn typedoc will generate TypeDoc documentation for public Classes into ./docs folder


Tests

yarn test

Runs Unit & Integration tests.

Unit Tests

yarn test:unit

Runs Unit tests using jest framework.

Integration Tests

yarn test:integration

Runs Integration tests using our custom framework. Tries to convert octopus components + manifest for saved designs and compares them using jsondiffpatch with saved expected output.

3.0.0-rc.46

11 months ago

3.0.0-rc.45

12 months ago

3.0.0-rc.48

11 months ago

3.0.0-rc.47

11 months ago

3.0.0-rc.49

11 months ago

3.0.0-rc.44

12 months ago

3.0.0-rc.43

12 months ago

3.0.0-rc.37

1 year ago

3.0.0-rc.39

1 year ago

3.0.0-rc.38

1 year ago

3.0.0-rc.40

1 year ago

3.0.0-rc.42

1 year ago

3.0.0-rc.41

1 year ago

3.0.0-rc.32-umd

1 year ago

3.0.0-rc.26

1 year ago

3.0.0-rc.25

1 year ago

3.0.0-rc.28

1 year ago

3.0.0-rc.27

1 year ago

3.0.0-rc.29

1 year ago

3.0.0-rc.35

1 year ago

3.0.0-rc.36

1 year ago

3.0.0-rc.31

1 year ago

3.0.0-rc.30

1 year ago

3.0.0-rc.33

1 year ago

3.0.0-rc.32

1 year ago

3.0.0-rc.24

1 year ago

3.0.0-rc.23

1 year ago

3.0.0-rc.19

2 years ago

3.0.0-rc.20

2 years ago

3.0.0-rc.22

1 year ago

3.0.0-rc.21

2 years ago

3.0.0-rc.18

2 years ago

3.0.0-rc.17

2 years ago

3.0.0-rc.16

2 years ago

3.0.0-rc.15

2 years ago