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

zoid-demo

v1.0.4

Published

Javascript module template.

Downloads

4

Readme

zoid demo

A forkable demo repo for zoid to help you get started.

zoid is a cross-domain component library which helps you render iframes and popups, pass down props, accept callbacks, and much more. This repo sets you up with the best possible starting point for building an xcomponent, including:

  • Predefined webpack, babel, karma etc. configs for working with xcomponent
  • Predefined test-setup, including a mock component frame
  • Predefined demo pages for both iframe and popup components

Useful starting points

Quick Start

Getting Started

  • Fork the module
  • Install: npm install
  • Start editing code in ./src and writing tests in ./tests
  • Build: npm run build

Building

npm run build

Running Demo Server

npm run demo

Deploying

  • Host your bundled xcomponent script somewhere, e.g. https://mysite.com/login.xcomponent.js
  • Set up a public url for your component, e.g. https://mysite.com/login
  • Make sure the login.xcomponent.js is included in the login page, and using window.xprops

Now other sites can include https://mysite.com/login.xcomponent.js on their pages, and render your component!

Tests

  • Edit tests in ./test/tests

  • Run the tests:

    npm run test

Testing with different/multiple browsers

npm run karma -- --browser=PhantomJS
npm run karma -- --browser=Chrome
npm run karma -- --browser=Safari
npm run karma -- --browser=Firefox
npm run karma -- --browser=PhantomJS,Chrome,Safari,Firefox

Keeping the browser open after tests

npm run karma -- --keep-open

Publishing

Before you publish for the first time:
  • Remove the example code in ./src, ./test/tests and ./demo
  • Edit the module name in package.json
  • Edit README.md and CONTRIBUTING.md
Then:
  • Publish your code: npm run release to build and publish a patch version
  • Or npm run release:patch, npm run release:minor, npm run release:major

Notes

  • webpack.config.js is set up to build both iframe and popup versions of your component. Normally this will be overkill and you'll just want to pick one. The reason there's an example of both is, the popup rendering code adds more to the bundle size, so cutting this out can streamline your bundle if you only need iframe support.

  • The karma tests use a mock for the component window (i.e. everything displayed in the popup window or iframe window). This can be seen here. When writing tests which need to consume window.xprops and call callbacks like window.xprops.onLogin(), you'll need to do that here.

  • This module imports from zoid/src rather than zoid/dist, allowing your build to take advantage of tree-shaking, flow-types, etc. from zoid and all of its dependencies. That means that various babel plugins etc. that are required by zoid and its dependencies are included in this module. If this isn't to your liking, you're free to switch to zoid/dist, but be warned that you will lose out on some benefits this way. It will reduce the build time though.

  • This module is forked from grumbler, which gives a solid (but opinionated) default setup for front-end javascript libraries, including webpack, karma, babel, flowtype, etc. You're free to switch out any of these technologies, but the existing setup is likely to give the best compatibility especially given the previous note around importing from zoid/src.