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

gremlins

v2.0.0-beta4

Published

dead simple web components

Downloads

36

Readme

GremlinJS

#GREMLIN.JS dead simple web components

GREMLIN.JS is a highly modularized library to build web components. These components are not as fancy as libraries like Polymer, but they're great to build reusable javascript components for boringly normal websites, where your HTML is rendered on the server.
Throw in some bundled js, add the corresponding tags to your HTML, and you're good to go.

import gremlins from 'gremlins';
gremlins.create('my-slider', {
  created: function(){
    this.initSlider();
  }
  // awesome slider magic
});
<my-slider>
  <!-- awesome slider HTML -->
</my-slider>

Installation

Release Notes

npm

$ npm install --save gremlins

global

<script src="gremlin.js" />

All examples in this documentation use the ES2015/ES6 syntax. Use a compiler like Babel to compile them into ES5 compatible Javascript.

Creating Components

To create a new component, you'll have to add new specs for them to GREMLIN.JS

A Spec is a javascript object literal, that later will be used as a prototype for all the components found and intantiated in the page.

Every component will inherit from Gremlin, the base prototype of all components.


Gremlin

mixins

An object, or an array of objects, used as mixin(s). This way it's easy to extend you're components capabilities in a modular way.
If you're mixins and componenet use the same method names, they will be decorated and called in the order they were added to the spec.

el

The dom element for this component. Available inside the initialize call

created()

called, when the element was created. Best understood as a constructor function that's only called once.
This happens if it's an element already existing in the HTML or after using document.createElement()

attached()

called, when the element was added to the dom

detached()

called, when the element was removed from the dom

create()

extends the base prototype with a new spec. Don't overwrite this, you can't extend from your new component anymore if you do so.
This is the method gremlins.create calls!


gremlins.create(tagName, Spec)

Create a new spec for components

gremlins.create('foo-bar', {
  created: function(){
  	// your constructor function called in the context of every dom element found for this spec
  	this.hello();
  },
  hello: function(){
    this.el.querySelector('span').innerHTML = 'hello world!';
  }
});

Using Components

<foo-bar>
	<span></span>
</foo-bar>

will be rendered with javascript as

<foo-bar>
	<span>hello world!</span>
</foo-bar>

GREMLIN.JS, a dependency-free library to build reusable Javascript components.

Visit Website