-
Notifications
You must be signed in to change notification settings - Fork 67
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: Better support for multiple themes #2792
base: alpha
Are you sure you want to change the base?
Conversation
Thanks for the pull request, @xitij2000! What's next?Please work through the following steps to get your changes ready for engineering review: 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. 🔘 Let us know that your PR is ready for review:Who will review my changes?This repository is currently maintained by Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:
When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
✅ Deploy Preview for paragon-openedx ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
3574ba7
to
9be0b1e
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## alpha #2792 +/- ##
=======================================
Coverage 93.48% 93.48%
=======================================
Files 216 216
Lines 3671 3671
Branches 902 902
=======================================
Hits 3432 3432
Misses 234 234
Partials 5 5 ☔ View full report in Codecov by Sentry. |
Hi @adamstankiewicz! Would you mind reviewing for us? Thanks! |
lib/build-tokens.js
Outdated
|
||
if (allThemes) { | ||
themesToProcess = fs | ||
.readdirSync(`${tokensSource}/themes/`, { withFileTypes: true }) |
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.
This line fails for me locally when I triy to build all themes for Paragon, because tokensSource
is undefined
by default. I think this setting is used to overwrite default tokens which we don't need to do in Paragon, so we don't use this parameter internally in repository.
Changing this line to .readdirSync(`${tokensSource || path.resolve(__dirname, '../tokens/src')}}/themes/`, { withFileTypes: true })
seems to work for me (basically defaulting to the root folder of Paragon's tokens)
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've applied your suggestion. Do tell if there are any other changed you'd like me to make to get this merged.
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.
@xitij2000 It seems we still have problems with the tokensSource
. Could you check if everything is working correctly?
*/ | ||
async function buildTokensCommand(commandArgs) { | ||
const defaultParams = { | ||
themes: ['light'], | ||
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.
Any specific reason to switch from themes
argument as a list, to a string and splitting it later in :48
?
If so, please also update the @param
doc in :15
to reflect the same
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.
The reason is that currently specifying a single theme via --theme
is simply broken. You will get an error if you run the command.
The reason for that is that if you specify a single theme as --theme light
the value of themes above will be the string "light" and so the themes.forEach
later on will fail. You'll need to either go with the default value, or specify themes twice as:
paragon build-tokens --themes light --themes dark
This change makes it possible to specify multiple themes as:
paragon build-tokens --themes "light dark"
This is also a bit clumsy, but is more consistent. I'll update the docstring and also make this more robust to support the old syntax.
This change adds support for two CLI options to the build-tokens command. The first, --all-themes makes the build-tokens command process all themes in the source directory as opposed to specifying all the names via --theme. Secondly, --base-theme allows you to have multiple themes derived from the same common base. If specified, you can have a derived theme that still loads tokens from the light theme. For example, you can have a site theme called 'theme-one' and set the base theme to light so it will reuse the core light theme tokens and layer on changes from 'theme-one'.
8128b26
to
e8d15d1
Compare
e8d15d1
to
fd4d634
Compare
Hi @brian-smith-tcril! Are you able to review / merge this for us? |
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'm not fully sure how all these new options interact with each other:
--themes |
--base-theme |
--all-themes |
expected behavior |
---|---|---|---|
not set | not set | false | ? |
not set | not set | true | ? |
not set | set | false | ? |
not set | set | true | ? |
single theme | not set | false | ? |
single theme | not set | true | ? |
single theme | set | false | ? |
single theme | set | true | ? |
multiple themes | not set | false | ? |
multiple themes | not set | true | ? |
multiple themes | set | false | ? |
multiple themes | set | true | ? |
Sure, I can clarify the interactions. First, the This option is to allow creating theme variants. Currently, you can create your own With the
Here it would pull the tokens from the Second, the interaction between If |
Flagging this, @brian-smith-tcril, just in case you're still able to review. |
@xitij2000 Thanks for your improvements! We need to solve the problem of specifying specific themes. I like the shorter declaration format you proposed and the flexibility we can provide to consumers. Unfortunately, I was not able to test this locally (maybe I missed something). We may still have a problem with |
Could you tell me what didn't work when testing? Were you getting an error? I've added test instructions in the PR description above. Do tell me if those steps do not work. |
@xitij2000 @PKulkoRaccoonGang just following up on this :) |
Friendly ping, @PKulkoRaccoonGang @xitij2000! |
Sorry. The code here is good to go from my side and I wasn't able to reproduce any issues,so just waiting to hear back. |
@PKulkoRaccoonGang I see you mentioned
and @xitij2000 reponded
@PKulkoRaccoonGang - were you able to test locally after the steps were added? Either way, I know quite a few things have changed in the I know @PKulkoRaccoonGang is working to update |
This change adds support for two CLI options to the build-tokens command.
The first, --all-themes makes the build-tokens command process all themes in the source directory as opposed to specifying all the names via --theme.
Secondly, --base-theme allows you to have multiple themes derived from the same common base. If specified, you can have a derived theme that still loads tokens from the light theme. For example, you can have a site theme called 'theme-one' and set the base theme to light so it will reuse the core light theme tokens and layer on changes from 'theme-one'.
Testing instructions:
./bin/paragon-scripts.js build-tokens --source /tmp/pr-2792 --build-dir /tmp/pr-2792/build --themes test1 --themes test2
. You will need to specify both themes since currently, if you specify only one it will fail.build
directory inside/tmp/pr-2792
that acore
anthemes
directory where the themes directory in turn will have avariables.css
file with the variable defined above, andutility-classes.css
will be empty. Delete this directory../bin/paragon-scripts.js build-tokens --source /tmp/pr-2792 --build-dir /tmp/pr-2792/build --themes test1
: This would error before but will work now../bin/paragon-scripts.js build-tokens --source /tmp/pr-2792 --build-dir /tmp/pr-2792/build --all-themes
: This will build all themes without specifying a name../bin/paragon-scripts.js build-tokens --source /tmp/pr-2792 --build-dir /tmp/pr-2792/build --themes test1 --base-theme light
: This will compile the test1 theme using the light theme as a base. Soutility-classes.css
will not longer be empty but contain styles from the light theme.