studiometa / scss-toolkit

A small and configurable SCSS Toolkit to boost your project! 🚀
MIT License
5 stars 0 forks source link

Adding helpers for positioning #30

Closed notjb closed 5 years ago

notjb commented 5 years ago

What about having helpers for positioning ? Draft.scss ⬇️

/*============================================================================*\
  Position helpers
\*============================================================================*/

/** @type {Boolean} Do we need classes? */
$has-classes: false !default;

/*============================================================================*\
  Relative
\*============================================================================*/

@if $has-classes {
  .relative {
    position: relative;
  }

  @include for-each-breakpoints using ($breakpoint) {
    .relative--#{$breakpoint} {
      position: relative;
    }
  }
}

/*============================================================================*\
  Absolute
\*============================================================================*/

@if $has-classes {
  .absolute {
    position: absolute;
  }

  @include for-each-breakpoints using ($breakpoint) {
    .absolute--#{$breakpoint} {
      position: absolute;
    }
  }
}

/*============================================================================*\
  Initial
\*============================================================================*/

@if $has-classes {
  .static {
    position: static;
  }

  @include for-each-breakpoints using ($breakpoint) {
    .static--#{$breakpoint} {
      position: static;
    }
  }
}

/*============================================================================*\
  Fixed
\*============================================================================*/

@if $has-classes {
  .fixed {
    position: fixed;
  }

  @include for-each-breakpoints using ($breakpoint) {
    .fixed--#{$breakpoint} {
      position: fixed;
    }
  }
}

/*============================================================================*\
  Fixed
\*============================================================================*/

@if $has-classes {
  .sticky {
    position: sticky;
  }

  @include for-each-breakpoints using ($breakpoint) {
    .sticky--#{$breakpoint} {
      position: sticky;
    }
  }
}
titouanmathis commented 5 years ago

Thanks for the proposal! 👍

Actually, we already have helpers for position generating the following classes by default :

And you can add more by setting the $positions variable in your configuration :

$positions: (sticky, static, relative, absolute);

See src/framework/_positions.scss for more details.

There is an open issue (#28) to complete the documentation with the missing elements such as these helpers, your help is more than welcome! 😉