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

elementals

v1.0.0

Published

JavaScript library for components

Downloads

2

Readme

Elementals

A JS framework for managing HTML elements enriched by JS.

Installation

Add the following css to the head of your body in order for the activeOn property to work:

.responsive-tracking--visible-on-tablet,
.responsive-tracking--visible-on-desktop,
.responsive-tracking--visible-on-large-desktop {
  display: none;
  height: 1px;
  width: 1px
}

@media only screen and (min-width: 668px) {
  .responsive-tracking--visible-on-tablet {
    display: block
  }
}

@media only screen and (min-width: 1024px) {
  .responsive-tracking--visible-on-tablet {
    display: none
  }
  .responsive-tracking--visible-on-desktop {
    display: block
  }
}

@media only screen and (min-width: 1280px) {
  .responsive-tracking--visible-on-desktop {
    display: none
  }
  .responsive-tracking--visible-on-large-desktop {
    display: block
  }
}

Usage

The power of Elemental components is that it can easily enrich your content without requiring janky code solutions whenever you are in need of re-usable components. Besides, it also makes name-spacing your components very easy, which means that if one does crash, it will log the error but load the rest of the components nonetheless.

Initializing an Elemental is really easy:

import {Elemental, ElementalManager, Install} from 'src/elemental';

let elemental = Elemental("someElemental", function (elemental, options) {
    // You get access to an object with access to the current DOM you are working in.
    // .name is the elemental name
    // .el is the javascript context
    // .destroy is the removal callable
    // .getInstance fetches an already instantiated instance in the current namespace
    // .getInstances fetches all elementals in the current namespace
    // .getInstanceFromElement fetches an elemental from another provided namespace
    // .pubSubClient is the event manager subscription
    elemental.el.innerHTML = 'Testing some text';

    return {
        resume: function () {},
        destroy: function () {},
        pause: function () {}
    }
});

ElementalManager.initElementals({
    someElemental: elemental
}, document);

// bind resize events (we do this after initializing the elementals
// to avoid page jumping when we are still initializing elementals.
Install();
<div data-elemental="someElemental"></div>

You can also add JSON content in the data-elemental tag for more control over elementals:

For optional parameters, you can pass the following json content with anything you want in "options":

{
  "name": "someElemental",
  "isActiveOn": ["mobile"],
  "options": {}
}

You can also initialize multiple elementals on the same element:

[
    {
      "name": "someElemental",
      "isActiveOn": ["mobile"],
      "options": {}
    },
    {
      "name": "someElemental2",
      "isActiveOn": ["tablet", "desktop", "desktop-large"],
      "options": {}
    }
]