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

piecewisecss

v1.7.8

Published

A SCSS @mixin for easy implementation of dynamic breakpoints.

Downloads

6

Readme

Seamless Media Queries Made Simple

PiecewiseCSS makes use of an intuitive responsive design pattern to make writing Sass for all screen sizes fast and easy.

main.scss

@import '../node_modules/piecewisecss/piecewise.scss';

h1 {
    @include piecewise(font-size, 24, 48, 480, 1200, !important);
}

The piecewise() mixin takes six arguments:

  1. a CSS property;
  2. the minimum
  3. and maximum desired values of that property (in px);
  4. the browser widths, beneath
  5. and above which those values will be applied;
  6. and an optional appender argument for values such as !important.

In the example above, the <h1> tag will have:

  • a font-size of 24px at browser width <= 480px;
  • a font-size of 48px at browser width >= 1200px;
  • between 480px and 1200px, the font-size will be scaled linearly with the browser width, resulting in a seamless, gradual breakpoint.

Global Breakpoint Variables

New in 1.4: Use global variables to keep your breakpoints consistent. Using one or both of the local screen width arguments will override these.

main.scss

$globalMin: 480px;
$globalMax: 1000px;

./some-other-file.scss

@import './main.scss';
.class {
    @include piecewise(padding: 0 5px, 20px);
}

Use as Breakpoint

New in 1.2: Invoke piecewise() to apply one-line media queries by using only the pxMin argument. In the example below, flex-basis will simply flip from 100% to 33% at 480px.

.class {
    @include piecewise(flex-basis, 100%, 33%, 480);
    @include piecewise(flex-direction, column, row, 480);
}

Note this is the only mode of piecewise() that supports non-px and string values.

@inversePiecewise()

New in 1.5: The @mixin inversePiecewise() provides you with the inverse value (100% - that value) of what piecewise() provides you. Say you want control of two divs that split the width of a parent:

.sidebar {
    @include piecewise(width, 100, 120, 480, 1000);
}
.window {
    @include inversePiecewise(width, 100, 120, 480, 1000);
}

In this example, .sidebar will adjust its width from 100px to 120px from view-widths 480px to 1000px, and the .window element will occupy the rest of the remaining space.

On, Off, On Again

New in 1.7: Invoke piecewise() to set three values at two breakpoints:

@include piecewise(display, none, inline, none, 650, 1000);

This element will be displayed inline between 650px and 1000px, and disappear otherwise.