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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@dustinpoissant/device-frame

v1.0.3

Published

A customizable web component that renders an iframe inside a mobile device frame

Readme

Device Frame Web Component

A customizable web component that renders an iframe inside a mobile device frame, with options for device selection, orientation, folding, and scaling.

Repository | Full Documentation

Installation

You can install the Device Frame component via NPM or download it manually.

NPM Installation

Install the package using NPM:

npm install @dustinpoissant/device-frame

Then include the minified script in your HTML:

<script type="module" src="node_modules/@dustinpoissant/device-frame/DeviceFrame.min.js"></script>

Manual Download

Download DeviceFrame.min.js directly from the repository and include it in your project:

<script type="module" src="DeviceFrame.min.js"></script>

Attributes

| Attribute | Description | Default | |-----------|-------------|---------| | src | The URL to load in the iframe | false | | device | Device type (e.g., iphone15promax, galaxys22ultra) | "iphone15" | | controls | Comma-separated list of controls to show (device, orientation, fold, scaled) | "" | | orientation | Device orientation (portrait/landscape) | "portrait" | | scaled | Scales device to fit 80% of viewport | false | | devices | Comma-separated list of device keys to show in device picker (leave empty to show all) | "" |

Available Devices

  • iPhone 15 Pro Max, iPhone 15 Pro, iPhone 15, iPhone SE
  • Galaxy S22 Ultra, Galaxy S22+, Galaxy S22
  • Galaxy Tab S9, Galaxy Tab A8
  • Pixel 8, Pixel Fold, Galaxy Z Fold5, Pixel Tablet
  • iPad Pro 12.9", iPad Pro 10.5", iPad Air 4, iPad 10.2"

Basic Usage

Simple Device Frame

<device-frame src="https://example.com"></device-frame>

Basic device frame

Device Picker

<device-frame src="https://example.com" controls="device"></device-frame>

Device picker

All Controls

<device-frame src="https://example.com" controls="device,orientation,fold,scaled"></device-frame>

All controls

JavaScript API

Importing and Creating Instances

import DeviceFrame from './DeviceFrame.js';

// Create with constructor
const frame = new DeviceFrame({
  src: 'https://example.com',
  device: 'iphone15',
  controls: 'device,orientation'
});
document.body.appendChild(frame);

// Or create with document.createElement
const frame2 = document.createElement('device-frame');
frame2.src = 'https://example.com';
frame2.device = 'iphone15';
document.body.appendChild(frame2);

// Control existing elements
const existingFrame = document.querySelector('device-frame');
existingFrame.src = 'https://new-url.com';
existingFrame.device = 'galaxys22ultra';
existingFrame.devices = 'iphone15,galaxys22ultra,ipadpro12'; // Limit options
existingFrame.orientation = 'landscape';
existingFrame.controls = 'device,orientation';

Adding Custom Devices

import DeviceFrame from './DeviceFrame.js';

DeviceFrame.devices['customphone'] = {
  name: 'Custom Phone',
  resolution: [400, 800],
  topFrameSize: 20,
  bottomFrameSize: 20,
  sideFrameSize: 15,
  innerRadius: 10,
  outerRadius: 15
};

Event Handling

const frame = document.querySelector('device-frame');

frame.addEventListener('devicechange', (event) => {
  console.log('Device changed to:', event.detail.device);
});

frame.addEventListener('orientationchange', (event) => {
  console.log('Orientation changed to:', event.detail.orientation);
});

frame.addEventListener('load', (event) => {
  console.log('Iframe loaded:', event.detail.src);
  // Access iframe for message passing
  const iframe = frame.iframe;
  iframe.contentWindow.postMessage('Hello!', '*');
});