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

plumber-box

v1.1.0

Published

Plumber extension to align boxes to the baseline grid

Downloads

39

Readme

Plumber box

Plumber extension to align boxes to the vertical grid.

Use this mixin whenever you need to add margins, paddings, and borders to a flexible container element without breaking the grid.

Installation

First, make sure to install and import plumber-sass before using plumber-box.

Manual

Download and extract the latest release, move _plumber-box.scss into the vendor folder of your project and import it:

@import "vendor/plumber-box";

NPM / Yarn

Install:

# NPM
$ npm install plumber-box --save-dev

# Yarn
$ yarn add plumber-box --dev

And import it in your project:

@import "node_modules/plumber-box/plumber-box";

Bower

Install:

$ bower install plumber-box --save-dev

And import it in your project:

@import "bower_components/plumber-box/plumber-box";

Usage

1. Set up the grid height for Plumber if you haven't done it before:

@include plumber-set-defaults($grid-height: 1rem);

2. Include the plumber-box mixin. Specify margins and paddings as multiples of the grid height.

blockquote {
	@include plumber-box(
		$margin: 2 0, // top margin: 2, bottom margin: 0
		$padding: 1 1 // top padding: 1, bottom padding: 1
	);
}

This will generate the following CSS:

blockquote {
	margin-top: 2rem;
	padding-top: 1rem;
	margin-bottom: 0;
	padding-bottom: 1rem;
}

Borders

Borders can be set on the inside or on the outside of the box, taking away some space from the padding or margin respectively.

Inside

Add the $border parameter to the mixin, define borders and box-sizing:

blockquote {
	@include plumber-box(
		$margin: 2 0,
		$border: 2px 2px,
		$padding: 1 1
	);

	border: 2px solid gold;
	box-sizing: border-box;
}

The border width will be substracted from the padding.

Inside borders cannot be used with 0 padding.

Outside

Use the CSS outline property to add outside borders:

blockquote {
	@include plumber-box(
		$margin: 2 0,
		$padding: 1 1
	);

	outline: 2px solid gold;
}

The outline will visually decrease the margin but it is not included in the element size so it won't break the grid.

Rounded borders are not possible with this method.

Shorthands

You can use shorthands to set the same top and bottom values:

blockquote {
	@include plumber-box(
		$margin: 2, // top and bottom margin
		$border: 1px // top and bottom border
		$padding: 1 // top and bottom padding
	);
}

API

plumber-box

The main mixin.

Parameters: All parameters are optional, the default grid height can be set with plumber-set-defaults.

Name | Description | Type | Default value ---- | ----------- | ---- | ------------- $grid-height | Override the default grid height | Any unit | As set in Plumber $margin | Top and bottom margin as a multiple of grid height | One or two integers | 0 $border | Top and bottom border width | One or two non-negative px values or 0s | 0px $padding | Top and bottom padding as a multiple of grid height | One or two non-negative integers | 0

Output: margin-top, margin-bottom, padding-top, padding-bottom properties with the same unit as the grid height.

License

MIT License