Skip to content

Upgrade choo version to 6 #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

The default template for [choo-cli](https://github.com/trainyard/choo-cli)

> Updated to work with choo 4

## Create a new template

To create a new template
Expand Down
6 changes: 0 additions & 6 deletions _app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ applications and reusability.
assets/ images and fonts, if you have any
elements/ standalone application-specific elements
lib/ generalized components, should be moved out of project later
models/ choo models
pages/ views that are directly mounted on the router
scripts/ shell scripts, to be interfaced with through `npm scripts`
client.js main application entry; programmatic manifest file
Expand All @@ -22,11 +21,6 @@ Pages
$ choo generate page my-page
```

Models
```bash
$ choo generate model my-model
```

Elements
```bash
$ choo generate element my-element
Expand Down
3 changes: 0 additions & 3 deletions _app/_choo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ generators:
element:
src: .generators/element.js
target: elements
model:
src: .generators/model.js
target: models
required:
- _choo.yaml
- _gitignore
Expand Down
2 changes: 1 addition & 1 deletion _app/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"choo": "^4.1.0"
"choo": "^6.1.0"
},
"devDependencies": {
"bankai": "^9.0.0-rc7",
Expand Down
16 changes: 9 additions & 7 deletions _app/client.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const choo = require('choo')
const app = choo()

app.model(require('./models/app'))

app.router(['/', require('./pages/home')])

const tree = app.start()

document.body.appendChild(tree)
app.use(require('./stores/home'))
app.route('/', require('./pages/home'))

// Support for Server-Side Rendering
if (module.parent) {
module.exports = app
} else {
app.mount('body')
}
46 changes: 0 additions & 46 deletions _app/models/README.md

This file was deleted.

34 changes: 0 additions & 34 deletions _app/models/app.js

This file was deleted.

10 changes: 5 additions & 5 deletions _app/pages/home.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
const html = require('choo/html')

module.exports = function (state, prev, send) {
module.exports = function (state, emit) {
return html`
<main>
<body>
<h1>Hello, World!</h1>
<p>If you are seeing this, then the generator works!</p>
<h2>Demo</h2>
<h3>${state.title}</h3>
<input type="text" oninput=${update} />
</main>
<input type="text" oninput=${update} value=${state.title} />
</body>
`

function update (e) {
send('update', { value: e.target.value })
emit('update', { value: e.target.value })
}
}
8 changes: 8 additions & 0 deletions _app/stores/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = function (state, emitter) {
state.title = ''

emitter.on('update', function({ value }) {
state.title = value
emitter.emit('render')
})
}
37 changes: 0 additions & 37 deletions _generators/model.js

This file was deleted.