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

intrinsic

v2.0.1

Published

A simple mixin for easy intrinsic ratios.

Downloads

205

Readme

@include intrinsic(16/9);

Bower

A simple mixin for easy intrinsic ratios.

Why?

Intrinsic ratios are pretty sweet for making certain content responsive. They're also pretty sweet for helping to mitigate page reflow (something visitors really hate).

A lot of people use stuff like FitVids.js to help make YouTube videos and such responsive, but it seems pretty heavy-handed to use a JS lib for a simple CSS technique. It also obfuscates what's going on and people tend to just throw it in their stack whenever they are embedding a YouTube video.

This approach combines Dave Rupert's (FitVids' author) mixin approach with Matthijs Kuiper's &::before approach and sprinkles in the ability to feed it your own ratios for various content and background-color while said content is loading.

When should I use this?

Use it on embedded videos, maps, and pretty much anywhere you have an element with a standardized size (thumbnails, hero images, etc.) to help prevent page reflow.

Installation

  • bower install intrinsic
  • @import 'bower_components/intrinsic/intrinsic';

Usage

CodePen Demo Be sure to throttle your connection ("Regular 2G" is good) to see how how it looks in low-bandwidth settings.

.youtube {
  @include intrinsic(); // defaults to 16/9
}

.bg-cover {
  @include intrinsic(2/1);
  
  background: lighten(dodgerblue, 25%) url(https://www.fillmurray.com/1600/900) center no-repeat;
  background-size: cover;
}
<div class="youtube">
  <iframe width="560" height="315" src="https://www.youtube.com/embed/JhHMJCUmq28" frameborder="0" allowfullscreen></iframe>
</div>

<div class="bg-cover"></div>

Options

  • $ratio - The width/height ratio (preferably without units, see below). Defaults to 16/9.
  • $bg - The background color. Defaults to darken(white, 5%). You need to manually add this to your background property if you use the background cover technique (see the example code).

Note: You can use fixed numbers but they'll get stripped. intrinsic(1600px/900px) turns into 1600/900. This is because we can't divide numbers with units (not even with calc).