Skip to content

Types used in importFromFigma()

This article is part of importFromFigma() documentation.

FigmaImportResult

On success, importFromFigma() returns FigmaImportResult object, which has the following properties:

  • name, string. Document name.
  • version, string. Document version.
  • lastModified, string. Time of last modification as string. You can pass it to ifModifiedSince to check if document has been modified since last parse.
  • iconSet, IconSet. Icon set instance.
  • nodesCount, number. Number of icons that were found (that iconNameForNode marked as icons).
  • generatedIconsCount, number. Number of icons that Figma API generated. If not identical to nodesCount, some layers were marked as icons incorrectly.
  • downloadedIconsCount, number. Number of icons that were downloaded. If not identical to generatedIconsCount, there were some errors, most likely caused by bad internet connection.
  • missing, FigmaIconNode. List of icons that were not retrieved. See below.

FigmaIconNode

Type FigmaIconNode is used in callback and in missing property of FigmaImportResult.

It represents one icon and has the following properties:

  • id, string. Node ID in Figma document.
  • name, string. Node name.
  • keyword, string. Keyword for icon, returned by iconNameForNode callback.

On various stages of parsing icons, the following properties are added to object:

  • url, string. URL of generated image. If missing, Figma API could not export icon.
  • content, string. Icon content, downloaded from url. If missing, import function could not retrieve exported icon data.

FigmaImportNodeData

Type FigmaImportNodeData is used in first parameter for iconNameForNode callback.

It is a simple object with the following properties:

  • id, string. Node id.
  • type, string. Node type: "FRAME", "COMPONENT" or "INSTANCE".
  • name, string. Node name.
  • width and height, number. Dimensions of node.
  • parents, FigmaParentNodeData[]. List of parent nodes (first item is page, last item is parent node of icon).

Example of node data passed to callback:

json{
   "id": "12:724",
   "type": "FRAME",
   "name": "arrow-down",
   "width": 32,
   "height": 32,
   "parents": [
       { "id": "0:1", "type": "CANVAS", "name": "Icons" },
       { "id": "12:479", "type": "FRAME", "name": "Regular" }
   ]
}

FigmaParentNodeData

Type FigmaParentNodeData is used in FigmaImportNodeData and in first parameter for filterParentNode callback.

It is a simple object with the following properties:

  • id, string. Node id.
  • type, string. Node type: "CANVAS", "FRAME" or "GROUP".
  • name, string. Node name.

Examples:

json{
   "id": "0:1",
   "type": "CANVAS",
   "name": "Icons"
}
json{
   "id": "12:479",
   "type": "FRAME",
   "name": "Regular"
}

Released under the Apache 2.0 License.