Skip to content

Commit 02d7e93

Browse files
committed
Make it so 🚀
1 parent 6220eb2 commit 02d7e93

File tree

5 files changed

+1170
-1
lines changed

5 files changed

+1170
-1
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: node_js
2+
node_js:
3+
- "node"
4+
- "4"
5+
- "6"

README.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,61 @@
11
# 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

index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const hyperHTML = require('hyperhtml')
2+
const slice = Array.prototype.slice
3+
const WIRE_OR_BOUND_NODE = /(update|hyperHTML)$/
4+
5+
module.exports = function hypercomponent (component) {
6+
const render = hyperHTML.wire()
7+
8+
return function wireComponent () {
9+
const args = slice.call(arguments)
10+
11+
if (typeof args[0] === 'function' && WIRE_OR_BOUND_NODE.test(args[0].name)) {
12+
return component.apply(component, args)
13+
}
14+
15+
args.unshift(render)
16+
return component.apply(component, args)
17+
}
18+
}

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "hypercomponent",
3+
"version": "1.0.0",
4+
"description": "Fast and light component system, backed by hyperHTML",
5+
"main": "index.js",
6+
"repository": "[email protected]:joshgillies/hypercomponent.git",
7+
"author": "Josh Gillies <[email protected]>",
8+
"license": "MIT",
9+
"keywords": [
10+
"dom",
11+
"hyper",
12+
"html",
13+
"template",
14+
"component",
15+
"fast",
16+
"performance",
17+
"diff",
18+
"hyperhtml",
19+
"universal"
20+
],
21+
"scripts": {
22+
"test": "standard"
23+
},
24+
"dependencies": {
25+
"hyperhtml": "^0.8.6"
26+
},
27+
"devDependencies": {
28+
"standard": "^9.0.2"
29+
}
30+
}

0 commit comments

Comments
 (0)