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

smartgrid-fixed

v1.0.3

Published

Smart CSS Grid with different preprocessors: LESS, SCSS, SASS or Stylus. Fixed issue from SASS

Downloads

4

Readme

Create adaptive CSS? It's fast and easy! With smart-grid! Fixed a warning from sass.

Install

$ npm i smartgrid-fixed --D
  • Create a file with the following config. Fox example smartgrid.js. Tweak it where needed.
const smartgrid = require("smartgrid-fixed");

/* It's principal settings in smart grid project */
const settings = {
  outputStyle: "scss" /* less || scss || sass || styl */,
  columns: 12 /* number of grid columns */,
  offset: "30px" /* gutter width px || % || rem */,
  mobileFirst: false /* mobileFirst ? 'min-width' : 'max-width' */,
  container: {
    maxWidth: "1200px" /* max-width оn very large screen */,
    fields: "30px" /* side fields */,
  },
  breakPoints: {
    lg: {
      width: "1366px" /* -> @media (max-width: 1366px) */,
    },
    md: {
      width: "1024px",
    },
    sm: {
      width: "768px",
      fields:
        "15px" /* set fields only if you want to change container.fields */,
    },
    xs: {
      width: "560px",
    },
    /*
        We can create any quantity of break points.

        some_name: {
            width: 'Npx',
            fields: 'N(px|%|rem)',
            offset: 'N(px|%|rem)'
        }
        */
  },
};

smartgrid("./path-to-your-folder", settings);
  • Run this file with node
node smartgrid.js
  • You can also implement this code in Gulp tasks, Grunt e t.c.

Why? How does it work?

We set JS array with settings and get LESS, SCSS, SASS or Stylus file with Smart Grid.

And what?

Standard bootstrap grid forces us to write a lot of classes in html and spoils the structure of the code.

In the proposed version, we won't touch classes in the html code at all. Instead we'll only add mixins to the existing selectors.

Usage examples

LESS

.items {
  .row-flex();
  .md(justify-content, center);

  .item {
    .col();
    .size(3);
    .size-md(5);
    .size-xs(10);
  }
}

OR SCSS

.items {
  @include row-flex();
  @include md(justify-content, center);

  .item {
    @include col();
    @include size(3);
    @include size-md(5);
    @include size-xs(10);
  }
}

OR SASS

.items
    +row-flex()
    +md(justify-content, center)

    .item
        +col()
        +size(3)
        +size-md(5)
        +size-xs(10)

OR Stylus

.items
    row-flex()
    md(justify-content, center)

    .item
        col()
        size(3)
        size-md(5)
        size-xs(10)

Result is large CSS

.items {
  display: flex;
  flex-wrap: wrap;
  margin-left: -15px;
  margin-right: -15px;
}

@media screen and (max-width: 992px) {
  .items {
    justify-content: center;
  }
}

.items .item {
  box-sizing: border-box;
  margin-left: 15px;
  margin-right: 15px;
  word-wrap: break-word;
  width: calc(100% / 12 * 3 - 30px);
}

@media screen and (max-width: 992px) {
  .items .item {
    width: calc(100% / 12 * 5 - 30px);
  }
}

@media screen and (max-width: 576px) {
  .items .item {
    width: calc(100% / 12 * 10 - 30px);
  }
}

Mostly nice! But too many media queries.

After using group-css-media-queries media queries are neatly grouped, same as you would do manually

.items {
  display: flex;
  flex-wrap: wrap;
  margin-left: -15px;
  margin-right: -15px;
}

.items .item {
  box-sizing: border-box;
  margin-left: 15px;
  margin-right: 15px;
  word-wrap: break-word;
  width: calc(100% / 12 * 3 - 30px);
}

@media screen and (max-width: 992px) {
  .items {
    justify-content: center;
  }
  .items .item {
    width: calc(100% / 12 * 5 - 30px);
  }
}

@media screen and (max-width: 576px) {
  .items .item {
    width: calc(100% / 12 * 10 - 30px);
  }
}

So, ideal CSS scheme

  1. Smart Grid generates mixins for LESS, SCSS, SASS or Stylus
  2. You use mixins to write code quickly
  3. And finaly, we compile the result through:
    • group-css-media-queries
    • autoprefixer
    • clean-css

Donate