Skip to content
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

Create/use an SCSS variables/mixins file #2749

Closed
Tracked by #4909
twschiller opened this issue Feb 15, 2022 · 6 comments
Closed
Tracked by #4909

Create/use an SCSS variables/mixins file #2749

twschiller opened this issue Feb 15, 2022 · 6 comments

Comments

@twschiller
Copy link
Contributor

twschiller commented Feb 15, 2022

Implementation Sketch

  • Check if the bootstrap SCSS have utilities as variables/mixins. If so can we re-use them in our modules?
  • Create a SCSS variables file if it does not already exist
  • Is should include: colors, padding (which should match the utility classes)
  • Add documentation on how to use (how to import, etc.)

Questions

  • Can we use the existing _variables.scss file?
  • We need to have a file for the options page/sidebar them, and another file for the devtools theme
  • Does padding/margin belong in there? Or do those get implemented using mixins?
@twschiller twschiller changed the title Create a SCSS variable file Create/use an SCSS variable file Feb 15, 2022
@twschiller twschiller changed the title Create/use an SCSS variable file Create/use an SCSS variables/mixins file Feb 15, 2022
This was referenced Feb 16, 2022
@mnholtz
Copy link
Collaborator

mnholtz commented Mar 10, 2022

FYI - finished looking into this today

It looks like with node-sass (which is apparently deprecated, by the way. Perhaps we should consider moving over to Dart Sass as recommended in the deprecation reference) we can simply import & use mixins and variables like so:

// Snippit from a quick experiment I did in the options page
// Including full path because it looks like this is where our main theme variables & mixins live
// It will be nice to eventually include a shortcut to the directory
@import "../../../../vendors/theme/assets/styles/_variables.scss";
@import "../../../../vendors/theme/assets/styles/mixins/_misc.scss";

.cardFooter {
  color: $sidebar-dark-menu-icon-color;
}

.sharingLabel {
  //overflow: hidden;
  //white-space: nowrap;
  //text-overflow: ellipsis;
  @include ellipsor;
}

Although, it looks like webpack is not happy with importing some of our existing files, like _variables.scss, in the way they are currently written. I had to comment out offending lines that were using improperly imported or non-existent variables.

Additionally, I think we should refactor files like _variables.scss to remove or replace unused or unhelpful variables & mixins (e.g. colors that we never want to use in the app). We'll have to take inventory on what kinds of styles are covered, and which ones are not.


Other alternatives I found in my research:
1. using sass-resources-loader

 // We could potentially register existing bootstrap theme files like this in webpack config
            resources: [
              './path/to/vars.scss',
              './path/to/mixins.scss',
              './path/to/functions.scss'
            ]

or
2. css modules variables?
Although this method doesn't look desirable for being able to reuse existing sass files, as well as providing a method to use mixins.

@fregante
Copy link
Collaborator

If we can stick to regular SCSS it would probably be easier, also because we're already using it.


Re: dart-sass

We can't upgrade due to our incompatible custom theme:

@mnholtz
Copy link
Collaborator

mnholtz commented Mar 11, 2022

If we can stick to regular SCSS it would probably be easier, also because we're already using it.

I agree

@fregante
Copy link
Collaborator

fregante commented Dec 31, 2022

Side requests:

  • Move our customizations out of the vendors folder because it takes some guesswork to figure out what is ours and what is the default Bootstrap theme
  • Find a way to use SCSS color variables in JS
    We have a few instances of colors copy-pasted into JS files. Maybe we can use this: https://stackoverflow.com/a/66120027 thanks to CSS modules.

@BLoe
Copy link
Collaborator

BLoe commented Jun 27, 2023

@mnholtz Is this ticket relevant any more? Was this before we created our color variables file and stuff?

@mnholtz
Copy link
Collaborator

mnholtz commented Jun 28, 2023

@BLoe I think we can tentatively close this. We've implemented a lot of points (e.g. being able to import variables) discussed in this ticket. We probably want to address newer tickets that address css architecture instead.

@mnholtz mnholtz closed this as completed Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants