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

@bitpas/make-grid

v0.1.2

Published

Extensible base helpers for making CSS grids

Downloads

1

Readme

@bitpas/make-grid

Unstable until v1. Updates may include breaking changes. Use at your own risk.

Extensible base helpers for making CSS grids.

Installation

Install @bitpas/make-grid with npm.

npm install @bitpas/make-grid

Basic usage

Import make-grid into your project.

@import '@bitpas/make-grid';

Include the make-grid mixins in your selectors.

.row {
  @include make-grid-row;
}

.col {
  @include make-grid-col;
  @include make-grid-props;
}

By default, make-grid-props creates size selectors to set an element's width. The default selectors are now available to use in your project's markup.

<div class="row">
  <div class="col size1of2">half</div>
  <div class="col size1of4">fourth</div>
  <div class="col size1of8">eighth</div>
  <div class="col size1of8">eighth</div>
</div>

Default selectors

In order to keep file size small, make-grid currently outputs simplified fractions. For example, size2of4 is invalid since it simplifies to size1of2. Proposed behavior changes are open to discussion.

size1of2
size1of3
size2of3
size1of4
size3of4
size1of6
size5of6
size1of8
size3of8
size5of8
size7of8
size1of12
size5of12
size7of12
size11of12

Customizing

The make-grid-props mixin takes optional arguments to customize its output.

make-grid-props($property, $pre, $post);

You can use make-grid-props to set any CSS property that accepts a percentage as a valid value by passing the property name as a string to $property.

Prepend the generated selector name—overriding the default size prefix—by passing any string to $pre. For example, passing foo__ as an argument to $pre makes the selector accessible as foo__1of2 in the markup.

Append the generated selector name by passing any string to $post. For example, passing --bar as an argument to $post makes the selector accessible as size1of2--bar in the markup.

Leverage the make-grid-props helper to construct grid based tools such as offsets and responsive selectors (discussed in the next section):

.col {
  @include make-grid-col;
  @include make-grid-props;
  @include make-grid-props('margin-left', 'offset');
}
<div class="row">
  <div class="col size1of2 offset1of2">offset by half</div>
</div>

Responsive grids

This package is unopinionated about responsiveness and currently excludes built in handling of breakpoints. Responsive support is relatively simple to setup as shown in the following use case.

$project-breakpoints: (
  phone: 340px,
  tablet: 640px,
  desktop: 1024px,
);

@function get-breakpoint($bp) {
  map-get($project-breakpoints, $bp);
}

.col {
  @include make-grid-col;
  @include make-grid-props('width', 'size');

  @each $breakpoint, $val in $project-breakpoints {
    @media (min-width: get-breakpoint($breakpoint)) {
      @include make-grid-props('width', 'size', #{-$breakpoint});
    }
  }
}

Responsive selectors are now available to use in your project's markup.

<div class="row">
  <div class="col size2of3 size1of2-tablet size5of12-desktop">responsive</div>
</div>