Hacker News new | ask | show | jobs
by jenius 4995 days ago
If you are looking for more power, you can use mixins rather than extends. This way, you do get an additional and very signficant power boost - what previously were utility classes are now functions, which take parameters and have the ability to adapt and flex if you write them correctly.
1 comments

Yup, I've been using mixins for a while now to reduce code bloat. It seems like placeholders are degenerate forms of mixins.

edit After more reading, they are most definitely not degenerate forms of mixins. Placeholders FTW!

The one advantage that extends provides is less code bloat (if you use them right) in the compiled product - rather than inserting the same code, extends will add the select to the list with the previous selector. So if you were to write something like this:

.hello { color: red; }

.world { @extends .hello; background: blue }

...it would compile to something like this:

.hello, .world { color: red; }

.world { background: blue; }

na'mean?

I'm picking up what you're putting down, but I was thinking more placeholders vs. mixins. Although I guess placeholders would avoid this code bloat too, and they can be used as selectors.