-
Notifications
You must be signed in to change notification settings - Fork 69
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
feat: create themes flag to build tokens #2357
feat: create themes flag to build tokens #2357
Conversation
Thanks for the pull request, @dcoa! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
6cb3004
to
88b1522
Compare
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.
Allowing users of the CLI to pass in custom themes
makes a lot of sense! @edx/brand
packages could begin defining their own themes before upstream Paragon does. The @edx/frontend-build
and @edx/frontend-platform
PRs should be able to support any custom themes as well already, if that is a concern.
tokens/utils.js
Outdated
@@ -162,7 +162,37 @@ async function transformInPath(location, variablesMap, transformType = 'definiti | |||
} | |||
} | |||
|
|||
|
|||
function createIndexFile(buildDir, isTheme, themeVariant){ |
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.
I agree having it programmatically create the index file makes sense! 🥇
tokens/build-tokens.js
Outdated
// This line creates the index file for core folder, specially when buildDir is outside Paragon. | ||
createIndexFile(buildDir,false); | ||
|
||
const THEME_VARIANTS = themes ? themes : ['light']; |
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.
nit:
const THEME_VARIANTS = themes ? themes : ['light']; | |
const THEME_VARIANTS = themes || ['light']; |
tokens/utils.js
Outdated
@@ -162,7 +162,37 @@ async function transformInPath(location, variablesMap, transformType = 'definiti | |||
} | |||
} | |||
|
|||
|
|||
function createIndexFile(buildDir, isTheme, themeVariant){ |
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.
nit: It may be worth changing the function signature here to be more like kwargs in python, e.g. function createIndexFile({ buildDir, isTheme, themeVariant }) {
. Makes it more explicit what args you're passing in at first glance.
tokens/build-tokens.js
Outdated
|
||
program | ||
.version('0.0.1') | ||
.description('CLI to build design tokens for various platforms (currently only CSS is supported) from Paragon Design Tokens.') | ||
.option('--build-dir <char>', 'A path to directory where to put files with built tokens, must end with a /.', './build/') | ||
.option('--source <char>', 'A path where to look for additional tokens that will get merged with Paragon ones, must be a path to root directory of the token files that contains "root" and "themes" subdirectories.') | ||
.option('--source-tokens-only', 'If provided, only tokens from --source will be included in the output; Paragon tokens will be used for references but not included in the output.') | ||
.option('--themes <themes...>', 'A list of all the themes do you want to build, by default Paragn build light theme.') |
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.
nit grammar and typo. Perhaps something like:
.option('--themes <themes...>', 'A list of all the themes do you want to build, by default Paragn build light theme.') | |
.option('--themes <themes...>', 'A list of theme variants to build. By default, Paragon currently only supports a light theme.') |
tokens/utils.js
Outdated
@@ -162,7 +162,37 @@ async function transformInPath(location, variablesMap, transformType = 'definiti | |||
} | |||
} | |||
|
|||
|
|||
function createIndexFile(buildDir, isTheme, themeVariant){ |
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.
nit: tiny naming nit; perhaps something like createIndexCssFile
just to be a tad bit more explicit in what type of file is being created by this function?
tokens/utils.js
Outdated
return; | ||
} | ||
|
||
const jsonFiles = files.filter(file => file !== 'index.css'); |
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.
[clarification] Is this variable named jsonFiles
because the resulting file names are the output from building the JSON design tokens? If so, this wasn't immediately obvious where for awhile I was thinking the files
contains file names with .json
file extensions but I don't think that's the case? If we're solely working with CSS files here, I wonder if there's a clearer name here, e.g. nonIndexCssFiles
or outputCssFiles
, etc.
tokens/utils.js
Outdated
} | ||
|
||
const jsonFiles = files.filter(file => file !== 'index.css'); | ||
isTheme && jsonFiles.reverse(); |
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.
It may be worth leaving a comment in the code explaining why the .reverse()
is necessary.
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.
I add a comment, it's not exactly necessary, it's just to maintain the order, I mean variables first when run build-scss.
A more explicit approach could be the following:
outputCssFiles.sort((a,b) => a.includes('variables') ? -1 : 0)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## alpha #2357 +/- ##
=======================================
Coverage 91.58% 91.58%
=======================================
Files 214 214
Lines 3519 3519
Branches 852 852
=======================================
Hits 3223 3223
Misses 288 288
Partials 8 8 ☔ View full report in Codecov by Sentry. |
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.
Great work, lgtm! Appreciate the contribution 🙌 💯
@dcoa 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
🎉 This PR is included in version 21.0.0-alpha.37 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 22.0.0-alpha.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 23.0.0-alpha.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 23.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
This PR is a proposal to be able to build tokens of any custom theme throughout CLI. Also, add a function to create the index file for the output, understanding that the build-scss command needs this file.
The user can run something like
build-design-tokens --build-dir ./<folder_path> --source /<folder_path> --themes custom_theme_a custom_theme_b light
Merge Checklist
example
app?wittjeff
andadamstankiewicz
as reviewers on this PR.Post-merge Checklist
@adamstankiewicz