Ready to use SASS boilerplate to develop web projects with gulp.js including SASS features like mixins, breakpoints, variables and normalize.css.
yarn install
npm install
ββ dist
β ββ index.css
β ββ index.css.map
| ββ script.js
| ββ script.js
ββ src
β ββ assets
β ββ images
β β ββ tech-stack.png
β ββ js
β β ββ script.js
β ββ styles
β ββ abstracts - Breakpoints, variables, functions and mixin values.
β β ββ _breakpoint.scss
β β ββ _fonts.scss
β β ββ _functions.scss
β β ββ _index.scss
β β ββ _mixin.scss
β β ββ _variables.scss
β ββ base - Base styles and typography rules.
β β ββ _base.scss
β β ββ _index.scss
β β ββ _typo.scss
β ββ components - All the components.
β β ββ _components.scss
β β ββ _index.scss
β ββ layout - Styles of page elements like navigation bar, header, footer etc.
β β ββ _footeer.scss
β β ββ _grid.scss
β β ββ _header.scss
β β ββ _index.scss
β β ββ _layout.scss
β β ββ _nav.scss
β β ββ _sidebar.scss
β ββ pages - Specific styles for different pages.
β β ββ _home.scss
β β ββ _index.scss
β ββ themes - Specific themes like admin page, dark mode etc.
β β ββ _admin.scss
β β ββ _index.scss
β β ββ _theme.scss
β ββ vendors - Store all helper utilities like normalize.css, Bootstrap etc.
β ββ _breakpoint.scss
β ββ _index.scss
β ββ _normalize.scss
β
β
ββ .gitignore
ββ .gulpfile.js
ββ index.html
ββ LICENSE
ββ package.json
ββ README.md
ββ yarn.lock
When a new file created in any directory, the name of the file should be @forward to the index.scss on the same directory. It won't compile into the main.scss file otherwise.
Pass the abstracts folder as a global value at the start of any.scss file if you wish to utilize the mixin, variables, or breakpoints.
@use '../abstracts/' as *;
Edit the breakpoints object as you wish.
$breakpoints: (
small: 36em,
medium: 47em,
large: 75em,
);
Use the SASS @mixin and @include functions to define and apply the breakpoints.
@mixin mq($args) {
$size: map-get($breakpoints, $args);
@media only screen and (min-width: $size) {
@content;
}
}
Apply @include function to any class.
.some-content {
@include mq(small) {
display:flex;
}
}
@media only screen and (min-width: 36em){
.torso{
display:flex
}
}
@mixin grid($cols, $marg) {
margin: 0 $marg $marg 0;
width: ((100% - (($cols - 1) * $marg)) / $cols);
&:nth-child(#{$cols}n) {
margin-right: 0;
}
}
Apply @include function to any class. First argument is a grid number (1-12), second one is for spacing.
.box {
@include grid(4, 2%);
background-color: limegreen;
width: 100px;
height: 100px;
}
.box {
margin: 0 2% 2% 0;
width: 23.5%;
background-color: #32cd32;
width: 100px;
height: 100px
}
.box:nth-child(4n) {
margin-right: 0
}
@mixin make-container($padding-x: $container-padding-x) {
width: 100%;
padding-right: $padding-x;
padding-left: $padding-x;
margin-right: auto;
margin-left: auto;
}
Apply @include function to a container or wrapper element.
.container {
@include make-container(20em);
}
.container {
width: 100%;
padding-right: 20em;
padding-left: 20em;
margin-right: auto;
margin-left: auto
}
@mixin pseudo(
$loc: before,
$content: "",
$pos: absolute,
$top: 0,
$bottom: 0,
$left: 0,
$right: 0
) {
position: relative;
&::#{$loc} {
content: $content;
position: $pos;
top: $top;
bottom: $bottom;
left: $left;
right: $right;
@content;
}
}
Apply @include function to an element and define arguments in the order of mixin declaration.
.element {
@include pseudo(before, "content", absolute, 0, 0, 1em, 2em);
}
.element {
position: relative
}
.element::before {
content: "content";
position: absolute;
top: 0;
bottom: 0;
left: 1em;
right: 2em
}
@mixin transition($args) {
-webkit-transition: $args;
-moz-transition: $args;
-o-transition: $args;
transition: $args;
}
Apply @include function to an element and it will compiles the autoprefixer rules for cross browser compatibility.
.element {
@include transition(1s all ease);
}
.element {
-webkit-transition: 1s all ease;
-moz-transition: 1s all ease;
-o-transition: 1s all ease;
transition: 1s all ease
}
@mixin box-shadow($args) {
-webkit-box-shadow: $args;
-moz-box-shadow: $args;
box-shadow: $args;
}
Apply @include function to an element and it will compiles the autoprefixer rules for cross browser compatibility.
.element {
@include box-shadow(0px 10px 15px -3px rgba(0, 0, 0, 0.1));
}
.element {
-webkit-box-shadow: 0px 10px 15px -3px rgba(0, 0, 0, .1);
-moz-box-shadow: 0px 10px 15px -3px rgba(0, 0, 0, .1);
box-shadow: 0px 10px 15px -3px rgba(0, 0, 0, .1)
}
Edit the font-weight object as you wish.
$font-weight: (
"regular": 400,
"semi-bold": 500,
"bold": 700,
);
Use the SASS map-get function to choose the font-weight.
font-weight: map-get($font-weight, bold);
Compiles to:
h1 {
font-weight: 700;
}
Licensed under the MIT license, see LICENSE for details.
I took some of the @mixin patterns from Kevin Powell's Github page. Check his Youtube Channel for great information.