File tree Expand file tree Collapse file tree 1 file changed +50
-27
lines changed
frameworks/keyed/qwik/src/components/app Expand file tree Collapse file tree 1 file changed +50
-27
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,48 @@ export function buildData(count: number) {
74
74
return data ;
75
75
}
76
76
77
+ export const Row = component$ (
78
+ ( {
79
+ item,
80
+ state,
81
+ isSelected,
82
+ } : {
83
+ item : BenchState [ "data" ] [ 0 ] ;
84
+ state : BenchState ;
85
+ isSelected : boolean ;
86
+ } ) => {
87
+ const { id, label } = item ;
88
+ return (
89
+ < tr class = { isSelected ? "danger" : "" } >
90
+ < td class = "col-md-1" > { item . id } </ td >
91
+ < td class = "col-md-4" >
92
+ < a
93
+ onClick$ = { ( ) => {
94
+ state . selected = id ;
95
+ } }
96
+ >
97
+ { label }
98
+ </ a >
99
+ </ td >
100
+ < td class = "col-md-1" >
101
+ < a
102
+ onClick$ = { ( ) => {
103
+ const d = state . data ;
104
+ d . splice (
105
+ d . findIndex ( ( d ) => d . id === id ) ,
106
+ 1
107
+ ) ;
108
+ } }
109
+ >
110
+ < span class = "glyphicon glyphicon-remove" aria-hidden = "true" />
111
+ </ a >
112
+ </ td >
113
+ < td class = "col-md-6" />
114
+ </ tr >
115
+ ) ;
116
+ }
117
+ ) ;
118
+
77
119
type BenchState = {
78
120
data : Array < { id : number ; label : string } > ;
79
121
selected : number | null ;
@@ -163,33 +205,14 @@ export const App = component$(() => {
163
205
</ div >
164
206
< table class = "table table-hover table-striped test-data" >
165
207
< tbody >
166
- { state . data . map ( ( { id, label } ) => {
167
- return (
168
- < tr key = { id } class = { id === state . selected ? "danger" : "" } >
169
- < td class = "col-md-1" > { id } </ td >
170
- < td class = "col-md-4" >
171
- < a onClick$ = { ( ) => ( state . selected = id ) } > { label } </ a >
172
- </ td >
173
- < td class = "col-md-1" >
174
- < a
175
- onClick$ = { ( ) => {
176
- const d = state . data ;
177
- d . splice (
178
- d . findIndex ( ( d ) => d . id === id ) ,
179
- 1
180
- ) ;
181
- } }
182
- >
183
- < span
184
- class = "glyphicon glyphicon-remove"
185
- aria-hidden = "true"
186
- />
187
- </ a >
188
- </ td >
189
- < td class = "col-md-6" />
190
- </ tr >
191
- ) ;
192
- } ) }
208
+ { state . data . map ( ( item ) => (
209
+ < Row
210
+ key = { item . id }
211
+ item = { item }
212
+ state = { state }
213
+ isSelected = { item . id === state . selected }
214
+ />
215
+ ) ) }
193
216
</ tbody >
194
217
</ table >
195
218
< span class = "preloadicon glyphicon glyphicon-remove" aria-hidden = "true" />
You can’t perform that action at this time.
0 commit comments