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

Commit

Permalink
Contrib > Toast Component (#1676)
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackbaud-SteveBrush authored May 21, 2018
1 parent 7db88e8 commit 65824da
Show file tree
Hide file tree
Showing 55 changed files with 1,887 additions and 5 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"microedge-rxstate": "2.0.2",
"moment": "2.21.0",
"ng2-dragula": "1.5.0",
"ng2-toastr": "4.1.2",
"web-animations-js": "2.3.1"
},
"devDependencies": {
Expand Down
6 changes: 5 additions & 1 deletion skyux-spa-visual-tests/config/utils/start-visual.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ function spawnServer() {
function spawnBuild(skyPagesConfig, webpack) {
return new Promise(resolve => {
logger.info('Running build');
build([], skyPagesConfig, webpack).then(stats => {
build(
{ logFormat: 'compact' },
skyPagesConfig,
webpack
).then(stats => {
logger.info('Completed build');
resolve(stats.toJson().chunks);
});
Expand Down
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
2 changes: 2 additions & 0 deletions skyux-spa-visual-tests/src/app/toast/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<toast-visual>
</toast-visual>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<strong
class="sky-custom-toast"
>
Toast component
</strong>
19 changes: 19 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,19 @@
import {
ChangeDetectionStrategy,
Component
} from '@angular/core';

import {
SkyToastInstance
} from '@blackbaud/skyux/dist/core';

@Component({
selector: 'sky-test-cmp-toast',
templateUrl: './toast-demo.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ToastDemoComponent {
constructor(
public message: SkyToastInstance
) { }
}
18 changes: 18 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,18 @@
<div
id="screenshot-toast"
>
<button
class="sky-btn sky-btn-primary"
type="button"
(click)="openToasts()"
>
Open toasts
</button>
<button
class="sky-btn sky-btn-secondary"
type="button"
(click)="openComponents()"
>
Open custom toasts
</button>
</div>
43 changes: 43 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,43 @@
import {
Component,
ChangeDetectionStrategy,
OnDestroy
} from '@angular/core';

import {
SkyToastService,
SkyToastType
} 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 implements OnDestroy {
constructor(
private toastService: SkyToastService
) { }

public ngOnDestroy(): void {
this.toastService.closeAll();
}

public openToasts(): void {
this.toastService.openMessage('Toast message', { type: SkyToastType.Info });
this.toastService.openMessage('Toast message', { type: SkyToastType.Success });
this.toastService.openMessage('Toast message', { type: SkyToastType.Warning });
this.toastService.openMessage('Toast message', { type: SkyToastType.Danger });
}

public openComponents(): void {
this.toastService.openComponent(ToastDemoComponent, { type: SkyToastType.Info });
this.toastService.openComponent(ToastDemoComponent, { type: SkyToastType.Success });
this.toastService.openComponent(ToastDemoComponent, { type: SkyToastType.Warning });
this.toastService.openComponent(ToastDemoComponent, { type: SkyToastType.Danger });
}
}
58 changes: 58 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,58 @@
import {
SkyVisualTest
} from '../../../config/utils/visual-test-commands';

import {
by,
element
} 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: '.sky-toaster'
});
});
});

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-component',
selector: '.sky-toaster'
});
});
});

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-xs',
selector: '.sky-toaster'
});
});
});

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-component-xs',
selector: '.sky-toaster'
});
});
});
});
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
37 changes: 36 additions & 1 deletion src/demos/demo.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { Injectable } from '@angular/core';
// #region imports
import {
Injectable
} from '@angular/core';

import {
SkyActionButtonDemoComponent,
Expand Down Expand Up @@ -52,13 +55,15 @@ import {
SkyTextHighlightDemoComponent,
SkyTileDemoComponent,
SkyTimepickerDemoComponent,
SkyToastDemoComponent,
SkyTokensDemoComponent,
SkyToolbarDemoComponent,
SkyUrlValidationDemoComponent,
SkyVerticalTabsDemoComponent,
SkyWaitDemoComponent,
SkyWizardDemoComponent
} from './index';
// #endregion

/**
* This service provides consumers with the raw file contents for each component demo.
Expand Down Expand Up @@ -1025,6 +1030,36 @@ export class SkyDemoService {
}
]
},
{
name: 'Toast',
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: 'toast-custom-demo-context.ts',
fileContents: require('!!raw-loader!./toast/toast-custom-demo-context.ts')
}
]
},
{
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-custom-demo.component';
export * from './toast-demo.component';
5 changes: 5 additions & 0 deletions src/demos/toast/toast-custom-demo-context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class SkyToastCustomDemoContext {
constructor(
public message: string
) { }
}
13 changes: 13 additions & 0 deletions src/demos/toast/toast-custom-demo.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<p>
{{ context.message }}
</p>
<p>
Some link: <a href="http://example.com">example.com</a>
</p>
<button
class="sky-btn sky-btn-default"
type="button"
(click)="close()"
>
Close
</button>
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 {
ChangeDetectionStrategy,
Component
} from '@angular/core';

import {
SkyToastInstance
} from '../../core';

import {
SkyToastCustomDemoContext
} from './toast-custom-demo-context';

@Component({
selector: 'sky-toast-custom-demo',
templateUrl: './toast-custom-demo.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class SkyToastCustomDemoComponent {
constructor(
public context: SkyToastCustomDemoContext,
private instance: SkyToastInstance
) { }

public close(): void {
this.instance.close();
}
}
44 changes: 44 additions & 0 deletions src/demos/toast/toast-demo.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<div class="sky-toast-demo">
<fieldset>
<label class="sky-control-label">
Select toast type:
</label>
<ul class="sky-list-unstyled">
<li *ngFor="let type of types">
<sky-radio
name="radiogroup"
[value]="type.value"
[(ngModel)]="selectedType"
>
<sky-radio-label>
{{ type.label }}
</sky-radio-label>
</sky-radio>
</li>
</ul>
</fieldset>

<button
class="sky-btn sky-btn-primary"
type="button"
(click)="openMessage()"
>
Open toast
</button>

<button
class="sky-btn sky-btn-primary"
type="button"
(click)="openComponent()"
>
Open toast with custom component
</button>

<button
class="sky-btn sky-btn-default"
type="button"
(click)="closeAll()"
>
Close all
</button>
</div>
Loading

0 comments on commit 65824da

Please sign in to comment.