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

sscreen

v0.0.5

Published

A scss library for working with custom media queries

Downloads

5

Readme

sscreen

A scss library for working with custom media queries

Install

npm i sscreen -D

Usage

The library consists of a mixin screen-set which lets you define your breakpoints and a function screen-get for retrieval as well as mixins screen-up and screen-down by which you actually make your stuff responsive.

Note: For getting sscreen to work in recent user-agents, @custom-media directives must be transpiled on top of scss compilation. See postcss-custom-media for further information

Here's a complete example...

// postcss.config.js
module.exports = {
  plugins: [
    require('postcss-custom-media')({
      preserve: true // For the sake of example, we preserve our transpiled @custom-media rules
    })
  ]
};
$screen-prefix: prefix-;
$screen-style: kebabCase;
$screen-breakpoint-delimiter: '-';

// Define your breakpoints
@include screen-set((
  xs: 0,
  sm: 576px,
  md: 768px,
  lg: 992px,
  xl: 1200px
));
// Grid.scss
.Grid {
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  margin: -1rem;
  box-sizing: border-box;
}
// GridItem.scss
.GridItem {
  padding: 1rem;
  box-sizing: border-box;
  $columns: 12;

  @each $breakpoint in map-keys(screen-get()) {
    $infix: screen-infix($breakpoint);

    @include screen-up($breakpoint) {
      @for $size from 1 through $columns {
        &--#{$infix}#{$size} {
          flex: 0 0 percentage($size / $columns);
          max-width: percentage($size / $columns);
        }
      }
    }
  }
}

Output:

@custom-media --prefix-xs-down (max-width: 575.98px);

@custom-media --prefix-sm-up (min-width: 576px);

@custom-media --prefix-sm-down (max-width: 767.98px);

@custom-media --prefix-md-up (min-width: 768px);

@custom-media --prefix-md-down (max-width: 991.98px);

@custom-media --prefix-lg-up (min-width: 992px);

@custom-media --prefix-lg-down (max-width: 1199.98px);

@custom-media --prefix-xl-up (min-width: 1200px);

.Grid {
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  margin: -1rem;
  box-sizing: border-box;
}

.GridItem {
  padding: 1rem;
  box-sizing: border-box;
}

.GridItem--1 {
  flex: 0 0 8.33333%;
  max-width: 8.33333%;
}

/* ... */

.GridItem--12 {
  flex: 0 0 100%;
  max-width: 100%;
}

@media (min-width: 576px) {
  .GridItem--sm-1 {
    flex: 0 0 8.33333%;
    max-width: 8.33333%;
  }
  /* ... */
  .GridItem--sm-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

@media (--prefix-sm-up) {
  .GridItem--sm-1 {
    flex: 0 0 8.33333%;
    max-width: 8.33333%;
  }
  /* ... */
  .GridItem--sm-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

@media (min-width: 768px) {
  .GridItem--md-1 {
    flex: 0 0 8.33333%;
    max-width: 8.33333%;
  }
  /* ... */
  .GridItem--md-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

@media (--prefix-md-up) {
  .GridItem--md-1 {
    flex: 0 0 8.33333%;
    max-width: 8.33333%;
  }
  /* ... */
  .GridItem--md-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

@media (min-width: 992px) {
  .GridItem--lg-1 {
    flex: 0 0 8.33333%;
    max-width: 8.33333%;
  }
  /* ... */
  .GridItem--lg-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

@media (--prefix-lg-up) {
  .GridItem--lg-1 {
    flex: 0 0 8.33333%;
    max-width: 8.33333%;
  }
  /* ... */
  .GridItem--lg-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

@media (min-width: 1200px) {
  .GridItem--xl-1 {
    flex: 0 0 8.33333%;
    max-width: 8.33333%;
  }
  /* ... */
  .GridItem--xl-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

@media (--prefix-xl-up) {
  .GridItem--xl-1 {
    flex: 0 0 8.33333%;
    max-width: 8.33333%;
  }
  /* ... */
  .GridItem--xl-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

Note: sscreen is intented for being used at application level and is currently not suited for being incorporated into a dedicated scss library

Development

In order to run specs, issue the following from your terminal:

npm test

Run dev-server

npm start

Create a build (for whatever purpose)

npm run build