I recently started using suitCSS naming conventions in my Sass (not using default PostCSS setup) and it's not clear what's the correct way of naming variables:
Variables used inside of component's media queries. In official docs, I only saw the reference for using responsive utilities, but no conventions for responsive variables. For examples let's take this code:
.MyComponent {
margin-left: $MyComponent-marginLeft;
@include media('sm') {
margin-left: $sm-MyComponent-marginLeft;
}
}
What variable name should I use? $u-sm-MyComponent-marginLeft
or $sm-MyComponent-marginLeft
and why?
And the other question is about nested variables and/or inside of pseudo-classes.
.Nav-listItem {
&:last-child {
.Nav-link {
margin-right: $Nav-listItem-onLastChild-NavLink-marginRight;
}
}
}
Disclaimer: opinion based answer
As you have said for your particular case the documentation is not entirely clear. So you can choose how you name them. The important thing is that you are consistent in your naming and that other developers are clear what the conventions are.
Responsive variables
For the naming of responsive variables I would choose the following convention
Why?
For me this reads logically,
sm
,md
,lg
are a subset ofmarginLeft
and therefore should proceedmarginLeft
. When grouped together, as above, it is easy to scan as it is the last characters of the variable that are different.A similar example can be seen here.
Nested variables
From the docs:
Your naming here is too explicit of the internal structure of the component. I would suggest something like
I think this describes the use of the variable better.