Skip to content

Commit

Permalink
Nesting Creams example
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxenko committed Mar 29, 2017
1 parent 88ba1a6 commit bb500c6
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/nesting/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
'presets' : ['es2015', 'react']
}
10 changes: 10 additions & 0 deletions examples/nesting/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script src="./bundle.js"></script>
</body>
</html>
33 changes: 33 additions & 0 deletions examples/nesting/app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/** @jsx h */
import './index.html';
import {h, Cream, create, inject, _container } from '../../../';
import Store from './store';
import Record from './record';

var c =create({
element : document.body,
elementId : 'application',
elementClass : 'cake-application'
})
.route('/', 'records.index')

Cream.extend({
_namespace: 'records.index',

render: function() {
return (
<div>
<h2>List of Records</h2>
{Store.store.map(function(r, i) {
return (
<Record title={i + '. ' + r.title}>
<em>{r.content}</em>
</Record>
);
})
}
</div>
);
}
});

13 changes: 13 additions & 0 deletions examples/nesting/app/record.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @jsx h */
import {h, Cream} from '../../../';

export default Cream.extend({
render: function() {
return (
<div>
<h3>{this.props.title}</h3>
<div>{this.props.children}</div>
</div>
);
}
});
13 changes: 13 additions & 0 deletions examples/nesting/app/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {Cream} from '../../../';

export default Cream.extend({
byId: function(id) {
return this.store[id];
},

store: [
{ title: 'First record', content: 'First record content' },
{ title: 'Second record', content: 'Second record content' },
{ title: 'Third record', content: 'Third record content' }
]
});
13 changes: 13 additions & 0 deletions examples/nesting/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "example",
"author": "Svetlana Linuxenko <linuxenko@yahoo.com> (http://www.linuxenko.pro)",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.18.2",
"babel-loader": "^6.2.8",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"file-loader": "^0.9.0",
"webpack": "^1.13.3"
}
}
49 changes: 49 additions & 0 deletions examples/nesting/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* global __dirname */

var path = require('path');

var webpack = require('webpack');
var dir_js = path.resolve(__dirname, 'app');
var dir_build = path.resolve(__dirname, 'build');

module.exports = {
entry: {
app : path.resolve(dir_js, 'index.js')
},
devtool: 'source-map',
output: {
path: dir_build,
filename: 'bundle.js'
},
resolveLoader: {
fallback: [path.join(__dirname, 'node_modules')]
},
resolve: {
modulesDirectories: ['node_modules', '../../../', dir_js],
fallback: [path.join(__dirname, 'node_modules')]
},
devServer: {
contentBase: dir_build,
},
module: {
loaders: [
{
loader: 'babel-loader',
test: /\.js$/,
exclude: /node_modules/,
presets : ['es2015', 'react']
},
{
test : /\.html$/,
loader : 'file?name=[name].html'
}
]
},
plugins: [
new webpack.NoErrorsPlugin()

],
stats: {
colors: true
}
};

0 comments on commit bb500c6

Please sign in to comment.