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

@desinax/typographic-grid

v1.1.3

Published

Desinax LESS/SASS module for typographic grid

Downloads

12

Readme

Desinax Typographic Grid (LESS)

npm version Join the chat at https://gitter.im/desinax/typographic-grid

Build Status CircleCI

LESS module implementing a typographic grid. This is also knows as a horizontal grid, a baseline grid. These types of grid are used to create vertical rythm for the typography in a layout.

It can look like this when applying the typgraphy to a vertical grid.

With showgrid

Table of content

Documentation online

You can read this README and try out the example files htdocs/*.html by using GitHub Pages.

Viewing this documentation on GitHub Pages makes it easier to both read this documentation and try out the examples on the same time.

Install

You can install using npm to take advantage of version management. Semantic versioning is used to label the various versions.

npm install @desinax/typographic-grid

Or clone this repo and use it as is.

About the grid

The grid consists of two less-files, src/less/typography-font-families.less and src/less/typography-defaults.less.

This is how you can import and activate the grid into your own theme.

/**
 * Import the typographic grid.
 */
@import "src/less/typography-font-families.less";
@import "src/less/typography-defaults.less";

You have now imported the grid, the next step is to activate it.

The first thing is to set the base font for the body element.

// Activate the grid base font
body {
    #desinax-hgrid.font(@fontSizeBody);
}

Next step is to activate all grid styles to the typographic elements, such as h1-h6, p, code, table and so on. You do this by calling another mixin.

// Activate grid and affect all typographic elements
#desinax-hgrid.activateDefaultTypography();

The next step is to optionally enable the to show the grid. This is helpful when one want to check that the typography actually alines to the grid.

// Show the grid
.hgrid .wrap {
    @gridImage: "../../img/magic-number-@{magicNumber}.png";
    #desinax-hgrid.showGrid(@gridImage);
}

Or you can use the alternative showGrid that works more dynamiccaly, without a need of a background image.

// Show the grid
.hgrid .wrap {
    #desinax-hgrid.showGridAlt();
}

Now you are done. An example showing how this can look like is in htdocs/typographic_default.html. The style used for the example is in src/less/test_typography_default.less.

This is how the example looks like.

Defaults

Customizing the grid

The idea behind the grid is to select a magic number which all typography should align vertically to.

You can also set the base for the fontsize used.

There are defaults which you can override.

// Magic number and base fontsize
@magicNumber:  24px;  // 22px
@fontSizeBody: 16px;

You can review the example in htdocs/typographic_custom_24.html which show a slightly modified grid using fontsize 16px and a magic number of 24px. The style used for the example is in src/less/test_typography_custom_24.less.

It looks like this.

Custom 24

There is another example with the magic number set to 22px. You can review it in htdocs/typographic_custom_22.html. The style used for the example is in src/less/test_typography_custom_22.less.

It looks like this.

Custom 22

Modify more

The basic typography for the grid is in the file src/less/typography-defaults.less. It contains mixins that activate the grid, it contains basic settings for common typographic elements and it contains a set of variables that can be customized by you in your own theme.

About typography-font-families.less

This file contains a set of font families stored in variables. You can review the file in src/less/typography-font-families.less.

Here is an extract from the file. You can use these variables when you customize what font families to use.

// Monospace
@fontFamilyCourier:         "Courier New", Courier, monospace;

// Serif
@fontFamilyCambria:         Cambria, Georgia, Times, 'Times New Roman', serif;

// Sans-serif
@fontFamilyVerdana:         Verdana, Geneva, sans-serif;

In your own theme style you can then set the font families to use in the grid.

// Set font family to use
@fontFamilyHeadings:  @fontFamilyCambria;
@fontFamilyBody:      @fontFamilyCalibri;
@fontFamilyCode:      @fontFamilyCourier;

The variables @fontFamilyHeadings, @fontFamilyBody and @fontFamilyCode are defined, together with a large set of other variables that can be customized, in the file src/less/typography-defaults.less.

License

The license is MIT, review it in LICENSE.

 . 
..:  Copyright (c) 2016-2018 Mikael Roos, [email protected]