Skip to content

Commit

Permalink
feat(toast): add ability to pass multiple classes to cssClass
Browse files Browse the repository at this point in the history
references #7618
  • Loading branch information
brandyscarney committed Aug 9, 2016
1 parent 466dea3 commit 79e25a3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/components/toast/test/basic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class E2EPage {
showLongToast() {
const toast = this.toastCtrl.create({
message: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea voluptatibus quibusdam eum nihil optio, ullam accusamus magni, nobis suscipit reprehenderit, sequi quam amet impedit. Accusamus dolorem voluptates laborum dolor obcaecati.',
duration: 5000
duration: 5000,
cssClass: 'custom-class my-toast'
});

toast.onDidDismiss(this.dismissHandler);
Expand Down
15 changes: 13 additions & 2 deletions src/components/toast/toast-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ import { ViewController } from '../nav/view-controller';
},
})
export class ToastCmp implements AfterViewInit {
private d: any;
private d: {
message?: string;
cssClass?: string;
duration?: number;
showCloseButton?: boolean;
closeButtonText?: string;
dismissOnPageChange?: boolean;
position?: string;
};
private descId: string;
private dismissTimeout: number = undefined;
private enabled: boolean;
Expand All @@ -53,7 +61,10 @@ export class ToastCmp implements AfterViewInit {
this.d = params.data;

if (this.d.cssClass) {
renderer.setElementClass(_elementRef.nativeElement, this.d.cssClass, true);
this.d.cssClass.split(' ').forEach(cssClass => {
// Make sure the class isn't whitespace, otherwise it throws exceptions
if (cssClass.trim() !== '') renderer.setElementClass(_elementRef.nativeElement, cssClass, true);
});
}

this.id = (++toastIds);
Expand Down

0 comments on commit 79e25a3

Please sign in to comment.