package
Generic UI Component class
npm install huiGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
bret
bcomnes@gmail.com
Or you can use the shorthand if you are not subclassing
const view = new Component({
createElement () {
return someDomElement
},
onload () {
console.log('component loaded')
},
onunload () {
console.log('component unloaded')
},
render () {
console.log('update the rendering')
}
})Call component.update() to trigger a rendering on the next raf. Multiple calls to .update() are automatically debounced.
If your render method just involves reconstructing the entire dom of your element and then diffing it against the mounted one you can use a morph component as a conveinience.
const Component = require('hui/morph')
const el = new Component({
createElement () {
return html`...` // this is called on every render
}
})const Component = require('hui')Base component with manual rendering and hooks for load, unload and automatic event life cycle
const MorphComponent = require('hui/morph')A auto morphing component using DOM diffing.
component.on(emitter, name, fn)addEventListener / on helper that auto gc's the listener on unload.
component.off(emitter, name, fn)removeEventListener / off helper that cancels out the above method.
component.loadedBoolean wheather or not the component is currently loaded.
component.elementThe DOM element attached.
component.update()Trigger a render in the next animation frame.
const html = require('hui/html')HTML with template strings
const raw = require('hui/html/raw')Prevent escaping with template strings
const css = require('hui/css')Inline css styles
const guard = require('hui/guard')Protect a DOM subtree against morphing
npm install huiEstimated unpacked size across 51 packages.
2.6 MB
Includes dependencies.
5 direct dependencies.
^1.8.0
1.10.0
^8.0.0
8.0.0
^5.4.0
5.4.3
^1.0.0
1.2.0
^2.1.0
2.1.0