|
1 | 1 | # hypercomponent |
2 | | -Fast and light component system, backed by hyperHTML |
| 2 | + |
| 3 | +[![Build Status][0]][1] |
| 4 | +[![Standard - JavaScript Style Guide][2]][3] |
| 5 | + |
| 6 | +> Fast and light component system, backed by [hyperHTML][hyper] :zap: |
| 7 | +
|
| 8 | +## Usage |
| 9 | + |
| 10 | +### Basic |
| 11 | + |
| 12 | +```js |
| 13 | +const hyperHTML = require('hyperhtml') |
| 14 | +const component = require('hypercomponent') |
| 15 | +const app = hyperHTML.bind(document.body) |
| 16 | + |
| 17 | +const Button = component((render, text) => render` |
| 18 | + <button> |
| 19 | + ${text} |
| 20 | + </button> |
| 21 | +`) |
| 22 | + |
| 23 | +app`${Button('Hello world!')}` |
| 24 | +``` |
| 25 | + |
| 26 | +### Pass your own [wire][wire] or bound node |
| 27 | + |
| 28 | +```js |
| 29 | +const hyperHTML = require('hyperhtml') |
| 30 | +const component = require('hypercomponent') |
| 31 | +const app = hyperHTML.bind(document.body) |
| 32 | + |
| 33 | +const Button = component((render, text) => render` |
| 34 | + <button> |
| 35 | + ${text} |
| 36 | + </button> |
| 37 | +`) |
| 38 | + |
| 39 | +app`${[ |
| 40 | + Button(hyperHTML.wire(), 'Hello world!'), |
| 41 | + Button(hyperHTML.wire(), 'Hello again!') |
| 42 | +]}` |
| 43 | +``` |
| 44 | + |
| 45 | +## See also: |
| 46 | + |
| 47 | +- [yoshuawuyts/nanocomponent][nano] |
| 48 | +- [joshgillies/microcomponent][micro] |
| 49 | + |
| 50 | +## License |
| 51 | + |
| 52 | +MIT |
| 53 | + |
| 54 | +[0]: https://travis-ci.org/joshgillies/hypercomponent.svg?branch=master |
| 55 | +[1]: https://travis-ci.org/joshgillies/hypercomponent |
| 56 | +[2]: https://img.shields.io/badge/code_style-standard-brightgreen.svg |
| 57 | +[3]: http://standardjs.com/ |
| 58 | +[hyper]: https://github.com/WebReflection/hyperHTML |
| 59 | +[wire]: https://github.com/WebReflection/hyperHTML#wait--there-is-a-wire--in-the-code |
| 60 | +[nano]: https://github.com/yoshuawuyts/nanocomponent |
| 61 | +[micro]: https://github.com/joshgillies/microcomponent |
0 commit comments