Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 569b724

Browse files
committed
Merge branch 'ember-template-imports' of https://github.com/IgnaceMaes/js-framework-benchmark into IgnaceMaes-ember-template-imports
2 parents 9688e85 + 6c45fe5 commit 569b724

File tree

11 files changed

+26654
-15811
lines changed

11 files changed

+26654
-15811
lines changed

frameworks/keyed/ember/.prettierrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict';
22

33
module.exports = {
4+
plugins: ['prettier-plugin-ember-template-tag'],
45
overrides: [
56
{
6-
files: '*.{js,ts}',
7+
files: '*.{js,ts,gts,gjs}',
78
options: {
89
singleQuote: true,
910
},
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<template>
2+
<button
3+
type="button"
4+
class="btn btn-primary btn-block"
5+
...attributes>
6+
{{yield}}
7+
</button>
8+
</template>

frameworks/keyed/ember/app/components/bs-button.hbs

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
import Component from '@glimmer/component';
2+
import { action } from '@ember/object';
3+
import { tracked } from '@glimmer/tracking';
4+
import { inject as service } from '@ember/service';
5+
import { on } from '@ember/modifier';
6+
import { fn } from '@ember/helper';
7+
8+
import BsButton from 'ember-temp/components/bs-button';
9+
import {
10+
run, runLots, add, update, swapRows, deleteRow,
11+
} from 'ember-temp/utils/benchmark-helpers';
12+
13+
function eq(a, b) {
14+
return a === b;
15+
}
16+
17+
export default class MyTable extends Component {
18+
@tracked
19+
id = 1;
20+
21+
@tracked
22+
data = [];
23+
24+
@tracked selected = undefined;
25+
26+
@action create() {
27+
const result = run(this.id);
28+
29+
this.id = result.id;
30+
this.data = result.data;
31+
this.selected = undefined;
32+
}
33+
34+
@action add() {
35+
const result = add(this.id, this.data);
36+
this.id = result.id;
37+
this.data = result.data;
38+
}
39+
40+
@action update() {
41+
update(this.data);
42+
}
43+
44+
@action runLots() {
45+
const result = runLots(this.id);
46+
47+
this.data = result.data;
48+
this.id = result.id;
49+
this.selected = undefined;
50+
}
51+
52+
@action clear() {
53+
this.data = [];
54+
this.selected = undefined;
55+
}
56+
57+
@action swapRows() {
58+
this.data = swapRows(this.data);
59+
}
60+
61+
@action remove({id}) {
62+
this.data = deleteRow(this.data, id);
63+
this.selected = undefined;
64+
}
65+
66+
@action select({id}) {
67+
this.selected = id;
68+
}
69+
70+
<template>
71+
<div class="jumbotron">
72+
<div class="row">
73+
<div class="col-md-6">
74+
<h1>Ember</h1>
75+
</div>
76+
<div class="col-md-6">
77+
<div class="row">
78+
<div class="col-sm-6 smallpad">
79+
<BsButton id="run" {{on 'click' this.create}}>
80+
Create 1,000 rows
81+
</BsButton>
82+
</div>
83+
<div class="col-sm-6 smallpad">
84+
<BsButton id="runlots" {{on 'click' this.runLots}}>
85+
Create 10,000 rows
86+
</BsButton>
87+
</div>
88+
<div class="col-sm-6 smallpad">
89+
<BsButton id="add" {{on 'click' this.add}}>
90+
Append 1,000 rows
91+
</BsButton>
92+
</div>
93+
<div class="col-sm-6 smallpad">
94+
<BsButton id="update" {{on 'click' this.update}}>
95+
Update every 10th row
96+
</BsButton>
97+
</div>
98+
<div class="col-sm-6 smallpad">
99+
<BsButton id="clear" {{on 'click' this.clear}}>
100+
Clear
101+
</BsButton>
102+
</div>
103+
<div class="col-sm-6 smallpad">
104+
<BsButton id="swaprows" {{on 'click' this.swapRows}}>
105+
Swap Rows
106+
</BsButton>
107+
</div>
108+
</div>
109+
</div>
110+
</div>
111+
</div>
112+
113+
{{#if this.data.length}}
114+
<table class="table table-hover table-striped test-data">
115+
<tbody>
116+
{{#each this.data key="id" as |item|}}
117+
<tr class={{if (eq item.id this.selected) 'danger'}}>
118+
<td class="col-md-1">{{item.id}}</td>
119+
<td class="col-md-4"><a {{on 'click' (fn this.select item)}}>{{item.label}}</a></td>
120+
<td class="col-md-1"><a {{on 'click' (fn this.remove item)}}><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></td>
121+
<td class="col-md-6"></td>
122+
</tr>
123+
{{/each}}
124+
</tbody>
125+
</table>
126+
{{/if}}
127+
128+
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span>
129+
</template>
130+
}

frameworks/keyed/ember/app/components/my-table.hbs

Lines changed: 0 additions & 60 deletions
This file was deleted.

frameworks/keyed/ember/app/components/my-table.js

Lines changed: 0 additions & 73 deletions
This file was deleted.

frameworks/keyed/ember/app/helpers/eq.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

frameworks/keyed/ember/app/services/state.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)