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 🙏

© 2024 – Pkg Stats / Ryan Hefner

sass-mix

v0.1.5

Published

Library of useful sass mixins

Downloads

41

Readme

Sass Mix

Library of useful sass mixins

Blending functions

These functions attempt to support the color blending Photoshop provides. All functions expect a color as the $foreground and $background colors. The colors can be any hex, rgb, rgba, hsl, or hsla color supported by Sass. Blending functions work by combining the colors from the top-most layer, the $foreground, with the lower layer, the $background.

NOTE: All blending and HSV functions were taken directly from scss-blend-modes, namespaced under mix-, and reordered to work without compass support.

  • mix-blend-normal( $foreground, $background ) - Normal is used primarily to preserve the opacity after the blending has been applied to the RGB values.
  • mix-blend-multiply( $foreground, $background )
  • mix-blend-lighten( $foreground, $background )
  • mix-blend-darken( $foreground, $background )
  • mix-blend-darkercolor( $foreground, $background ) - Not found in Photoshop.
  • mix-blend-lightercolor( $foreground, $background ) - Not found in Photoshop.
  • mix-blend-lineardodge( $foreground, $background )
  • mix-blend-linearburn( $foreground, $background )
  • mix-blend-difference( $foreground, $background )
  • mix-blend-screen( $foreground, $background )
  • mix-blend-exclusion( $foreground, $background )
  • mix-blend-overlay( $foreground, $background )
  • mix-blend-softlight( $foreground, $background )
  • mix-blend-hardlight( $foreground, $background )
  • mix-blend-colordodge( $foreground, $background )
  • mix-blend-colorburn( $foreground, $background )
  • mix-blend-linearlight( $foreground, $background )
  • mix-blend-vividlight( $foreground, $background )
  • mix-blend-pinlight( $foreground, $background )
  • mix-blend-hardmix( $foreground, $background )
  • mix-blend-colorblend( $foreground, $background )
  • mix-blend-dissolve( $foreground, $background ) - Not implemented. Dissolve treats transparency as a pixel pattern and applies a diffusion dither pattern.
  • mix-blend-divide( $foreground, $background )
  • mix-blend-hue( $foreground, $background )
  • mix-blend-luminosity( $foreground, $background )
  • mix-blend-saturation( $foreground, $background )
  • mix-blend-subtract( $foreground, $background )

Examples

// Solid background
.multiply {
  background-color: blend-multiply(#7FFFD4, #DEB887);
}

// RGBa background
.multiply {
  background-color: blend-multiply(rgba(#7FFFD4, 0.5), rgba(#DEB887, 0.5));
}

HSV Functions

These functions are used to convert between RGB, HSL and HSV color formats. The HSV color format is not natively supported by CSS or Sass. These functions were taken directly from this Gist. HSV values are used to calculate the results for the mix-blend-colorblend, mix-blend-hue, mix-blend-luminosity and mix-blend-saturation functions.

NOTE: As above, these are from scss-blend-modes.

  • mix-hsv-to-hsl( $h, [ $s: 0, $v: 0 ] ) - Converts a HSV color values into HSL color values. $h can be a list of three values representing $h, $s and $v.
  • mix-hsl-to-hsv( $h, [ $ss: 0, $ll: 0 ] ) - Converts a HSL color values into HSV color values. $h can be a list of three values representing $h, $ss and $ll.
  • mix-color-to-hsv( $color ) - Converts a Sass Color into a list HSV color values.
  • mix-hsv-to-color( $h, [ $s: 0, $v: 0 ] ) - Converts a list of HSV color values into a Sass Color. $h can be a list of three values representing $h, $s and $v

Center

Center transform an element on an axis. Doesn't include position absolute.

@include mix-center( [ x, y, xy ] )

Example

.container {
  position: relative;
  height: 500px;
  width: 500px;

  .centered {
    position: absolute;
    @include mix-center;
  }
}

Clearfix

Clearfix an element containing floats.

@include mix-clearfix

Example

.container {
  @include mix-clearfix;

  .float-left {
    float: left;
  }

  .float-right {
    float: right;
  }
}

Pick Visible Color

Returns the most visible colour for a given background.

@include mix-pick-visible-color( $foreground, $color-1, $color-2, )

Example

.panel__heading {
  color: mix-pick-visible-color($background-color, $black-text-color, $white-text-color);
}

Tint and Shade

Alternative to sass lighten and darken. Tint is a mix of color with white, shade is a mix of color with black.

mix-tint( $color, $percentage )

mix-shade( $color, $percentage )

Example

.background {
  background-color: mix-tint(red, 40%);
}

.background {
  background-color: mix-shade(blue, 60%);
}

Ellipsis

Truncate text and add an ellipsis

@include mix-ellipsis( [ $width: 100% ] )

Example

.panel__heading {
  @include mix-ellipsis(90%);
}

.panel__heading {
  // Defaults to 100%
  @include mix-ellipsis;
}

Viewport Units

Fix for vw, vh, vmin, vmax on iOS 7. Works by replacing viewport units with px values on known screen sizes.

@include mix-viewport-unit( $property, $value )

Example

.banner {
  @include mix-viewport-unit(height, 50vh);
}

HiDPI

Target high DPI devices.

NOTE: Default of 1.3 targets the Nexus 7. You can find more DPI ratios here.

@include mix-viewport-unit( [$ratio: 1.3] )

Example

.image {
  background-image: url("normal-dpi.png");

  @include mix-hidpi(1.5) {
    background-image: url("high-dpi.png");
  }
}

Smart Underline

Create a nice underline styling that is cut by the descendants

The background variable define the text-shadow that create the cut effect, it needs to be set to the background of the container.

@include smart-underline( [$background: #fff], [$text: #fff], [$hover: #00acb0]) )

Example

.container {
  background-color: black
}

.container .link {
  @include smart-underline(black, white, grey);
}

Image Shade

Add an image overlay

@mixin image-shade([$percent: 20%],[$color: #000]);

Example

.img {
  @include image-shade(50%, black);
}

Output

.img {
  position: relative;
}

.img:before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;

  background-color: rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

Aspect Ratio

Using psuedo elements to maintain an elements aspect ratio, even as it scales

@mixin aspect-ratio($width, $height);

Example

.sixteen-nine {
  @include aspect-ratio(16, 9);
}

Output

.sixteen-nine {
  position: relative;
}

.sixteen-nine:before {
  display: block;
  content: "";
  width: 100%;
  padding-top: 56.25%;
}

.sixteen-nine > .content {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

Reset input

Reset the style of an input field

@mixin reset-input();

Example

.text-input {
  @include reset-input();
}

Output

.text-input {
  -webkit-appearance: none;
  border-radius: 0 !important;
  background: transparent;
  outline: 0;
  border: 0;
}