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

pxsmlx

v1.0.1

Published

An adaptable, concise SCSS mixin library for generating nested media queries.

Downloads

6

Readme

pxsmlx

ˈpɪks mɪlks'

A mixin library to make writing responsive CSS simple.

About

Do you nest media queries inside elements in SCSS, but get sick of writing out media queries for small responsive changes, especially if you need multiple? This is a set of mixins designed to reduce that work by condensing it down to as concise a syntax as possible, by baking in some assumptions.

pxsmlx is opinionated — it only uses min-width queries and Bootstrap breakpoints (plus an extra one at 1440px). But it allows you to write complex sets of media queries much more quickly.

  // You write...
  div.responsive {
    @include pxsmlx(width, 100px, 200px, 300px, 400px, 500px);
  }

  // And it generates...
  div.responsive {
    width: 100px;
  }
  @media (min-width: 576px) {
    div.responsive {
      width: 200px;
    }
  }
  @media (min-width: 768px) {
    div.responsive {
      width: 300px;
    }
  }
  @media (min-width: 992px) {
    div.responsive {
      width: 400px;
    }
  }
  @media (min-width: 1200px) {
    div.responsive {
      width: 500px;
    }
  }

Installation

  $ npm i pxsmlx

Usage

  @import '~/node_modules/pxsmlx/pxsmlx';

pxsmlx stands for property, xs, sm, md, lg, and xl. It's a shorthand to help you remember the mixin arguments. You can use any combination of breakpoints within that set: pxsm, psm, psmlx, etc.

First, set your breakpoints, if they differ from the default Bootstrap breakpoints. They're the variables at the top.

$mixin-sm-min-width: 768px;
$mixin-md-min-width: 992px;
$mixin-lg-min-width: 1200px;
$mixin-xl-min-width: 1440px;

A note about code size

This library adds media queries that contain a single selector, which may inflate the size of your CSS versus combining them. Available evidence, however, indicates that if you serve your files with Gzip the difference is negligible because of the repetitive nature of media queries allowing Gzip to mostly nullify their weight.

If you're still concerned, you can use a tool like PostCSS MQPacker to combine media queries at compile time. This may cause problems if you're doing a lot of overwriting down the cascade, instead of using a low-specificity methodology like BEM or Atomic CSS (which is recommended).

Ultimately, you have to determine whether the extra bytes are a tradeoff worth making. You may find that the most efficient way to use pxsmlx is selectively, when you need to inject a set of breakpoint styles for a single property here and there. If you're changing several properties at once, you may be better off writing a normal media query rather than including a pxsmlx mixin several times in a row.

License