This is the folder structure and organize attributes neatly for newbie to learn about sass syntax.
sass/
|
|β abstracts/
| |β _variables.scss // Variables
| |β _functions.scss // Functions
| |β _mixins.scss // Mixins
|
|β base/
| |β _animation.scss // Animation
| |β _global.scss // Global define
| |β _fonts.scss // Fonts define
| |β _reset.scss // Reset/normalize
| |β _utilities.scss // utilities
|
|β components/
| |β _buttons.scss // Buttons
| |β _tabs.scss // Tabs
| |β _slider.scss // Slider
|
|β layout/
| |β _navigation.scss // Navigation
| |β _grid.scss // Grid system
| |β _header.scss // Header
| |β _footer.scss // Footer
| |β _sidebar.scss // Sidebar
| |β _forms.scss // Forms
|
|β pages/
| |β _home.scss // Home specific styles
| |β _about.scss // About specific styles
| |β _contact.scss // Contact specific styles
|
`β main.scss // Main SASS file
@import 'abstracts/variables';
@import 'abstracts/functions';
@import 'abstracts/mixins';
// Import library from node_modules
@import 'node_modules/jquery';
@import 'node_modules/bootstrap';
@import 'base/reset';
@import 'base/fonts';
@import 'base/animation';
@import 'base/global';
@import 'layout/grid';
@import 'layout/header';
@import 'layout/footer';
@import 'layout/navigation';
@import 'layout/sidebar';
@import 'layout/forms';
@import 'components/buttons';
@import 'components/tabs';
@import 'components/slider';
@import 'pages/home';
@import 'pages/about';
@import 'pages/contact';
@import 'base/utilities';
To help make the code cleaner and more organized, sorting the attributes according to a specific rule will help both yourself and others maintain it more easily. When this is done, your code will also be highly appreciated:
.component {
// Layout properties
display: flex;
justify-content: center;
align-items: center;
// Position properties
position: relative;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1;
// Box model properties
width: 100px;
height: 200px;
padding: 10px 0;
margin: 0 10px;
// Visual Properties
background: $white;
color: $primary;
border: 1px solid $dark-1;
border-radius: 10px;
outline: 0;
box-shadow: 0 5px 0 $white;
// Typography properties
font-family: $font-base;
font-size: $font-size-base;
font-weight: bold;
line-height: 1.5;
text-align: center;
text-transform: uppercase;
// Mics properties
cursor: pointer;
overflow: auto;
// CSS3 properties
transform: scale(2);
transition: all .3s;
// Pseudo class
&:hover {}
&:after {}
&:before {}
&:first-child {}
&:last-child {}
// Breakpoint sorted descending
@media screen and (max-width: 1200px) {}
@media screen and (max-width: 992px) {}
@media screen and (max-width: 767px) {}
// Selector
&__list {}
.selector {}
}
Selector should only write up to 3 levels, the more levels there are, the more limited the performance will be affected.
.section {
.list {
.items {
// STOP!
}
}
}