Skip to content

Commit 2820735

Browse files
committed
Merge branch 'leeoniya-leeoniya/ivi-simplify-2'
2 parents 395df57 + a578357 commit 2820735

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

frameworks/keyed/ivi/src/main.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ interface RowProps {
6565
const Row = component<RowProps>((c) => {
6666
const onSelect = () => { dispatch(c, { type: ActionType.Select, entry: getProps(c).entry }); };
6767
const onRemove = () => { dispatch(c, { type: ActionType.Remove, entry: getProps(c).entry }); };
68+
6869
return ({ entry, selected }) => html`
6970
<tr class=${selected === true ? "danger" : ""}>
7071
<td class="col-md-1" .textContent=${entry.id}/>
@@ -81,28 +82,32 @@ const Row = component<RowProps>((c) => {
8182
`;
8283
});
8384

84-
const Button = (text: string, id: string, onClick: () => void) => /* preventClone */ html`
85+
const Button = (text: string, id: string, onClick: () => void) => html`
8586
<div class="col-sm-6 smallpad">
86-
<button class="btn btn-primary btn-block" type="button" id=${id} @click=${onClick} .textContent=${text}/>
87+
<button class="btn btn-primary btn-block" type="button" id=${id} @click=${onClick}>
88+
${text}
89+
</button>
8790
</div>
8891
`;
8992

9093
const App = component((c) => {
9194
const [_state, _dispatch] = useReducer(c, INITIAL_STATE, appStateReducer);
9295

9396
const onDispatch = (ev: CustomEvent<Action>) => { _dispatch(ev.detail); };
97+
9498
const buttons = [
95-
Button("Create 1,000 rows", "run", () => { _dispatch({ type: ActionType.Run }); }),
96-
Button("Create 10,000 rows", "runlots", () => { _dispatch({ type: ActionType.RunLots }); }),
97-
Button("Append 1,000 rows", "add", () => { _dispatch({ type: ActionType.Add }); }),
98-
Button("Update every 10th row", "update", () => { _dispatch({ type: ActionType.Update }); }),
99-
Button("Clear", "clear", () => { _dispatch({ type: ActionType.Clear }); }),
100-
Button("Swap Rows", "swaprows", () => { _dispatch({ type: ActionType.SwapRows }); }),
99+
Button("Create 1,000 rows", "run", () => { _dispatch({ type: ActionType.Run }); }),
100+
Button("Create 10,000 rows", "runlots", () => { _dispatch({ type: ActionType.RunLots }); }),
101+
Button("Append 1,000 rows", "add", () => { _dispatch({ type: ActionType.Add }); }),
102+
Button("Update every 10th row", "update", () => { _dispatch({ type: ActionType.Update }); }),
103+
Button("Clear", "clear", () => { _dispatch({ type: ActionType.Clear }); }),
104+
Button("Swap Rows", "swaprows", () => { _dispatch({ type: ActionType.SwapRows }); }),
101105
];
102106

103107
return () => {
104108
const { data, selected } = _state();
105-
return /* preventClone */ html`
109+
110+
return html`
106111
<div class="container">
107112
<div class="jumbotron">
108113
<div class="row">
@@ -117,10 +122,9 @@ const App = component((c) => {
117122
</div>
118123
</div>
119124
<table class="table table-hover table-striped test-data" @dispatch=${onDispatch}>
120-
${data.length
121-
? html`<tbody>${List(data, getEntryId, (entry) => Row({ entry, selected: selected === entry.id }))}</tbody>`
122-
: html`<tbody/>`
123-
}
125+
<tbody>
126+
${List(data, getEntryId, (entry) => Row({ entry, selected: selected === entry.id }))}
127+
</tbody>
124128
</table>
125129
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"/>
126130
</div>

0 commit comments

Comments
 (0)