@@ -65,6 +65,7 @@ interface RowProps {
65
65
const Row = component < RowProps > ( ( c ) => {
66
66
const onSelect = ( ) => { dispatch ( c , { type : ActionType . Select , entry : getProps ( c ) . entry } ) ; } ;
67
67
const onRemove = ( ) => { dispatch ( c , { type : ActionType . Remove , entry : getProps ( c ) . entry } ) ; } ;
68
+
68
69
return ( { entry, selected } ) => html `
69
70
< tr class =${ selected === true ? "danger" : "" } >
70
71
< td class ="col-md-1 " .textContent =${ entry . id } / >
@@ -81,28 +82,32 @@ const Row = component<RowProps>((c) => {
81
82
` ;
82
83
} ) ;
83
84
84
- const Button = ( text : string , id : string , onClick : ( ) => void ) => /* preventClone */ html `
85
+ const Button = ( text : string , id : string , onClick : ( ) => void ) => html `
85
86
< 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 >
87
90
</ div >
88
91
` ;
89
92
90
93
const App = component ( ( c ) => {
91
94
const [ _state , _dispatch ] = useReducer ( c , INITIAL_STATE , appStateReducer ) ;
92
95
93
96
const onDispatch = ( ev : CustomEvent < Action > ) => { _dispatch ( ev . detail ) ; } ;
97
+
94
98
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 } ) ; } ) ,
101
105
] ;
102
106
103
107
return ( ) => {
104
108
const { data, selected } = _state ( ) ;
105
- return /* preventClone */ html `
109
+
110
+ return html `
106
111
< div class ="container ">
107
112
< div class ="jumbotron ">
108
113
< div class ="row ">
@@ -117,10 +122,9 @@ const App = component((c) => {
117
122
</ div >
118
123
</ div >
119
124
< 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 >
124
128
</ table >
125
129
< span class ="preloadicon glyphicon glyphicon-remove " aria-hidden ="true "/>
126
130
</ div >
0 commit comments