Skip to content

Commit

Permalink
feat: p2 alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
bart-krakowski committed Jun 14, 2021
1 parent 0e25f0d commit 31211fd
Show file tree
Hide file tree
Showing 9 changed files with 624 additions and 136 deletions.
Binary file modified .DS_Store
Binary file not shown.
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"rules": {
"max-params": ["off"],
"complexity": ["off"],
"react/jsx-boolean-value": ["error", "always"],
"prefer-destructuring": [
"error",
{
Expand Down
Binary file modified packages/.DS_Store
Binary file not shown.
89 changes: 28 additions & 61 deletions packages/p1/code.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,32 @@
const __awaiter =
(this && this.__awaiter) ||
function (thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P
? value
: new P(function (resolve) {
resolve(value)
})
}

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value))
} catch (e) {
reject(e)
}
}

function rejected(value) {
try {
step(generator.throw(value))
} catch (e) {
reject(e)
}
}

function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected)
}

step((generator = generator.apply(thisArg, _arguments || [])).next())
})
}

function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
function traverse(node) {
return __awaiter(this, void 0, void 0, function* () {
if ('children' in node) {
if (node.type !== 'INSTANCE') {
for (const child of node.children) {
traverse(child)
return __awaiter(this, void 0, void 0, function* () {
if ('children' in node) {
if (node.type !== 'INSTANCE') {
for (const child of node.children) {
traverse(child);
}
}
else if (node.name === '_Specification') {
const spaceComp = node.children.find((element) => /^(size|space)\/(width|height)/.test(element.name));
const textNode = node.children.find((element) => element.type === 'TEXT');
const valueToDisplay = /^(size|space)\/(width)/.test(spaceComp.name) ? spaceComp === null || spaceComp === void 0 ? void 0 : spaceComp.width : spaceComp === null || spaceComp === void 0 ? void 0 : spaceComp.height;
const textToDisplay = String(`${valueToDisplay}px`);
const len = textNode.characters.length;
yield figma.loadFontAsync(textNode.getRangeFontName(0, 1));
textNode.deleteCharacters(0, len);
textNode.insertCharacters(0, textToDisplay);
}
}
} else if (node.name === '_Specification') {
const spaceComp = node.children.find((element) => /^(size|space)\/(width|height)/.test(element.name))
const textNode = node.children.find((element) => element.type === 'TEXT')
const valueToDisplay = /^(size|space)\/(width)/.test(spaceComp.name)
? spaceComp === null || spaceComp === void 0
? void 0
: spaceComp.width
: spaceComp === null || spaceComp === void 0
? void 0
: spaceComp.height
const textToDisplay = String(`${valueToDisplay}px`)
const len = textNode.characters.length
yield figma.loadFontAsync(textNode.getRangeFontName(0, 1))
textNode.deleteCharacters(0, len)
textNode.insertCharacters(0, textToDisplay)
}
}
})
});
}

traverse(figma.root)
figma.closePlugin()
traverse(figma.root);
figma.closePlugin();
Binary file modified packages/p2/.DS_Store
Binary file not shown.
Loading

0 comments on commit 31211fd

Please sign in to comment.