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

postcss-grid-span

v1.1.0

Published

PostCSS plugin to output a column span value when using CSS Grid

Downloads

5

Readme

postcss-grid-span Build Status

PostCSS plugin to output a column span value when using CSS grid layout. This is similar to Susy’s span function.

Installation

$ npm install postcss-grid-span

Usage

See PostCSS usage docs for examples for your environment.

const gridSpan = require("postcss-grid-span");

postcss([
  gridSpan({
    columns: 12,
    gap: 30,
    maxWidth: 1290,
    appendUnit: true
  })
]);

By default, the span function outputs a pixel value without the unit. The px unit can be appended by setting appendUnit to true in the plugin’s settings.

Input

.foo {
  max-width: span(7);
}

Output

.foo {
  max-width: 740px;
}

The span function can also calculate and output a percentage value on the fly by passing fluid as the second option. Note that if a the percentage value is requested, then the appendUnit option will have no effect on the output, even if set to true.

Input

.foo {
  width: span(7 fluid);
}

Output

.foo {
  width: 57.36434108527132%;
}

Practical example

Here is a practical example of how this plugin can be used to help provide fallback styles for a CSS grid layout.

/* Set up the grid container */
.container {
  max-width: 1290px;

  @supports (display: grid) {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-column-gap: 30px;
  }
}

/* Place items on the grid */
.content {
  float: left;
  width: span(7 fluid);

  @supports (display: grid) {
    grid-column: span 7;
    width: auto;
  }
}

.aside {
  float: right;
  width: span(3 fluid);

  @supports (display: grid) {
    grid-column: 10 / span 3;
    width: auto;
  }
}

Options

| Name | Required | Type | Description | | ---- | -------- | ---- | ----------- | | columns | yes | number | Total number of columns in grid layout, e.g., 12 | | gap | yes | number | Width of grid gap (gutter) in pixels, e.g., 30 | | maxWidth | yes | number | Maximum width of grid container in pixels, e.g., 1290 | | appendUnit | no | boolean | Whether or not to append px unit onto span values; default value is false |