Skip to content

Commit

Permalink
chore(sample): support toggling between div and table markup
Browse files Browse the repository at this point in the history
  • Loading branch information
martingust committed Jul 8, 2016
1 parent 0281d31 commit cb23200
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
25 changes: 24 additions & 1 deletion sample/src/phone-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
<button class="btn btn-primary" click.delegate="removeLast()">Remove 1 at bottom</button>
<button class="btn btn-primary" click.delegate="toggle()">Toggle visibility</button>
<button class="btn btn-primary" click.delegate="swap()">Swap</button>
<select value.bind="selectedMarkup" class="form-control">
<option value="div">div</option>
<option value="table">table</option>
</select>
</div>

<div if.bind="isVisible">
<div if.bind="isVisible && selectedMarkup === 'div'">
<div virtual-repeat.for="item of objectArray" class="contact-list-item ${item.name}">
<div class="contact-item">
<div class="avatar" click.delegate="click()" css="background-color: ${item.color}">${item.firstLetter}</div>
Expand All @@ -25,4 +29,23 @@
</div>
</div>
</div>

<div if.bind="isVisible && selectedMarkup === 'table'">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Phone</th>
<th>Country</th>
</tr>
</thead>
<tr virtual-repeat.for="item of objectArray" class="contact-list-item ${item.name}">
<td class="avatar" click.delegate="click()" css="background-color: ${item.color}">${item.firstLetter}</td>
<td class="name">${$index} ${item.name}</td>
<td><strong>Phone:</strong> ${item.phone} </td>
<td>Country:</strong> ${item.country} </td>
</tr>
</table>
</div>
</template>
8 changes: 5 additions & 3 deletions sample/src/phone-list.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export class PhoneList {
selectedMarkup = 'div';

constructor() {
this.objectArray = [];
this.objectArray2 = [];
this.numberOfItems = 100;
this.isSelected = false;
this.isVisible = true;
this.viewStrategy = 'div';
}

setViewStrategy(strategy){
Expand Down Expand Up @@ -67,8 +67,10 @@ export class PhoneList {
this.objectArray.splice(1, 0, item);
}

addItemFirst(){
this.objectArray.unshift(this.createItem());
addItemFirst(count = 10){
for(let i = 0; i < count; ++i) {
this.objectArray.unshift(this.createItem());
}
}

removeItems(count){
Expand Down
13 changes: 13 additions & 0 deletions sample/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,16 @@ section {
text-align: center;
line-height: 65px;
}

.array-actions select {
width: 100px;
}

table.table {
margin-top: 200px;
border-top: 0px solid red;
}

table.table td, table.table th {
color: #fff;
}

0 comments on commit cb23200

Please sign in to comment.