forked from PortableStudios/figma2theme
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds Tailwind as an export option #1
Open
andrewfulton
wants to merge
69
commits into
develop
Choose a base branch
from
export-tailwind-config
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
bf9d364
/feat Scaffolds of command for exporting a tailwind config file.
andrewfulton d318046
/feat Adds a translation of figma2theme tokens to a workable tailwind…
andrewfulton 06c7727
Update dependencies
spykr 85ed22f
Merge pull request #288 from PortableStudios/update-dependencies
spykr f125fd1
Bump version to 0.6.5
spykr 16d3566
Bump follow-redirects from 1.14.5 to 1.14.8
dependabot[bot] 2e2134d
Merge pull request #287 from PortableStudios/dependabot/npm_and_yarn/…
spykr 42f11a5
chore: update dependencies
spykr afbcb1c
chore: bump version to `0.6.6`
spykr 243c238
chore: update dependencies
spykr 9f0ecfa
Merge pull request #301 from PortableStudios/update-dependencies
spykr 8c283a6
chore: bump version to `0.6.7`
spykr 48fff2d
Bump minimist from 1.2.5 to 1.2.6
dependabot[bot] 95f2ba6
Merge pull request #299 from PortableStudios/dependabot/npm_and_yarn/…
spykr 7bb7673
chore: update dependencies
spykr 625f3cc
chore: update readme
spykr dce2e1f
chore: bump version to `0.6.8`
spykr 5f7e7fb
Bump @emotion/react from 11.9.0 to 11.9.3
dependabot[bot] 39b63e9
Merge pull request #322 from PortableStudios/dependabot/npm_and_yarn/…
spykr fbe947e
Bump @emotion/styled from 11.8.1 to 11.9.3
dependabot[bot] 04b2b0f
Merge pull request #323 from PortableStudios/dependabot/npm_and_yarn/…
spykr 94323fa
chore: update dependencies
spykr 737875b
chore: bump version to `0.6.9`
spykr b6afed7
chore: update `storybook` to use `webpack` v5
spykr 2bf280a
Bump terser from 4.8.0 to 4.8.1
dependabot[bot] d117c3e
fix: ignore text styles that begin with `_`
spykr 6b7807d
feat: import all colours from figma file not just ones starting with …
spykr d97c29d
fix: when exporting chakra text styles replace hardcoded font familie…
spykr 1d409e1
feat: add the ability to define font fallbacks in `.figma2themerc`
spykr f6baa07
update tests based on change to colour import
spykr 25ef2a0
chore: bump version to `0.7.0`
spykr cbf9aba
✨ feat: adding preinstall script
EllyLoel e76a133
✨ feat: adding check for global config file
EllyLoel f1b251e
chore: update dependencies
spykr 9534b3c
Merge pull request #342 from PortableStudios/update-dependencies
spykr 85977a4
chore: add storybook testing to ci
spykr 8408ae3
Merge pull request #334 from PortableStudios/dependabot/npm_and_yarn/…
spykr 2d4f5e6
Merge pull request #343 from PortableStudios/add-storybook-tests
spykr e5a2984
chore: bump version to `0.7.1`
spykr 4c78a07
✨ feat: switching from color-convert to colorjs.io and adding style-d…
EllyLoel 673289e
✨ feat: switch to using colorjs.io
EllyLoel ae8f0d0
✨ feat: updating tokens to match design token format module spec
EllyLoel fdb08f8
✨ feat: adding css generator
EllyLoel 276af31
Merge branch 'develop' into feature/design-token-format
EllyLoel 80db483
Merge branch 'develop' into feature/export-css-custom-properties
EllyLoel 4b4ae11
🐛 fix: rolling back changes related to PR #340
EllyLoel 4c8d4a7
Merge branch 'feature/export-css-custom-properties' of github.com:Por…
EllyLoel 46d4248
🐛 fix: rolling back changes related to PR #340
EllyLoel 3c32526
🐛 fix: removing ts-ignore and unneeded type check
EllyLoel 45c5329
✂️ refactor: refactoring reshapeDesignTokens function and adding comm…
EllyLoel 4ffb2d8
🐛 fix: removing ts-ignore and unneeded type check
EllyLoel 31db34e
✂️ refactor: refactoring reshapeDesignTokens function and adding comm…
EllyLoel c22827a
🧹 chore: updating gitignore file
EllyLoel 85811cd
🐛 fix: removing .figma2themerc
EllyLoel 1bc2069
feat: update token types to match new structure
spykr 45fac7e
Merge branch 'feature/design-token-format' into feature/export-css-cu…
spykr f612883
Merge branch 'feature/design-token-format' into feature/export-css-cu…
EllyLoel c762aea
Merge branch 'feature/export-css-custom-properties' of github.com:Por…
EllyLoel 9901026
Merge pull request #353 from PortableStudios/feature/export-css-custo…
EllyLoel 07e6803
Merge pull request #356 from PortableStudios/chore/update-gitignore
EllyLoel e8f21b6
Merge pull request #352 from PortableStudios/feature/design-token-format
EllyLoel 1026f6a
🧹 chore: bump version to 0.8.0
EllyLoel d1583f1
🧹 chore: adding myself as a contributor
EllyLoel 5d58c8e
feat(UIKIT-17): update to support new page name "Icons & Media"
spykr 3d3f8d5
feat: make the "sizes" page optional
spykr 77922a8
Merge pull request #366 from PortableStudios/UIKIT-17-support-icons-a…
spykr 9bf6ee2
Merge pull request #367 from PortableStudios/make-sizes-page-optional
spykr 132ad39
chore: bump version to `0.8.1`
spykr 2137b61
Merge branch 'develop' into export-tailwind-config
andrewfulton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
import prettier from 'prettier'; | ||
|
||
import { version } from '../../package.json'; | ||
import { renderTemplate } from './templating'; | ||
|
||
import type { Tokens } from '../utils/types'; | ||
|
||
const prettierConfigFile = path.resolve(__dirname, '../../.prettierrc'); | ||
const templateDir = path.resolve(__dirname, '../../templates'); | ||
|
||
// Run Prettier on JS code using the config file | ||
const formatFileContents = async (contents: string) => { | ||
return prettier.resolveConfig(prettierConfigFile).then((options) => { | ||
return prettier.format(contents, { ...options, parser: 'babel' }); | ||
}); | ||
}; | ||
|
||
export default async function exportJsonFromTokens( | ||
tokens: Tokens, | ||
outputDir: string, | ||
figmaFileKey: string, | ||
versionDescription: string | ||
) { | ||
await fs.mkdirs(outputDir); | ||
|
||
const tailwind = { | ||
content: [], | ||
theme: { | ||
extend: {}, | ||
}, | ||
plugins: [], | ||
}; | ||
|
||
// render the main config | ||
await renderTemplate( | ||
`${templateDir}/tailwind.config.js.ejs`, | ||
`${outputDir}/tailwind.config.js`, | ||
{ | ||
tailwind, | ||
version, | ||
figmaFileKey, | ||
versionDescription, | ||
}, | ||
formatFileContents | ||
); | ||
|
||
// and the local edits file if it doesn't already exist. | ||
if (!fs.existsSync(`${outputDir}/tailwind.config.local.js`)) { | ||
await renderTemplate( | ||
`${templateDir}/tailwind.config.local.js.ejs`, | ||
`${outputDir}/tailwind.config.local.js`, | ||
{ | ||
tailwind, | ||
version, | ||
figmaFileKey, | ||
versionDescription, | ||
}, | ||
formatFileContents | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { default as exportChakra } from './export-chakra'; | ||
export { default as exportJson } from './export-json'; | ||
export { default as exportTailwind } from './export-tailwind'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import fs from 'fs-extra'; | ||
import ejs from 'ejs'; | ||
|
||
import type { Data } from 'ejs'; | ||
|
||
// Render an EJS template with the given data, format it with Prettier and write the result to the output path | ||
export const renderTemplate = async ( | ||
templatePath: string, | ||
outputPath: string, | ||
data: Data, | ||
formatFileContents: (s: string) => Promise<string> | ||
) => { | ||
const contents = await ejs | ||
.renderFile(templatePath, data) | ||
.then((str) => formatFileContents(str)); | ||
return fs.outputFile(outputPath, contents); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// AUTO-GENERATED - File generated by figma2theme <%- version %>, manual edits may be overwritten | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unclear at the moment why format-on-save is indenting this file, but not the other. |
||
// Figma file: https://www.figma.com/file/<%- figmaFileKey %> | ||
// File version selected: <%- versionDescription %> | ||
// Generated at: <%- new Date().toString() %> | ||
|
||
const withLocalChanges = require('./tailwind.config.local'); | ||
|
||
module.exports = withLocalChanges(<%- JSON.stringify(tailwind) %>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// This file should contain any local edits that need to be made to the tailwind config | ||
// eg any additional plugins or project specific settings. | ||
// The figma2theme setup expects it, if you don't need it just leave it as is | ||
|
||
module.exports = (tailwindConfig) => tailwindConfig; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know if there is a more correct parser option here but it din't like it when I left it out