|
|
|
|
|
by Partyfists
4360 days ago
|
|
Of course! The idea behind using preprocessors is helping you write CSS more easily. The goal is not to write obfuscated CSS, but rather to write CSS well! What it really enables (imo) is to think of styling in an Object Oriented way. Whenever you're about to write a block of Sass think "What is this thing?". The answer is almost never a "green button" but rather "getting started button". Or something like that. It also helps you to think in terms of inheritance: The "getting started button" and "buy button" are both interaction buttons. (Similar buttons, but one is green and the other is yellow). In Sass you represent that this way:
1. Placeholder %interaction-button class where you outline the fact that it has a border radius, color, and any other shared styling.
2. A button maker mixin where you put the colors that need to be changed, and any other flags (like has_sub_text: true for the unbold text) and then @extend's the placeholder above.
3. The classes ".buy-button {}" which include the mixin you made. |
|
Also, is there a good place I can learn these kind of things? I'm a programmer trying to get better at CSS (SCSS now that we've setup the asset pipeline)—so far I've been reading random A List Apart and The Sass Way articles, but I feel like I could use a more holistic, in-depth understanding of CSS if there's a good book out there for that.