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

@apmg/mimas

v2.0.1

Published

A React component that takes an image endpoint from APM's APIs and returns a proper image with srcset.

Downloads

148

Readme

@apmg/mimas

NPM Stable Release MIT License

@apmg/mimas is a small library that takes an endpoint from American Public Media's internal image API and turns it into a valid <img /> or <amp-img /> object with a srcset and proper sizing. This library is used on its own and in our other component libraries, such as Titan and Amat React.

Installation

Simply run the command yarn add @apmg/mimas or npm i @apmg/mimas.

Usage

In files where you want to use the <Image /> component, import { Image } from '@apmg/mimas' at the top of your file. On pages that need to be compliant with Google's AMP (which we here at MPR adore and think is great), import AmpImage instead in the same manner.

For example, this:

import Image from './Image'
import { imageData } from './__tests__/data/image'

<Image image={imageData} aspectRatio='widescreen' />

Will produce a large widescreen image in the app at the appropriate size for the viewport, presuming that the data fed into the image property looked like this.

const imageWithPreferred = {
  preferredAspectRatio: {
    instances: [
      {
        width: 400,
        url:
          'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/square/5ecd52-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
        height: 400
      },
      {
        width: 600,
        url:
          'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/square/de193e-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
        height: 600
      },
      {
        width: 1000,
        url:
          'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/square/7cb7e2-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
        height: 1000
      },
      {
        width: 1400,
        url:
          'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/square/822d4e-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
        height: 1400
      },
      {
        width: 2000,
        url:
          'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/square/f977a8-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
        height: 2000
      }
    ],
    slug: 'square'
  },
  aspect_ratios: {
    normal: {
      instances: [
        {
          width: 400,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/normal/fa6aa0-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 301
        },
        {
          width: 600,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/normal/00b407-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 451
        },
        {
          width: 1000,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/normal/10ac72-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 752
        },
        {
          width: 1400,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/normal/6e721c-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 1053
        },
        {
          width: 2000,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/normal/f49c92-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 1504
        }
      ],
      slug: 'normal'
    },
    square: {
      instances: [
        {
          width: 400,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/square/5ecd52-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 400
        },
        {
          width: 600,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/square/de193e-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 600
        },
        {
          width: 1000,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/square/7cb7e2-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 1000
        },
        {
          width: 1400,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/square/822d4e-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 1400
        },
        {
          width: 2000,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/square/f977a8-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 2000
        }
      ],
      slug: 'square'
    },
    thumbnail: {
      instances: [
        {
          width: 120,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/thumbnail/e8796f-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 90
        },
        {
          width: 300,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/thumbnail/dfad0f-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 226
        }
      ],
      slug: 'thumbnail'
    },
    widescreen: {
      instances: [
        {
          width: 400,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/widescreen/e428bc-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 225
        },
        {
          width: 600,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/widescreen/58b2ba-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 337
        },
        {
          width: 1000,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/widescreen/95c885-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 562
        },
        {
          width: 1400,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/widescreen/b3a373-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 787
        },
        {
          width: 2000,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/widescreen/6ceb83-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 1124
        }
      ],
      slug: 'widescreen'
    },
    portrait: {
      instances: [
        {
          width: 400,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/portrait/e6415b-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 500
        },
        {
          width: 600,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/portrait/0ebc89-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 750
        },
        {
          width: 1000,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/portrait/fed99c-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 1250
        },
        {
          width: 1400,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/portrait/523b4b-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 1750
        },
        {
          width: 1883,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/portrait/766692-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 2354
        }
      ],
      slug: 'portrait'
    },
    uncropped: {
      instances: [
        {
          width: 400,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/uncropped/35bd3b-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 320
        },
        {
          width: 600,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/uncropped/f5db37-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 480
        },
        {
          width: 1000,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/uncropped/04a63f-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 800
        },
        {
          width: 1400,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/uncropped/72bc48-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 1120
        },
        {
          width: 2000,
          url:
            'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/uncropped/f20034-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
          height: 1600
        }
      ],
      slug: 'uncropped'
    }
  },
  long_caption: 'Serena Brook opens our show at The Town Hall',
  short_caption: 'Serena Brook opens our show at The Town Hall',
  width: 'full',
  preferred_aspect_ratio_slug: 'widescreen',
  id: 'c2c452354fbff94d720ba8f86e2c71ba7427b306',
  credit_url: '',
  type: 'apmImage',
  float: 'none',
  credit: 'American Public Media',
  fallback:
    'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/uncropped/f5db37-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg',
  srcset:
    'https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/widescreen/e428bc-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg 400w, https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/widescreen/58b2ba-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg 600w, https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/widescreen/95c885-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg 1000w, https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/widescreen/b3a373-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg 1400w, https://img.apmcdn.org/c2c452354fbff94d720ba8f86e2c71ba7427b306/widescreen/6ceb83-20181220-serena-brook-opens-our-show-at-the-town-hall.jpg 2000w'
}

Full Documentation

For complete usage details, head to apm-mimas.github.io/docs.