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

type-director

v0.2.8

Published

Type Director generates a responsive, modular, nuanced typographic system from only a few key variables.

Downloads

5

Readme

Type Director

Type Director generates a responsive, modular, nuanced typographic system from only a few key variables. Metrics are exported as json and cross-platform Theo tokens.

Features

  1. Modular. Typographic measurements are based on proportional lists of values.
  2. Responsive. Typography adjusts to the unique constraints of each breakpoint.
  3. Nuanced. Various properties allow detail-oriented typographers to align additional fonts or uppercase styles to a modular scale.

Install

  • Terminal: npm install type-director --save

Usage

Defining typefaces

Easily apply various typeface-specific adjustments:

const typefaces = [
  {
    name: 'georgia',
    fontFamily: 'Georgia',
    fontFamilyFallbacks: ['Times', 'Times New Roman'], 
    fontFamilyGeneric: 'serif',
    fontSizeAdjustment: 1.00,
    lineHeightAdjustment: 1.00,
    uppercaseAdjustment: 0.82
  },
  {
    name: 'verdana',
    fontFamily: 'Verdana',
    fontFamilyFallbacks: [],
    fontFamilyGeneric: 'sans-serif',
    fontSizeAdjustment: 0.89,
    lineHeightAdjustment: 0.94,
    uppercaseAdjustment: 0.85
  },
  {
    name: 'menlo',
    fontFamily: 'Menlo',
    fontFamilyFallbacks: ['Consolas'],
    fontFamilyGeneric: 'monospace',
    fontSizeAdjustment: 1.00,
    lineHeightAdjustment: 1.00,
    uppercaseAdjustment: 0.85
  }
]

Oftentimes two typfaces set to the same font-size do not appear to be. This is because the heights of their lowercase letters are not equal. Use the fontSizeAdjustment property to normalize additional typefaces to the default typeface, ensuring they align to the modular scale.

For example, Verdana appears 11% larger than Georgia. To normalize it with Georgia, we can set a fontSizeAdjustment: 0.89. This will cause Verdana to be 11% smaller than Georgia when set to the same "size".

Similarly, you can also apply an adjustment to line-height on a typeface-by-typeface basis by specifying a lineHeightAdjustment.

Define your modular scales

Easily create a modular scales that adapt to each environment:


const scales = [ 
  {
    name: 'phone',
    fontSize: {
      base: 16,
      max: 28,
      unit: 'px'
    },
    lineHeight: {
      base: 1.45,
      max: 1.35,
      unit: ''
    }
  },
  {
    name: 'tablet',
    fontSize: {
      base: 18,
      max: 42,
      unit: 'px'
    },
    lineHeight: {
      base: 1.4,
      max: 1.25,
      unit: ''
    }
  }
]

For each scale, provide a font size and line height for both your base size and max size. The other sizes will be interpolated from these constraints.

Build typography

const typography = TypeDirector({
  typefaces: typefaces,
  scales: scales,
  sizes: {
    smaller: 1,
    larger: 3
  },
})

That's it! The returned object will include Theo tokens for font size, line height, and font family.

If you need a bit of typographic guidance, Responsive Typography: The Basics by Information Architects is an excellent read.

Advanced Usage

Rounding

Rounding to any precision is supported.


const scales = [ 
  {
    name: 'phone',
    fontSize: {
      base: 16,
      max: 28,
      unit: 'px',
      precision: 0.1
    },
    lineHeight: {
      base: 1.45,
      max: 1.35,
      unit: '',
      precision: 0.01
    }
  },
  ...
]

Tight line-heights

Oftentimes you may need to set very narrow lines of text, causing your line-height to look too loose. For a tighter line-height, use the "line-height": "tight" option.

.caption-tight { 
  @include td-responsive-type-size("verdana", -1, $opts: ("line-height": "tight"));
}