Skip to content

Commit

Permalink
feat: add the ability to generate theme from elements with specific p…
Browse files Browse the repository at this point in the history
…refix
  • Loading branch information
aliceinapple committed Jun 13, 2024
1 parent 3afa7f2 commit 61299b9
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 23 deletions.
38 changes: 20 additions & 18 deletions .pnp.cjs

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

9 changes: 8 additions & 1 deletion theme/theme-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ logger.heading = 'figma-theme' as string
value.split(',').map((page) => page.replace('-', ':')))
.option('--included-pages <includedPages>', 'Included pages', (value) =>
value.split(',').map((page) => page.replace('-', ':')))
.option('--prefix <prefix>', 'Prefix for components')
.arguments('<fileId>')
.parse(process.argv)

Expand All @@ -34,7 +35,13 @@ if (!fileId) {
// eslint-disable-next-line dot-notation
process.env['FIGMA_TOKEN'] = id
readline.close()
run(fileId, (program as any).output, options.ignoredPages, options.includedPages)
run(
fileId,
(program as any).output,
options.ignoredPages,
options.includedPages,
options.prefix
)
.then(() => logger.info('Theme successful generated'))
.catch((error) => logger.error(error.message))
})
Expand Down
4 changes: 2 additions & 2 deletions theme/theme-cli/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { FileResponse } from 'figma-js'
import { FigmaFileLoader } from '@atls/figma-file-loader'
import { FigmaTheme } from '@atls/figma-theme'

export const run = async (fileId, output, ignoredPages, includedPages) => {
export const run = async (fileId, output, ignoredPages, includedPages, prefix) => {
const loader = new FigmaFileLoader()

const file: FileResponse = await loader.load(fileId)

const theme = new FigmaTheme(file, output, ignoredPages, includedPages)
const theme = new FigmaTheme(file, output, ignoredPages, includedPages, prefix)

await theme.generate()
}
1 change: 1 addition & 0 deletions theme/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@atls/figma-theme-line-heights-generator": "workspace:*",
"@atls/figma-theme-radii-generator": "workspace:*",
"@atls/figma-theme-shadows-generator": "workspace:*",
"@atls/figma-utils": "workspace:*",
"figma-js": "1.16.1-0",
"prettier": "2.8.8"
},
Expand Down
Loading

0 comments on commit 61299b9

Please sign in to comment.