In my Figma project i have a color library imported that i’m getting this way.
const availableLibraryVariable = await figma.teamLibrary.getAvailableLibraryVariableCollectionsAsync();
const colorsLibrary = availableLibraryVariable.find((library) => library.name === "colors");
Then i’m getting the variables in the library collection this way:
const colorsLibraryVariables = await figma.teamLibrary.getVariablesInLibraryCollectionAsync(colorsLibrary?.key);
This is one of the library items (color).
{
“name”: “background/law-school/primary”,
“resolvedType”: “COLOR”,
“key”: “6e07ad8def7c441404abc072ced5c85bccc9fa99”
}
This is the the color variable that i’m getting this way.
const colorLibraryItem = colorsLibraryVariablesy0];
const colorVariable = await figma.variables.importVariableByKeyAsync(colorLibraryItem.key);
{
id: “VariableID:6e07ad8def7c441404abc072ced5c85bccc9fa99/710:31”
codeSyntax: Object
WEB: “background/university/primary”
description: “”
hiddenFromPublishing: true
key: “6e07ad8def7c441404abc072ced5c85bccc9fa99”
name: “background/law-school/primary”
remote: true
resolvedType: “COLOR”
scopes: Array(1)
0: “FRAME_FILL”
valuesByMode: Object
22:0: {type: ‘VARIABLE_ALIAS’, id: ‘VariableID:2057bf5ce03176e63440923236355371570c64a9/621:75’}
22:1: {type: ‘VARIABLE_ALIAS’, id: ‘VariableID:7ece16b65be5eef58b465f30cbea62bb6a0b85a5/519:3’}
variableCollectionId: “VariableCollectionId:b93b2bafcb7f84578fad5e994cf74df004d34dff/163:227”
}
The problem is that i don’t know how to use this information to change a frame fills with one of this colors of the library.
if i have to use only the name or have to get the RGB.
Thanks in advance