-
Notifications
You must be signed in to change notification settings - Fork 0
Code Formatting Sass
Adroaldo de Andrade edited this page Sep 29, 2014
·
2 revisions
- Do not use tabs, use four spaces instead
- Indentation should have 4 spaces
- Do not leave space at end of line
- Leave a space between name and start bracket
- At end of file leave a new line
- Leave a new line before each selector
- One selector per line, one rule per line
- List related properties together
- Zero does not need unit
- Avoid to use ID's
- Variablize all common numbers and colors
- List @extends first
- List regular styles next
- List @includes after those
- Try to nest up most 4 levels deep (Furder nest can increase load time of generated CSS file on page and do not reusable code)
- Try to keep a class under 50 lines to readability purposes
- Partials beggin with underscore (_) sign
- Break into small files as it make sense
- Use mapping to debug purposes
- Do not commit CSS files
stylesheets/
|
|-- modules/ # Common modules
| |-- _all.scss # Include to get all modules
| |-- _utility.scss # Module name
| |-- _colors.scss # Etc...
| ...
|
|-- pages/ # Specific project pages styles
| |-- _index.scss
| |-- _login.scss
| ...
|
|-- partials/ # Partials
| |-- _base.scss # Imports for all mixins + global project variables
| |-- _buttons.scss # Buttons
| |-- _figures.scss # Figures
| |-- _grids.scss # Grids
| |-- _typography.scss # Typography
| |-- _reset.scss # Reset
| ...
|
|-- vendor/ # CSS or Sass from other projects
| |-- _colorpicker.scss
| |-- _jquery.ui.core.scss
| ...
|
|-- _shame.scss # Store quick styles fixes to move to its right place another time
|
|-- main.scss # Primary Sass file
File with just imports without any css code
Import order
- Vendor
- Mixins
- Partials
- Modules
- Pages
- All common variables
- Frameworks utilities
- Include your own mixins