Skip to content

Commit

Permalink
feat: Adding directives and pipes 🚧
Browse files Browse the repository at this point in the history
  • Loading branch information
flauc committed Jun 16, 2018
1 parent 8e3d481 commit 65e68e5
Show file tree
Hide file tree
Showing 27 changed files with 272 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ClickOutsideDirective } from './click-outside.directive';

describe('ClickOutsideDirective', () => {
it('should create an instance', () => {
const directive = new ClickOutsideDirective();
expect(directive).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Directive } from '@angular/core';

@Directive({
selector: '[libClickOutside]'
})
export class ClickOutsideDirective {

constructor() { }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ClickOutsideModule } from './click-outside.module';

describe('ClickOutsideModule', () => {
let clickOutsideModule: ClickOutsideModule;

beforeEach(() => {
clickOutsideModule = new ClickOutsideModule();
});

it('should create an instance', () => {
expect(clickOutsideModule).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {ClickOutsideDirective} from './click-outside.directive';

@NgModule({
imports: [
CommonModule
],
declarations: [
ClickOutsideDirective
],
exports: [
ClickOutsideDirective
]
})
export class ClickOutsideModule { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { FormTouchOnHoverDirective } from './form-touch-on-hover.directive';

describe('FormTouchOnHoverDirective', () => {
it('should create an instance', () => {
const directive = new FormTouchOnHoverDirective();
expect(directive).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Directive } from '@angular/core';

@Directive({
selector: '[libFormTouchOnHover]'
})
export class FormTouchOnHoverDirective {

constructor() { }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { FormTouchOnHoverModule } from './form-touch-on-hover.module';

describe('FormTouchOnHoverModule', () => {
let formTouchOnHoverModule: FormTouchOnHoverModule;

beforeEach(() => {
formTouchOnHoverModule = new FormTouchOnHoverModule();
});

it('should create an instance', () => {
expect(formTouchOnHoverModule).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {FormTouchOnHoverDirective} from './form-touch-on-hover.directive';

@NgModule({
imports: [
CommonModule
],
declarations: [
FormTouchOnHoverDirective
],
exports: [
FormTouchOnHoverDirective
]
})
export class FormTouchOnHoverModule { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { StopPropagationDirective } from './stop-propagation.directive';

describe('StopPropagationDirective', () => {
it('should create an instance', () => {
const directive = new StopPropagationDirective();
expect(directive).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Directive } from '@angular/core';

@Directive({
selector: '[libStopPropagation]'
})
export class StopPropagationDirective {

constructor() { }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { StopPropagationModule } from './stop-propagation.module';

describe('StopPropagationModule', () => {
let stopPropagationModule: StopPropagationModule;

beforeEach(() => {
stopPropagationModule = new StopPropagationModule();
});

it('should create an instance', () => {
expect(stopPropagationModule).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {StopPropagationDirective} from './stop-propagation.directive';

@NgModule({
imports: [
CommonModule
],
declarations: [
StopPropagationDirective
],
exports: [
StopPropagationDirective
]
})
export class StopPropagationModule { }
31 changes: 31 additions & 0 deletions projects/ng-helpers/src/helpers/rx-destroy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {OnDestroy} from '@angular/core';
import {Subject} from 'rxjs';

/**
* Uses the destroyed$ subject to indicate that the component was destroyed
*
* @example
* class SomeComponent extends RxDestroy {
* ngOnInit() {
* interval(1000)
* .pipe(
* takeUntil(this.destroyed$)
* )
* .subscribe(_ => {});
* }
* }
*/
export class RxDestroy implements OnDestroy {
/**
* Used like this in classes that extend RxDestroy: someObservable$.takeUntil(this.destroyed$)
*/
destroyed$ = new Subject<void>();

/**
* Calls next() on this.destroyed$ to cancel all listeners
*/
ngOnDestroy() {
this.destroyed$.next();
this.destroyed$.complete();
}
}
25 changes: 0 additions & 25 deletions projects/ng-helpers/src/lib/ng-helpers.component.spec.ts

This file was deleted.

19 changes: 0 additions & 19 deletions projects/ng-helpers/src/lib/ng-helpers.component.ts

This file was deleted.

10 changes: 0 additions & 10 deletions projects/ng-helpers/src/lib/ng-helpers.module.ts

This file was deleted.

15 changes: 0 additions & 15 deletions projects/ng-helpers/src/lib/ng-helpers.service.spec.ts

This file was deleted.

9 changes: 0 additions & 9 deletions projects/ng-helpers/src/lib/ng-helpers.service.ts

This file was deleted.

13 changes: 13 additions & 0 deletions projects/ng-helpers/src/pipes/enum/enum.module.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { EnumModule } from './enum.module';

describe('EnumModule', () => {
let enumModule: EnumModule;

beforeEach(() => {
enumModule = new EnumModule();
});

it('should create an instance', () => {
expect(enumModule).toBeTruthy();
});
});
16 changes: 16 additions & 0 deletions projects/ng-helpers/src/pipes/enum/enum.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {EnumPipe} from './enum.pipe';

@NgModule({
imports: [
CommonModule
],
declarations: [
EnumPipe
],
exports: [
EnumPipe
]
})
export class EnumModule { }
8 changes: 8 additions & 0 deletions projects/ng-helpers/src/pipes/enum/enum.pipe.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { EnumPipe } from './enum.pipe';

describe('EnumPipe', () => {
it('create an instance', () => {
const pipe = new EnumPipe();
expect(pipe).toBeTruthy();
});
});
12 changes: 12 additions & 0 deletions projects/ng-helpers/src/pipes/enum/enum.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'enum'
})
export class EnumPipe implements PipeTransform {

transform(value: any, args?: any): any {
return null;
}

}
13 changes: 13 additions & 0 deletions projects/ng-helpers/src/pipes/sanitize/sanitize.module.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { SanitizeModule } from './sanitize.module';

describe('SanitizeModule', () => {
let sanitizeModule: SanitizeModule;

beforeEach(() => {
sanitizeModule = new SanitizeModule();
});

it('should create an instance', () => {
expect(sanitizeModule).toBeTruthy();
});
});
16 changes: 16 additions & 0 deletions projects/ng-helpers/src/pipes/sanitize/sanitize.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {SanitizePipe} from './sanitize.pipe';

@NgModule({
imports: [
CommonModule
],
declarations: [
SanitizePipe
],
exports: [
SanitizePipe
]
})
export class SanitizeModule { }
8 changes: 8 additions & 0 deletions projects/ng-helpers/src/pipes/sanitize/sanitize.pipe.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { SanitizePipe } from './sanitize.pipe';

describe('SanitizePipe', () => {
it('create an instance', () => {
const pipe = new SanitizePipe();
expect(pipe).toBeTruthy();
});
});
12 changes: 12 additions & 0 deletions projects/ng-helpers/src/pipes/sanitize/sanitize.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'sanitize'
})
export class SanitizePipe implements PipeTransform {

transform(value: any, args?: any): any {
return null;
}

}
4 changes: 2 additions & 2 deletions projects/ng-helpers/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"directive-selector": [
true,
"attribute",
"lib",
"jp",
"camelCase"
],
"component-selector": [
true,
"element",
"lib",
"jp",
"kebab-case"
]
}
Expand Down

0 comments on commit 65e68e5

Please sign in to comment.