Git Product home page Git Product logo

figma-plugin-raw-json-exporter's Introduction

Raw Json Exporter

Exports figma data as a single json document with as much as possible of the internal figma data structure left as-is. The purpose of this plugin is act as a data dump for further processing externally.

Designed (but not limited) to be used with https://github.com/kasper573/figma-to-typescript.

All values will be discriminated into the following typescript signature based on its type:

type DiscriminatedValue =
  | { type: "alias"; id: string }
  | { type: "boolean"; value: boolean }
  | { type: "string"; value: string }
  | { type: "number"; value: number }
  | { type: "rgba", r: number, g: number, b: number, a: number }
  | { type: "rgb" r: number, g: number, b: number };

All variable bound values (aliases) will be of the alias type mentioned above. You can use the id and variables list to look up the aliased value.

Here's an example json dump:

{
  "variables": [
    {
      "id": "VariableID:5:14",
      "name": "Color/Blue/50",
      "collection": "Reference",
      "valuesByMode": {
        "Mode 1": {
          "type": "rgba",
          "r": 0.9607843160629272,
          "g": 0.9803921580314636,
          "b": 0.9960784316062927,
          "a": 1
        }
      }
    },
    {
      "id": "VariableID:5:76",
      "name": "Color/Primary/Base/Light",
      "collection": "Theme",
      "valuesByMode": {
        "Light": { "type": "alias", "id": "VariableID:5:20" },
        "Dark": { "type": "alias", "id": "VariableID:5:18" }
      }
    }
  ],
  "textStyles": [
    {
      "remote": false,
      "description": "",
      "name": "Caption",
      "textCase": "ORIGINAL",
      "hangingList": false,
      "hangingPunctuation": false,
      "listSpacing": 0,
      "paragraphSpacing": 0,
      "paragraphIndent": 0,
      "leadingTrim": "NONE",
      "lineHeight": { "type": "alias", "id": "VariableID:5:181" },
      "textDecoration": "NONE",
      "fontSize": { "type": "alias", "id": "VariableID:5:181" },
      "type": "TEXT",
      "fontName": { "family": "Lato", "style": "Light" },
      "letterSpacing": { "unit": "PERCENT", "value": 0 },
      "fontFamily": { "type": "alias", "id": "VariableID:5:177" },
      "fontStyle": { "type": "alias", "id": "VariableID:5:180" }
    }
  ],
  "effectStyles": [
    {
      "name": "Shadow/Thin",
      "effects": [
        {
          "showShadowBehindNode": false,
          "blendMode": "NORMAL",
          "visible": true,
          "spread": 0,
          "radius": { "type": "alias", "id": "VariableID:6:307" },
          "type": "DROP_SHADOW",
          "color": { "type": "alias", "id": "VariableID:5:167" },
          "offset": { "x": 0, "y": 4 },
          "offsetY": { "type": "alias", "id": "VariableID:6:307" }
        }
      ]
    }
  ],
  "paintStyles": [
    {
      "name": "Test color",
      "paints": [
        {
          "gradientTransform": [
            [6.123234262925839e-17, 1, 0],
            [-1, 6.123234262925839e-17, 1]
          ],
          "type": "GRADIENT_LINEAR",
          "blendMode": "NORMAL",
          "opacity": 1,
          "visible": true,
          "gradientStops": [{}, {}]
        }
      ]
    }
  ],
  "gridStyles": [
    {
      "name": "Test grid",
      "grids": [
        {
          "pattern": "GRID",
          "sectionSize": { "type": "alias", "id": "VariableID:6:306" },
          "visible": true
        },
        { "pattern": "GRID", "sectionSize": 10, "visible": true }
      ]
    }
  ]
}

figma-plugin-raw-json-exporter's People

Contributors

kasper573 avatar

Stargazers

Lars Törner avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.