-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from choojs/update-to-nc-6
Update adapters
- Loading branch information
Showing
7 changed files
with
152 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
dist: trusty | ||
language: node_js | ||
node_js: | ||
- "4" | ||
- "5" | ||
- "6" | ||
- "7" | ||
- 'node' | ||
sudo: false | ||
language: node_js | ||
script: "npm run test" | ||
after_script: "npm i -g codecov.io && cat ./coverage/lcov.info | codecov" | ||
cache: | ||
directories: | ||
- ~/.npm | ||
install: | ||
- npm i | ||
script: | ||
- npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,37 @@ | ||
var component = require('nanocomponent') | ||
var Nanocomponent = require('nanocomponent') | ||
var reactDom = require('react-dom') | ||
var react = require('react') | ||
var html = require('bel') | ||
var toReact = require('./react') | ||
|
||
// create new nanocomponent | ||
var Button = component({ | ||
render: function (data) { | ||
return html` | ||
<button>hello planet</button> | ||
` | ||
} | ||
}) | ||
function Button () { | ||
if (!(this instanceof Button)) return new Button() | ||
this.color = null | ||
|
||
Button = toReact(Button, react) | ||
Nanocomponent.call(this) | ||
} | ||
Button.prototype = Object.create(Nanocomponent.prototype) | ||
|
||
Button.prototype.handleClick = function () { | ||
console.log('yay') | ||
} | ||
|
||
Button.prototype.createElement = function ({color}) { | ||
this.color = color | ||
return html` | ||
<button onclick=${this.handleClick} style="background-color: ${color}"> | ||
Click Me | ||
</button> | ||
` | ||
} | ||
|
||
// Implement conditional rendering | ||
Button.prototype.update = function ({newColor}) { | ||
return newColor !== this.color | ||
} | ||
|
||
var ReactButton = toReact(Button, react) | ||
var el = document.createElement('div') | ||
document.body.appendChild(el) | ||
reactDom.render(react.createElement(Button), el) | ||
reactDom.render(react.createElement(ReactButton, { color: 'green' }), el) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.