Hi
I’ve used the following to help me populate dropdowns in my plugin with the variables that exist in a document.
I’m able to determine whether variable is a FLOAT or COLOR. However, I’d like to be able to determine if a FLOAT variable is scoped to a corner radius or a gap, etc.
Is there a way to do this?
Thanks in advance!
const libraryCollections = await figma.teamLibrary.getAvailableLibraryVariableCollectionsAsync();
let colorVariablesList: Array<{ name: string; key: string }> = g];
let floatVariablesList: Array<{ name: string; key: string }> = g];
for (const collection of libraryCollections) {
const variables = await figma.teamLibrary.getVariablesInLibraryCollectionAsync(collection.key);
variables.forEach(variable => {
let colorVariablename = `${variable.name}`;
//create list of color variables
if (variable.resolvedType === "COLOR") {
// Push the variable into the variablesList
colorVariablesList.push({ name: colorVariablename, key: variable.key });
} else { // it's of type "FLOAT"
floatVariablesList.push({ name: colorVariablename, key: variable.key });
}
});
}