Skip to content

Commit

Permalink
cleanup dynamic tab demo
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewseguin committed Dec 5, 2016
1 parent 11cce4d commit 41eda70
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 70 deletions.
127 changes: 65 additions & 62 deletions src/demo-app/tabs/tabs-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,76 +16,79 @@ <h1>Tab Nav Bar</h1>

<h1>Tab Group Demo - Dynamic Tabs</h1>

<md-card>
<md-card-title>Add New Tab</md-card-title>
<md-card-content>
<md-checkbox [(ngModel)]="createWithLongContent">
Include extra content
</md-checkbox>
<md-checkbox [(ngModel)]="gotoNewTabAfterAdding">
Select after adding
</md-checkbox>
<div>
Position:
<md-input type="number" [(ngModel)]="addTabPosition"></md-input>
</div>
<button md-raised-button color="primary"
(click)="addTab(createWithLongContent)">
Add
</button>
</md-card-content>
</md-card>

<div>
Selected tab index:
<md-input type="number" [(ngModel)]="activeTabIndex"></md-input>
</div>
<md-tab-group class="demo-tab-group"
md-dynamic-height
[(selectedIndex)]="activeTabIndex">
<md-tab *ngFor="let tab of dynamicTabs" [disabled]="tab.disabled">
<template md-tab-label>{{tab.label}}</template>
{{tab.content}}
<br>
<br>
<div *ngIf="tab.extraContent">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla venenatis ante augue.
Phasellus volutpat neque ac dui mattis vulputate. Etiam consequat aliquam cursus.
In sodales pretium ultrices. Maecenas lectus est, sollicitudin consectetur felis nec,
feugiat ultricies mi. Aliquam erat volutpat. Nam placerat, tortor in ultrices porttitor,
orci enim rutrum enim, vel tempor sapien arcu a tellus. Vivamus convallis sodales ante varius
gravida. Curabitur a purus vel augue ultrices ultricies id a nisl. Nullam malesuada consequat
diam, a facilisis tortor volutpat et. Sed urna dolor, aliquet vitae posuere vulputate, euismod
ac lorem. Sed felis risus, pulvinar at interdum quis, vehicula sed odio. Phasellus in enim
venenatis, iaculis tortor eu, bibendum ante. Donec ac tellus dictum neque volutpat blandit.
Praesent efficitur faucibus risus, ac auctor purus porttitor vitae. Phasellus ornare dui nec
orci posuere, nec luctus mauris semper.

<div class="dynamic-tabs-demo">
<md-card>
<md-card-title>Add New Tab</md-card-title>
<md-card-content>
<md-checkbox [(ngModel)]="createWithLongContent">
Include extra content
</md-checkbox>
<md-checkbox [(ngModel)]="gotoNewTabAfterAdding">
Select after adding
</md-checkbox>
<div>
Position:
<md-input type="number" [(ngModel)]="addTabPosition"></md-input>
</div>
<button md-raised-button color="primary"
(click)="addTab(createWithLongContent)">
Add
</button>
</md-card-content>
</md-card>

<md-tab-group class="demo-tab-group"
md-dynamic-height
[(selectedIndex)]="activeTabIndex">
<md-tab *ngFor="let tab of dynamicTabs" [disabled]="tab.disabled">
<template md-tab-label>{{tab.label}}</template>
{{tab.content}}
<br>
<br>
Morbi viverra, ante vel aliquet tincidunt, leo dolor pharetra quam, at semper massa orci nec
magna. Donec posuere nec sapien sed laoreet. Etiam cursus nunc in condimentum facilisis.
Etiam in tempor tortor. Vivamus faucibus egestas enim, at convallis diam pulvinar vel.
Cras ac orci eget nisi maximus cursus. Nunc urna libero, viverra sit amet nisl at, hendrerit
tempor turpis. Maecenas facilisis convallis mi vel tempor. Nullam vitae nunc leo. Cras sed
nisl consectetur, rhoncus sapien sit amet, tempus sapien.
<div *ngIf="tab.extraContent">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla venenatis ante augue.
Phasellus volutpat neque ac dui mattis vulputate. Etiam consequat aliquam cursus.
In sodales pretium ultrices. Maecenas lectus est, sollicitudin consectetur felis nec,
feugiat ultricies mi. Aliquam erat volutpat. Nam placerat, tortor in ultrices porttitor,
orci enim rutrum enim, vel tempor sapien arcu a tellus. Vivamus convallis sodales ante varius
gravida. Curabitur a purus vel augue ultrices ultricies id a nisl. Nullam malesuada consequat
diam, a facilisis tortor volutpat et. Sed urna dolor, aliquet vitae posuere vulputate, euismod
ac lorem. Sed felis risus, pulvinar at interdum quis, vehicula sed odio. Phasellus in enim
venenatis, iaculis tortor eu, bibendum ante. Donec ac tellus dictum neque volutpat blandit.
Praesent efficitur faucibus risus, ac auctor purus porttitor vitae. Phasellus ornare dui nec
orci posuere, nec luctus mauris semper.
<br>
<br>
Morbi viverra, ante vel aliquet tincidunt, leo dolor pharetra quam, at semper massa orci nec
magna. Donec posuere nec sapien sed laoreet. Etiam cursus nunc in condimentum facilisis.
Etiam in tempor tortor. Vivamus faucibus egestas enim, at convallis diam pulvinar vel.
Cras ac orci eget nisi maximus cursus. Nunc urna libero, viverra sit amet nisl at, hendrerit
tempor turpis. Maecenas facilisis convallis mi vel tempor. Nullam vitae nunc leo. Cras sed
nisl consectetur, rhoncus sapien sit amet, tempus sapien.
<br>
<br>
Integer turpis erat, porttitor vitae mi faucibus, laoreet interdum tellus. Curabitur posuere
molestie dictum. Morbi eget congue risus, quis rhoncus quam. Suspendisse vitae hendrerit erat,
at posuere mi. Cras eu fermentum nunc. Sed id ante eu orci commodo volutpat non ac est.
Praesent ligula diam, congue eu enim scelerisque, finibus commodo lectus.
</div>
<br>
<br>
Integer turpis erat, porttitor vitae mi faucibus, laoreet interdum tellus. Curabitur posuere
molestie dictum. Morbi eget congue risus, quis rhoncus quam. Suspendisse vitae hendrerit erat,
at posuere mi. Cras eu fermentum nunc. Sed id ante eu orci commodo volutpat non ac est.
Praesent ligula diam, congue eu enim scelerisque, finibus commodo lectus.
</div>
<br>
<br>
<md-input placeholder="Tab Label" [(ngModel)]="tab.label"></md-input>
<br><br>
<button md-raised-button
[disabled]="dynamicTabs.length == 1"
(click)="deleteTab(tab)">
Delete Tab
</button>
</md-tab>
</md-tab-group>
<md-input placeholder="Tab Label" [(ngModel)]="tab.label"></md-input>
<br><br>
<button md-raised-button
[disabled]="dynamicTabs.length == 1"
(click)="deleteTab(tab)">
Delete Tab
</button>
</md-tab>
</md-tab-group>
</div>

<h1>Tab Group Demo - Dynamic Height</h1>

Expand Down
33 changes: 25 additions & 8 deletions src/demo-app/tabs/tabs-demo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,33 @@
tabs-demo md-card {
width: 160px;

md-checkbox {
display: block;
margin-top: 8px;
}
}

.dynamic-tabs-demo {
display: flex;
width: 100%;

md-input {
width: 100px;
md-tab-group {
min-width: 200px;
margin-bottom: 0;
flex-grow: 1;
}

button {
width: 100%;
md-card {
min-width: 160px;
margin-right: 16px;

md-checkbox {
display: block;
margin-top: 8px;
}

md-input {
width: 100px;
}

button {
width: 100%;
}
}
}

0 comments on commit 41eda70

Please sign in to comment.