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

element-creator

v1.0.6

Published

A javascript library that helps creating html elements easily. Inspired by mithriljs framework.

Downloads

16

Readme

element-creator Build Status size npm version License: MIT

A library that helps to create interactive HTML elements (virtual dom) easily. Inspired by MithrilJs framework.

Installation

element-creator is available on NPM and as a Javascript library.

Install on NPM

npm install element-creator

Or include on html file on unpkg


<script  type="text/javascript" src="https://unpkg.com/[email protected]/build/element-creator.min.js"></script>

Examples:

A one page content example located at build/index.html. Or a quick demo below

// using node with es6, otherwise var e = require('element-creator');
import e from 'element-creator';

var myDiv = e('div#myElement.class__1[name=awesome-div]', 'My awesome div', {
    on: { 'click': function(e) {
        alert('You have clicked on My awesome div');
    }}
})

The variable myDiv above generates div html element with click event that prop an alert message.

<div id="myElement" class="class__1" name="awesome-div">My awesome div</div>

Documentation

element-creator contains Elementextended (or wrapper) which wraps/adds interactive functions such as .find, .all to standard element and ElementCreator which creates HTML elements then wrap and return an ElementExtended element.

ElementCreator

// vdom return new element
var vdom = e(elementString, children, options)

Where:

  • elementString is a string that specify the element parameters creation with following pattern:

{elementType}{(*)elementId}{(*)elementClasses}{(*)elementAttributes}

(*) is optional

| Parameters | Default | Description | Example | |-------------------|---------|---------------------------------------|---------| | elementType | div | Type of element or element's tag type | p or h1. Use default incase left empty | | elementId | | Element's id | #firstParagraph | | elementClasses | | Element classes | .class__1 or multiple classes .class__1.class_2 | | elementAtrributes | | Element attributes | [name=title] or multiple attributes [name=title,ref=titleRef]|

  • children is text node or html elements that stay inside the element.

  • options os other configuration including:

    • on: add event listener
    • attrs: element's attributes
    • data: element's data

ElementExtended

// wrappedElement return a html element within the html body with more interactive functions
var wrappedElement = e.wrap(querySelector, isMultiple)

Where:

  • querySelector is standard query selector string for example h1 will look for heading h1, .class__1 will look for any element has class .class__1.
  • isMultiple is false by default. If set to true it will return an array of element match with querySelector.