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

ta-dom-components

v0.0.8

Published

another web-component library

Downloads

4

Readme

Ta-Dom! 🎉 Components

A tiny web components library using ta-dom and morphdom

What is it?

Ta-Dom! Components is a small library that combines some of the best features of the React and Polymer libraries to make writing web components fast, fun, and easy.

How it Works

Ta-Dom! Components are built a lot like Polymer components, using a class to define your component. However, it also leverages the virtual DOM concept from React to allow writing a pure render function instead of a template (string!) littered with <dom-if>'s and <dom-repeat>'s. This lets you keep your display logic neatly in one place, where you can leverage the full power of javascript.

Like Polymer, Ta-Dom! Components expose their state as local instance properties that can be manipulated however you see fit without having to learn any new api's. Whether you change a property directly, or batch your changes through the inherited setState({key:value}) interface, the Ta-Dom! base class will handle updating your screen for you in a fast and efficient manner thanks to Morphdom.

Unlike React's virtual DOM, in Ta-Dom! you're always dealing with real DOM elements. It's encouraged to use the Ta-Dom! DOM creation library because it's awesome, but you're free to construct your DOM however you see fit. All of the native DOM api's are available.

Getting Started

npm install --save ta-dom-components

A Simple Ta-Dom Component

// import TaDomElement
import TaDom from './node-modules/ta-dom-components/ta-dom-element.js';

// define your element's class
export class MyElement extends TaDom.TaDomElement {

  // define a static getter for your css
  // alternatively, return a link() element
  static get css() {
    return `
      :host {
        display: block;
        background: gray;
      }
      :host([read]) {
        background: green;
      }
      h1 {
        color: brown;
      }
      article {
        background: brown;
        color: white;
      }

    `
  }

  // define a static getter for your properties
  static get properties() {
    return {
      header:{
        value: '',
      },
      content: {
        value: ''
      },
      read: {
        value: false,
        reflectToAttribute: true
      }
    }
  }

  // a static getter for any attributes you want to observe
  static get observedAttributes() {
    return ['header', 'content', 'read']
  }

  // a render function returns the current state of your dom
  render() {
    return div({class:'wrapper'},
            h1(`${this.header}`),
            article({'on-click':(event) => this.onClickArticle(event)}, `${this.content}`)
    );
  }

  // event handler called when the article is clicked
  onClickArticle(event) {
    this.read = true;
  }
}
// register your element
TaDom.customElement('my-element', MyElement);
More Examples

Check out this flash card game built with Ta-Dom! Components