Skip to content

Commit 970b34f

Browse files
committed
reproduce exactly the correct css
1 parent f3e82b3 commit 970b34f

File tree

1 file changed

+79
-17
lines changed

1 file changed

+79
-17
lines changed

frameworks/keyed/ivi/src/main.ts

Lines changed: 79 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,49 @@ import { htm } from "@ivi/tpl";
33
import { Entry, State, Action, ActionType } from "./types.js";
44

55
const random = (max: number) => Math.round(Math.random() * 1000) % max;
6-
const A = ["pretty", "large", "big", "small", "tall", "short", "long", "handsome", "plain", "quaint", "clean", "elegant", "easy", "angry", "crazy", "helpful", "mushy", "odd", "unsightly", "adorable", "important", "inexpensive", "cheap", "expensive", "fancy"];
6+
const A = [
7+
"pretty",
8+
"large",
9+
"big",
10+
"small",
11+
"tall",
12+
"short",
13+
"long",
14+
"handsome",
15+
"plain",
16+
"quaint",
17+
"clean",
18+
"elegant",
19+
"easy",
20+
"angry",
21+
"crazy",
22+
"helpful",
23+
"mushy",
24+
"odd",
25+
"unsightly",
26+
"adorable",
27+
"important",
28+
"inexpensive",
29+
"cheap",
30+
"expensive",
31+
"fancy",
32+
];
733
const C = ["red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"];
8-
const N = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse", "keyboard"];
34+
const N = [
35+
"table",
36+
"chair",
37+
"house",
38+
"bbq",
39+
"desk",
40+
"car",
41+
"pony",
42+
"cookie",
43+
"sandwich",
44+
"burger",
45+
"pizza",
46+
"mouse",
47+
"keyboard",
48+
];
949

1050
let nextId = 1;
1151
function buildData(count: number): Entry[] {
@@ -64,15 +104,19 @@ interface RowProps {
64104
}
65105

66106
const Row = component<RowProps>((c) => {
67-
const onSelect = () => { dispatch(c, { type: ActionType.Select, entry: getProps(c).entry }); };
68-
const onRemove = () => { dispatch(c, { type: ActionType.Remove, entry: getProps(c).entry }); };
107+
const onSelect = () => {
108+
dispatch(c, { type: ActionType.Select, entry: getProps(c).entry });
109+
};
110+
const onRemove = () => {
111+
dispatch(c, { type: ActionType.Remove, entry: getProps(c).entry });
112+
};
69113
return ({ entry, selected }) => htm`
70114
tr${selected === true ? "danger" : ""}
71115
td.col-md-1 =${entry.id}
72116
td.col-md-4
73-
a @click=${onSelect} =${entry.label}
117+
a.lbl @click=${onSelect} =${entry.label}
74118
td.col-md-1
75-
a @click=${onRemove} span.glyphicon.glyphicon-remove :aria-hidden='true'
119+
a.remove @click=${onRemove} span.remove.glyphicon.glyphicon-remove :aria-hidden='true'
76120
td.col-md-6
77121
`;
78122
});
@@ -86,14 +130,28 @@ const Button = (text: string, id: string, onClick: () => void) => /* preventClon
86130
const App = component((c) => {
87131
const [_state, _dispatch] = useReducer(c, INITIAL_STATE, appStateReducer);
88132

89-
const onDispatch = (ev: CustomEvent<Action>) => { _dispatch(ev.detail); };
133+
const onDispatch = (ev: CustomEvent<Action>) => {
134+
_dispatch(ev.detail);
135+
};
90136
const buttons = [
91-
Button("Create 1,000 rows", "run", () => { _dispatch({ type: ActionType.Run }); }),
92-
Button("Create 10,000 rows", "runlots", () => { _dispatch({ type: ActionType.RunLots }); }),
93-
Button("Append 1,000 rows", "add", () => { _dispatch({ type: ActionType.Add }); }),
94-
Button("Update every 10th row", "update", () => { _dispatch({ type: ActionType.Update }); }),
95-
Button("Clear", "clear", () => { _dispatch({ type: ActionType.Clear }); }),
96-
Button("Swap Rows", "swaprows", () => { _dispatch({ type: ActionType.SwapRows }); }),
137+
Button("Create 1,000 rows", "run", () => {
138+
_dispatch({ type: ActionType.Run });
139+
}),
140+
Button("Create 10,000 rows", "runlots", () => {
141+
_dispatch({ type: ActionType.RunLots });
142+
}),
143+
Button("Append 1,000 rows", "add", () => {
144+
_dispatch({ type: ActionType.Add });
145+
}),
146+
Button("Update every 10th row", "update", () => {
147+
_dispatch({ type: ActionType.Update });
148+
}),
149+
Button("Clear", "clear", () => {
150+
_dispatch({ type: ActionType.Clear });
151+
}),
152+
Button("Swap Rows", "swaprows", () => {
153+
_dispatch({ type: ActionType.SwapRows });
154+
}),
97155
];
98156

99157
return () => {
@@ -106,16 +164,20 @@ const App = component((c) => {
106164
div.col-md-6 div.row ${buttons}
107165
table.table.table-hover.table-striped.test-data
108166
@dispatch=${onDispatch}
109-
${data.length
110-
? htm`tbody ${List(data, getEntryId, (entry) => Row({ entry, selected: selected === entry.id }))}`
111-
: htm`tbody`}
167+
${
168+
data.length
169+
? htm`tbody ${List(data, getEntryId, (entry) => Row({ entry, selected: selected === entry.id }))}`
170+
: htm`tbody`
171+
}
112172
span.preloadicon.glyphicon.glyphicon-remove :aria-hidden='true'
113173
`;
114174
};
115175
});
116176

117177
update(
118178
// Defines a custom root node that disables batching for benchmark.
119-
defineRoot((root) => { dirtyCheck(root); })(document.getElementById("main")!),
179+
defineRoot((root) => {
180+
dirtyCheck(root);
181+
})(document.getElementById("main")!),
120182
App()
121183
);

0 commit comments

Comments
 (0)