-
Notifications
You must be signed in to change notification settings - Fork 65
Toastr service and component #1614
Changes from 44 commits
3f4222e
a450054
4b809aa
d55f351
833bcc7
b553659
ab82ba3
db21c76
a282a86
995f024
f4c10f0
c8994ae
d210c2b
11ab289
a49ebf3
28c09b6
3b5d5cb
35de170
ce8ba62
bc37187
82c286d
52f7983
692cbf0
803a205
ed4558f
35e789d
8c8f6c2
a4f23b3
7d3458f
03c63ae
a37b829
99696ac
874ef58
636c5dd
0158250
f57ffc0
e548824
c6c847b
bdc97a6
ff5093c
83e7d04
6104aaf
01c38d6
2fa1e41
57bfe9c
6e766de
d576545
15103e0
37f50ec
ac1e7bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<toast-visual></toast-visual> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<strong class="sky-custom-toast">Toast component</strong> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { | ||
Component, | ||
ChangeDetectionStrategy | ||
} from '@angular/core'; | ||
|
||
import { | ||
SkyToastService, | ||
SkyToastInstance | ||
} from '@blackbaud/skyux/dist/core'; | ||
|
||
@Component({ | ||
selector: 'sky-test-cmp-toast', | ||
templateUrl: './toast-demo.component.html', | ||
providers: [SkyToastService], | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class ToastDemoComponent { | ||
constructor( | ||
public message: SkyToastInstance | ||
) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div | ||
id="screenshot-toast" | ||
style="height: 500px;"> | ||
<button | ||
class="sky-btn sky-btn-primary" | ||
type="button" | ||
(click)="openToast()"> | ||
Open toast | ||
</button> | ||
<button | ||
class="sky-btn sky-btn-secondary" | ||
type="button" | ||
(click)="openTemplatedToast()"> | ||
Open custom toast | ||
</button> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
Component, | ||
ChangeDetectionStrategy | ||
} from '@angular/core'; | ||
|
||
import { | ||
SkyToastService | ||
} from '@blackbaud/skyux/dist/core'; | ||
|
||
import { | ||
ToastDemoComponent | ||
} from './toast-demo.component'; | ||
|
||
@Component({ | ||
selector: 'toast-visual', | ||
templateUrl: './toast-visual.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class ToastVisualComponent { | ||
constructor( | ||
private toastService: SkyToastService | ||
) { } | ||
|
||
public openToast() { | ||
this.toastService.openMessage('Toast message'); | ||
} | ||
|
||
public openTemplatedToast() { | ||
this.toastService.openTemplatedMessage(ToastDemoComponent, {}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { | ||
SkyVisualTest | ||
} from '../../../config/utils/visual-test-commands'; | ||
|
||
import { | ||
element, | ||
by | ||
} from 'protractor'; | ||
|
||
describe('Toast', () => { | ||
it('should match previous toast screenshot', () => { | ||
return SkyVisualTest.setupTest('toast') | ||
.then(() => { | ||
element(by.css('.sky-btn-primary')).click(); | ||
SkyVisualTest.moveCursorOffScreen(); | ||
return SkyVisualTest.compareScreenshot({ | ||
screenshotName: 'toast', | ||
selector: 'body' | ||
}).then(() => { | ||
expect(by.css('.sky-toast')).toBeTruthy(); | ||
element(by.css('.sky-toast')).click(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should match previous templated toast screenshot', () => { | ||
return SkyVisualTest.setupTest('toast') | ||
.then(() => { | ||
element(by.css('.sky-btn-secondary')).click(); | ||
SkyVisualTest.moveCursorOffScreen(); | ||
return SkyVisualTest.compareScreenshot({ | ||
screenshotName: 'toast', | ||
selector: 'body' | ||
}).then(() => { | ||
expect(by.css('.sky-custom-toast')).toBeTruthy(); | ||
element(by.css('.sky-toast')).click(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should match previous toast screenshot on tiny screens', () => { | ||
return SkyVisualTest.setupTest('toast', 480) | ||
.then(() => { | ||
element(by.css('.sky-btn-primary')).click(); | ||
SkyVisualTest.moveCursorOffScreen(); | ||
return SkyVisualTest.compareScreenshot({ | ||
screenshotName: 'toast', | ||
selector: 'body' | ||
}).then(() => { | ||
expect(by.css('.sky-toast')).toBeTruthy(); | ||
element(by.css('.sky-toast')).click(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should match previous templated toast screenshot on tiny screens', () => { | ||
return SkyVisualTest.setupTest('toast', 480) | ||
.then(() => { | ||
element(by.css('.sky-btn-secondary')).click(); | ||
SkyVisualTest.moveCursorOffScreen(); | ||
return SkyVisualTest.compareScreenshot({ | ||
screenshotName: 'toast', | ||
selector: 'body' | ||
}).then(() => { | ||
expect(by.css('.sky-custom-toast')).toBeTruthy(); | ||
element(by.css('.sky-toast')).click(); | ||
}); | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,7 @@ import { | |
SkyTextHighlightDemoComponent, | ||
SkyTileDemoComponent, | ||
SkyTimepickerDemoComponent, | ||
SkyToastDemoComponent, | ||
SkyTokensDemoComponent, | ||
SkyToolbarDemoComponent, | ||
SkyUrlValidationDemoComponent, | ||
|
@@ -1017,6 +1018,32 @@ export class SkyDemoService { | |
} | ||
] | ||
}, | ||
{ | ||
name: 'Toast', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you missing the "custom" toast component here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
component: SkyToastDemoComponent, | ||
files: [ | ||
{ | ||
name: 'toast-demo.component.html', | ||
fileContents: require('!!raw-loader!./toast/toast-demo.component.html') | ||
}, | ||
{ | ||
name: 'toast-demo.component.ts', | ||
fileContents: require('!!raw-loader!./toast/toast-demo.component.ts'), | ||
componentName: 'SkyToastDemoComponent', | ||
bootstrapSelector: 'sky-toast-demo' | ||
}, | ||
{ | ||
name: 'toast-custom-demo.component.html', | ||
fileContents: require('!!raw-loader!./toast/toast-custom-demo.component.html') | ||
}, | ||
{ | ||
name: 'toast-custom-demo.component.ts', | ||
fileContents: require('!!raw-loader!./toast/toast-custom-demo.component.ts'), | ||
componentName: 'SkyToastCustomDemoComponent', | ||
bootstrapSelector: 'sky-toast-custom-demo' | ||
} | ||
] | ||
}, | ||
{ | ||
name: 'Tokens', | ||
component: SkyTokensDemoComponent, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './toast-demo.component'; | ||
export * from './toast-custom-demo.component'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<p> | ||
{{text}} | ||
<a | ||
*ngIf='!(message.isClosing | async)' | ||
href='http://example.com'> | ||
example.com | ||
</a> | ||
</p> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { | ||
Component, | ||
OnInit, | ||
ChangeDetectionStrategy | ||
} from '@angular/core'; | ||
|
||
import { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newline between unlike package imports. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
SkyToastInstance | ||
} from '../../core'; | ||
|
||
@Component({ | ||
selector: 'sky-toast-custom-demo', | ||
templateUrl: './toast-custom-demo.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
export class SkyToastCustomDemoComponent implements OnInit { | ||
public text = 'This is a templated message. It can even link you to '; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we polish up this message to be a bit more professional? |
||
|
||
constructor( | ||
public message: SkyToastInstance | ||
) {} | ||
|
||
public ngOnInit() { | ||
this.message.isClosing.subscribe(() => { | ||
this.text = 'Bye bye :D'; | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<div> | ||
<fieldset> | ||
<legend>Toast type</legend> | ||
<ul class="sky-list-unstyled"> | ||
<li *ngFor="let type of types"> | ||
<sky-radio | ||
name="radiogroup" | ||
[value]="type" | ||
[(ngModel)]="selectedType"> | ||
<sky-radio-label>{{ typeTranslator[type] }}</sky-radio-label> | ||
</sky-radio> | ||
</li> | ||
</ul> | ||
</fieldset> | ||
<button | ||
class="sky-btn sky-btn-primary" | ||
(click)="openMessage()"> | ||
Open toast | ||
</button> | ||
<button | ||
class="sky-btn sky-btn-primary" | ||
(click)="openTemplatedMessage()"> | ||
Open templated toast | ||
</button> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { | ||
Component | ||
} from '@angular/core'; | ||
|
||
import { | ||
SkyToastService, | ||
SkyToastType | ||
} from '../../core'; | ||
|
||
import { | ||
SkyToastCustomDemoComponent | ||
} from './toast-custom-demo.component'; | ||
|
||
@Component({ | ||
selector: 'sky-toast-demo', | ||
templateUrl: './toast-demo.component.html' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs |
||
}) | ||
export class SkyToastDemoComponent { | ||
public selectedType = SkyToastType.Info; | ||
public typeTranslator = SkyToastType; | ||
public types = [SkyToastType.Info, SkyToastType.Success, SkyToastType.Warning, SkyToastType.Danger]; | ||
|
||
constructor( | ||
private toastSvc: SkyToastService | ||
) {} | ||
|
||
public openMessage() { | ||
this.toastSvc.openMessage('This is a ' + SkyToastType[this.selectedType] + ' toast.', {toastType: this.selectedType}); | ||
} | ||
|
||
public openTemplatedMessage() { | ||
this.toastSvc.openTemplatedMessage(SkyToastCustomDemoComponent, {toastType: this.selectedType}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export { | ||
SkyToastContainerComponent | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My previous comment about "blind" exports was probably confusing; sorry about that. For index.ts "barrel" files, these should be written like the following. ("Blind", because they're exporting a wildcard)
|
||
} from './toast-container.component'; | ||
export { | ||
SkyToastService | ||
} from './services/toast.service'; | ||
export { | ||
SkyToastModule | ||
} from './toast.module'; | ||
export * from './types'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this providers array is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gone