Skip to content

Commit

Permalink
rename mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jake-figma committed Jun 21, 2023
1 parent 4917c9f commit e9eaaaf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions styles-to-variables/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ function createTokens(tokenData) {
}
const collection = figma.variables.createVariableCollection(`Style Tokens`);
let aliasCollection;
const modeId = collection.modes[0].modeID;
const modeId = collection.modes[0].modeId;
// collection.renameMode(modeId, "Style");
console.log(tokenData);
tokenData.forEach(({ color, hex, opacity, tokens }) => {
if (tokens.length > 1) {
aliasCollection =
aliasCollection ||
figma.variables.createVariableCollection(`Style Tokens: Aliased`);
// aliasCollection.renameMode(aliasCollection.modes[0].modeID, "Style")
// aliasCollection.renameMode(aliasCollection.modes[0].modeId, "Style")
const opacityName =
opacity === 1 ? "" : ` (${Math.round(opacity * 100)}%)`;
const parentToken = figma.variables.createVariable(
`${hex.toUpperCase()}${opacityName}`,
aliasCollection.id,
"COLOR"
);
parentToken.setValueForMode(aliasCollection.modes[0].modeID, {
parentToken.setValueForMode(aliasCollection.modes[0].modeId, {
r: color.r,
g: color.g,
b: color.b,
Expand Down
4 changes: 2 additions & 2 deletions variables-import-export/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ console.clear();

function createCollection(name) {
const collection = figma.variables.createVariableCollection(name);
const modeId = collection.modes[0].modeID;
const modeId = collection.modes[0].modeId;
return { collection, modeId };
}

Expand Down Expand Up @@ -140,7 +140,7 @@ function processCollection({ name, modes, variableIds }) {
variableIds.forEach((variableId) => {
const { name, resolvedType, valuesByMode } =
figma.variables.getVariableById(variableId);
const value = valuesByMode[mode.modeID];
const value = valuesByMode[mode.modeId];
if (value !== undefined && ["COLOR", "FLOAT"].includes(resolvedType)) {
let obj = file.body;
name.split("/").forEach((groupName) => {
Expand Down

0 comments on commit e9eaaaf

Please sign in to comment.