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

reflow-breakpoints

v1.0.1

Published

reflow is a JS and SCSS responsive breakpoint library that makes it easy to build UI that flows across any device 🥊 ✨

Downloads

5

Readme

reflow

  • Abstracts away the complexity of media queries
  • Bring your own framework
  • Very little overhead
  • Zero configuration, just use it
  • Does one thing and does it well

Installation

You can install reflow on the JS side or SCSS side. You might want one or both depending on how complex your frontend app is.

JavaScript

On the JS side of things, you can install via npm or just add a script tag.

With a bundler:
npm install reflow-breakpoints

And then import it at some root-level file in your project. Make sure this file runs in the browser and not in node.

import 'reflow-breakpoints'

For example, in a Vue project you could import reflow in the main.js file.

No bundler:
You can also simply add a script tag to your HTML to load it from a CDN or your own server. For script tags, don't load it as an ES module because you'll want the reflow object to be available globally.


SCSS

Using reflow in SCSS requires that the _variables.scss and _mixins.scss files get imported wherever you want to use the reflow SCSS mixin. Make sure to import variables first, and then mixins

// In webpack you might need to prepend a ~ (tilde) to indicate reflow is a module
@import 'reflow-breakpoints/scss/variables';
@import 'reflow-breakpoints/scss/mixins';

Depending on your project, you might be able to do these imports globally, or might need to prepend these imports to every file. If you are using SvelteKit for example, you can prepend the above snippet into every <style lang="scss"> block automatically using svelte-preprocess.

Check your framework's and/or bundler's docs to see how preprocessing can be done in your project, if you don't have a way of importing SCSS files globally.


Usage

Now, time for the easy part.

Breakpoint Thresholds

| Device | Code | Type | Range | |-------------|------|---------------------------|--------------------| | Extra small | xd | Small to large phone | < 600px | | Small | sm | Small to medium tablet | 600px > < 960px | | Medium | md | Large tablet to laptop | 960px > < 1280px | | Large | lg | Desktops and most laptops | 1280px > < 1920px | | Extra large | xl | 4k and ultra-wide | > 1920px |


JavaScript

reflow will declare a reflow object globally. For something as core to your app as responsive breakpoints, you'll want reflow accessible from anywhere.

// 👇 These are all the same
reflow
window.reflow
globalThis.reflow

You get to import once, and use everywhere. Normally you'd want code-splitting to use a module only where necesarry, but again responsive breakpoints will be used throughout your entire app so the global var will come in handy.

// TODO: Refer to offten codebase and put some JS examples
reflow.

SCSS


@import 'reflow-breakpoints/scss/variables';
@import 'reflow-breakpoints/scss/mixins';

.my-div-element {
    /* Base styles go here */
    height: 200px;

    /* Overrides for if the device has an 'lg' screen */
    @include reflow('lg-only') {
        height: 150px;
    }

    /* Overrides for if the device is considered as 'mobile'. Same as md-and-down */
    @include reflow('mobile') {
        height: 100px;
    }
}

Available breakpoints for the reflow SCSS mixin:

  • print-only
  • screen-only
  • mobile (same as md-and-down)
  • xs-only
  • sm-only
  • sm-and-down
  • sm-and-up
  • md-only
  • md-and-down
  • md-and-up
  • lg-only
  • lg-and-down
  • lg-and-up
  • xl-only