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-kit

v0.1.0

Published

A collection of Sass functions & mixins

Downloads

5

Readme

Sass Kit Build Status npm

A collection of Sass functions & mixins.

Install

npm install --save sass-kit

Usage

As these are functions and mixins they can all be imported and will only impact the size of the compiled CSS if used:

@import 'node_modules/sass-kit/index';

h1 { font-size: em( 24px ); }

Optionally, the utility CSS classes can be imported as well.
This will add to the size of the compiled CSS regardless of if they are used:

@import 'node_modules/sass-kit/index';
@import 'node_modules/sass-kit/util-classes';
<div class="u-cf">...</div>
<div class="u-visually-hidden">...</div>

API

See the source and tests for examples.

Functions

str-replace( $source: string, $find: string, $replace: string ) → string

String replacement

strip-units( $val: value ) → number

Remove units from a value

lower-bound( $range: array ) → number

Get the lower bound of an array

upper-bound( $range: array ) → number

Get the upper bound of an array

em( $px: value, $base: ?value ) → value

Convert a pixel value to ems

rem( $px: value, $base: ?value ) → value

Convert a pixel value to rems

image( $file: string, $raw: ?bool ) → url|string

Generate an image asset URL based on $asset-base-path

font( $file: string, $raw: ?bool ) → url|string

Generate an font asset URL based on $asset-base-path

color( $color: string, $tone: ?string ) → color

Get a value from the color palette

ls( $val: number ) → value

Convert Photoshop "tracking" to CSS letter spacing

nested-border-radius( $outer-size: value, $padding: value ) → value

Calculate correct nested border radii sizes

Mixins

rem( $property, $values )

Output dimensions as rem with px fallbacks

inline-block( $alignment: ?value )

Cross browser inline block

opacity( $opacity: number )

Cross browser opacity

ir

Image replacement #1

font-crush

Image replacement #2

cf

Clearfix

hidden

Hide from both screenreaders and browsers

visually-hidden( $focusable: ?bool )

Hide only visually, but have it available for screenreaders

invisible

Hide visually and from screenreaders, but maintain layout

text-ellipsis

Text overflow ellipsis

hyphenate

Hyphenate long words

momentum-scroll

iOS smooth momentum scrolling

font-smoothing( $value: ?string )

Text antialiasing

antialiased

Adjust font rendering of light text on dark backgrounds in Chrome on macOS

no-click

Prevent an element from being clickable and allow the click to pass through to the element below

cover

Cover an element

alpha-attribute( $attribute, $color, $background )

Generates a fallback for alpha colors based on the background & foreground colors

font-face( $name: string, $path: string, $weight: ?value, $style: ?value: $exts: ?list )

Generate all the necessary font-face properties

vertical-center-legacy( $content-el: string )

Vertical centering for legacy browsers

vertical-center( $includeWidth: ?bool )

Easy vertical centering of anything in IE9+

center( $includeWidth: ?bool )

Easy horizontal & vertical centering of anything in IE9+

center-block

Center block level content

responsive-background-image( $width: value, $height: value, $url: ?value, $size: ?value )

Responsive background images that maintain their aspect ratio

media-object( $spacing: ?bool )

Media object pattern

fluid-embed

Makes media embeds maintain a fixed aspect ratio but adapt to the width of their parent container

Responsive

Responsive / media query helpers.

Usage

Basic

An em Sass function is required to convert px values to ems. You can provide one or import the included functions/em file as well:

@import 'node_modules/sass-kit/functions/em';
@import 'node_modules/sass-kit/mixins/responsive';

p {
	color: black;

	@include below( 320px ) {
		color: red;
	}

	@include between( 480px, 500px ) {
		color: cyan;
	}

	@include above( 720px ) {
		color: orange;
	}

	@include landscape() {
		color: green;
	}

	@include portrait() {
		color: blue;
	}
}

Without conversion

Don't convert the media queries to ems:

@import 'node_modules/sass-kit/mixins/responsive';

p {
	color: black;

	@include below( 320px, $convert: false ) {
		color: red;
	}

	@include between( 480px, 500px, $convert: false ) {
		color: cyan;
	}

	@include above( 720px, $convert: false ) {
		color: blue;
	}
}

Dimensions other than width

@import 'node_modules/sass-kit/functions/em';
@import 'node_modules/sass-kit/mixins/responsive';

p {
	@include above( 720px, height ) {
		color: cyan;
	}
}

Keywords

You can also use predefined keywords, to do so create a map called $breakpoints:

@import 'node_modules/sass-kit/functions/em';
@import 'node_modules/sass-kit/mixins/responsive';

// these are the predefined keywords which you can overwrite
$breakpoints: (
	small  : 320px,
	medium : 640px,
	large  : 1024px,
	xlarge : 1440px,
	xxlarge: 1920px,
);

p {
	@include above( medium ) {
		color: cyan;
	}
}

API

The following mixins are available:

break( $type: string, $from: value, $to: ?value, $dimension: ?string, $convert: bool )

The base mixin.

$type
Breakpoint type, one of 'above', 'below', 'between'.

$from
Breakpoint start.

$to
Default: false
Breakpoint end, only required for $type: 'between'.

$dimension
Default: 'width'
Breakpoint dimension, one of 'width', 'height'.

$convert
Default: true
Convert px based $from & $to values to ems.

below( $size: value, $dimension: ?string, $convert: ?bool )

Include styles below $size.

above( $size: value, $dimension: ?string, $convert: ?bool )

Include styles above $size.

between( $from: value, $to: value, $dimension: ?string, $convert: ?bool )

Include styles between $from & $to.

landscape()

Include styles in landscape orientation.

portrait()

Include styles in portrait orientation.