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
Use CSS variables in TypeScript #1853
Merged
tdonohue
merged 9 commits into
DSpace:main
from
atmire:w2p-94233_use-css-vars-in-CSSVariableService
Oct 18, 2022
Merged
Use CSS variables in TypeScript #1853
tdonohue
merged 9 commits into
DSpace:main
from
atmire:w2p-94233_use-css-vars-in-CSSVariableService
Oct 18, 2022
Conversation
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
tdonohue
added
the
1 APPROVAL
pull request only requires a single approval to merge
label
Sep 22, 2022
tdonohue
moved this from Needs Reviewers Assigned
to Under Review
in DSpace 7.4 release
Sep 22, 2022
tdonohue
added this to Needs Reviewers Assigned
in DSpace 7.5 release (OLD - Migrated, see note above)
via automation
Oct 4, 2022
tdonohue
removed this from Needs Reviewers Assigned
in DSpace 7.5 release (OLD - Migrated, see note above)
Oct 11, 2022
tdonohue
approved these changes
Oct 18, 2022
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.
👍 Thanks @LotteHofstede . This looks good to me. I gave it some light testing by changing the values of the CSS variables used in typescript. I also agree this is much better than the current hardcoded approach in app.component.ts
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR restores the feature we used to have to read out CSS variables from TypeScript. With the upgrade to Angular 8 we had to hardcode those values (so they would no longer update automatically if they changed in CSS). This PR bases them on CSS again. Because by now all our variables are CSS variables, it also gives us a lot more info than we used to have.
Its implementation is based on this article.
The variables are saved in the store when the page is loaded.
Any references to existing variables used were updated to use the correct CSS variables.
Instructions for Reviewers
After the application has started, all our custom and bootstrap CSS variables should be visible in the store under "cssVariables". (Using Redux DevTools).
The easiest way to test this PR would be to:
private
topublic
for the service in the constructor ofAppComponent
. That'll allow us to access it from the html template<h1>{{ cssService.getVariable('--bs-sm-min') | async }}</h1>
to the app component html templateWhen you run the app now, you should see
990px
in app component; the version from the theme.You can do the same thing on the current main branch, only there that same variable is named slighty different, so add
<h1>{{ cssService.getVariable('smMin') | async }}</h1>
to the app component html file instead. On main you'll see that the value doesn't change when you change the css file. Instead you'll see the hardcoded versionChecklist
yarn run lint
package.json
), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.