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

css-modularscale

v1.1.1

Published

Modular scale calculator built into your CSS

Downloads

1,176

Readme

Modular Scale

A modular scale is a list of values that share the same relationship. These values are often used to size type and create a sense of harmony in a design. Proportions within modular scales are all around us from the spacing of the joints on our fingers to branches on trees. These natural proportions have been used since the time of the ancient Greeks in architecture and design and can be a tremendously helpful tool to leverage for web designers.

Ems work especially well with modular scales as their recursive properties mimic modular scales making them more predictable and easier to manage. Pixels and other units work just fine and breakpoints in responsive web design can naturally fall on your scale to create better relevance to your text as all the values in your layout harmonize with each other.

To get started, you need to select a ratio and a base value. The base value is usually your text font size or 1em. This base size paired with a ratio such as the golden ratio or any musical proportion will create your scale of values which all share this proportion.

Install

  • npm install css-modularscale
  • then, in your css: @import "css-modularscale"

Compatability

css-modularscale is created with future CSS syntax in mind. For more information about CSS variables and the spec, consult The W3C's Working Draft on the topic. You can use any CSS "postprocessor" that has support for custom properties, such as PostCSS or Rework. If you want to get started fast, I recommend checking out the CSSNext project.

Usage

Modular Scale has two default variables that you should place with your other site wide variables. --ms-base is usually your font size or 1rem. --ms-ratio is the factor of change between each number so if the ratio is 1.5 then each number in the sequence will be 1.5 times that of the previous number.

:root {
	--ms-base: 1em;
	--ms-ratio: var(--golden);
}

Modular-scale is used as a custom property. Simply pass it through in place of any value to use a value based on a modular scale.

font-size: var(--ms2); // two up the modular scale

Ratios

Modular scale includes functions for a number of classic design and musical scale ratios. You can add your own ratios as well.

By default, the variable --ms-ratio is set to --golden.

Add your own ratio in CSS by setting a variable and passing that to modular-scale.

:root {
	--my-ratio: calc(1 / 3.14159265);
	--ms-ratio: var(--my-ratio);
}

Changelog