-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: Expose xmodule xblocks Sass variables as vanilla CSS variables #35233
Conversation
efdd4df
to
d8ff25c
Compare
Looking great so far @farhan . Does this capture every Sass variable that used within xmodule/assets? Also, I just edited the issue to include a Step 4:
Could you choose a builtin block, and apply Step 4 for that block in this PR? There will also be "Step 5: Convert each blocks' Sass into CSS", but I need to do some discovery before I can provide details for that. Let's worry about Step 5 in a future PR. |
No, it doesn't cover all the sass variables, we are working on it. Variables like Annotators xblock's need to be discussed with @irtazaakram
I have converted the .input-cloud {
margin: var(--baseline)/4
/*margin: 5px;*/
} |
@kdmccormick It includes all the sass variables directly import from the imports excluding the one locally defined in the files. |
Great. Let me know when you are ready for review. |
2419afa
to
890155d
Compare
890155d
to
45cf850
Compare
45cf850
to
2ac1a69
Compare
2ac1a69
to
6996950
Compare
6996950
to
6e5e8aa
Compare
I believe these Sass variables are missing from _builtin-block-variables.scss:
Here is the bash script I used to determine that (it requires # Search for all Sass var references, sort them, and save them to a file.
rg '\$[a-zA-Z0-9-_]*' xmodule/assets/**/*scss --no-line-number --no-filename --only-matching \
| sort | uniq > variable_references.txt
# Search for local declarations of Sass vars (like '$selected_color: ...'), sort them,
# and save them to a file.
rg '\$[a-zA-Z0-9-_]*: ' xmodule/assets/**/*scss --no-line-number --no-filename --only-matching \
| sed 's/..$//' | sort | uniq > local_variable_declarations.txt
# Compare the set of var references with the set of local declarations.
# Variables which are referenced but *don't* have local declarations must be themeable Sass variable.
# Save them to a file.
diff --unified local_variable_declarations.txt variable_references.txt \
| rg '^\+' | sed 's/^.//' > themable_variables.txt
# Search the new _builtin-block-variables.scss file to get a list of CSS->Sass mapped variables.
# Sort and save them to a file.
rg '\$[A-Za-z0-9-_]*' common/static/sass/_builtin-block-variables.scss --no-line-number --no-filename --only-matching \
| sort | uniq > css_mapped_variables.txt
# Finally, compare the CSS->Sass-mapped variables with the themed ones we saved earlier.
# This is the list of variables that we are missing CSS->Sass mappings for.
diff --unified css_mapped_variables.txt themable_variables.txt \
| rg '^\+' | sed 's/^.//' I think it would be best to get all these variables into _builtin-block-variables.scss now so that we don't have bugs later. Let me know if you are curious how any part of that bash script works-- I find bash really helpful when I have to do these sort of tasks and I'd be happy to share the knowledge. |
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.
(see my comment above)
@kdmccormick Thanks for sharing FYI: I have removed PR is available for review again |
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.
Looks great, thanks @farhan !
Can you explain how you manually tested this to ensure that the CSS variables are available in legacy views?
@kdmccormick I have added my testing steps in the description of the PR. Hope this is what you are asking for. |
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.
Forgive me @farhan , when I said "legacy views" what I should have said is "server-rendered views" (as opposed to MFE pages). XBlocks fall into that category, so your testing steps look perfect 👍🏻 🚀
When you squash & merge, please include a link to the ticket in the commit message. |
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
2U Release Notice: This PR has been deployed to the edX production environment. |
Late the party, but can't this |
TIL 😄 |
…penedx#35233) * feat: Expose xmodule xblocks Sass variables as vanilla CSS variables * openedx#35173
Ticket: #35173
Following script is used to extract out the required sass variables to expose:**
How to test:
Test in xmodule xblocks:
npm run compile-sass
ornpm run compile-sass-dev
in lms shell. Restart lms if changes don't reflect.getComputedStyle(document.documentElement).getPropertyValue('--baseline')
Test in extracted xblocks:
getComputedStyle(document.documentElement).getPropertyValue('--baseline')