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

@financial-times/o-spacing

v3.2.5

Published

Maintain consistent spaces across components and projects in accordance to our baseline grid and design guidelines.

Downloads

6,227

Readme

o-spacing

A styling utility component to aid projects and component with consistent spacing, according to the baseline grid within the design guidelines.

Usage

Check out how to include Origami components in your project to get started with o-spacing.

For Build Service users, o-spacing provides CSS classes for vertical space and CSS Custom Properties (CSS Variables) for other usecases. For Sass users o-spacing also provides a number of Sass functions and mixins for applying space to a project.

Spaces

Visual representation of spaces defined below.

The above illustration is taken from the UXD Sketch Toolkit.

Baseline

Our baseline grid defaults to 4px. Any multiple of this default may be applied to a project. We recommend using our named spaces for consistency.

Named Spaces

Named spaces are the sizes we use to layout a component or page consistently. Each space is based on the 4px baseline. Small sizes such as s1 or s2 are ideal for space within a component; use medium sizes m12 and m16 for related content on a page; and large sizes l18, l24 for separating distinct areas within a project.

| name | value | |------|-------| | s1 | 4px | | s2 | 8px | | s3 | 12px | | s4 | 16px | | s6 | 24px | | s8 | 32px | | m12 | 48px | | m16 | 64px | | l18 | 72px | | l24 | 96px |

To apply named spaces see o-spacing markup and Sass documentation.

Markup

o-spacing provides utility classes to help space Origami components vertically within your project.

<!-- Add a 48px vertical margin between elements. -->
<div class='o-spacing-m12'></div>
<div class='o-spacing-m12'></div>

To apply spaces to other properties o-spacing provides CSS Custom Properties (CSS Variables).

CSS Custom Properties

Named Space Custom Properties

o-spacing outputs a CSS Custom Property (CSS Variable) for each named space. E.g. --o-spacing-s1. These may be used to apply spaces in custom CSS if your project supports CSS Custom Properties. This is particularly useful for Build Service users who do not have access to o-spacing's Sass functions.

.example {
	margin: var(--o-spacing-s1);
}

Baseline Custom Property

We recommend using a named space, but for more granular control a project may output any space which is a multiple of our baseline value. For users who do not have access to Sass, o-spacing outputs a --o-spacing-baseline CSS variable.

.example {
	padding: calc(var(--o-spacing-baseline) * 1); // A small padding (4px).
	margin-bottom: calc(var(--o-spacing-baseline) * 4); // A large space (16px).
}

Sass

Relative Units

For compatibility with existing Origami projects, o-spacing outputs px values by default. To use relative rem values, set $o-spacing-relative-units: true before importing @financial-times/o-spacing/main.

	$o-spacing-relative-units: true;

	.example {
		padding: oSpacingByName('s1');  // Small padding (0.24rem).
		margin-bottom: oSpacingByName('m12'); // Medium margin (3rem).
	}

If using o-typography set $o-typography-relative-units also.

Named Space

We recommend Sass users apply space to their project using the oSpacingByName function. It accepts a space name and returns a px value (or rem value, if relative units are enabled).

	.example {
		padding: oSpacingByName('s1');  // Small padding (4px).
		margin-bottom: oSpacingByName('m12'); // Medium margin (48px).
	}

Baseline Space

We recommend the use of named spaces, but any space that multiplies our baseline is allowed. To apply a multiple of the baseline value use oSpacingByIncrement. It accepts a value to multiply the baseline by and returns a px value (or rem value, if relative units are enabled).

	.example {
		margin-bottom: oSpacingByIncrement(4);
	}

Custom Properties & Utility Classes

We recommend users apply named spaces using the Sass function oSpacingByName, but Sass users may output all o-spacing CSS including utility classes and CSS custom properties using the oSpacing mixin.

@include oSpacing($opts: (
	'margin-bottom-utilities': true, // Output CSS classes such as `o-spacing-s1`
	'custom-properties': true // Output CSS variables
));

Migration

State | Major Version | Last Minor Release | Migration guide | :---: | :---: | :---: | :---: ✨ active | 3 | N/A | migrate to v3 ⚠ maintained | 2 | 2.1 | migrate to v2 | ╳ deprecated | 1 | 1.0 | N/A |

Contact

If you have any questions or comments about this component, or need help using it, please either raise an issue, visit #origami-support or email Origami Support.

Licence

This software is published by the Financial Times under the MIT licence.