Reputation: 49054
For example in Bootstrap's source I found, mixins.less defines:
.clearfix() {
&:before,
&:after {
content: " "; // 1
display: table; // 2
}
&:after {
clear: both;
}
}
and utilities.less:
.clearfix {
.clearfix();
}
I understand it is useful to have a clearfix class, but will there be any reason other than have only mixins and no classes in mixins.less, to not define a class instead of a mixin in mixins.less?
Upvotes: 0
Views: 94
Reputation: 72281
Since Bootstrap is a library, they realize that some people will not want to use classes from Bootstrap, but will want to use the mixins. By keeping the separation, a user can import mixins.less
and apply .clearfix()
into their own code under their own class name(s), without it actually creating an output of a .clearfix
class itself. At the same time, if one wants to use the whole Bootstrap library, they want to provide an actual class by the name .clearfix
for users of the whole library.
Upvotes: 3
Reputation: 11820
I see no reasons except keeping the library organization consistent (E.g. "mixins.less should not produce any CSS and utilities.less should have only classes").
Upvotes: 1