-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Class using mixin of same name generates double CSS #1437
Comments
Hey Mark! You could do the following:
Results in:
Note that this will result in the base class (.clearfix) being output. If you didn't want
Which will result in:
The other which is further in development is referencing a less file by reference.
This will result in no CSS properties being generated until they are extended or used as a mixin. Bootstrap is actually one of the examples used for the reference feature, where people could, by default, import the entire Bootstrap library, but essentially map customized sections of the library to CSS classes they designate, as in:
Try out the new LESS Hopefully, we'll have mixin extending implemented soon, but we're still working out the syntax. |
@mdo here is a comparison of using mixins to do this versus extend. (I used http://less2css.org/, screen caps were faster to illustrate...). Keep in mind that, by default, Using MixinsUsing
|
lol, sorry I started my answer earlier today then came back and didn't scroll to see that I basically duplicated @matthew-dean's answer. my bad FWIW, I started using this convention (from the |
@jonschlinkert You added the bit about the "all" keyword, which is important info, especially for the traditional clearfix set of properties. :-) |
Original discussion: less/less.js#1437 (comment). Since we’re switching to `grunt-contrib-less`, we can take advantage of newer LESS features than what RECESS supported. Included in that is the ability to `:extend`, and not only that, but `:extend(.mixin-name all)`. By doing so, we remove duplicate CSS for all our elements that were being clearfix-ed. Fixes #8947, #8968, #8991, #9257, #9268, #9291, #9430, #9604, #9686, #9929, #10731, #10793, #11305, #11498, #11533, #11570, #11604, #11652. (dem issues, tho)
Original discussion: less/less.js#1437 (comment). Since we’re switching to `grunt-contrib-less`, we can take advantage of newer LESS features than what RECESS supported. Included in that is the ability to `:extend`, and not only that, but `:extend(.mixin-name all)`. By doing so, we remove duplicate CSS for all our elements that were being clearfix-ed. Fixes twbs#8947, twbs#8968, twbs#8991, twbs#9257, twbs#9268, twbs#9291, twbs#9430, twbs#9604, twbs#9686, twbs#9929, twbs#10731, twbs#10793, twbs#11305, twbs#11498, twbs#11533, twbs#11570, twbs#11604, twbs#11652. (dem issues, tho)
Original discussion: less/less.js#1437 (comment). Since we’re switching to `grunt-contrib-less`, we can take advantage of newer LESS features than what RECESS supported. Included in that is the ability to `:extend`, and not only that, but `:extend(.mixin-name all)`. By doing so, we remove duplicate CSS for all our elements that were being clearfix-ed. Fixes twbs#8947, twbs#8968, twbs#8991, twbs#9257, twbs#9268, twbs#9291, twbs#9430, twbs#9604, twbs#9686, twbs#9929, twbs#10731, twbs#10793, twbs#11305, twbs#11498, twbs#11533, twbs#11570, twbs#11604, twbs#11652. (dem issues, tho)
In Bootstrap 3 we've made a change to avoid generating CSS from our
mixins.less
file by doing something like the following:While this compiles no problem, it results in duplicate code in the generated CSS whenever the mixin is used.
Should we be doing this? If it's indeed valid Less (which it seems to be since it's compiling), I suppose this is a bug then?
(Relevant issue from Bootstrap: twbs/bootstrap#8557)
The text was updated successfully, but these errors were encountered: