completed new status bar
This commit is contained in:
@@ -1,8 +1,33 @@
|
||||
<div class="status-bar" [ngClass]="{'status-bar-warning':isWarning}" *ngIf="isActive">
|
||||
<i class="material-icons right white-text cursor" (click)="statusService.hideStatus()" mz-tooltip position="top"
|
||||
tooltip="Close this status.">close</i>
|
||||
<div *ngIf="isWarning" class="right btn small-button green" (click)="getHelp.emit(statusMessage)">Get Help</div>
|
||||
<span class="status-message truncate" [innerHTML]="statusMessage | sanitizeHtml">
|
||||
|
||||
</span>
|
||||
<div class="status" [ngClass]="{'status-open': isActive}">
|
||||
<div class='sq-toast sq-toast--top-right' *ngIf="isActive && (notification.isError || notification.isSuccess)">
|
||||
<div @anim>
|
||||
<div class='sq-toast__message' [ngClass]="{
|
||||
'sq-toast__message--info': notification.isInfo,
|
||||
'sq-toast__message--success': notification.isSuccess,
|
||||
'sq-toast__message--error': notification.isError
|
||||
}">
|
||||
<div class='sq-toast__message__icon-box' [ngClass]="{
|
||||
'sq-toast__message__icon-box--info': notification.isInfo,
|
||||
'sq-toast__message__icon-box--success': notification.isSuccess,
|
||||
'sq-toast__message__icon-box--error': notification.isError
|
||||
}">
|
||||
<div class='sq-toast__message__icon-box__icon'>
|
||||
<svg *ngIf='notification.isError' width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M23.5405 16.069L14.9416 1.64366C13.6359 -0.547887 10.3666 -0.547887 9.06078 1.64366L0.459539 16.069C-0.846244 18.2606 0.785985 21 3.39997 21H20.6C23.214 21 24.8462 18.2606 23.5405 16.069ZM13.4618 17.7408C13.0797 18.0943 12.5961 18.2699 12.0085 18.2699C11.4112 18.2699 10.9203 18.0943 10.5382 17.7408C10.1562 17.3872 9.96274 16.9564 9.96274 16.446C9.96274 15.9239 10.1538 15.4954 10.5358 15.1606C10.9203 14.8257 11.4112 14.6572 12.0085 14.6572C12.6057 14.6572 13.0942 14.8257 13.4714 15.1606C13.8487 15.4954 14.0373 15.9239 14.0373 16.446C14.0373 16.9564 13.8462 17.3872 13.4618 17.7408ZM13.3554 13.6831H10.6471L9.98208 5.95183H14.0373L13.3554 13.6831Z" fill="white"/>
|
||||
</svg>
|
||||
<svg *ngIf='notification.isSuccess' width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M12 0C5.37378 0 0 5.37377 0 12C0 18.6262 5.37378 24 12 24C18.6289 24 24 18.6262 24 12C24 5.37377 18.6289 0 12 0ZM15.9607 12.7199L13.322 15.3586L10.6833 17.9973L8.0446 15.3586L5.40589 12.7199L8.0446 10.0812L10.6833 12.7199L13.322 10.0812L15.9607 7.44246L18.5995 10.0812L15.9607 12.7199Z" fill="white"/>
|
||||
</svg>
|
||||
<svg *ngIf='notification.isInfo' width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M11.9987 0C5.37317 0 0 5.37377 0 12C0 18.6262 5.37317 24 11.9987 24C18.6268 24 24 18.6262 24 12C24 5.37377 18.6268 0 11.9987 0ZM10.7838 5.47279C11.1049 5.157 11.5116 4.99911 12.0067 4.99911C12.5017 4.99911 12.9085 5.157 13.2296 5.47279C13.5533 5.78858 13.7112 6.19268 13.7112 6.68778C13.7112 7.18287 13.5507 7.58965 13.2296 7.91079C12.9085 8.23194 12.5017 8.39518 12.0067 8.39518C11.5009 8.39518 11.0915 8.23461 10.7758 7.91079C10.46 7.58965 10.3021 7.18287 10.3021 6.68778C10.2995 6.19268 10.46 5.78858 10.7838 5.47279ZM14.8886 19.0036H9.11138V16.9242H10.6607V11.5665H9.11138V9.48706H13.3527V11.5665V16.9242H14.8886V19.0036Z" fill="white"/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class='sq-toast__message__text-box'>
|
||||
{{notification.isSuccess ? 'Success' : notification.isError ? 'Error' : ''}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="status-bar-inner" [innerHTML]="notification.message | sanitizeHtml"></div>
|
||||
</div>
|
||||
|
||||
@@ -7,9 +7,132 @@
|
||||
left: 0;
|
||||
color: white;
|
||||
width: 100%;
|
||||
padding: 5px;
|
||||
padding-left: 10px;
|
||||
}
|
||||
.status-bar-inner{
|
||||
padding: 10px;
|
||||
padding-left: 15px;
|
||||
padding-right: 80px;
|
||||
}
|
||||
.status-bar-warning {
|
||||
background-color: #ff9800;
|
||||
}
|
||||
.status{
|
||||
background-color: #E51253;
|
||||
position: fixed;
|
||||
z-index: 9999;
|
||||
bottom: -45px;
|
||||
left: 0;
|
||||
color: white;
|
||||
width: 100%;
|
||||
transition: bottom 350ms;
|
||||
}
|
||||
.status-open{
|
||||
bottom: 0px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$info-icon-background-color: rgba(114, 137, 218, 1);
|
||||
$success-icon-background-color: rgba(97, 185, 72, 1);
|
||||
$warning-icon-background-color: rgba(251, 176, 59, 1);
|
||||
$error-icon-background-color: rgba(229, 18, 83, 1);
|
||||
|
||||
$toast-text-color: rgba(255, 255, 255, 1);
|
||||
|
||||
$info-background-color: rgba(71, 98, 195, 1);
|
||||
$success-background-color: rgba(58, 137, 36, 1);
|
||||
$warning-background-color: rgba(211, 135, 15, 1);
|
||||
$error-background-color: rgba(155, 10, 54, 1);
|
||||
|
||||
$info-shadow-color: rgba(114, 137, 218, 0.4);
|
||||
$success-shadow-color: rgba(97, 185, 72, 0.4);
|
||||
$warning-shadow-color: rgba(251, 176, 59, 0.4);
|
||||
$error-shadow-color: rgba(229, 18, 83, 0.4);
|
||||
|
||||
|
||||
.sq-toast {
|
||||
position: fixed;
|
||||
min-width: 6rem;
|
||||
opacity: 0.9;
|
||||
font-family: Roboto, sans-serif;
|
||||
font-size: 12px;
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
line-height: 14px;
|
||||
letter-spacing: 0;
|
||||
z-index: 9999;
|
||||
text-align: right;
|
||||
}
|
||||
@media (max-width: 1024px)
|
||||
{
|
||||
.sq-toast{
|
||||
width: 90%;
|
||||
}
|
||||
}
|
||||
|
||||
.sq-toast--top-right {
|
||||
bottom: -4px;
|
||||
right: 0px;
|
||||
}
|
||||
|
||||
.sq-toast__message {
|
||||
display: inline-block;
|
||||
color: $toast-text-color;
|
||||
min-height: 42px;
|
||||
margin-left: 1em;
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.sq-toast__message--info {
|
||||
background-color: $info-background-color;
|
||||
box-shadow: 0 4px 10px $info-shadow-color;
|
||||
}
|
||||
.sq-toast__message--success {
|
||||
background-color: $success-background-color;
|
||||
box-shadow: 0 4px 10px $success-shadow-color;
|
||||
}
|
||||
.sq-toast__message--warning {
|
||||
background-color: $warning-background-color;
|
||||
box-shadow: 0 4px 10px $warning-shadow-color;
|
||||
}
|
||||
.sq-toast__message--error {
|
||||
background-color: $error-background-color;
|
||||
box-shadow: 0 4px 10px $error-shadow-color;
|
||||
}
|
||||
|
||||
.sq-toast__message__icon-box {
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.sq-toast__message__text-box {
|
||||
padding: 1.2em;
|
||||
margin-left: 3em;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.sq-toast__message__icon-box--info {
|
||||
background-color: $info-icon-background-color;
|
||||
}
|
||||
.sq-toast__message__icon-box--success {
|
||||
background-color: $success-icon-background-color;
|
||||
}
|
||||
.sq-toast__message__icon-box--warning {
|
||||
background-color: $warning-icon-background-color;
|
||||
}
|
||||
.sq-toast__message__icon-box--error {
|
||||
background-color: $error-icon-background-color;
|
||||
}
|
||||
|
||||
.sq-toast__message__icon-box__icon {
|
||||
font-size: 2rem;
|
||||
margin: .5rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,86 @@
|
||||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||
import { StatusBarService } from '../status-bar.service';
|
||||
import { animate, sequence, style, transition, trigger } from '@angular/animations';
|
||||
|
||||
export enum StatusType {
|
||||
INFO,
|
||||
ERROR,
|
||||
SUCCESS,
|
||||
}
|
||||
export class Notification {
|
||||
type: StatusType;
|
||||
message: string;
|
||||
get isError() {
|
||||
return this.type === StatusType.ERROR;
|
||||
}
|
||||
get isSuccess() {
|
||||
return this.type === StatusType.SUCCESS;
|
||||
}
|
||||
get isInfo() {
|
||||
return this.type === StatusType.INFO;
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-status-bar',
|
||||
templateUrl: './status-bar.component.html',
|
||||
styleUrls: ['./status-bar.component.scss'],
|
||||
animations: [
|
||||
trigger('anim', [
|
||||
transition(':leave', [
|
||||
style({
|
||||
height: '*',
|
||||
opacity: '1',
|
||||
transform: 'translateX(0)',
|
||||
}),
|
||||
sequence([
|
||||
animate(
|
||||
'.1s ease',
|
||||
style({
|
||||
height: '*',
|
||||
opacity: '.2',
|
||||
transform: 'translateX(20px)',
|
||||
})
|
||||
),
|
||||
animate('.1s ease', style({ height: '0', opacity: 0, transform: 'translateX(20px)' })),
|
||||
]),
|
||||
]),
|
||||
transition(':enter', [
|
||||
style({ height: '0', opacity: '0', transform: 'translateX(20px)' }),
|
||||
sequence([
|
||||
animate(
|
||||
'.35s ease',
|
||||
style({
|
||||
height: '*',
|
||||
opacity: 1,
|
||||
transform: 'translateX(0)',
|
||||
})
|
||||
),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class StatusBarComponent implements OnInit {
|
||||
isWarning: boolean;
|
||||
isActive: boolean;
|
||||
showDiscord: boolean;
|
||||
statusMessage: string;
|
||||
@Output() getHelp = new EventEmitter();
|
||||
constructor(public statusService: StatusBarService) {}
|
||||
isActive = false;
|
||||
private timeout;
|
||||
notification: Notification = new Notification();
|
||||
constructor(public statusService: StatusBarService) {
|
||||
statusService.setStatusComponent(this);
|
||||
}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
showStatus(message: string, isError?: boolean, isInfo?: boolean) {
|
||||
clearTimeout(this.timeout);
|
||||
this.notification.message = message;
|
||||
this.notification.type = isError ? StatusType.ERROR : isInfo ? StatusType.INFO : StatusType.SUCCESS;
|
||||
this.isActive = true;
|
||||
this.timeout = setTimeout(
|
||||
() => {
|
||||
this.isActive = false;
|
||||
},
|
||||
this.notification.isError ? 7500 : 3500
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user