Skip to content

ready to go sass boilerplate with gulp and autoprefixer

License

Notifications You must be signed in to change notification settings

aycanogut/sass-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

52 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

sass-boilerplate



image

Ready to use SASS boilerplate to develop web projects with gulp.js including SASS features like mixins, breakpoints, variables and normalize.css.

Gulp Features

Installation

yarn

yarn install

npm

npm install 

Structure

β”œβ”€ 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

Documentation

Adding a new .scss file

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.

Usage of abstracts folder

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 *;

Examples of @mixin functions

Breakpoints (Media Quaries)

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 rules:
@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;
  }
}
Compiles to:
@media only screen and (min-width: 36em){
  .torso{
    display:flex
  }
}

Grid

@mixin rules:
@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;
}
Compiles to:
.box {
  margin: 0 2% 2% 0;
  width: 23.5%;
  background-color: #32cd32;
  width: 100px;
  height: 100px
}

.box:nth-child(4n) {
  margin-right: 0
}

Container

@mixin rules:
@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);
}
Compiles to:
.container {
  width: 100%;
  padding-right: 20em;
  padding-left: 20em;
  margin-right: auto;
  margin-left: auto
}

Pseudo (Absolute positioning)

@mixin rules:
@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);
}
Compiles to:
.element {
  position: relative
}

.element::before {
  content: "content";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 1em;
  right: 2em
}

Transition

@mixin rules:
@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);
}
Compiles to:
.element {
  -webkit-transition: 1s all ease;
  -moz-transition: 1s all ease;
  -o-transition: 1s all ease;
  transition: 1s all ease
}

Box Shadow

@mixin rules:
@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));
}
Compiles to:
.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)
}

Example of font-weight

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;
 }

License

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.



About

ready to go sass boilerplate with gulp and autoprefixer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published