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

How to include mixins correctly? #80

Open
jyggiz opened this issue Jun 11, 2021 · 3 comments
Open

How to include mixins correctly? #80

jyggiz opened this issue Jun 11, 2021 · 3 comments
Assignees
Labels
styles issues relates to styling or CSS

Comments

@jyggiz
Copy link
Contributor

jyggiz commented Jun 11, 2021

I noticed when checking several pull requests that there are cases when mixins are inserted not at the beginning of the selector:

.caption {
  font-weight: bold;
  @include copy-1;
}

I think it's best practice to include mixins at the very top so that you do not accidentally overwrite the styles you wrote earlier. We also need to add a new line after the mixin to improve the reading of the code. Example:

.caption {
  @include copy-1;

  font-weight: bold;
}

I think it would be nice to add this to the coding standards if it really is best practice. I noticed that we do not have a section with rules for CSS or is it better to add this rule somewhere else?

@nswaldman
Copy link
Collaborator

In agreement there -it is best practice to place mixins first and separate your mixin(s) and regular declarations with a newline for legibility.

Input on CSS was requested last week and this particular example should definitely live under a SCSS sub-chapter.

@larsvanbraam
Copy link

larsvanbraam commented Jun 11, 2021

While on the topic of adding this to the coding standards, maybe we should also include a section about excessive parenthesis on mixins that do not require any arguments as well?

.caption {
  @include copy-1; // Using this notation

   font-weight: bold;
}

.caption { 
  @include copy-1(); // In favor of this

   font-weight: bold;
}

@nswaldman
Copy link
Collaborator

I never enforce that concept because it doesn't really help make code more legible or the output smaller.

  • When skimming through scss, @xxxxxxx xxxxx(); sticks out way more than @xxxxxxx xxxxx;
  • Those parentheses have no effect on the output's size, so it's not like we're breaking the bank leaving them in.

@psimk psimk added the styles issues relates to styling or CSS label Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
styles issues relates to styling or CSS
Projects
None yet
Development

No branches or pull requests

6 participants