8000 Fix form SCSS variables no longer being defined in the outermost scope, so no longer being accessible by gigorok · Pull Request #7341 · activeadmin/activeadmin · GitHub
[go: up one dir, main page]

Skip to content

Fix form SCSS variables no longer being defined in the outermost scope, so no longer being accessible #7341

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

Merged
merged 2 commits into from
Mar 8, 2022

Conversation

gigorok
Copy link
Contributor
@gigorok gigorok commented Feb 17, 2022
  • Make SCSS forms variables to be accessible in the global SCSS scope
  • Allow to override $filter-field-seperator-width SCSS variable

@Fivell Fivell marked this pull request as ready for review February 18, 2022 16:04
@Fivell Fivell requested review from Fivell and javierjulio February 18, 2022 16:04
Copy link
Member
@Fivell Fivell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gigorok thanks

@Fivell
Copy link
Member
Fivell commented Feb 21, 2022

@javierjulio , hello, what do you think about this?

Copy link
Member
@javierjulio javierjulio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don't need to be moved, just marked with a !default at the end which the form variables don't have. The gradient variables do have it already though. Are you sure you can't override those gradient variables currently?

Copy link
Member
@deivid-rodriguez deivid-rodriguez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a look at this PR and I think it's correct.

I believe the issue is that since #6922, these variables are only defined under a @media screen scope, so they no longer work when accessed from active_admin_datepicker outside of any scopes:

https://github.com/activeadmin-plugins/active_admin_datetimepicker/blob/9a7993b9c566926d57273c16fe0bd9308e46b7af/app/assets/stylesheets/active_admin_datetimepicker.scss#L1-L15

If the variables are moved to _variables.scss, they are again defined outside of any @media scope as they used to (because that file gets imported from the top level), so the issue gets fixed. This explains why also the alternative fix of wrapping rules in active_admin_datepicker under a @media scope also works.

@gigorok gigorok changed the title possibility to override forms & gradients variables add the possibility to override forms variables Mar 8, 2022
@gigorok gigorok changed the title add the possibility to override forms variables add the possibility to override forms SCSS variables Mar 8, 2022
@gigorok
Copy link
Contributor Author
gigorok commented Mar 8, 2022

@deivid-rodriguez yep. you are right. I'm going to fix active_admin_datetimepicker. unfortunately wrapping rules in active_admin_datepicker under a @media scope is not working (activeadmin-plugins/active_admin_datetimepicker#73)

@deivid-rodriguez
Copy link
Member
deivid-rodriguez commented Mar 8, 2022

Alright, so if I understand correctly, this is actually fixing two issues:

  • One is the variables no longer being accessible outside of @media scopes, which is fixed by moving them to _variables.scss. That fixes the error you're getting in active_admin_datepicker Error: Undefined variable: "$filter-field-seperator-width.

  • Another issue is that, even with the above patch, the overridden value is not taking effect due to missing !default.

Correct?

@gigorok
Copy link
Contributor Author
gigorok commented Mar 8, 2022

Alright, so if I understand correctly, this is actually fixing two issues:

  • One is the variables no longer being accessible outside of @media scopes, which is fixed by moving them to _variables.scss. That fixes the error you're getting in active_admin_datepicker Error: Undefined variable: "$filter-field-seperator-width.
  • Another issue is that, even with the above patch, the overridden value is not taking effect due to missing !default.

Correct?

Correct. After merging of this PR $filter-field-seperator-width SCSS variable can be overridden & can be accessible in the global SCSS scope

@deivid-rodriguez
Copy link
Member

Alright, this looks good to me. Only nitpick would be if you would mind to split both changes into two separate commits, and explain each of them on its own commit message.

@deivid-rodriguez
Copy link
Member

@javierjulio We have confirmed that you were right that gradient variables were fine, and that !default was missing from form variables, but we did find that they do need to be moved since #6922 as explained above. This PR should be now ready from my side other than the commit splitting which is nice but not strictly necessary and I can do it myself if needed anyways.

@gigorok
Copy link
Contributor Author
gigorok commented Mar 8, 2022

Alright, this looks good to me. Only nitpick would be if you would mind to split both changes into two separate commits, and explain each of them on its own commit message.

Done. Please, check it up.

Copy link
Member
@deivid-rodriguez deivid-rodriguez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

As far as I understand, the addition of !default is not necessary for active_admin_datetimepicker because:

  • Variables are not overridden, just used.
  • Even if they were overridden, they are overridden after the default values are set, so !default would have no effect.

That said, the change keeps consistency with all the other variables in _variables.scss, so it seems good!

@deivid-rodriguez deivid-rodriguez changed the title add the possibility to override forms SCSS variables Fix form variables no longer being defined in the outermost scope, so no longer being accessible Mar 8, 2022
@deivid-rodriguez deivid-rodriguez changed the title Fix form variables no longer being defined in the outermost scope, so no longer being accessible Fix form SCSS variables no longer being defined in the outermost scope, so no longer being accessible Mar 8, 2022
@javierjulio javierjulio merged commit 3455a7f into activeadmin:master Mar 8, 2022
@deivid-rodriguez
Copy link
Member

Thanks @gigorok and @javierjulio! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0