This repository has been archived by the owner on Dec 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fleshed out an initial structure for templated toasts
- Loading branch information
1 parent
35de170
commit ce8ba62
Showing
18 changed files
with
150 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
<div> | ||
<button class='sky-btn sky-btn-primary' (click)='openMessage()'>Open toast</button> | ||
<button class='sky-btn sky-btn-primary' (click)='openPersistentMessage()'>Open persistent toast</button> | ||
<button class='sky-btn sky-btn-primary' (click)='openTemplatedMessage()'>Open templated toast</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { SkyToastComponent } from './toast.component'; | ||
export { SkyToastContainerComponent } from './toast-container.component'; | ||
export { SkyToastService } from './toast.service'; | ||
export { SkyToastModule } from './toast.module'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="sky-toaster"> | ||
<sky-toast *ngFor="let message of messages | async" [message]="message"></sky-toast> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@import "../../scss/variables"; | ||
|
||
.sky-toaster { | ||
bottom: 0; | ||
right: 0; | ||
display: block; | ||
position: fixed; | ||
padding-bottom: $sky-margin-double; | ||
padding-right: $sky-margin-double; | ||
-webkit-touch-callout: none; /* iOS Safari */ | ||
-webkit-user-select: none; /* Safari */ | ||
-khtml-user-select: none; /* Konqueror HTML */ | ||
-moz-user-select: none; /* Firefox */ | ||
-ms-user-select: none; /* Internet Explorer/Edge */ | ||
user-select: none; /* Chrom and Opera */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './toast-custom.directive'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Directive, ViewContainerRef } from '@angular/core'; | ||
|
||
@Directive({ | ||
selector: '[sky-toast-custom]' | ||
}) | ||
export class SkyCustomToastDirective { | ||
constructor(public viewContainerRef: ViewContainerRef) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<aside> | ||
<ng-template sky-toast-custom *ngIf="message.componentRef"></ng-template> | ||
<div class="sky-toast" *ngIf="!message.componentRef" | ||
[ngClass]="{'sky-toast-info': message.toastType=='info', | ||
'sky-toast-warning': message.toastType=='warning', | ||
'sky-toast-danger': message.toastType=='danger', | ||
'sky-toast-success': message.toastType=='success', | ||
'sky-toast-closing': message.isClosing | async}"> | ||
<div | ||
(click)="message.close()" | ||
class='sky-toast-content'> | ||
{{message.message}} | ||
</div> | ||
<button | ||
type="button" | ||
class="sky-toast-close" | ||
(click)="message.close()" | ||
[attr.aria-label]="'toast_close' | skyResources"> | ||
<span aria-hidden="true"><i class="fa fa-close"></i></span> | ||
</button> | ||
</div> | ||
</aside> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Component, Input, ComponentFactoryResolver, OnInit, ViewChild } from '@angular/core'; | ||
import { SkyToastMessage, SkyToastCustomComponent } from '../types'; | ||
import { SkyCustomToastDirective } from '.'; | ||
|
||
@Component({ | ||
selector: 'sky-toast', | ||
templateUrl: './toast.component.html', | ||
styleUrls: ['./toast.component.scss'], | ||
}) | ||
export class SkyToastComponent implements OnInit { | ||
@Input('message') | ||
public message: SkyToastMessage; | ||
|
||
@ViewChild(SkyCustomToastDirective) | ||
private customToastHost: SkyCustomToastDirective; | ||
|
||
constructor( | ||
private resolver: ComponentFactoryResolver | ||
) { } | ||
|
||
public ngOnInit() { | ||
if (this.message.customComponentType) { | ||
this.loadComponent(); | ||
} | ||
} | ||
|
||
private loadComponent() { | ||
let componentFactory = this.resolver.resolveComponentFactory(this.message.customComponentType); | ||
|
||
let viewContainerRef = this.customToastHost.viewContainerRef; | ||
viewContainerRef.clear(); | ||
|
||
let componentRef = viewContainerRef.createComponent(componentFactory); | ||
(<SkyToastCustomComponent>componentRef.instance).message = this.message; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './toast-config'; | ||
export * from './toast-custom'; | ||
export * from './toast-message'; | ||
export * from './toast-message-type'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { SkyToastMessage } from "./toast-message"; | ||
|
||
export interface SkyToastCustomComponent { | ||
message: SkyToastMessage | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters