Skip to content

Instantly share code, notes, and snippets.

View lydemann's full-sized avatar

Christian Lüdemann lydemann

View GitHub Profile
@lydemann
lydemann / spy-helper.ts
Last active April 21, 2018 10:24
Provides helpers for easy and typesafe mocking with spies
/*
This class provides helpers for easy and typesafe mocking with spies
*/
// get keys of type
export declare function keys<T extends object>(): Array<keyof T>;
export class SpyHelper {
/*
export class GenericAction<ActionType, PayloadType> {
constructor(type: ActionType, payload?: PayloadType) {
this.type = type;
this.payload = payload;
}
type: ActionType;
payload?: PayloadType;
@lydemann
lydemann / husky config
Created July 12, 2018 17:55
Husky precommit hooks with concurrently
"husky": {
"hooks": {
"pre-commit": "concurrently --kill-others \"npm run lint\" \"npm run test\" \"npm run build\"",
"pre-push": "git pull origin master"
}
}
@lydemann
lydemann / VS Code Settings
Created July 12, 2018 18:05
My preferred VS Code Settings
{
"gitlens.advanced.messages": {
"suppressFileNotUnderSourceControlWarning": true,
"suppressShowKeyBindingsNotice": true
},
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"workbench.editor.enablePreview": false,
"tslint.autoFixOnSave": true,
@lydemann
lydemann / index.html
Created July 28, 2018 09:39
HTML to show before Angular is loaded
<app-root>
<div class="container">
<div class="row">
<div id="loader">
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
@lydemann
lydemann / styles.scss
Created July 28, 2018 09:40
Spinner added to global style
/* You can add global styles to this file, and also import other style files */
/* Bootstrap */
@import '~bootstrap/scss/bootstrap';
@import "styles/spinner";
import { Overlay, OverlayRef } from '@angular/cdk/overlay';
import { ComponentPortal } from '@angular/cdk/portal';
import { Injectable } from '@angular/core';
import { SpinnerOverlayComponent } from '@app/core/spinner-overlay/spinner-overlay.component';
@Injectable({
providedIn: 'root'
})
export class SpinnerOverlayService {
private overlayRef: OverlayRef = null;
@lydemann
lydemann / spinner-overlay.component.html
Created July 28, 2018 09:43
Template for spinner portal component used by Spinner service (CDK overlay service).
<div class="spinner-wrapper">
<app-spinner></app-spinner>
</div>
.spinner-wrapper {
position: fixed;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
top: 0;
left: 0;
background-color: rgba(255, 255, 255, 0.5);
import { Component, Input, OnInit } from '@angular/core';
@Component({
selector: 'app-spinner-overlay',
templateUrl: './spinner-overlay.component.html',
styleUrls: ['./spinner-overlay.component.scss']
})
export class SpinnerOverlayComponent implements OnInit {
@Input() public message: string;
constructor() {}