-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
Used updates from #2, and cherry-picked them over to code.ts file. Notification and logic improved, with contextual notification wording. Thank you very much! Co-Authored-By: Yury Zeliankouski <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
let successCount = 0, | ||
layerCount = figma.currentPage.selection.length; | ||
|
||
let successCount = 0, layerCount = figma.currentPage.selection.length; | ||
if (layerCount === 0) { | ||
figma.closePlugin("Select at least one Text Layer") | ||
figma.closePlugin("Select at least one Text Layer"); | ||
} | ||
|
||
figma.currentPage.selection.forEach(node => { | ||
if (node.type === "TEXT") { | ||
node.name = ""; | ||
successCount++ | ||
} | ||
else { | ||
figma.notify('For "' + node.name + '" the name is not reset. Select the Text Layer.') | ||
} | ||
}) | ||
|
||
if (layerCount >= 1 && successCount >= 1) { | ||
figma.notify(successCount + " Text Layer names reset ✅", { timeout: 2000 }) | ||
if (node.type === "TEXT") { | ||
node.name = ""; | ||
successCount++; | ||
} | ||
else { | ||
figma.notify('⚠️ "' + node.name + '" name was not reset. A text layer must be selected.', { timeout: 4000 }); | ||
} | ||
}); | ||
if (layerCount > 1 && successCount > 1) { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
figma.notify("✅ " + successCount + " text layer names reset", { timeout: 2000 }); | ||
} | ||
else if (layerCount == 1 && successCount == 1) { | ||
This comment has been minimized.
Sorry, something went wrong.
tank666
Author
Contributor
|
||
figma.notify("✅ Text layer name reset", { timeout: 2000 }); | ||
} | ||
|
||
figma.closePlugin(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
let layerCount = (figma.currentPage.selection.length) | ||
|
||
let successCount = 0, | ||
layerCount = figma.currentPage.selection.length; | ||
if (layerCount === 0) { | ||
figma.closePlugin("Select at least one Text Layer") | ||
} | ||
figma.currentPage.selection.forEach(node => { | ||
if (node.type == 'TEXT') { | ||
if (node.type === "TEXT") { | ||
node.name = ""; | ||
figma.closePlugin(layerCount + " Text layer names reset ✅"); | ||
return | ||
successCount++ | ||
} | ||
|
||
else { | ||
figma.notify("That's not a Text layer silly!", { timeout: 2000 }); | ||
figma.closePlugin(); | ||
figma.notify('⚠️ "' + node.name + '" name was not reset. A text layer must be selected.', | ||
{ timeout: 4000 }) | ||
} | ||
}) | ||
}) | ||
if (layerCount > 1 && successCount > 1) { | ||
figma.notify("✅ " + successCount + " text layer names reset", { timeout: 2000 }) | ||
} | ||
else if (layerCount == 1 && successCount == 1) { | ||
figma.notify("✅ Text layer name reset", { timeout: 2000 }) | ||
} | ||
|
||
figma.closePlugin(); |
You can also delete layerCount here. This will remain
if (successCount > 1) {…}
.