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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nrg-ui/ember-media

v0.2.1

Published

An Ember addon for safe media query handling

Downloads

9

Readme

@nrg-ui/ember-media

An Ember addon for safe media query handling.

Compatibility

  • Ember.js v5.12 or above
  • Embroider or ember-auto-import v2

Installation

ember install @nrg-ui/ember-media

Usage

Breakpoints

There are 6 breakpoints available, with the following media queries:

| Breakpoint | Media Query | | ---------- | --------------------------------------------- | | xsmall | (min-width: 0px) and (max-width: 575px) | | small | (min-width: 576px) and (max-width: 767px) | | medium | (min-width: 768px) and (max-width: 991px) | | large | (min-width: 992px) and (max-width: 1199px) | | xlarge | (min-width: 1200px) and (max-width: 1399px) | | xxlarge | (min-width: 1400px) |

There is a corresponding property on the media service for each breakpoint, e.g. isSmall, isMedium, etc.

The queries can be adjusted via the Embroider build config, if needed:

// ember-cli-build.js
module.exports = function (defaults) {
  let app = new EmberApp(defaults, {
    '@embroider/macros': {
      setConfig: {
        '@nrg-ui/ember-media': {
          breakpoints: {
            small: '(min-width: 600px) and (max-width: 799px)',
            // other breakpoints...
          },
        },
      },
    },
  });

  return app;
};

Accessing Custom Breakpoints

You can add arbitrary custom breakpoints via the Embroider build config:

// ember-cli-build.js
module.exports = function (defaults) {
  let app = new EmberApp(defaults, {
    '@embroider/macros': {
      setConfig: {
        '@nrg-ui/ember-media': {
          breakpoints: {
            short: '(min-height: 0px) and (max-height: 320px)',
          },
        },
      },
    },
  });

  return app;
};

Custom breakpoints like short in the example above do not have convenience properties (i.e. there is no media.isShort). However, you can use the media.matches TrackedSet to access custom breakpoints:

export default class MyComponent extends Component {
  @service
  declare media: MediaService;

  get isShortScreen() {
    return this.media.matches.has('short');
  }
}

Events

The media service emits a change event whenever the matched media queries change. You can listen for this event to react to changes in screen size.

export default class MyComponent extends Component {
  @service
  declare media: MediaService;

  constructor(owner: Owner, args: unknown) {
    super(owner, args);

    this.media.on('change', () => {
      console.log('Matched media queries:', Array.from(this.media.matches));
    });
  }
}

Testing

When testing components or services that depend on the media service, you can use the provided test helpers to simulate different screen sizes.

import { setupRenderingTest } from 'ember-qunit';
import { module, test } from 'qunit';
import { setBreakpoint } from '@nrg-ui/ember-media/test-support';

module('Integration | Component | my-component', function (hooks) {
  setupRenderingTest(hooks);

  test('my test', async function (assert) {
    const service = this.owner.lookup('service:media');

    await setBreakpoint('small');
    // ...
  });
});

Example

Inject the media service into your component, controller, or route:

import Component from '@glimmer/component';
import { service } from '@ember/service';

import type { Owner } from '@ember/owner';
import type MediaService from '@nrg-ui/ember-media/services/media';

export default class MyComponent extends Component {
  @service
  declare media: MediaService;

  constructor(owner: unknown, args: unknown) {
    super(owner, args);

    this.media.on('change', this.handleMediaChange);
  }

  onClick = () => {
    if (this.media.isLarge) {
      // Do something for large screens
    }
  };

  handleMediaChange = () => {
    console.log('Matched media queries:', Array.from(this.media.matches));
  };
}

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.