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

scss-query

v1.0.1

Published

Simple and memorizeable @media queries helper function

Downloads

5

Readme

Scss Query

Simple and memorizeable @media queries helper function; build query strings defining a mode and a breakpoint name.

Example:

// Set custom breakpoints
$query-breakpoints: (
  'tall':    500px,
  'grande':  900px,
  'venti':  1400px
);

// @import query function

// Profit
@media (query(min, tall)) {
  body::before { content: "only at screens with a min-width of 500px"; }
}

Protip: Use @include query(init, $query-breakpoints) to (re)initialize query() function whenever you want. Refer to the API for an overview of all the available runtime manipulation mixins.

Installation

The recommended installation method is Bower but you can manually install query() function as well.

Install using Bower

$ bower install --save scss-query

Install via file download

You can always just download this repository into your project and @import it.

Usage

The initial example should cover pretty much everything there is to know for basic usage. But let's quick-start you even more:

with Bootstrap

// v4
$query-breakpoints: $grid-breakpoints;

// v3
$query-breakpoints: (
  'xs': $screen-xs-min,
  'sm': $screen-sm-min,
  'md': $screen-md-min,
  'lg': $screen-lg-min
);

with Foundation

// v6
$query-breakpoints: $breakpoints;

Function query( mode , size )

Parameter mode

Mode can be one of the following:

  • min - Min breakpoints
  • max - Max breakpoints
  • only - Min and max breakpoints

In case mode is max or only 1px will be substracted from max breakpoint value to prevent conflicting breakpoints. If breakpoint value is not in pixels, conversion will be handled trough a function named after breakpoint value unit – for em there is a fallback integrated.

If mode is only, max size will be next breakpoint in context.

Parameter size

Key in $query-breakpoints.

query() function ships with a list of common screen sizes as default breakpoints. These are just for a quick start and it is recommended to change them to fit your design.

Defaults

Defaults are in pixels. However, if you want to use another value like em you can do that too. Remember to set $query-breakpoints before importing query() function in order to overwrite the defaults.

$query-breakpoints: (
  'micro':   320px,
  'mini':    480px,
  'small':   768px,
  'medium':  960px,
  'large':  1440px,
  'huge':   2560px,
  'giant':  5120px
) !default;

API

The API allows for runtime manipulation of query() context. The following methods are provided as mixin via @include query($method, $args...):

| Method | Description |----------|------------ | add | Add a new breakpoint | remove | Remove an existing breakpoint | set | Set one or multible existing breakpoints at once | reset | Reset context (aka remove all breakpoints) | init | Initialise query function by passing a map | use | Use a breakpoint while in mixin's @content

See query/_api.scss for documentation on the individual mixins.

Contributing

As an open-source project, contributions are more than welcome, they're extremely helpful and actively encouraged. In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt. If you see any room for improvement, open an issue or submit a pull request.

License

This project is provided under the terms of the MIT License.


Authored by Nicolas Müller Noulezas · Github · Twitter · CodePen