Skip to content

Commit

Permalink
Merge pull request #6 from mikeozornin/master
Browse files Browse the repository at this point in the history
Add option to get icons as root frames from page
  • Loading branch information
tsimenis authored Jun 3, 2021
2 parents fcf184b + 683eb5b commit eec8b6f
Show file tree
Hide file tree
Showing 4 changed files with 333 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ node_modules
.env

#figma-export-icons
icons-config.json
icons-config.json
images
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"iconsPath": "assets/svg/icons"
}
```
Update: from > v1.3.0 you can set the frame to -1 and it will fetch the icons from the whole page.


## Features

Expand Down
15 changes: 10 additions & 5 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,17 @@ function getFigmaFile () {
console.log(chalk.red.bold('Cannot find Icons Page, check your settings'))
return
}
if (!page.children.find(c => c.name === config.frame)) {
console.log(chalk.red.bold('Cannot find Icons Frame in this Page, check your settings'))
return
const shouldGetFrame = isNaN(config.frame) && parseInt(config.frame) !== -1
let iconsArray = page.children
if (shouldGetFrame) {
if (!page.children.find(c => c.name === config.frame)) {
console.log(chalk.red.bold('Cannot find Icons Frame in this Page, check your settings'))
return
}
iconsArray = iconsArray.find(c => c.name === config.frame).children
}
let icons = page.children.find(c => c.name === config.frame).children.map((icon) => {
return {id: icon.id, name: icon.name}
let icons = iconsArray.map((icon) => {
return { id: icon.id, name: icon.name }
})
icons = findDuplicates('name', icons)
resolve(icons)
Expand Down
320 changes: 319 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eec8b6f

Please sign in to comment.