Skip to content
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

maquette-v3.0.1-keyed #271

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 16 additions & 0 deletions maquette-v3.0.1-keyed/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const rollup = require('rollup').rollup;
const buble = require('rollup-plugin-buble');
const uglify = require('rollup-plugin-uglify');
const commonjs = require('rollup-plugin-commonjs');

rollup({
input: 'src/main.es6.js',
plugins: [
commonjs(),
buble(),
uglify(),
]
}).then(bundle => bundle.write({
file: 'dist/bundle.js',
format: 'iife'
})).catch(err => console.log(err.stack));
11 changes: 11 additions & 0 deletions maquette-v3.0.1-keyed/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>maquette v3.0.1-keyed</title>
<link href="/css/currentStyle.css" rel="stylesheet"/>
</head>
<body>
<script src='dist/bundle.js'></script>
</body>
</html>
18 changes: 18 additions & 0 deletions maquette-v3.0.1-keyed/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "js-framework-benchmark-maquette-keyed",
"version": "3.0.1-non-keyed",
"description": "Benchmark for maquette framework (keyed)",
"scripts": {
"build-dev": "node build.js",
"build-prod": "node build.js"
},
"devDependencies": {
"rollup": "*",
"rollup-plugin-buble": "*",
"rollup-plugin-commonjs": "*",
"rollup-plugin-uglify": "*"
},
"dependencies": {
"maquette": "^3.0.1"
}
}
112 changes: 112 additions & 0 deletions maquette-v3.0.1-keyed/src/main.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import maquette from './maquette.umd.js';
import {Store} from './store.es6';

const h = maquette.h;
const projector = maquette.createProjector();

const store = new Store();
const app = App();

projector.append(document.body, app.render);

function App() {
const jumbo = Jumbotron();
const table = Table();

return {
render: () =>
h("div#main", [
h("div.container", [
jumbo.render(),
table.render(),
h("span.preloadicon.glyphicon.glyphicon-remove", {"aria-hidden": ""})
])
])
};
}

function Jumbotron() {
let exec = name => e => {
store[name]();
};

let run = exec("run");
let runLots = exec("runLots");
let add = exec("add");
let update = exec("update");
let clear = exec("clear");
let swapRows = exec("swapRows");

return {
render: () =>
h("div.jumbotron", [
h("div.row", [
h("div.col-md-6", [
h("h1", ["maquette v3.0.1 (keyed)"])
]),
h("div.col-md-6", [
h("div.row", [
h("div.col-sm-6.smallpad", [
h("button.btn.btn-primary.btn-block#run", {type: "button", onclick: run}, ["Create 1,000 rows"])
]),
h("div.col-sm-6.smallpad", [
h("button.btn.btn-primary.btn-block#runlots", {type: "button", onclick: runLots}, ["Create 10,000 rows"])
]),
h("div.col-sm-6.smallpad", [
h("button.btn.btn-primary.btn-block#add", {type: "button", onclick: add}, ["Append 1,000 rows"])
]),
h("div.col-sm-6.smallpad", [
h("button.btn.btn-primary.btn-block#update", {type: "button", onclick: update}, ["Update every 10th row"])
]),
h("div.col-sm-6.smallpad", [
h("button.btn.btn-primary.btn-block#clear", {type: "button", onclick: clear}, ["Clear"])
]),
h("div.col-sm-6.smallpad", [
h("button.btn.btn-primary.btn-block#swaprows", {type: "button", onclick: swapRows}, ["Swap Rows"])
])
])
])
])
])
};
}

function Table() {
// delegated handler
function tableClick(e) {
var node = e.target;

if (node.matches(".remove, .remove *")) {
while (node.nodeName != "TR")
node = node.parentNode;
store.delete(+node.firstChild.textContent);
e.stopPropagation();
}
else if (node.matches(".lbl")) {
while (node.nodeName != "TR")
node = node.parentNode;
store.select(+node.firstChild.textContent);
e.stopPropagation();
}
}

return {
render: () =>
h("table.table.table-hover.table-striped.test-data", {onclick: tableClick}, [
h("tbody", store.data.map(item =>
h("tr" + (item.id === store.selected ? '.danger' : ''), {key: item.id}, [
h("td.col-md-1", [""+item.id]),
h("td.col-md-4", [
h("a.lbl", [item.label])
]),
h("td.col-md-1", [
h("a.remove", [
h("span.glyphicon.glyphicon-remove", {"aria-hidden": ""})
])
]),
h("td.col-md-6")
])
))
])
};
}
Loading