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

@danscan/modular-scale

v0.1.0

Published

Easily configure and generate modular scales in `rem`s.

Downloads

11

Readme

Modular Rem Scale

Easily configure and generate modular scales in rems.

Configuration

The ModularRemScale constructor takes a config object with the following properties:

| property | type | description | |----------|------|-------------| |firstPower|number|The power value of the first step in the scale.| |ratio|number | RatioName|The ratio to use for the scale.| |rootFontSizePx|number|The root font size to use when converting rem values to px.|

Methods

| method | type | description | |----------|------|-------------| |getMap|(steps: number) => ModularRemScaleMap|Generate an object of steps entries, mapping step numbers (starting at 1) to rem values on the scale.| |getStepPx|(step: number) => string|Get the px value of a step on the scale.|

Named Ratios

| Key | Value | Decimal Value | |------------------|-------------|-------------------| |minor-second |16 / 15 |1.0667 | |major-second |9 / 8 |1.125 | |minor-third |6 / 5 |1.2 | |augmented-fourth|√2 |1.4142 | |perfect-fifth |3 / 2 |1.5 | |minor-sixth |8 / 5 |1.6 | |golden |1.618033...|1.61803398875 | |phi |1.618033...|1.61803398875 | |major-sixth |5 / 3 |1.6667 | |minor-seventh |16 / 9 |1.7778 | |major-seventh |15 / 8 |1.875 | |octave |2 |2 | |major-tenth |5 / 2 |2.5 | |major-eleventh |8 / 3 |2.6667 | |major-twelfth |3 |3 | |double-octave |4 |4 |

Example

import ModularRemScale from '@danscan/modular-scale';

const scale = new ModularRemScale({
  firstPower: -1,
  ratio: 'perfect-fifth',
  rootFontSizePx: 12,
});

scale.getMap(15);
// {
//   '1': '0.67rem',
//   '2': '1.00rem',
//   '3': '1.50rem',
//   '4': '2.25rem',
//   '5': '3.38rem',
//   '6': '5.06rem',
//   '7': '7.59rem',
//   '8': '11.39rem',
//   '9': '17.09rem',
//   '10': '25.63rem',
//   '11': '38.44rem',
//   '12': '57.67rem',
//   '13': '86.50rem',
//   '14': '129.75rem',
//   '15': '194.62rem'
// }

scale.getStepPx(2);
// 12px

scale.getStepPx(3);
// 18px

scale.getStepPx(4);
// 27px