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

refactoring grid classes to be able to :extend them? #7887

Closed
maniqui opened this issue May 15, 2013 · 2 comments
Closed

refactoring grid classes to be able to :extend them? #7887

maniqui opened this issue May 15, 2013 · 2 comments
Labels

Comments

@maniqui
Copy link

maniqui commented May 15, 2013

This is a feature request for the not-so-distant future, when the upcoming new version of LESS (1.4.0) gets into its final shape.
Also, I understand the new grid system (and the mixin utilities that help to create it) on 3.0.0-wip is still a WIP, and still being overhauled.

The current way the grid system is dynamically created, using mixins (.generate-grid-columns() and .generate-grid-columns()) makes it impossible to :extend the bunch of classes (.col-sm-* and .col-lg-*).
One desirable advantage of :extending (over including mixins) is that the compiled output is far less bloated, as the original selectors are extended (ie. extending selectors are added as comma-separated selectors on the original rule). Compare that to including mixins, where a bunch of code is being duplicated on each include.

This would open the possibility of having another way of wring a cleaner (a.k.a "more semantic") HTML/CSS. I said "another way" because Bootstrap 3.0.0-wip currently provides
a way
to work with semantic classes when using the grid system. But, precisely, this current way is the one using mixins as included, generating a more bloated code than the approach that uses ':extend'.

To be realistic, I'm not sure if this will be easily achievable in tandem the way the current Bootstrap grid system names its classes ((.col-*-[1...n]).
The limitation imposed by this way of naming classes is probably the explanation behind why other new (and innovative) grid systems, like csswizardry-grids and Unsemantic took a different approach for naming classes, using fractions and/or percentages, which are far more verbose and less readable (particularly when using them directly in class="" attribute).
In that sense, Bootstrap's class names for grid system are... neat.

Let's see if we can come up with a few ideas on how to take advantage of the upcoming ':extend' (and also silent classes and silent imports) on LESS 1.4.0.

Complementary reads:

@maniqui
Copy link
Author

maniqui commented May 15, 2013

Some possible workarounds or solutions to investigate:

  • pre-compile your grid system, and then, copy the generated CSS (the list of rules using a .col-*-* selector) in a .less file that gets imported (ie. custom-grid.less). This is a somewhat acceptable solution on a project where the grid system is not going to change that often.
  • in a similar fashion, if there could be a way to have 2 sets of .less files to be compiled, where the second set includes the output (compiled) files of the first set, to be treated (imported) as .less files too. In other words, you first compile the grid system (and probably, other common .less assets, like the whole Bootstrap), and then, you import those compiled assets in a second set of .less files (the project's .less files). Like if doing a "second pass".

@mdo
Copy link
Member

mdo commented May 17, 2013

For now we won't be changing anything, but I might try to improve the way we do our grid classes in v3. We'll revisit any of this after 1.4 lands and things have settled.

@mdo mdo closed this as completed May 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants