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

poly-fluid-sizing

v1.2.1

Published

SASS mixin for linear interpolation between multiple values across multiple breakpoints using CSS calc() and viewport units

Downloads

8,240

Readme

Poly Fluid Sizing

Poly Fluid Sizing is a SASS mixin to linear interpolation size values using calc() across multiple breakpoints. It uses some basic math behind the scenes. You don't need to know the math or understand it to use this mixin.

Usage

// Import Poly Fluid Sizing mixin
@import 'poly-fluid-sizing';

h1 {
  @include poly-fluid-sizing('font-size', (320px:18px, 768px:26px, 1024px:38px, 1440px:46px));
}

This outputs the following CSS (The comments are not generated and are only here for clarity)

h1 {
  /* The minimum font-size */
  font-size: 18px;
}
@media (min-width: 320px) {
  h1 {
    /* Interpolate the font-size between 18px @ 320px and 26px @ 768px viewport */
    font-size: calc(1.78571429vw + 12.28571429px);
  }
}
@media (min-width: 768px) {
  h1 {
    /* Interpolate the font-size between 26px @ 768px and 38px @ 1024px viewport */
    font-size: calc(4.6875vw - 10px);
  }
}
@media (min-width: 1024px) {
  h1 {
    /* Interpolate the font-size between 38px @ 1024px and 46px @ 1440px viewport */
    font-size: calc(1.92307692vw + 18.30769231px);
  }
}
@media (min-width: 1440px) {
  h1 {
    /* The maximum font-size */
    font-size: 46px;
  }
}

It can do more than font-size

Using Poly Fluid Sizing on font-size is an obvious use case. But it can be used for any CSS property that uses a numeric size value. For example, padding, margin, border-width, margin-left, etc...

section {
  @include poly-fluid-sizing('margin-right', (768px:40px, 1024px:60px));
}

blockquote {
  @include poly-fluid-sizing('padding', (768px:30px 15px, 1024px:50px 25px));
}

SASS map order

The SASS map that is passed into the mixin can be in any order. It doesn't have to be ordered from smallest viewport to largest viewport. The functions will automatically sort it for you. This is perfectly valid syntax:

article {
  @include poly-fluid-sizing('font-size', (1024px:22px, 500px:16px, 1440px:24px, 768px:18px));
}

Limitations

  • You can't mix value types. For example, trying to use 2em font-size @ 786px viewport width. SASS just really won't know what to do mathematically when 1 value is using em and the other is using px.

Coverage

Smashing Magazine: Fluid Responsive Typography With CSS Poly Fluid Sizing

Medium.com/@jakobud CSS Poly Fluid Sizing using calc(), vw, breakpoints and linear equations

MIT License (see LICENSE file)