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

@lamansky/mq

v1.0.0

Published

A library of media query mixins for Sass.

Downloads

2

Readme

mq

A library of media query mixins for Sass.

Installation and Usage

If you have Node.js installed, you can add this module to your project using npm:

npm i @lamansky/mq

Assuming you’re using webpack for your project, include the module into your own Sass/SCSS stylesheet like so:

@use "~@lamansky/mq";

Functions

The mq library includes three functions.

dark

Tests for a dark-mode media query.

@use "~@lamansky/mq";

body {
  background: white;
  color: black;

  @include mq.dark {
    background: black;
    color: white;
  }
}

This function also adds the classes necessary for a manual JavaScript-powered dark-mode/light-mode toggle. The default settings are:

@use "~@lamansky/mq" with (
  $color-scheme-override-root: 'html',
  $dark-class: 'dark-mode',
  $default-color-class: 'default-color-mode',
  $light-class: 'light-mode',
);

With these defaults, your dark-mode styles can be triggered by adding a dark-mode class to the html element.

If the dark-mode styles are already active as a result of the media query, the dark-mode styles can be manually disabled by adding a light-mode or default-color-mode class to the html element.

light

Tests for a light-mode media query (useful for stylesheets that go with a dark default).

@use "~@lamansky/mq";

body {
  background: black;
  color: white;

  @include mq.light {
    background: white;
    color: black;
  }
}

This function also adds the classes necessary for a manual JavaScript-powered light-mode/dark-mode toggle. The default settings for this are:

@use "~@lamansky/mq" with (
  $color-scheme-override-root: 'html',
  $dark-class: 'dark-mode',
  $default-color-class: 'default-color-mode',
  $light-class: 'light-mode',
);

With these defaults, your light-mode styles can be triggered by adding a light-mode class to the html element.

If the light-mode styles are already active as a result of the media query, the light-mode styles can be manually disabled by adding a dark-mode or default-color-mode class to the html element.

width

Creates a media query that tests whether the viewport width is between two given multiples of a certain measurement. By default, this multiple is 160px.

@use "~@lamansky/mq";

body {
  font-size: 14px;

  @include mq.width(6) { // Viewport is at least 160px * 6 = 960px
    font-size: 16px;
  }
}

.sidebar {
  float: right;

  @include mq.width(0, 4) { // Viewport is less than 160px * 4 = 640px
    float: none;
  }
}

.menu {
  li {
    padding-left: .5em;
    padding-right: .5em;

    @include mq.width(4, 6) {
      padding-left: 1em;
      padding-right: 1em;
    }

    @include mq.width(6) {
      padding-left: 1.5em;
      padding-right: 1.5em;
    }
  }
}

For a "greater than" query, omit the second argument. For a "less than" query, set the first argument to zero.

You can customize the settings for this function using the with keyword:

@use "~@lamansky/mq" with (
  $scrollbar-padding: 0px,
  $width-step: 160px,
);

If you set a $scrollbar-padding, it will be subtracted from all viewport width measurements in the resulting media queries.

Related

  • styles: A small library of commonly-used stylesheet rules, packaged as a Sass module.