Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Toastr service and component #1614

Closed
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
3f4222e
Resolving Card action bar still visable after hiding with *ngIf #1421
blackbaud-conorwright Mar 7, 2018
a450054
Addressed PR style comments
blackbaud-conorwright Mar 8, 2018
4b809aa
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 9, 2018
d55f351
Merge branch 'master' into master
Blackbaud-SteveBrush Mar 9, 2018
833bcc7
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 12, 2018
b553659
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 15, 2018
ab82ba3
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 19, 2018
db21c76
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 27, 2018
a282a86
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 30, 2018
995f024
started porting over alert design to toast
blackbaud-conorwright Apr 3, 2018
f4c10f0
began working on toast component from scratch
blackbaud-conorwright Apr 4, 2018
c8994ae
got a base demo and toast service running
blackbaud-conorwright Apr 4, 2018
d210c2b
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Apr 10, 2018
11ab289
Merge remote-tracking branch 'origin/master' into toastr-fromscratch
blackbaud-conorwright Apr 10, 2018
a49ebf3
Got the base toast service functional
blackbaud-conorwright Apr 10, 2018
28c09b6
moved the toaster to the bottom right
blackbaud-conorwright Apr 10, 2018
3b5d5cb
Steve's comments. Added fading close to toasts
blackbaud-conorwright Apr 10, 2018
35de170
styled the toast demo button
blackbaud-conorwright Apr 10, 2018
ce8ba62
fleshed out an initial structure for templated toasts
blackbaud-conorwright Apr 11, 2018
bc37187
implemented templated toast demo
blackbaud-conorwright Apr 11, 2018
82c286d
fixed hiding issue with templated toasts
blackbaud-conorwright Apr 11, 2018
52f7983
removed timeout. removed custom toast directive.
blackbaud-conorwright Apr 12, 2018
692cbf0
finished templating functionality.added types to demo
blackbaud-conorwright Apr 12, 2018
803a205
finished up the base set of unit testing
blackbaud-conorwright Apr 16, 2018
ed4558f
fixed import to target core.ts
blackbaud-conorwright Apr 17, 2018
35e789d
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Apr 17, 2018
8c8f6c2
Merge remote-tracking branch 'origin/master' into toastr-fromscratch
blackbaud-conorwright Apr 17, 2018
a4f23b3
add visual tests for toast service
blackbaud-conorwright Apr 17, 2018
7d3458f
fixed style issues with toast component
blackbaud-conorwright Apr 17, 2018
03c63ae
expanded test coverage of the toast component
blackbaud-conorwright Apr 18, 2018
a37b829
fixed import issue for toastcontainer tests
blackbaud-conorwright Apr 18, 2018
99696ac
cleaned up based on style guide from steve in infinite scroll pr
blackbaud-conorwright Apr 19, 2018
874ef58
Switched to using sky-shadow on hover of toasts
blackbaud-conorwright Apr 19, 2018
636c5dd
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Apr 23, 2018
0158250
Merge remote-tracking branch 'origin/master' into toastr-fromscratch
blackbaud-conorwright Apr 23, 2018
f57ffc0
fixed styling issues that came from inf scroll PR
blackbaud-conorwright Apr 24, 2018
e548824
added unit testing for the toast adapter
blackbaud-conorwright Apr 25, 2018
c6c847b
added aria-live and role attrs to toasts
blackbaud-conorwright Apr 30, 2018
bdc97a6
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright May 1, 2018
ff5093c
Merge remote-tracking branch 'origin/master' into toastr-fromscratch
blackbaud-conorwright May 1, 2018
83e7d04
Merge branch 'master' into toastr-fromscratch
Blackbaud-SteveBrush May 1, 2018
6104aaf
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright May 2, 2018
01c38d6
refactored toast design to address PR comments
blackbaud-conorwright May 3, 2018
2fa1e41
prettied up the demo a little
blackbaud-conorwright May 4, 2018
57bfe9c
updated for the remaining PR comments
blackbaud-conorwright May 4, 2018
6e766de
Merge branch 'master' into toastr-fromscratch
Blackbaud-SteveBrush May 7, 2018
d576545
refactored for PR comments
blackbaud-conorwright May 8, 2018
15103e0
Merge branch 'toastr-fromscratch' of github.com:blackbaud-conorwright…
blackbaud-conorwright May 8, 2018
37f50ec
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright May 8, 2018
ac1e7bd
Merge remote-tracking branch 'origin/master' into toastr-fromscratch
blackbaud-conorwright May 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions skyux-spa-visual-tests/src/app/app-extras.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NgModule } from '@angular/core';

import { FlyoutDemoComponent } from './flyout/flyout-demo.component';
import { ToastDemoComponent } from './toast/toast-demo.component';

import { ModalDemoComponent } from './modal/modal-demo.component';
import { ModalLargeDemoComponent } from './modal/modal-large-demo.component';
Expand All @@ -16,6 +17,7 @@ import { Tile2Component } from './tiles/tile2.component';
providers: [],
entryComponents: [
FlyoutDemoComponent,
ToastDemoComponent,
ModalDemoComponent,
ModalLargeDemoComponent,
ModalFullPageDemoComponent,
Expand Down
1 change: 1 addition & 0 deletions skyux-spa-visual-tests/src/app/toast/index.html
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>
21 changes: 21 additions & 0 deletions skyux-spa-visual-tests/src/app/toast/toast-demo.component.ts
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],

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gone

changeDetection: ChangeDetectionStrategy.OnPush
})
export class ToastDemoComponent {
constructor(
public message: SkyToastInstance
) {}
}
16 changes: 16 additions & 0 deletions skyux-spa-visual-tests/src/app/toast/toast-visual.component.html
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>
31 changes: 31 additions & 0 deletions skyux-spa-visual-tests/src/app/toast/toast-visual.component.ts
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, {});
}
}
70 changes: 70 additions & 0 deletions skyux-spa-visual-tests/src/app/toast/toast.visual-spec.ts
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();
});
});
});
});
3 changes: 3 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import { SkyTabsModule } from './modules/tabs';
import { SkyTextExpandModule } from './modules/text-expand';
import { SkyTextExpandRepeaterModule } from './modules/text-expand-repeater';
import { SkyTextHighlightModule } from './modules/text-highlight';
import { SkyToastModule } from './modules/toast';
import { SkyTokensModule } from './modules/tokens';
import { SkyToolbarModule } from './modules/toolbar';
import { SkyTilesModule } from './modules/tiles';
Expand Down Expand Up @@ -125,6 +126,7 @@ import { SkyWaitModule } from './modules/wait';
SkyTextHighlightModule,
SkyTilesModule,
SkyTimepickerModule,
SkyToastModule,
SkyTokensModule,
SkyToolbarModule,
SkyUrlValidationModule,
Expand Down Expand Up @@ -190,6 +192,7 @@ export * from './modules/text-expand-repeater';
export * from './modules/text-highlight';
export * from './modules/tiles';
export * from './modules/timepicker';
export * from './modules/toast';
export * from './modules/tokens';
export * from './modules/toolbar';
export * from './modules/url-validation';
Expand Down
4 changes: 4 additions & 0 deletions src/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ import {
SkyTextHighlightDemoComponent,
SkyTileDemoComponent,
SkyTimepickerDemoComponent,
SkyToastDemoComponent,
SkyToastCustomDemoComponent,
SkyTokensDemoComponent,
SkyToolbarDemoComponent,
SkyUrlValidationDemoComponent,
Expand Down Expand Up @@ -148,6 +150,8 @@ const components = [
SkyTextHighlightDemoComponent,
SkyTileDemoComponent,
SkyTimepickerDemoComponent,
SkyToastDemoComponent,
SkyToastCustomDemoComponent,
SkyTokensDemoComponent,
SkyToolbarDemoComponent,
SkyUrlValidationDemoComponent,
Expand Down
27 changes: 27 additions & 0 deletions src/demos/demo.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
SkyTextHighlightDemoComponent,
SkyTileDemoComponent,
SkyTimepickerDemoComponent,
SkyToastDemoComponent,
SkyTokensDemoComponent,
SkyToolbarDemoComponent,
SkyUrlValidationDemoComponent,
Expand Down Expand Up @@ -1017,6 +1018,32 @@ export class SkyDemoService {
}
]
},
{
name: 'Toast',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you missing the "custom" toast component here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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,
Expand Down
1 change: 1 addition & 0 deletions src/demos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export * from './text-expand';
export * from './text-highlight';
export * from './tile';
export * from './timepicker';
export * from './toast';
export * from './tokens';
export * from './toolbar';
export * from './url-validation';
Expand Down
2 changes: 2 additions & 0 deletions src/demos/toast/index.ts
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';
8 changes: 8 additions & 0 deletions src/demos/toast/toast-custom-demo.component.html
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>
28 changes: 28 additions & 0 deletions src/demos/toast/toast-custom-demo.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {
Component,
OnInit,
ChangeDetectionStrategy
} from '@angular/core';

import {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline between unlike package imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs OnPush change detection strategy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 ';

Choose a reason for hiding this comment

The 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';
});
}
}
25 changes: 25 additions & 0 deletions src/demos/toast/toast-demo.component.html
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>
34 changes: 34 additions & 0 deletions src/demos/toast/toast-demo.component.ts
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'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs OnPush change detection strategy.

})
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});
}
}
4 changes: 4 additions & 0 deletions src/locales/resources_en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,10 @@
"_description": "The close button for the timepicker modal",
"message": "Done"
},
"toast_close_button": {
"_description": "Screen reader text for the close button on toasts",
"message": "Close the toast"
},
"token_dismiss_button_title": {
"_description": "The default text for the token dismiss button title.",
"message": "Remove item"
Expand Down
10 changes: 10 additions & 0 deletions src/modules/toast/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export {
SkyToastContainerComponent

Choose a reason for hiding this comment

The 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)

export * from './toast-container.component';
// ...

} from './toast-container.component';
export {
SkyToastService
} from './services/toast.service';
export {
SkyToastModule
} from './toast.module';
export * from './types';
Loading