Retain color overrides in instances of components that get updated by plugin

the plugin is fetching svgs from a webresource and updates an entire icon set with potential tweaks in the vectors on the current page

it does so by exchanging the content of each component with the corresponding key in the array we just fetched. works like a charm so far.

however, the override for color that we may or may not have in the instances of the same component is lost when I replace the content of the component.

The content of the component is structurally identical before and after the plugin ran,m
so how can I retain the overrides in the instances?

the components are expected to be used in many places using different color tokens for different states so loosing hte override is not okay.

Hi @Wolf_Boese, Thanks for reaching out. I totally understand how important it is to retain overrides.

Is this plugin from our community?

If it is, you might find it helpful to reach out directly to the plugin’s creator. You can leave your feedback in the comments section on the plugin page, or send them a message via the support email provided on the right side of the plugin page.

The plugin’s creator will then report any bugs in Figma to our support team.

I hope this information is useful. If anyone in our community has any insights to share, feel free to chime in!

Thanks,

This is a Plugin API category so it’s a question about API, not a community plugin.

@Wolf_Boese, here are two ways you can approach this:

  1. I use this approach in my plugin Master to save overrides in depending instances when swapping an instance in a main component. Find all instances, save all their contents temporarily and replace then, then use saved contents to restore overrides. This way you’ll need to go through each file where instances are used and replace them with the plugin.

  2. For saving icon colors though, there is a simpler method. You can replace the path data without affecting the color. Just need to make sure every icon is flattened into a single vector.

  3. If that’s not possible, you can make a wrapper component for your icons, putting them into a union and assigning the color to it. This way no matter the icon, the color would stay the same as the wrapper defines the color and not the icon component.

Options 2 and 3 seem feasible.

the vector data (icons) is a single path … I’ll review the script and see if i can get option 2 to work.

If not fall back to option 3.

Thanks for the tips!

1 Like