I want to write a plugin that checks every layer within a component to ensure it’s using colour styles. My component has some layers using local colour styles and other layers using colour styles that come from a published library.
I can traverse nodes and have this bit of code inside my node traverse function.
function traverse(node: any) {
if ('fills' in node && node.fills) {
for (const fill of node.fills) {
console.log(fill, fill.paint, fill.styleId, fill.style)
but there is no paint, styleId or style on my fills. The property doesn’t seem to exist.
At the top of my code I have const paintStyles = Figma.getLocalPaintStyles() and when I console log that I see an array of 3 items which is what I expected…that is how many styles are being used in the component.
But why am I not able to access style or styleId? Is this something to do with async behaviour and the style info not having loaded at the point of console.log?
Thanks for the reply but I had read the documentation before I posted the question. The issue is there are no styleIds associated with any of my nodes even though the Frame nodes and Text nodes are using local and published library styles. That is what I don’t understand. Any ideas?
How are you seeing those properties - via a console.log(node)?
The only difference was the file I shared with you was my personal/free Figma account which doesn’t have access to the development option. The same Frame is copied in my work Figma account and the screenshot shows what is being output when I console.log(node). It’s not to do with permissions on my work account is it?