JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q35827F
  • License MIT

Fast and light component system, backed by hyperHTML

Package Exports

  • hypercomponent

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hypercomponent) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

hypercomponent

Build Status Standard - JavaScript Style Guide

Fast and light component system, backed by hyperHTML

Usage

Basic

const hyperHTML = require('hyperhtml')
const component = require('hypercomponent')
const app = hyperHTML.bind(document.body)

const Button = component((render, text) => render`
  <button>
    ${text}
  </button>
`)

app`${Button('Hello world!')}`

Pass your own wire or bound node

const hyperHTML = require('hyperhtml')
const component = require('hypercomponent')
const app = hyperHTML.bind(document.body)

const Button = component((render, text) => render`
  <button>
    ${text}
  </button>
`)

app`${[
  Button(hyperHTML.wire(), 'Hello world!'),
  Button(hyperHTML.wire(), 'Hello again!')
]}`

Subscribe to lifecycle events

const hyperHTML = require('hyperhtml')
const component = require('hypercomponent')
const app = hyperHTML.bind(document.body)

const Button = component({
  onload: (e) => {
    console.log(e, 'loaded')
  },
  onunload: (e) => {
    console.log(e, 'unloaded')
  },
  render: (render, text) => render`
    <button onclick="${(e) => e.target.parentNode.removeChild(e.target)}">
      ${text}
    </button>
  `
})

app`${[
  Button(hyperHTML.wire(), 'Hello world!'),
  Button(hyperHTML.wire(), 'Hello again!')
]}`

See also:

License

MIT