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

grid-in-js

v0.1.4

Published

Make a reliable CSS Grid framework at the snap of a function.

Downloads

15

Readme

Grid-in-JS

Make a reliable CSS Grid framework at the snap of a function.

Table of Contents

Benefits

Subgrid 🔥

HTML isn’t written one layer deep. A great grid framework should allow you to embed divs within divs, but still remember how many columns are available. Without subgrids, users of your grid framework are prone to accidently break out of your design spec.

Progressive Enhancement 📉

Different experiences have different browser requirements based on the users visiting. Your grid framework should also be performant with the smallest amount of code needed. With this project’s fine-tuned browser compatibility settings, you can support the right browser versions with as little grid code as possible.

JavaScript? 🤔

The truth is that the name Grid-in-JS is a joke to weed out critics that don’t try stuff before critiquing it. However, we get a lot of flexibility by writing this package in isomorphic JavaScript:

  • Wanna configure your grid framework and just copy and paste the CSS straight from this project’s website? Go ahead.
  • Need to distribute your grid framework to multiple projects with a Node package? Add Grid-in-JS as a dependency and compile it there.
  • Are you bleeding-edge enough to compile the grid framework directly in your client-side code? Now we’re cooking!

Browser Compatibility

This package lets you configure your grid’s browser compatibility. The trade-off is that with more backwards compatibility, the larger the size of the grid code will be. This configuration option is great for developers that have multiple products with differing browser requirements.

| Support Mode | Chrome | Edge | Firefox | IE | Opera | Safari | | | | ------------------ | ------ | ------ | ------- | --- | ----- | ------ | ------------------- | ----------------------------------------------------------------------------------------- | | displayFlex | 29 | 12 | 20 | 11 | 12.1 | 9 | Available | Details | | cssVariables | 49 | 15 | 31 | NA | 36 | 9.1 | Available | Details | | displayGrid | 57 | 16** | 52 | NA | 44 | 10.1 | Available (Default) | Details | | displaySubgrid* | ? | ? | ? | NA | ? | ? | Work-in-Progress | Details |

* CSS Grid Level 2 is still a working draft. Once this support mode is added, it will significantly cut file size due to support for display: subgrid.
** This implementation is currently broken on Edge. See Edge Issue 18676405 for more details.

Instructions

Install

npm install grid-in-js

Use

import gridInJS from "grid-in-js";

var yourGridCSS = gridInJS({
  prefix: "bx--", // Prefix for all CSS class names. Can be empty.
  support: "displayGrid", // `displayFlex`, `cssVariables`, or `displayGrid`
  maxWidth: 1584, // Max-width of entire grid in pixels. Optional.
  progressive: false, // Include all browser support fallbacks older than selected support
  subgrid: true, // Embedded grids and rows know the remaining amount of columns available.
  breakpoints: [
    {
      name: "sm", // Class name prefix fot the breakpoint.
      size: 0, // Starting screen width in pixels of the breakpoint.
      columns: 4, // Amount of columns available.
      gutter: 32, // Space between content of adjacent columns in pixels.
      margin: 0 // Space on outside of entire grid in pixels.
    },
    {
      name: "md",
      size: 672,
      columns: 8,
      gutter: 32,
      margin: 16
    },
    {
      name: "lg",
      size: 1056,
      columns: 16,
      gutter: 32,
      margin: 16
    },
    {
      name: "xl",
      size: 1312,
      columns: 16,
      gutter: 32,
      margin: 16
    },
    {
      name: "max",
      size: 1584,
      columns: 16,
      gutter: 32,
      margin: 32
    }
  ]
});

Contribute

To work on this project locally, just do npm i once and then npm run start to open up dev mode in browser at http://localhost:4000.