AWESOME BITS
- We can use constants for z-indexes to prevent the endless desire of devs to make them higher forever. z-index: @z-modal > z-index: 999999999
- Separate .less files for each UI widget makes for awesome code organization. This is HUGE!
- Makes CSS3 browser prefixes a little more manageable.
- Using variables for color names makes it a lot easier to make sure you're on the same page with a designer.
- CSS code re-use FTW!
- Mixins are okay.
NOT-SO AWESOME BITS
- Weird issue with using the @arguments variable where there are commas. (See: https://github.com/cloudhead/less.js/issues/301)
- connect-less initially had some trouble including files with includes inside them, but I think it's fixed now.
- It would be really nice to be able to just include a full directory instead of manually including all x number of files (within the widgets directory for example) manually.
- LESS doesn't encouraged any specific structure or good patterns, which is fine, but you sometimes get really excited about using the nesting feature, because it seems so convenient and clean, but it can actually can make your code less re-usable if you don't do it right.
LESS is pretty awesome. However I have found that it doesn't handle errors very well, the node module will just crash the server if you try to reference a variable that doesn't exist.
ReplyDeleteI agree with your last point that you need to be careful with nesting because you can end up generating a bunch of inefficient selectors.
One thing that I fell a lot of people don't realize is that you don't need LESS/SASS/Stylus to be able to split your CSS files into smaller modules. You just need a compiler which combines all the CSS files together. HTML5-Boilerplate has a build script that inlines all the `@import` and the RequireJS optimizer as well. You could even use the LESS/SASS/Stylus compiler just for that feature.
ReplyDelete"Find and replace" inside a project folder in many cases are more than enough to make sure values are synchronized, no need for constants.
But at the end of day what really matters is if the tool is helping you to be more productive or not. If you find that LESS is a good tool for the job than you should definitely use it, but we should always question once in a while if the tools are indeed necessary/helpful and if there is a "better" approach.
Cheers.
PS: @Rob the nesting isn't bad because of performance but because it can create specificity problems, making it hard to overwrite a rule.