Skip to content

Commit 517f90f

Browse files
committed
Merge branch 'syduki-master'
2 parents e7b0bea + 1b3be2f commit 517f90f

File tree

3 files changed

+25
-31
lines changed

3 files changed

+25
-31
lines changed

frameworks/keyed/karyon/app.js

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,42 @@ const rows = State([]);
88
const selection = State();
99

1010
const create = ((ID, $) => count => [...Array(count)].map(() =>
11-
Row(++ID, `${$(adjectives)} ${$(colours)} ${$(nouns)}`)
11+
Row(++ID, State(`${$(adjectives)} ${$(colours)} ${$(nouns)}`))
1212
))(0, $ => $[Math.round(Math.random() * 1000) % $.length]);
1313

14-
const select = function () { selection(this.row.ID); };
14+
const select = function () { selection(this.ID); };
1515

16-
const remove = function () {
17-
const data = new Set(rows());
18-
data.delete(this.row) && rows([...data]);
19-
};
16+
const remove = (filter => function () {
17+
rows(rows().filter(filter, this.ID));
18+
})(function (row) { return row?.ID !== this; });
2019

21-
const Row = (ID, label) => {
22-
const danger = State.track(selection, ID);
23-
const row = {is: 'tr', class: {danger}, ID, label: State(label)};
24-
row.content = [
20+
const Row = (selected => (ID, text) =>
21+
({is: 'tr', content: [
2522
{is: 'td', class: 'col-md-1', content: ID},
2623
{is: 'td', class: 'col-md-4', content:
27-
{is: 'a', action: select, row, content: row.label}},
24+
{is: 'a', action: select, content: text}},
2825
{is: 'td', class: 'col-md-1', content:
29-
{is: 'a', action: remove, row, content: Icon()}},
26+
{is: 'a', action: remove, content: Icon('')}},
3027
{is: 'td', class: 'col-md-6'}
31-
];
32-
return row;
33-
};
28+
], class: State.track(selection, ID, selected), ID, text})
29+
)(on => on && 'danger');
3430

35-
const Icon = (type = '') =>
31+
const Icon = name =>
3632
({is: 'span', attrs: {'aria-hidden': 'true'},
37-
class: `glyphicon glyphicon-remove ${type}`});
33+
class: `glyphicon glyphicon-remove ${name}`});
3834

3935
const actions = [
4036
['Create 1,000 rows', 'run', () => rows(create(1000))],
4137
['Create 10,000 rows', 'runlots', () => rows(create(10000))],
4238
['Append 1,000 rows', 'add', () => rows([...rows(), ...create(1000)])],
4339
['Clear', 'clear', () => rows([])],
4440
['Update every 10th row', 'update', () => {
45-
const data = rows();
46-
for (let i = 0, row; i < data.length; i += 10)
47-
(row = data[i])?.label(row.label() + ' !!!');
41+
for (let i = 0, all = rows(), row; i < all.length; i += 10)
42+
(row = all[i])?.text(`${row.text()} !!!`);
4843
}],
4944
['Swap Rows', 'swaprows', () => {
50-
const data = rows();
51-
[data[1], data[998]] = [data[998], data[1]];
52-
rows([...data]);
45+
const all = rows();
46+
[all[1], all[998]] = [all[998], all[1]], rows([...all]);
5347
}]].map(([content, id, click]) =>
5448
({class: 'col-sm-6 smallpad', content:
5549
{is: 'button', id, class: 'btn btn-primary btn-block',

frameworks/keyed/karyon/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/keyed/karyon/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"issues": [801]
88
},
99
"dependencies": {
10-
"karyon": "1.5.1"
10+
"karyon": "1.6.0"
1111
},
1212
"devDependencies": {
1313
"esbuild": "0.15.15"

0 commit comments

Comments
 (0)