Skip to content

Commit 81384c4

Browse files
authored
Merge pull request #10 from IzumiSy/upgrade_choo_version
Upgrade choo version to 6
2 parents 6c05756 + e021f6f commit 81384c4

File tree

10 files changed

+23
-141
lines changed

10 files changed

+23
-141
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

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

5-
> Updated to work with choo 4
6-
75
## Create a new template
86

97
To create a new template

_app/README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ applications and reusability.
77
assets/ images and fonts, if you have any
88
elements/ standalone application-specific elements
99
lib/ generalized components, should be moved out of project later
10-
models/ choo models
1110
pages/ views that are directly mounted on the router
1211
scripts/ shell scripts, to be interfaced with through `npm scripts`
1312
client.js main application entry; programmatic manifest file
@@ -22,11 +21,6 @@ Pages
2221
$ choo generate page my-page
2322
```
2423

25-
Models
26-
```bash
27-
$ choo generate model my-model
28-
```
29-
3024
Elements
3125
```bash
3226
$ choo generate element my-element

_app/_choo.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ generators:
99
element:
1010
src: .generators/element.js
1111
target: elements
12-
model:
13-
src: .generators/model.js
14-
target: models
1512
required:
1613
- _choo.yaml
1714
- _gitignore

_app/_package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"author": "",
1414
"license": "MIT",
1515
"dependencies": {
16-
"choo": "^4.1.0"
16+
"choo": "^6.1.0"
1717
},
1818
"devDependencies": {
1919
"bankai": "^9.0.0-rc7",

_app/client.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
const choo = require('choo')
22
const app = choo()
33

4-
app.model(require('./models/app'))
5-
6-
app.router(['/', require('./pages/home')])
7-
8-
const tree = app.start()
9-
10-
document.body.appendChild(tree)
4+
app.use(require('./stores/home'))
5+
app.route('/', require('./pages/home'))
6+
7+
// Support for Server-Side Rendering
8+
if (module.parent) {
9+
module.exports = app
10+
} else {
11+
app.mount('body')
12+
}

_app/models/README.md

Lines changed: 0 additions & 46 deletions
This file was deleted.

_app/models/app.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

_app/pages/home.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
const html = require('choo/html')
22

3-
module.exports = function (state, prev, send) {
3+
module.exports = function (state, emit) {
44
return html`
5-
<main>
5+
<body>
66
<h1>Hello, World!</h1>
77
<p>If you are seeing this, then the generator works!</p>
88
<h2>Demo</h2>
99
<h3>${state.title}</h3>
10-
<input type="text" oninput=${update} />
11-
</main>
10+
<input type="text" oninput=${update} value=${state.title} />
11+
</body>
1212
`
1313

1414
function update (e) {
15-
send('update', { value: e.target.value })
15+
emit('update', { value: e.target.value })
1616
}
1717
}

_app/stores/home.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = function (state, emitter) {
2+
state.title = ''
3+
4+
emitter.on('update', function({ value }) {
5+
state.title = value
6+
emitter.emit('render')
7+
})
8+
}

_generators/model.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)