Learning Sass
I am starting the learning process with Sass and I have decided to apply the concepts after learning PostCSS, automating the compilation to css with Gulp.
I have learnt the basis with Learn Sass - Codecademy:
- Unit 1. Create a Sass stylesheet: It explains the compilation process, nesting selectors and variables.
- Unit 2. Mixins and the & selector: The & selector in nesting, mixins and mixins with arguments and string interpolation for mixins.
- Unit 3. Functions and operators: Arithmetic and color functions, each-loop, for-loop and conditional.
- Unit 4. Sustainable SCSS: Structure, @import, organize with partials, @extend, placeholders and @extend vs @mixin.
I think this course is a good method to learn about Sass, but you need to apply it in real projects to retain the concepts.
I have also read an article for best practices: 8 Tips to Help You Get the Best out of Sass:
- Structure your Sass: Use a correct structure, use partials.
- Use Sass variables more effectively: Variables for colors and then variables to use the colors in the scss file (link-primary or primary-color).
- Reduce mixin usage: Including a mixin is the same as copying and pasting the styles throughout the CSS file. Use it only if an argument is present.
- Embrace placeholders: Placeholders can be used multiple times without adding any duplicate code.
- Use functions for calculations
- Order your work
- Limit Nesting: Never go more then 3 levels deep, ensure the CSS output is clean and reusable and use nesting when it makes sense to, not as a default option.
- Keep things simple: The purpose of Sass is to write cleaner more manageable CSS.
Do you have any recommendations to learn more about Sass?
Written on June 26, 2016