question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose the component ID in the ComponentExtras

See original GitHub issue

Currently the function getBasename in the output-components-as-svg module uses only the basename value to generate the file name in output:

https://github.com/marcomontalbano/figma-export/blob/9ac8278779265299e6101ce83717a9ee3b8b75a6/packages/output-components-as-svg/src/index.ts#L16

But if the icons are variants, there may be cases in which two different variants have the same name (because of how Figma assigns the name to the variants). For example, we have a set of icons as component sets, where each one of them has two sizes, (each one is a component, with two variants, and a property with two values sm and md assigned to each one of them).

When we export the icons, even if the icons’ (parent) component set have different names, the variants all have name Size=sm or Size=md so each icon exported overrides the previous one, and we end up with only two files (one called Size=sm.svg` and the other Size=md.svg`.

What I propose here is to expose also the ID of the component (which we know is unique) so that a consumer of the library can create their own unique basename and use the getBasename function (passed to the outputComponentsAsSvg outputter) to override the default behaviour, eg.

getBasename: (options): string => `${options.id}__${options.basename}.svg`

The way in which we can expose it is to add an id key to ComponentExtras type, and then in the getComponents method add the id value to the figmaExport object.

I’ll submit a PR for this small change.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
amcolashcommented, Sep 15, 2021

Sure thing, makes sense. I did take that route and it is working beautifully - I do love the figma API! Thanks again for the module and appreciate your suggestions.

1reaction
didoocommented, Sep 15, 2021

Personally I don’t think we should add too much to the object, apart from the ID. And this is my thinking: with the ID, essentially you can do whatever you want, using the REST APIs. So there’re no need to introduce other meta-data (everyone may have a different need, and in no time the metadata object would become uber-complex).

My suggestion (and that’s what I did on my side) is to use the REST APIs to build an object with all the metadata you need, and then when exporting the assets via Figma-Export use the specific metadata for that component ID for whatever is your need. You can see what I did here: https://github.com/hashicorp/flight/blob/85ea7fc6f22ae675a6d4d54b71adef8454c27135/flight-icons/scripts/sync.ts#L47-L53

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to find component ID? - Jira - Atlassian Community
I have a solution that uses only the UI: Add or remove the component from an already existing issue, then check the issue's...
Read more >
Windchill PDMLink : What are the "Component ID&quot
Windchill PDMLink : What are the "Component ID" and the related "Part ID" and "Part ID Path" System Properties exposed in Creo View?...
Read more >
Expose Component Attributes in Experience Builder
You use a design resource to control which attributes are exposed in Experience Builder. A design resource lives in the same folder as...
Read more >
Use a valid component Id in a view Id error when assigning ...
I have added a rich text component in Experience builder (Community) and i am trying to assign an audience to this newly added...
Read more >
Work with components - Product Documentation | ServiceNow
A component ID is automatically created and is based on the component label when you add a component to a page. You can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found