docs(segment): clean up docs on segment, update demo
the demo has been changed to show multiple segments in use, instead of a lot of segments thrown on the page. fixes driftyco/ionic-site#658
Before Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 59 KiB |
@ -7,18 +7,83 @@ import { ionicBootstrap } from 'ionic-angular';
|
|||||||
templateUrl: 'main.html'
|
templateUrl: 'main.html'
|
||||||
})
|
})
|
||||||
class ApiDemoPage {
|
class ApiDemoPage {
|
||||||
appType = "paid";
|
appType = "Paid";
|
||||||
safari = "links";
|
safari = "Shared Links";
|
||||||
news = "local";
|
weather = "sunny";
|
||||||
favorites = "recent";
|
|
||||||
|
|
||||||
purchased = "all";
|
apps = {
|
||||||
mapStyle = "sat";
|
"Paid": [
|
||||||
teslaModels = "X";
|
{
|
||||||
|
name: 'Monopoly',
|
||||||
|
price: '$0.99'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Angry Birds',
|
||||||
|
price: '$2.99'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Free": [
|
||||||
|
{
|
||||||
|
name: 'Snapchat',
|
||||||
|
price: 'GET'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Instagram',
|
||||||
|
price: 'OPEN'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Top": [
|
||||||
|
{
|
||||||
|
name: 'Spotify',
|
||||||
|
price: 'OPEN'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Pandora',
|
||||||
|
price: 'GET'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
pet = "puppies";
|
items = {
|
||||||
calendar = "day";
|
"Bookmarks": [
|
||||||
proxy = "auto";
|
{
|
||||||
|
name: 'Favorites',
|
||||||
|
icon: 'ios-star-outline'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'History',
|
||||||
|
icon: 'ios-clock-outline'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Reading List": [
|
||||||
|
{
|
||||||
|
name: 'Terms of Service',
|
||||||
|
icon: 'create'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'User Guide',
|
||||||
|
icon: 'book'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Shared Links": [
|
||||||
|
{
|
||||||
|
name: 'Ionic Framework',
|
||||||
|
icon: 'ionic'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Learn Angular',
|
||||||
|
icon: 'logo-angular'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
getItems(type) {
|
||||||
|
return this.apps[type];
|
||||||
|
}
|
||||||
|
|
||||||
|
getSafariItems(type) {
|
||||||
|
return this.items[type];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,147 +1,75 @@
|
|||||||
<ion-header>
|
<ion-header>
|
||||||
|
|
||||||
<ion-navbar>
|
<ion-navbar no-border-bottom>
|
||||||
<ion-title>Segment</ion-title>
|
<ion-title>Segment</ion-title>
|
||||||
</ion-navbar>
|
</ion-navbar>
|
||||||
|
|
||||||
<ion-toolbar no-border-top>
|
<ion-toolbar no-border-top>
|
||||||
<ion-segment [(ngModel)]="appType">
|
<ion-segment [(ngModel)]="appType">
|
||||||
<ion-segment-button value="paid">
|
<ion-segment-button value="Paid">
|
||||||
Paid
|
Paid
|
||||||
</ion-segment-button>
|
</ion-segment-button>
|
||||||
<ion-segment-button value="free">
|
<ion-segment-button value="Free">
|
||||||
Free
|
Free
|
||||||
</ion-segment-button>
|
</ion-segment-button>
|
||||||
<ion-segment-button value="top">
|
<ion-segment-button value="Top">
|
||||||
Top
|
Top
|
||||||
</ion-segment-button>
|
</ion-segment-button>
|
||||||
</ion-segment>
|
</ion-segment>
|
||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
|
|
||||||
<ion-toolbar no-border-top>
|
|
||||||
<ion-segment [(ngModel)]="news" secondary>
|
|
||||||
<ion-segment-button value="worldwide">
|
|
||||||
Worldwide
|
|
||||||
</ion-segment-button>
|
|
||||||
<ion-segment-button value="local">
|
|
||||||
Local
|
|
||||||
</ion-segment-button>
|
|
||||||
<ion-segment-button value="headlines">
|
|
||||||
Headlines
|
|
||||||
</ion-segment-button>
|
|
||||||
</ion-segment>
|
|
||||||
</ion-toolbar>
|
|
||||||
|
|
||||||
<ion-toolbar no-border-top>
|
|
||||||
<ion-segment [(ngModel)]="safari" dark class="icon-segment-demo">
|
|
||||||
<ion-segment-button value="bookmarks">
|
|
||||||
<ion-icon name="book"></ion-icon>
|
|
||||||
</ion-segment-button>
|
|
||||||
<ion-segment-button value="history">
|
|
||||||
<ion-icon ios="ios-glasses-outline" md="md-glasses"></ion-icon>
|
|
||||||
</ion-segment-button>
|
|
||||||
<ion-segment-button value="links">
|
|
||||||
<ion-icon ios="ios-at-outline" md="md-at"></ion-icon>
|
|
||||||
</ion-segment-button>
|
|
||||||
</ion-segment>
|
|
||||||
</ion-toolbar>
|
|
||||||
|
|
||||||
<ion-toolbar no-border-top>
|
|
||||||
<ion-segment [(ngModel)]="favorites" danger>
|
|
||||||
<ion-segment-button value="featured">
|
|
||||||
Featured
|
|
||||||
</ion-segment-button>
|
|
||||||
<ion-segment-button value="recent">
|
|
||||||
Recent
|
|
||||||
</ion-segment-button>
|
|
||||||
</ion-segment>
|
|
||||||
</ion-toolbar>
|
|
||||||
|
|
||||||
</ion-header>
|
</ion-header>
|
||||||
|
|
||||||
|
<ion-content class="outer-content">
|
||||||
|
<ion-list>
|
||||||
|
<ion-list-header>{{ appType }}</ion-list-header>
|
||||||
|
<ion-item *ngFor="let item of getItems(appType)">
|
||||||
|
{{ item.name }}
|
||||||
|
<button outline item-right>{{ item.price }}</button>
|
||||||
|
</ion-item>
|
||||||
|
</ion-list>
|
||||||
|
|
||||||
<ion-content padding>
|
<ion-card>
|
||||||
|
<ion-card-header>
|
||||||
<p>Segments can be placed in a toolbar or anywhere in the content.</p>
|
{{ safari }}
|
||||||
|
</ion-card-header>
|
||||||
<ion-segment [(ngModel)]="purchased" primary margin-bottom>
|
<ion-card-content>
|
||||||
<ion-segment-button value="all">
|
<ion-segment [(ngModel)]="safari" dark>
|
||||||
All
|
<ion-segment-button value="Bookmarks">
|
||||||
|
<ion-icon name="book"></ion-icon>
|
||||||
</ion-segment-button>
|
</ion-segment-button>
|
||||||
<ion-segment-button value="not">
|
<ion-segment-button value="Reading List">
|
||||||
Not on This Phone
|
<ion-icon ios="ios-glasses-outline" md="md-glasses"></ion-icon>
|
||||||
|
</ion-segment-button>
|
||||||
|
<ion-segment-button value="Shared Links">
|
||||||
|
<ion-icon ios="ios-at-outline" md="md-at"></ion-icon>
|
||||||
</ion-segment-button>
|
</ion-segment-button>
|
||||||
</ion-segment>
|
</ion-segment>
|
||||||
|
<ion-list style="margin: 0" inset>
|
||||||
<ion-segment [(ngModel)]="mapStyle" secondary margin-bottom>
|
<button ion-item *ngFor="let sItem of getSafariItems(safari)">
|
||||||
<ion-segment-button value="standard">
|
<ion-icon item-left [name]="sItem.icon" primary></ion-icon>
|
||||||
Standard
|
{{ sItem.name }}
|
||||||
</ion-segment-button>
|
</button>
|
||||||
<ion-segment-button value="hybrid">
|
</ion-list>
|
||||||
Hybrid
|
</ion-card-content>
|
||||||
</ion-segment-button>
|
</ion-card>
|
||||||
<ion-segment-button value="sat">
|
|
||||||
Satellite
|
|
||||||
</ion-segment-button>
|
|
||||||
</ion-segment>
|
|
||||||
|
|
||||||
<ion-segment [(ngModel)]="teslaModels" danger margin-bottom>
|
|
||||||
<ion-segment-button value="S">
|
|
||||||
Model S
|
|
||||||
</ion-segment-button>
|
|
||||||
<ion-segment-button value="X">
|
|
||||||
Model X
|
|
||||||
</ion-segment-button>
|
|
||||||
<ion-segment-button value="3">
|
|
||||||
Model 3
|
|
||||||
</ion-segment-button>
|
|
||||||
</ion-segment>
|
|
||||||
|
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|
||||||
|
|
||||||
<ion-footer>
|
<ion-footer>
|
||||||
|
<ion-toolbar no-border-bottom>
|
||||||
<ion-toolbar no-border-bottom primary>
|
<ion-title>
|
||||||
<ion-segment [(ngModel)]="pet" light>
|
Weather: {{ weather == 'sunny' ? '96' : '77' }}°
|
||||||
<ion-segment-button value="puppies">
|
<ion-icon [name]="weather" danger></ion-icon>
|
||||||
Puppies
|
</ion-title>
|
||||||
|
</ion-toolbar>
|
||||||
|
<ion-toolbar no-border-top no-border-bottom>
|
||||||
|
<ion-segment [(ngModel)]="weather" danger>
|
||||||
|
<ion-segment-button value="sunny">
|
||||||
|
Sunny
|
||||||
</ion-segment-button>
|
</ion-segment-button>
|
||||||
<ion-segment-button value="kittens">
|
<ion-segment-button value="rainy" checked>
|
||||||
Kittens
|
Rainy
|
||||||
</ion-segment-button>
|
|
||||||
<ion-segment-button value="ducklings">
|
|
||||||
Ducklings
|
|
||||||
</ion-segment-button>
|
</ion-segment-button>
|
||||||
</ion-segment>
|
</ion-segment>
|
||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
|
|
||||||
<ion-toolbar no-border-bottom dark>
|
|
||||||
<ion-segment [(ngModel)]="calendar" primary>
|
|
||||||
<ion-segment-button value="list">
|
|
||||||
List
|
|
||||||
</ion-segment-button>
|
|
||||||
<ion-segment-button value="day">
|
|
||||||
Day
|
|
||||||
</ion-segment-button>
|
|
||||||
<ion-segment-button value="month" checked>
|
|
||||||
Month
|
|
||||||
</ion-segment-button>
|
|
||||||
</ion-segment>
|
|
||||||
</ion-toolbar>
|
|
||||||
|
|
||||||
<ion-toolbar no-border-bottom danger>
|
|
||||||
<ion-segment [(ngModel)]="proxy" light>
|
|
||||||
<ion-segment-button value="off">
|
|
||||||
Off
|
|
||||||
</ion-segment-button>
|
|
||||||
<ion-segment-button value="manual">
|
|
||||||
Manual
|
|
||||||
</ion-segment-button>
|
|
||||||
<ion-segment-button value="auto">
|
|
||||||
Auto
|
|
||||||
</ion-segment-button>
|
|
||||||
</ion-segment>
|
|
||||||
</ion-toolbar>
|
|
||||||
|
|
||||||
</ion-footer>
|
</ion-footer>
|
||||||
|
@ -8,8 +8,22 @@ import { isPresent, isTrueProperty } from '../../util/util';
|
|||||||
* @name SegmentButton
|
* @name SegmentButton
|
||||||
* @description
|
* @description
|
||||||
* The child buttons of the `ion-segment` component. Each `ion-segment-button` must have a value.
|
* The child buttons of the `ion-segment` component. Each `ion-segment-button` must have a value.
|
||||||
|
*
|
||||||
* @usage
|
* @usage
|
||||||
|
*
|
||||||
* ```html
|
* ```html
|
||||||
|
* <ion-content>
|
||||||
|
* <!-- Segment buttons with icons -->
|
||||||
|
* <ion-segment [(ngModel)]="icons" secondary>
|
||||||
|
* <ion-segment-button value="camera">
|
||||||
|
* <ion-icon name="camera"></ion-icon>
|
||||||
|
* </ion-segment-button>
|
||||||
|
* <ion-segment-button value="bookmark">
|
||||||
|
* <ion-icon name="bookmark"></ion-icon>
|
||||||
|
* </ion-segment-button>
|
||||||
|
* </ion-segment>
|
||||||
|
*
|
||||||
|
* <!-- Segment buttons with text -->
|
||||||
* <ion-segment [(ngModel)]="relationship" primary>
|
* <ion-segment [(ngModel)]="relationship" primary>
|
||||||
* <ion-segment-button value="friends" (ionSelect)="selectedFriends()">
|
* <ion-segment-button value="friends" (ionSelect)="selectedFriends()">
|
||||||
* Friends
|
* Friends
|
||||||
@ -18,24 +32,7 @@ import { isPresent, isTrueProperty } from '../../util/util';
|
|||||||
* Enemies
|
* Enemies
|
||||||
* </ion-segment-button>
|
* </ion-segment-button>
|
||||||
* </ion-segment>
|
* </ion-segment>
|
||||||
*```
|
* </ion-content>
|
||||||
*
|
|
||||||
* Or with `FormBuilder`
|
|
||||||
*
|
|
||||||
*```html
|
|
||||||
* <form [ngFormModel]="myForm">
|
|
||||||
* <ion-segment ngControl="mapStyle" danger>
|
|
||||||
* <ion-segment-button value="standard">
|
|
||||||
* Standard
|
|
||||||
* </ion-segment-button>
|
|
||||||
* <ion-segment-button value="hybrid">
|
|
||||||
* Hybrid
|
|
||||||
* </ion-segment-button>
|
|
||||||
* <ion-segment-button value="sat">
|
|
||||||
* Satellite
|
|
||||||
* </ion-segment-button>
|
|
||||||
* </ion-segment>
|
|
||||||
* </form>
|
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@ -128,21 +125,33 @@ export class SegmentButton {
|
|||||||
* You could use Angular 2's `ngModel` or `FormBuilder` API. For an overview on how `FormBuilder` works, checkout [Angular 2 Forms](http://learnangular2.com/forms/), or [Angular FormBuilder](https://angular.io/docs/ts/latest/api/common/FormBuilder-class.html)
|
* You could use Angular 2's `ngModel` or `FormBuilder` API. For an overview on how `FormBuilder` works, checkout [Angular 2 Forms](http://learnangular2.com/forms/), or [Angular FormBuilder](https://angular.io/docs/ts/latest/api/common/FormBuilder-class.html)
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @usage
|
|
||||||
* ```html
|
* ```html
|
||||||
* <ion-segment [(ngModel)]="relationship" (ionChange)="onSegmentChanged($event)" danger>
|
* <!-- Segment in a header -->
|
||||||
* <ion-segment-button value="friends">
|
* <ion-header>
|
||||||
|
* <ion-toolbar>
|
||||||
|
* <ion-segment [(ngModel)]="icons" secondary>
|
||||||
|
* <ion-segment-button value="camera">
|
||||||
|
* <ion-icon name="camera"></ion-icon>
|
||||||
|
* </ion-segment-button>
|
||||||
|
* <ion-segment-button value="bookmark">
|
||||||
|
* <ion-icon name="bookmark"></ion-icon>
|
||||||
|
* </ion-segment-button>
|
||||||
|
* </ion-segment>
|
||||||
|
* </ion-toolbar>
|
||||||
|
* </ion-header>
|
||||||
|
*
|
||||||
|
* <ion-content>
|
||||||
|
* <!-- Segment in content -->
|
||||||
|
* <ion-segment [(ngModel)]="relationship" primary>
|
||||||
|
* <ion-segment-button value="friends" (ionSelect)="selectedFriends()">
|
||||||
* Friends
|
* Friends
|
||||||
* </ion-segment-button>
|
* </ion-segment-button>
|
||||||
* <ion-segment-button value="enemies">
|
* <ion-segment-button value="enemies" (ionSelect)="selectedEnemies()">
|
||||||
* Enemies
|
* Enemies
|
||||||
* </ion-segment-button>
|
* </ion-segment-button>
|
||||||
* </ion-segment>
|
* </ion-segment>
|
||||||
*```
|
|
||||||
*
|
*
|
||||||
* Or with `FormBuilder`
|
* <!-- Segment in a form -->
|
||||||
*
|
|
||||||
*```html
|
|
||||||
* <form [ngFormModel]="myForm">
|
* <form [ngFormModel]="myForm">
|
||||||
* <ion-segment ngControl="mapStyle" danger>
|
* <ion-segment ngControl="mapStyle" danger>
|
||||||
* <ion-segment-button value="standard">
|
* <ion-segment-button value="standard">
|
||||||
@ -156,6 +165,7 @@ export class SegmentButton {
|
|||||||
* </ion-segment-button>
|
* </ion-segment-button>
|
||||||
* </ion-segment>
|
* </ion-segment>
|
||||||
* </form>
|
* </form>
|
||||||
|
* </ion-content>
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|