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

spejson

v1.0.1

Published

Responsive spacing mixins and utility classes

Downloads

17

Readme

Build Status

Spejson

Responsive spacing mixins and utility classes written in Sass.

<div class="component">
  Hello world!
</div>
@import 'spejson';

.component {
  // Set paddings:
  //   viewport <  600px:  30px
  //   viewport >= 600px:  37.5px
  //   viewport >= 900px:  45px
  //   viewport >= 1200px: 52.5px
  //   viewport >= 1800px: 60px
  @include spacing-padding(lg);
}

Will generate

.component {
    padding-top: 30px !important;
    padding-right: 30px !important;
    padding-bottom: 30px !important;
    padding-left: 30px !important;
}

@media screen and (min-width: 600px) {
    .component {
        padding-top: 37.5px !important;
    }
}

@media screen and (min-width: 900px) {
    .component {
        padding-top: 45px !important;
    }
}

@media screen and (min-width: 1200px) {
    .component {
        padding-top: 52.5px !important;
    }
}

@media screen and (min-width: 1800px) {
    .component {
        padding-top: 60px !important;
    }
}

@media screen and (min-width: 600px) {
    .component {
        padding-right: 37.5px !important;
    }
}

@media screen and (min-width: 900px) {
    .component {
        padding-right: 45px !important;
    }
}

@media screen and (min-width: 1200px) {
    .component {
        padding-right: 52.5px !important;
    }
}

@media screen and (min-width: 1800px) {
    .component {
        padding-right: 60px !important;
    }
}

@media screen and (min-width: 600px) {
    .component {
        padding-bottom: 37.5px !important;
    }
}

@media screen and (min-width: 900px) {
    .component {
        padding-bottom: 45px !important;
    }
}

@media screen and (min-width: 1200px) {
    .component {
        padding-bottom: 52.5px !important;
    }
}

@media screen and (min-width: 1800px) {
    .component {
        padding-bottom: 60px !important;
    }
}

@media screen and (min-width: 600px) {
    .component {
        padding-left: 37.5px !important;
    }
}

@media screen and (min-width: 900px) {
    .component {
        padding-left: 45px !important;
    }
}

@media screen and (min-width: 1200px) {
    .component {
        padding-left: 52.5px !important;
    }
}

@media screen and (min-width: 1800px) {
    .component {
        padding-left: 60px !important;
    }
}

Don't worry about number of generated @media. You can easily optimize code by by merging @media with clean-css (look at mediaMerging) or a postcss plugin.

API

Variables

You can easily customise spejson by overriding variables. You can change almost everything. Look at default configration with explanation.

// Prefix is used for generate-spacing-* mixins
$spacing-prefix: 'u-' !default;

// Adjust sizes to your project. If you need only 2 sizes, e.g.
// [small, big] - you can set them below
$spacing-sizes: (
  xs: 5px,
  sm: 10px,
  md: 15px,
  lg: 30px,
  xl: 50px,
) !default;

// Names for breakpoints corresponds to names in $spacing-scales
// Names can be changed
$spacing-bp: (
  'tablet-portrait': 600px, // feel free to use here em based media queries
  'tablet-landscape': 900px,
  'desktop': 1200px,
  'big-desktop': 1800px,
) !default;

$spacing-scales: (
  'phone': 1, // this name cannot be changed and must be defined
  'tablet-portrait': 1.25,
  'tablet-landscape': 1.5,
  'desktop': 1.75,
  'big-desktop': 2,
) !default;

Integration mixins

Variable

$size-name {string} - one of xs, sm, md, lg, xl.

Margin

@include spacing-margin-top($size-name);

@include spacing-margin-right($size-name);

@include spacing-margin-bottom($size-name);

@include spacing-margin-left($size-name);

Padding

@include spacing-padding-top($size-name);

@include spacing-padding-right($size-name);

@include spacing-padding-bottom($size-name);

@include spacing-padding-left($size-name);

All

@include spacing-margin($size-name);

@include spacing-padding($size-name);

Generation mixins

@include generate-spacing-center;

Generates utility .u-mc class for easy horizontal centering.

@include generate-spacing-reset;

Generates utility classes that reset margins and paddings.

// Margins
.u-mt-0
.u-mr-0
.u-mb-0
.u-ml-0

// Paddings
.u-pt-0
.u-pr-0
.u-pb-0
.u-pl-0

@include generate-spacing-margin;

Generates responsive utility classes that set margins.

// xs
.u-mt-xs
.u-mr-xs
.u-mb-xs
.u-ml-xs

// sm
.u-mt-sm
.u-mr-sm
.u-mb-sm
.u-ml-sm

// md
.u-mt-md
.u-mr-md
.u-mb-md
.u-ml-md

// lg
.u-mt-lg
.u-mr-lg
.u-mb-lg
.u-ml-lg

// xl
.u-mt-xl
.u-mr-xl
.u-mb-xl
.u-ml-xl

@include generate-spacing-padding;

Generates responsive utility classes that set paddings.

// xs
.u-pt-xs
.u-pr-xs
.u-pb-xs
.u-pl-xs

// sm
.u-pt-sm
.u-pr-sm
.u-pb-sm
.u-pl-sm

// md
.u-pt-md
.u-pr-md
.u-pb-md
.u-pl-md

// lg
.u-pt-lg
.u-pr-lg
.u-pb-lg
.u-pl-lg

// xl
.u-pt-xl
.u-pr-xl
.u-pb-xl
.u-pl-xl

License

MIT