-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge in SUN/veera-components from feature-PH-125-toasts to master Squashed commit of the following: commit a12ccb70416a25ef3d0cae91d99a2b4ba73c777f Author: Aleksandr Beliaev <[email protected]> Date: Mon Nov 7 11:49:45 2022 +0200 refactor: replaced raw svg icons in toast with veera-ng-icon component commit 7739510b0c906a0e9a6ce8e42816a1bb5e88fad3 Author: Aleksandr Beliaev <[email protected]> Date: Mon Nov 7 11:37:55 2022 +0200 refactor: added success icon to registry for toasts commit ef1508f808733f3ae27ad04a1bbb75277dfd28a5 Author: Aleksandr Beliaev <[email protected]> Date: Mon Nov 7 11:36:36 2022 +0200 fix: sometimes icons have their viewBox removed commit adb6f7943710d3d06a4d20c699064cbde60b7007 Author: Markus Saarniit <[email protected]> Date: Wed Nov 2 12:26:11 2022 +0200 chore: revert check icon commit b208d7dce4baa90a0c7acabde72be45e41427537 Author: Markus Saarniit <[email protected]> Date: Wed Nov 2 12:02:37 2022 +0200 fix: export track component commit 7b19583f07bbcd626bed2e18d7a5a402d09e04e6 Author: Markus Saarniit <[email protected]> Date: Wed Nov 2 11:50:41 2022 +0200 fix: package json fix commit 3c1fe9b9ac5e1dfe095f40f4d5dd6403fe3bf650 Author: Markus Saarniit <[email protected]> Date: Wed Nov 2 11:40:26 2022 +0200 chore: fix formatting commit ae2622b7596176018fc718017617a7795069f756 Author: Markus Saarniit <[email protected]> Date: Wed Nov 2 11:39:54 2022 +0200 feat: refactor commit 65a54a2e132e885137ea2156ff5ff2683bde752b Author: Aleksandr Beliaev <[email protected]> Date: Tue Nov 1 21:26:39 2022 +0200 fix(styling): made toast shadow less strong and consistent with existing designs commit adb2ae097db71b7ede14f986a665cd3644be2566 Author: Aleksandr Beliaev <[email protected]> Date: Tue Nov 1 21:22:21 2022 +0200 feat(styling): added css variables for all colors in rgb format for sass-less usage with opacity specified commit 710966fd1f9e4c0d2cef33364f956a2baea1148f Author: Aleksandr Beliaev <[email protected]> Date: Tue Nov 1 20:54:45 2022 +0200 feat: added track utilitycomponent for quick creation of flex-like layout commit 96b9f0876f5444632314592e5d3d268de16ed222 Author: Aleksandr Beliaev <[email protected]> Date: Tue Nov 1 20:52:11 2022 +0200 format: tiny css formatting fixes commit 7aeb1c5b269e550ad17f253d2600f6d7a67ed035 Author: Aleksandr Beliaev <[email protected]> Date: Tue Nov 1 17:24:48 2022 +0200 fix(ui): ensure close button of a toast is situated on same distance from the edge on both axis commit 3676fe272c0040fa22e0f7ca074c1b33e42d0baa Author: Markus Saarniit <[email protected]> Date: Mon Oct 31 16:19:24 2022 +0200 chore: formatting commit 87e78ea4973d2656a19c4f6ee0c36109bd62b070 Author: Markus Saarniit <[email protected]> Date: Mon Oct 31 16:18:37 2022 +0200 feat: change detection strategy OnPush commit 72e9e9d6ab34c03e76c9843e8595e3c34262ed23 Author: Markus Saarniit <[email protected]> Date: Mon Oct 31 15:36:08 2022 +0200 chore: refactor commit 1cc5ccfa452a251196b1de3bd4daa11db7931891 Author: Markus Saarniit <[email protected]> Date: Mon Oct 31 15:32:52 2022 +0200 chore: fix formatting commit 567158033e53d2da2738c5033ce13680e5e1a375 Author: Markus Saarniit <[email protected]> Date: Mon Oct 31 15:32:15 2022 +0200 feat: add toasts
- Loading branch information
Markus Saarniit
committed
Nov 7, 2022
1 parent
f26bf19
commit d91044b
Showing
33 changed files
with
40,882 additions
and
487 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@mixin veera-toast-container($base: &) { | ||
position: fixed; | ||
top: get-spacing('elva'); | ||
right: get-spacing('elva'); | ||
} |
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,106 @@ | ||
@mixin veera-toast($base: &) { | ||
--comment: 'A toast aka floating notification'; | ||
|
||
position: relative; | ||
width: 300px; | ||
overflow: hidden; | ||
padding: var(--veera-spacing-haapsalu); | ||
margin-bottom: var(--veera-spacing-paldiski); | ||
border-radius: 5px; | ||
color: var(--veera-color-black-coral-18); | ||
cursor: pointer; | ||
display: block; | ||
|
||
&:hover { | ||
box-shadow: $veera-shadow-alpha; | ||
} | ||
|
||
@at-root { | ||
#{$base}__icon-wrapper { | ||
fill: get-color(black-coral-18); | ||
display: block; | ||
} | ||
|
||
#{$base}__icon { | ||
display: block; | ||
width: 16px; | ||
height: 16px; | ||
} | ||
|
||
#{$base}--appearance-success { | ||
background-color: var(--veera-color-sea-green-0); | ||
border: 1px solid var(--veera-color-sea-green-10); | ||
|
||
& #{$base}__progress-bar { | ||
background-color: var(--veera-color-sea-green-10); | ||
} | ||
} | ||
|
||
#{$base}--appearance-info { | ||
background-color: var(--veera-color-sapphire-blue-1); | ||
border: 1px solid var(--veera-color-sapphire-blue-10); | ||
|
||
& #{$base}__progress-bar { | ||
background-color: var(--veera-color-sapphire-blue-10); | ||
} | ||
} | ||
|
||
#{$base}--appearance-warning { | ||
background-color: var(--veera-color-dark-tangerine-1); | ||
border: 1px solid var(--veera-color-dark-tangerine-11); | ||
|
||
& #{$base}__progress-bar { | ||
background-color: var(--veera-color-dark-tangerine-11); | ||
} | ||
} | ||
|
||
#{$base}--appearance-error { | ||
background-color: var(--veera-color-jasper-0); | ||
border: 1px solid var(--veera-color-jasper-10); | ||
|
||
& #{$base}__progress-bar { | ||
background-color: var(--veera-color-jasper-10); | ||
} | ||
} | ||
|
||
#{$base}__title { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
#{$base}__title-text { | ||
font-size: 18px; | ||
margin-left: 10px; | ||
} | ||
|
||
#{$base}__close-button { | ||
position: absolute; | ||
top: 20px; | ||
right: 20px; | ||
cursor: pointer; | ||
} | ||
|
||
#{$base}__close-button-icon { | ||
fill: get-color(black-coral-18); | ||
display: block; | ||
width: 16px; | ||
height: 16px; | ||
} | ||
|
||
#{$base}__close-button-inner { | ||
display: block; | ||
} | ||
|
||
#{$base}__message { | ||
margin-top: var(--veera-spacing-elva); | ||
} | ||
|
||
#{$base}__progress-bar { | ||
position: absolute; | ||
left: 0; | ||
bottom: 0; | ||
height: 4px; | ||
opacity: 0.4; | ||
} | ||
} | ||
} |
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,12 @@ | ||
@mixin veera-track($base: &) { | ||
--comment: 'An utility for quick grid setting'; | ||
|
||
display: flex; | ||
gap: calc(var(--veera-spacing-unit) * var(--gap)); | ||
justify-content: var(--horizontal-alignment); | ||
flex-direction: var(--direction); | ||
flex-wrap: var(--wrap); | ||
|
||
@at-root { | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { | ||
ApplicationRef, | ||
ComponentRef, | ||
createComponent, | ||
Inject, | ||
Injectable, | ||
OnDestroy, | ||
Injector, | ||
EmbeddedViewRef, | ||
} from '@angular/core'; | ||
import { DOCUMENT } from '@angular/common'; | ||
import { ToastContainerComponent } from './toast-container.component'; | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class Overlay implements OnDestroy { | ||
private containerRef!: ComponentRef<ToastContainerComponent>; | ||
|
||
constructor( | ||
private readonly appRef: ApplicationRef, | ||
private readonly injector: Injector, | ||
@Inject(DOCUMENT) private readonly document: Document | ||
) {} | ||
|
||
ngOnDestroy() { | ||
if (this.containerRef) { | ||
this.containerRef.destroy(); | ||
} | ||
} | ||
|
||
getContainerElement(): ComponentRef<ToastContainerComponent> { | ||
if (!this.containerRef) { | ||
this.createContainer(); | ||
} | ||
|
||
return this.containerRef; | ||
} | ||
|
||
private createContainer(): void { | ||
this.containerRef = createComponent(ToastContainerComponent, { | ||
environmentInjector: this.appRef.injector, | ||
elementInjector: this.injector, | ||
}); | ||
this.appRef.attachView(this.containerRef.hostView); | ||
const domElement = (this.containerRef.hostView as EmbeddedViewRef<any>) | ||
.rootNodes[0] as HTMLElement; | ||
this.document.body.appendChild(domElement); | ||
} | ||
} |
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,46 @@ | ||
import { InjectionToken } from '@angular/core'; | ||
|
||
export interface ToastConfig { | ||
timeOut: number; | ||
toastTypes: ToastTypes; | ||
progressBar: boolean; | ||
easeTime: number; | ||
extendedTimeOut: number; | ||
} | ||
|
||
export interface ToastTypes { | ||
error: string; | ||
info: string; | ||
success: string; | ||
warning: string; | ||
} | ||
|
||
export interface ToastToken { | ||
default: ToastConfig; | ||
config: Partial<ToastConfig>; | ||
} | ||
|
||
export const DefaultToastConfig: ToastConfig = { | ||
timeOut: 5000, | ||
toastTypes: { | ||
error: 'veera-toast--appearance-error', | ||
info: 'veera-toast--appearance-info', | ||
success: 'veera-toast--appearance-success', | ||
warning: 'veera-toast--appearance-warning', | ||
}, | ||
progressBar: true, | ||
easeTime: 300, | ||
extendedTimeOut: 1000, | ||
}; | ||
|
||
export const TOAST_CONFIG = new InjectionToken<ToastToken>('ToastConfig'); | ||
|
||
export class ToastPackage { | ||
constructor( | ||
public id: number, | ||
public config: ToastConfig, | ||
public toastType: string, | ||
public title: string | undefined, | ||
public message: string | undefined | ||
) {} | ||
} |
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,13 @@ | ||
import { ChangeDetectionStrategy, Component, HostBinding } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'veera-ng-toast-container', | ||
template: `<ng-content></ng-content>`, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class ToastContainerComponent { | ||
@HostBinding('class') | ||
get hostClasses() { | ||
return 'veera-toast-container'; | ||
} | ||
} |
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,14 @@ | ||
<h1 class="veera-toast__title"> | ||
<veera-ng-icon *ngIf="isSuccessToast" name="success" class="veera-toast__icon-wrapper" svgClass="veera-toast__icon"></veera-ng-icon> | ||
<veera-ng-icon *ngIf="isInfoToast" name="info" class="veera-toast__icon-wrapper" svgClass="veera-toast__icon"></veera-ng-icon> | ||
<veera-ng-icon *ngIf="isWarningToast" name="warning_amber" class="veera-toast__icon-wrapper" svgClass="veera-toast__icon"></veera-ng-icon> | ||
<veera-ng-icon *ngIf="isErrorToast" name="error_outline" class="veera-toast__icon-wrapper" svgClass="veera-toast__icon"></veera-ng-icon> | ||
<div class="veera-toast__title-text">{{ title }}</div> | ||
<button class="veera-toast__close-button" (click)="remove()"> | ||
<veera-ng-icon name="close" class="veera-toast__close-button-inner" svgClass="veera-toast__close-button-icon"></veera-ng-icon> | ||
</button> | ||
</h1> | ||
<div *ngIf="message" class="veera-toast__message"> | ||
{{ message }} | ||
</div> | ||
<div *ngIf="progressBar" class="veera-toast__progress-bar" [style.width]="progressBarWidth + '%'"></div> |
Oops, something went wrong.