npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@sfem/scss-sugars

v2.0.0

Published

Simple scss mixins and functions.

Readme

sfem.scss-sugars

Useful SCSS functions and mixins.

Settings

$mq-generator-mod-prefix: '--'; // for media query helpers className
$mq-generator-val-prefix: '-'; // for media query helpers className

$sugar-text-contrast-dark: #000; // default dark for contrast checking
$sugar-text-contrast-light: #fff; // default light for contrast checking

$sugar-text-font: 'Roboto', sans-serif; // defaults for typo()
$sugar-text-size: 1rem; // defaults for typo()
$sugar-text-line-height: 1.5rem; // defaults for typo()
$sugar-text-weight: normal; // defaults for typo()

Functions

// strip-unit

strip-unit(10px) // 10
// convert-unit

convert-unit(10) // 10px
convert-unit(10, em) // 10em
convert-unit(10px, em) // 10em
// to-string

to-string(10) // 10 as string
to-string(10) + 10 // 1010
// rem

rem(10px) // 0.625rem
// color functions

luminance($color);
contrast($back, $front);
get-contrast-color($color, $light, $dark); // return contrast $light or $dark for $color
// letter spacing
// Tracking from Sketch / font size in px = letter spacing

letter-spacing($tracking, $font-size)
// typo
// helper for font definition

typo($font-size, $line-height, $weight, $font) // all params have defaults 
// deep-map-merge
// non destructive multilevel map merging

deep-map-merge($list1, $list2)
// str-replace

str-replace('foo bar', 'foo ', '') // bar

Mixins

// mq-generator
// generate @media helpers

.foo {
  @include mq-generator() {
    color: green;
  }
}

// to

.foo {
  color: green;
}

@media all and (min-width: 576px) {
  .foo-sm {
    color: green;
  }
}
@media all and (min-width: 768px) {
  .foo-md {
    color: green;
  }
}

// ================

.foo {
  @include mq-generator(bold) {
    font-weight: bold;
  }
}

// to

.foo--bold {
  font-weight: bold;
}

@media all and (min-width: 576px) {
  .foo--bold-sm {
    font-weight: bold;
  }
}
@media all and (min-width: 768px) {
  .foo--bold-md {
    font-weight: bold;
  }
}

// ====================

@for $i from 1 through 2 {
  .foo {
    @include mq-generator(order, $i) {
      order: $i;
    }
  }
}

// to

.foo--order-1 {
  order: 1;
}
@media all and (min-width: 576px) {
  .foo--order-sm-1 {
    order: 1;
  }
}
@media all and (min-width: 768px) {
  .foo--order-md-1 {
    order: 1;
  }
}
.foo--order-2 {
  order: 2;
}

@media all and (min-width: 576px) {
  .foo--order-sm-2 {
    order: 2;
  }
}
@media all and (min-width: 768px) {
  .foo--order-md-2 {
    order: 2;
  }
}
// box

.foo {
  @include box(10px);
}
.bar {
  @include box(10px, 20px);
}

// to

.foo {
  width: 10px;
  height: 10px;
}

.bar {
  width: 10px;
  height: 20px;
}
// aspect-padding

.foo {
  @include aspect-padding(3, 2);
}

// to

.foo {
  width: 100%;
  padding-top: 66.6666666667%;
}
// aspect-ratio

.foo {
  @include aspect-ratio(3, 2 [, position]);
}

// to

.foo {
  position: relative;
}
.foo:before {
  width: 100%;
  padding-top: 66.6666666667%;
  display: block;
  content: "";
}
// box-fill
// each prop can be pass to mixin

.foo {
  @include box-fill();
}

// to

.foo {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  position: absolute;
}
// center-block

.foo {
  @include center-block();
}
.bar {
  @include center-block(transform);
}
.baz {
  @include center-block(position);
}

// to

.foo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.bar {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.baz {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  position: absolute;
  margin: auto;
}
// ellipsis

.foo {
  @include ellipsis();
}

// to

.foo {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
// break-word

.foo {
  @include break-word();
}

// to

.foo {
  word-wrap: break-word;
  word-break: break-all;
  overflow-wrap: break-word;
}
// color-mods

$colors: (
  red: #D62237,
  orange: #FF7213
);

// -------

.foo {
  @include color-mods($colors)
}

// to

.foo--color-red {
  color: #D62237;
}
.foo--color-orange {
  color: #FF7213;
}
@media all and (min-width: 576px) {
  .foo--color-sm-red {
    color: #D62237;
  }
  .foo--color-sm-orange {
    color: #FF7213;
  }
}
// etc

// =============

.foo {
  @include color-mods($colors, bg)
}

// to

.foo--bg-red {
  background-color: #D62237;
}
.foo--bg-orange {
  background-color: #FF7213;
}
@media all and (min-width: 576px) {
  .foo--bg-sm-red {
    background-color: #D62237;
  }
  .foo--bg-sm-orange {
    background-color: #FF7213;
  }
}
// etc

// =============

.foo {
  @include color-mods($colors, $disable-bp: true)
}

// to (without media queries)

.foo--color-red {
  color: #D62237;
}
.foo--color-orange {
  color: #FF7213;
}

// =============

.foo {
  @include color-mods($colors, $type: bg, $alter-text: true, $disable-bp: true)
}

// to

.foo--bg-red {
  background-color: #D62237;
  color: #000;
}
.foo--bg-orange {
  background-color: #FF7213;
  color: #fff;
}
// mq-font

$fonts: (
  default: '16px Roboto, sans-serif',
  sm: '16px Roboto, sans-serif',
  md: '22px Roboto, sans-serif'
);

.foo {
  @include mq-font($fonts);
}

// to

.foo {
  font: 16px Roboto, sans-serif;
}
@media all and (min-width: 576px) {
  .foo {
    font: 16px Roboto, sans-serif;
  }
}
@media all and (min-width: 768px) {
  .foo {
    font: 22px Roboto, sans-serif;
  }
}