-
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.
- Loading branch information
1 parent
fd62a79
commit 9f36fdc
Showing
13 changed files
with
957 additions
and
91 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
7 changes: 7 additions & 0 deletions
7
design-system/projects/lib/src/directives/ng-if-loaded/injection.ts
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,7 @@ | ||
import {InjectionToken} from '@angular/core'; | ||
import {SpinnerComponent} from './spinner/spinner.component'; | ||
import {ComponentType} from '@angular/cdk/overlay'; | ||
|
||
export const defaultSpinner: ComponentType<any> = SpinnerComponent; | ||
|
||
export const IF_LOADED_SPINNER = new InjectionToken<ComponentType<any>>('defaultSpinner'); |
8 changes: 8 additions & 0 deletions
8
design-system/projects/lib/src/directives/ng-if-loaded/ng-if-loaded.directive.spec.ts
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 { NgIfLoadedDirective } from './ng-if-loaded.directive'; | ||
|
||
describe('NgIfLoadedDirective', () => { | ||
it('should create an instance', () => { | ||
const directive = new NgIfLoadedDirective(); | ||
expect(directive).toBeTruthy(); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
design-system/projects/lib/src/directives/ng-if-loaded/ng-if-loaded.directive.ts
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,42 @@ | ||
import { | ||
ComponentFactoryResolver, | ||
Directive, | ||
Inject, | ||
Input, | ||
TemplateRef, | ||
ViewContainerRef | ||
} from '@angular/core'; | ||
import {IF_LOADED_SPINNER} from './injection'; | ||
import {ComponentType} from '@angular/cdk/overlay'; | ||
|
||
@Directive({ | ||
// tslint:disable-next-line:directive-selector | ||
selector: '[ngIfLoaded]' | ||
}) | ||
export class NgIfLoadedDirective { | ||
|
||
spinner: ComponentType<any>; | ||
|
||
constructor( | ||
@Inject(IF_LOADED_SPINNER) spinnerComponent: ComponentType<any>, | ||
private templateRef: TemplateRef<any>, | ||
private viewContainer: ViewContainerRef, | ||
private resolver: ComponentFactoryResolver | ||
) { | ||
this.spinner = spinnerComponent; | ||
} | ||
|
||
|
||
@Input() | ||
set ngIfLoaded(value) { | ||
if (value) { | ||
this.viewContainer.clear(); | ||
this.viewContainer.createEmbeddedView(this.templateRef); | ||
} else { | ||
this.viewContainer.clear(); | ||
const factory = this.resolver.resolveComponentFactory(this.spinner); | ||
this.viewContainer.createComponent(factory); | ||
} | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
design-system/projects/lib/src/directives/ng-if-loaded/ng-if-loaded.module.ts
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,35 @@ | ||
import {ModuleWithProviders, NgModule} from '@angular/core'; | ||
import {CommonModule} from '@angular/common'; | ||
import {NgIfLoadedDirective} from './ng-if-loaded.directive'; | ||
import {SpinnerComponent} from './spinner/spinner.component'; | ||
import {IF_LOADED_SPINNER} from './injection'; | ||
import {CommandPaletteService} from '../../services/command-palette/command-palette.service'; | ||
import {CommandPaletteEntriesService} from '../../services/command-palette/command-palette-entries.service'; | ||
import {ComponentInjectorService} from '../../services/command-palette/component-injector.service'; | ||
import {ComponentType} from '@angular/cdk/overlay'; | ||
|
||
const directives = [ | ||
NgIfLoadedDirective, | ||
SpinnerComponent | ||
]; | ||
|
||
@NgModule({ | ||
declarations: directives, | ||
exports: directives, | ||
imports: [ | ||
CommonModule | ||
], | ||
}) | ||
export class NgIfLoadedModule { | ||
public static forRoot(spinnerComponent: ComponentType<any> = undefined): ModuleWithProviders<NgIfLoadedModule> { | ||
return { | ||
ngModule: NgIfLoadedModule, | ||
providers: [ | ||
CommandPaletteService, | ||
CommandPaletteEntriesService, | ||
ComponentInjectorService, | ||
{provide: IF_LOADED_SPINNER, useValue: spinnerComponent || SpinnerComponent}, | ||
] | ||
}; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
design-system/projects/lib/src/directives/ng-if-loaded/spinner/spinner.component.html
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,11 @@ | ||
<div class="pm-spinner"> | ||
<div class="d-flex justify-content-center w-100 h-100" style="min-height: 50px;"> | ||
<div class="spinner-wrap"> | ||
<div class="spinner-cube"> | ||
<div class="spinner-front"></div> | ||
<div class="spinner-left"></div> | ||
<div class="spinner-top"></div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
211 changes: 211 additions & 0 deletions
211
design-system/projects/lib/src/directives/ng-if-loaded/spinner/spinner.component.scss
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,211 @@ | ||
.pm-spinner { | ||
// Cube parameters | ||
$colorBorder: #f5f5f5; | ||
$colorMin: #dddddd; | ||
//$colorMax: #505050; | ||
$colorMax: #dddddd; | ||
$size: 30px; | ||
// Time parameters | ||
$duration: 1s; | ||
$wait: 20%; | ||
$borderSize: $size * 0.1; | ||
|
||
.spinner-wrap { | ||
perspective: 2 * $size; | ||
perspective-origin: 50% 0px; | ||
min-height: 50px; | ||
padding-top: 3px; | ||
align-self: center; | ||
} | ||
|
||
.spinner-cube { | ||
position: relative; | ||
width: $size; | ||
transform-style: preserve-3d; | ||
} | ||
|
||
.spinner-cube div { | ||
position: absolute; | ||
width: $size; | ||
height: $size; | ||
} | ||
|
||
.spinner-front { | ||
background: $colorMin; | ||
border: $borderSize solid $colorBorder; | ||
transform: translateZ($size * 0.5); | ||
animation: colorsf $duration ease-in-out infinite; | ||
-moz-animation: colorsf $duration ease-in-out infinite; | ||
-webkit-animation: colorsf $duration ease-in-out infinite; | ||
-o-animation: colorsf $duration ease-in-out infinite; | ||
-ms-animation: colorsf $duration ease-in-out infinite; | ||
} | ||
|
||
.spinner-left { | ||
background: $colorMax; | ||
border: $borderSize solid $colorBorder; | ||
transform: rotateY(270deg) translateX(-$size * 0.5); | ||
transform-origin: center left; | ||
animation: colorsl $duration ease-in-out infinite; | ||
-moz-animation: colorsl $duration ease-in-out infinite; | ||
-webkit-animation: colorsl $duration ease-in-out infinite; | ||
-o-animation: colorsl $duration ease-in-out infinite; | ||
-ms-animation: colorsl $duration ease-in-out infinite; | ||
} | ||
|
||
.spinner-top { | ||
background: $colorMax; | ||
border: $borderSize solid $colorBorder; | ||
transform: rotateX(90deg) translateZ($size * 0.5); | ||
animation: colorsl $duration ease-in-out infinite; | ||
-moz-animation: colorsl $duration ease-in-out infinite; | ||
-webkit-animation: colorsl $duration ease-in-out infinite; | ||
-o-animation: colorsl $duration ease-in-out infinite; | ||
-ms-animation: colorsl $duration ease-in-out infinite; | ||
} | ||
|
||
@keyframes colorsf { | ||
#{$wait} { | ||
background: $colorMin; | ||
} | ||
100% { | ||
background: $colorMax; | ||
} | ||
} | ||
|
||
@keyframes colorsl { | ||
#{$wait} { | ||
background: $colorMax; | ||
} | ||
100% { | ||
background: $colorMin; | ||
} | ||
} | ||
|
||
@keyframes cube { | ||
#{$wait} { | ||
transform: rotateY(0deg); | ||
} | ||
100% { | ||
transform: rotateY(90deg); | ||
} | ||
} | ||
|
||
@-webkit-keyframes colorsf { | ||
#{$wait} { | ||
background: $colorMin; | ||
} | ||
100% { | ||
background: $colorMax; | ||
} | ||
} | ||
|
||
@-webkit-keyframes colorsl { | ||
#{$wait} { | ||
background: $colorMax; | ||
} | ||
100% { | ||
background: $colorMin; | ||
} | ||
} | ||
|
||
@-webkit-keyframes cube { | ||
#{$wait} { | ||
transform: rotateY(0deg); | ||
} | ||
100% { | ||
transform: rotateY(90deg); | ||
} | ||
} | ||
|
||
|
||
@-o-keyframes colorsf { | ||
#{$wait} { | ||
background: $colorMin; | ||
} | ||
100% { | ||
background: $colorMax; | ||
} | ||
} | ||
|
||
@-o-keyframes colorsl { | ||
#{$wait} { | ||
background: $colorMax; | ||
} | ||
100% { | ||
background: $colorMin; | ||
} | ||
} | ||
|
||
@-o-keyframes cube { | ||
#{$wait} { | ||
transform: rotateY(0deg); | ||
} | ||
100% { | ||
transform: rotateY(90deg); | ||
} | ||
} | ||
|
||
@-ms-keyframes colorsf { | ||
#{$wait} { | ||
background: $colorMin; | ||
} | ||
100% { | ||
background: $colorMax; | ||
} | ||
} | ||
|
||
@-ms-keyframes colorsl { | ||
#{$wait} { | ||
background: $colorMax; | ||
} | ||
100% { | ||
background: $colorMin; | ||
} | ||
} | ||
|
||
@-ms-keyframes cube { | ||
#{$wait} { | ||
transform: rotateY(0deg); | ||
} | ||
100% { | ||
transform: rotateY(90deg); | ||
} | ||
} | ||
|
||
@-ms-keyframes colorsf { | ||
#{$wait} { | ||
background: $colorMin; | ||
} | ||
100% { | ||
background: $colorMax; | ||
} | ||
} | ||
|
||
@-moz-keyframes colorsl { | ||
#{$wait} { | ||
background: $colorMax; | ||
} | ||
100% { | ||
background: $colorMin; | ||
} | ||
} | ||
|
||
@-moz-keyframes cube { | ||
#{$wait} { | ||
transform: rotateY(0deg); | ||
} | ||
100% { | ||
transform: rotateY(90deg); | ||
} | ||
} | ||
|
||
.spinner-cube { | ||
z-index: 999; | ||
animation: cube $duration ease-in-out infinite; | ||
-moz-animation: cube $duration ease-in-out infinite; | ||
-webkit-animation: cube $duration ease-in-out infinite; | ||
-o-animation: cube $duration ease-in-out infinite; | ||
-ms-animation: cube $duration ease-in-out infinite; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
design-system/projects/lib/src/directives/ng-if-loaded/spinner/spinner.component.spec.ts
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,25 @@ | ||
import {ComponentFixture, TestBed} from '@angular/core/testing'; | ||
|
||
import {SpinnerComponent} from './spinner.component'; | ||
|
||
describe('SpinnerComponent', () => { | ||
let component: SpinnerComponent; | ||
let fixture: ComponentFixture<SpinnerComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [SpinnerComponent] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(SpinnerComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
design-system/projects/lib/src/directives/ng-if-loaded/spinner/spinner.component.ts
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 {Component, OnInit} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'pm-spinner', | ||
templateUrl: './spinner.component.html', | ||
styleUrls: ['./spinner.component.scss'] | ||
}) | ||
export class SpinnerComponent implements OnInit { | ||
|
||
constructor() { | ||
} | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
} |
Oops, something went wrong.
9f36fdc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: