Giter VIP home page Giter VIP logo

component-inspector's Introduction

Component Inspector

A Figma plugin for inspecting Figma components.

This plugin provides a look at Figma component properties similar to how they are described in code. This plugin does not generate style code. It generates code that describes component properties.

Currently supporting instance and component code generation for:

  • React function components
  • Angular components
  • Vue components (both option and composition APIs)
  • Web components

As well as:

  • JSON

Would love to hear from you about what works and what doesn't.

Conventions / Pro Tips

Slots

Currently, this plugin supports tag-named slots. Add the --SLOT[tagname] suffix to the name of a text component property in Figma and it will generate a slot for that attribute. For example, if you create a component with a text property named "heading--SLOT[h2]", it would generate the following React instance and definition code:

<Component heading={<h2>My slot content</h2>} />
const Component: FC<{
  heading: ReactNode;
}> = ({ heading }) => <>{heading}</>;

The tagname will default to span if you use the suffix --SLOT without a tagname.

If your Figma component has a single text property, it will be treated as a generic slot.

This can be configured by running the Component Inspector > Configuration command.

Boolean visibility

If you have a boolean Figma component property that controls visibility of a text or instance swap property (or one of their ancestors), that boolean property will be ignored in generated code and the text or instance swap property will disappear when the boolean is false.

"undefined" variant options and instance swaps

If you have a variant option property that defaults to the string "undefined", that property will be treated as truly optional (no default).

If you have an instance swap property that defaults to a component named "undefined", that property will be treated as truly optional (no default).

This can be configured by running the Component Inspector > Configuration command.

Ignored property prefix

You can configure the component inspector to ignore properties named with a provided prefix.

This can be configured by running the Component Inspector > Configuration command.

Numeric variant options

If your variant options are all numeric or if the default value for a text property is numeric, the generated code will treat it like a number type property.

component-inspector's People

Contributors

jake-figma 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.