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

rework-breakpoints

v0.6.0

Published

Adding a nice syntax for handling media query breakpoints for different devices for rework

Downloads

5

Readme

rework-breakpoints

NOTE Version v.0.5 uses min|max-width by default. To keep old behavior see Options below. Also the mixed syntax is new (see Example 5 below). NOTE Version v.0.6 uses screen instead of only screen by default. See Options below for how to keep old behavior.

Adding a nice syntax for handling media query breakpoints for different devices for the CSS Preprocessor rework.

Installation

npm install rework-breakpoints

Usage

An example of how to use rework-breakpoints:

var rework = require('rework'),
    breakpoints = require('rework-breakpoints');

var css = rework(cssString).use(breakpoints).toString();

Breakpoints plugin

Gives you a maintainable solution to handling media query breakpoints for different devices, with a syntax that's easy to remember.

A breakpoint is declared with: breakpoint-<name>: <type> <point> or breakpoint-<name>: <custom syntax>, where:

  • <name> - is the name for the breakpoint (to use in your media query)
  • <type> - values: min or max
  • <point> - the actual breakpoint value in px, em or rem
  • <custom syntax> - any breakpoint, e.g. screen and (orientation: landscape) and (max-width: 80em)

Note A breakpoint can be declared with var-breakpoint-<name> as well, for a valid CSS syntax.

Options

Available options are:

breakpoints-device

If set the type/point syntax will generate media queries with min|max-device-width instead of the default min|max-width.

Set it in your CSS like so:

:root {
  breakpoints-device: true; /* `yes` or `1` works as well */
  /* OR */
  var-breakpoints-device: true;
}

breakpoints-use-only

If set the type/point syntax will generate media queries with only screen instead of the default screen.

Set it in your CSS like so:

:root {
  breakpoints-use-only: true; /* `yes` or `1` works as well */
  /* OR */
  var-breakpoints-use-only: true;
}

Examples

Example 1 - max breakpoint

:root {
  breakpoint-mobile: max 340px;
}

@media mobile {
  /* all your mobile device styles goes here */
}

yields:

@media screen and (max-width: 340px) {
  /* styles... */
}

Example 2 - max breakpoint (using breakpoints-use-only option)

:root {
  breakpoints-use-only: true;
  breakpoint-mobile: max 340px;
}

@media mobile {
  /* all your mobile device styles goes here */
}

yields:

@media only screen and (max-width: 340px) {
  /* styles... */
}

Example 3 - min breakpoint (using var- prefix)

:root {
  var-breakpoint-desk: min 80em;
}

@media desk {
  /* all your desktop styles goes here */
}

yields:

@media screen and (min-width: 80em) {
  /* styles... */
}

Example 4 - multiple breakpoints (using breakpoints-device option)

:root {
  breakpoints-device: yes;
  breakpoint-palm: max 340px;
  breakpoint-tab: max 700px;
  breakpoint-desk: min 1000px;
  breakpoint-desk-wide: min 1200px;
}

@media palm {
  /* all your palm device styles goes here */
}
@media tab {
  /* all tablet styles */
}
@media tab-and-down {
  /* styles for tablets and smaller devices */
}
@media tab-and-up {
  /* styles for tablets and bigger screens */
}
@media desk-and-down {
  /* styles for desktops and smaller devices */
}
@media desk-and-up {
  /* styles for desktop and bigger screens */
}
@media desk-wide {
  /* styles for big screens */
}

yields:

@media screen and (max-device-width: 340px) {
  /* styles... */
}
@media screen and (min-device-width: 341px) and (max-device-width: 700px) {
  /* all tablet styles */
}
@media screen and (max-device-width: 700px) {
  /* styles for tablets and smaller devices */
}
@media screen and (min-device-width: 341px) {
  /* styles for tablets and bigger screens */
}
@media screen and (max-device-width: 1199px) {
  /* styles for desktops and smaller devices */
}
@media screen and (min-device-width: 1000px) {
  /* styles for desktop and bigger screens */
}
@media screen and (min-device-width: 1200px) {
  /* styles for big screens */
}

Example 5 - mixed breakpoints

:root {
  breakpoint-mobile: max 600px;
  breakpoint-landscape: (orientation: landscape);
}

@media mobile and landscape {
  body {
    color: #c00;
  }
}

yields:

@media screen and (max-width: 600px) and (orientation: landscape) {
  body {
    color: #c00;
  }
}

You get the point...

Unit tests

Make sure the dev-dependencies are installed, and then run:

npm test

Contributing

Feel free to contribute!

License

MIT