mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00

BREAKING CHANGES: Colors should be passed in the `color` input on components, not added individually as an attribute on the component. For example: ``` <ion-tabs primary> ``` Becomes ``` <ion-tabs color=”primary”> ``` Or to bind an expression to color: ``` <ion-navbar [color]="barColor"> ... </ion-navbar> ``` ```ts @Component({ templateUrl: 'build/pages/about/about.html' }) export class AboutPage { barColor: string; constructor(private nav: NavController, platform: Platform) { this.barColor = platform.is('android') ? 'primary' : 'light'; } } ``` Reason for this change: It was difficult to dynamically add colors to components, especially if the name of the color attribute was unknown in the template. This change keeps the css flat since we aren’t chaining color attributes on components and instead we assign a class to the component which includes the color’s name. This allows you to easily toggle a component between multiple colors. Speeds up performance because we are no longer reading through all of the attributes to grab the color ones. references #7467 closes #7087 closes #7401 closes #7523
72 lines
1.6 KiB
HTML
72 lines
1.6 KiB
HTML
<ion-header>
|
|
|
|
<ion-navbar>
|
|
<ion-title>Toggle</ion-title>
|
|
</ion-navbar>
|
|
|
|
</ion-header>
|
|
|
|
|
|
<ion-content>
|
|
|
|
<ion-list>
|
|
|
|
<ion-item>
|
|
<ion-label>Frodo Baggins</ion-label>
|
|
<ion-toggle [(ngModel)]="data.frodo"></ion-toggle>
|
|
</ion-item>
|
|
|
|
<ion-item>
|
|
<ion-label>Sam</ion-label>
|
|
<ion-toggle [(ngModel)]="data.sam"></ion-toggle>
|
|
</ion-item>
|
|
|
|
<ion-item>
|
|
<ion-label>Éowyn</ion-label>
|
|
<ion-toggle [(ngModel)]="data.eowyn" color="danger"></ion-toggle>
|
|
</ion-item>
|
|
|
|
<ion-item>
|
|
<ion-label>Legolas</ion-label>
|
|
<ion-toggle [(ngModel)]="data.legolas" disabled="true"></ion-toggle>
|
|
</ion-item>
|
|
|
|
<ion-item>
|
|
<ion-label>Gimli</ion-label>
|
|
<ion-toggle [(ngModel)]="data.gimli" color="danger"></ion-toggle>
|
|
</ion-item>
|
|
|
|
<ion-item>
|
|
<ion-label>Saruman</ion-label>
|
|
<ion-toggle [(ngModel)]="data.saruman" color="dark"></ion-toggle>
|
|
</ion-item>
|
|
|
|
<ion-item>
|
|
<ion-label>Gandalf</ion-label>
|
|
<ion-toggle [(ngModel)]="data.gandalf" color="secondary"></ion-toggle>
|
|
</ion-item>
|
|
|
|
<ion-item>
|
|
<ion-label>Arwen</ion-label>
|
|
<ion-toggle [(ngModel)]="data.arwen" disabled="true"></ion-toggle>
|
|
</ion-item>
|
|
|
|
<ion-item>
|
|
<ion-label>Boromir</ion-label>
|
|
<ion-toggle [(ngModel)]="data.boromir"></ion-toggle>
|
|
</ion-item>
|
|
|
|
<ion-item>
|
|
<ion-label>Gollum</ion-label>
|
|
<ion-toggle [(ngModel)]="data.gollum" color="dark"></ion-toggle>
|
|
</ion-item>
|
|
|
|
<ion-item>
|
|
<ion-label>Galadriel</ion-label>
|
|
<ion-toggle [(ngModel)]="data.galadriel" color="secondary"></ion-toggle>
|
|
</ion-item>
|
|
|
|
</ion-list>
|
|
|
|
</ion-content>
|