Skip to content

Commit 8ec5701

Browse files
committed
Merge branch 'Mikeysax-master'
2 parents c97490c + dc50dca commit 8ec5701

File tree

2 files changed

+39
-55
lines changed

2 files changed

+39
-55
lines changed

frameworks/non-keyed/literaljs/index.js

Lines changed: 34 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,7 @@ import { render, component, h } from 'literaljs';
44

55
import { Store } from './store';
66

7-
const Row = component({
8-
methods() {
9-
return {
10-
rowClass() {
11-
const { item, selected } = this.props;
12-
return item.id === selected ? 'danger' : '';
13-
}
14-
};
15-
},
16-
render() {
17-
const { item, selectRow, deleteRow } = this.props;
18-
return (
19-
<tr class={this.rowClass()}>
20-
<td class="col-md-1">{item.id}</td>
21-
<td class="col-md-4">
22-
<a events={{ click: () => selectRow(item.id) }}>
23-
{item.label}
24-
</a>
25-
</td>
26-
<td class="col-md-1">
27-
<a>
28-
<span
29-
class="glyphicon glyphicon-remove"
30-
aria-hidden="true"
31-
events={{ click: () => deleteRow(item.id) }}
32-
/>
33-
</a>
34-
</td>
35-
</tr>
36-
);
37-
}
38-
});
39-
407
const App = component({
41-
state: {
42-
store: new Store()
43-
},
448
methods() {
459
const { store } = this.getState();
4610
return {
@@ -75,22 +39,11 @@ const App = component({
7539
swapRows() {
7640
store.swapRows();
7741
this.setState({ store });
78-
},
79-
createRows() {
80-
return store.data.map(item => (
81-
<Row
82-
props={{
83-
item,
84-
selected: store.selected,
85-
deleteRow: this.delete,
86-
selectRow: this.select
87-
}}
88-
/>
89-
));
9042
}
9143
};
9244
},
9345
render() {
46+
const { store } = this.getState();
9447
return (
9548
<div class="container">
9649
<div class="jumbotron">
@@ -165,7 +118,38 @@ const App = component({
165118
</div>
166119
</div>
167120
<table class="table table-hover table-striped test-data">
168-
<tbody>{this.createRows()}</tbody>
121+
<tbody>
122+
{store.data.map(item => (
123+
<tr
124+
class={
125+
item.id === store.selected ? 'danger' : ''
126+
}
127+
>
128+
<td class="col-md-1">{item.id}</td>
129+
<td class="col-md-4">
130+
<a
131+
events={{
132+
click: () => this.select(item.id)
133+
}}
134+
>
135+
{item.label}
136+
</a>
137+
</td>
138+
<td class="col-md-1">
139+
<a>
140+
<span
141+
class="glyphicon glyphicon-remove"
142+
aria-hidden="true"
143+
events={{
144+
click: () =>
145+
this.delete(item.id)
146+
}}
147+
/>
148+
</a>
149+
</td>
150+
</tr>
151+
))}
152+
</tbody>
169153
</table>
170154
<span
171155
class="preloadicon glyphicon glyphicon-remove"
@@ -176,4 +160,4 @@ const App = component({
176160
}
177161
});
178162

179-
render(App, 'root', {});
163+
render(App, 'root', { store: new Store() });

frameworks/non-keyed/literaljs/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
"author": "Michael Farrell",
2121
"license": "MIT",
2222
"dependencies": {
23-
"@babel/runtime": "7.4.3",
24-
"literaljs": "5.2.0"
23+
"@babel/runtime": "7.4.5",
24+
"literaljs": "6.0.1"
2525
},
2626
"devDependencies": {
27-
"@babel/core": "7.4.3",
27+
"@babel/core": "7.4.5",
2828
"@babel/plugin-transform-react-jsx": "7.3.0",
29-
"@babel/plugin-transform-runtime": "7.4.3",
29+
"@babel/plugin-transform-runtime": "7.4.4",
3030
"cross-env": "5.2.0",
31-
"node-sass": "4.11.0",
31+
"node-sass": "4.12.0",
3232
"parcel-bundler": "1.12.3"
3333
}
3434
}

0 commit comments

Comments
 (0)