From 62a419432923125560a2cd109da6e0a77e2ef421 Mon Sep 17 00:00:00 2001 From: Alexander Nickel Date: Wed, 11 Sep 2019 22:27:15 +0200 Subject: [PATCH] Add clearer code-structure Rename legacy-directives to alias because we will keep them. Move alias-directory into directives. Add own NgModule holding only the aliases. Add own directory for modules. --- projects/ngx-intersection/package.json | 2 +- .../src/lib/angular-intersection.module.ts | 24 ------------------- .../alias}/enter-viewport-once.directive.ts | 2 +- .../alias}/enter-viewport.directive.ts | 2 +- .../alias}/exit-viewport.directive.ts | 2 +- .../alias}/has-entered-viewport.directive.ts | 2 +- .../alias}/public-api.ts | 2 +- .../alias}/will-enter-viewport.directive.ts | 2 +- .../src/lib/directives/public-api.ts | 2 +- .../modules/angular-intersection.module.ts | 11 +++++++++ .../intersection-directives-alias.module.ts | 22 +++++++++++++++++ .../intersection-directives.module.ts | 6 ++--- .../src/lib/modules/public-api.ts | 3 +++ projects/ngx-intersection/src/public-api.ts | 6 +---- src/app/components/app.component.styl | 2 ++ 15 files changed, 50 insertions(+), 40 deletions(-) delete mode 100644 projects/ngx-intersection/src/lib/angular-intersection.module.ts rename projects/ngx-intersection/src/lib/{legacy-directives => directives/alias}/enter-viewport-once.directive.ts (80%) rename projects/ngx-intersection/src/lib/{legacy-directives => directives/alias}/enter-viewport.directive.ts (80%) rename projects/ngx-intersection/src/lib/{legacy-directives => directives/alias}/exit-viewport.directive.ts (80%) rename projects/ngx-intersection/src/lib/{legacy-directives => directives/alias}/has-entered-viewport.directive.ts (82%) rename projects/ngx-intersection/src/lib/{legacy-directives => directives/alias}/public-api.ts (77%) rename projects/ngx-intersection/src/lib/{legacy-directives => directives/alias}/will-enter-viewport.directive.ts (81%) create mode 100644 projects/ngx-intersection/src/lib/modules/angular-intersection.module.ts create mode 100644 projects/ngx-intersection/src/lib/modules/intersection-directives-alias.module.ts rename projects/ngx-intersection/src/lib/{directives => modules}/intersection-directives.module.ts (94%) create mode 100644 projects/ngx-intersection/src/lib/modules/public-api.ts diff --git a/projects/ngx-intersection/package.json b/projects/ngx-intersection/package.json index b216bd9..58e610e 100644 --- a/projects/ngx-intersection/package.json +++ b/projects/ngx-intersection/package.json @@ -1,6 +1,6 @@ { "name": "@mralexandernickel/ngx-intersection", - "version": "0.9.0", + "version": "0.9.1", "publishConfig": { "access": "public" }, diff --git a/projects/ngx-intersection/src/lib/angular-intersection.module.ts b/projects/ngx-intersection/src/lib/angular-intersection.module.ts deleted file mode 100644 index be5baf9..0000000 --- a/projects/ngx-intersection/src/lib/angular-intersection.module.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { NgModule } from '@angular/core'; -import { EnterViewportDirective } from './legacy-directives/enter-viewport.directive'; -import { EnterViewportOnceDirective } from './legacy-directives/enter-viewport-once.directive'; -import { WillEnterViewportDirective } from './legacy-directives/will-enter-viewport.directive'; -import { ExitViewportDirective } from './legacy-directives/exit-viewport.directive'; -import { HasEnteredViewportDirective } from './legacy-directives/has-entered-viewport.directive'; - -@NgModule({ - declarations: [ - EnterViewportDirective, - EnterViewportOnceDirective, - WillEnterViewportDirective, - ExitViewportDirective, - HasEnteredViewportDirective - ], - exports: [ - EnterViewportDirective, - EnterViewportOnceDirective, - WillEnterViewportDirective, - ExitViewportDirective, - HasEnteredViewportDirective - ] -}) -export class AngularIntersectionModule {} diff --git a/projects/ngx-intersection/src/lib/legacy-directives/enter-viewport-once.directive.ts b/projects/ngx-intersection/src/lib/directives/alias/enter-viewport-once.directive.ts similarity index 80% rename from projects/ngx-intersection/src/lib/legacy-directives/enter-viewport-once.directive.ts rename to projects/ngx-intersection/src/lib/directives/alias/enter-viewport-once.directive.ts index 705f03b..98967be 100644 --- a/projects/ngx-intersection/src/lib/legacy-directives/enter-viewport-once.directive.ts +++ b/projects/ngx-intersection/src/lib/directives/alias/enter-viewport-once.directive.ts @@ -1,5 +1,5 @@ import { Directive, Output, EventEmitter } from '@angular/core'; -import { IntersectionPresentStartOnceDirective } from '../directives/public-api'; +import { IntersectionPresentStartOnceDirective } from '../public-api'; @Directive({ selector: '[libEnterViewportOnce]', diff --git a/projects/ngx-intersection/src/lib/legacy-directives/enter-viewport.directive.ts b/projects/ngx-intersection/src/lib/directives/alias/enter-viewport.directive.ts similarity index 80% rename from projects/ngx-intersection/src/lib/legacy-directives/enter-viewport.directive.ts rename to projects/ngx-intersection/src/lib/directives/alias/enter-viewport.directive.ts index 3cb5fa4..8e257fb 100644 --- a/projects/ngx-intersection/src/lib/legacy-directives/enter-viewport.directive.ts +++ b/projects/ngx-intersection/src/lib/directives/alias/enter-viewport.directive.ts @@ -1,5 +1,5 @@ import { Directive, Output, EventEmitter } from '@angular/core'; -import { IntersectionPresentStartDirective } from '../directives/public-api'; +import { IntersectionPresentStartDirective } from '../public-api'; @Directive({ selector: '[libEnterViewport]', diff --git a/projects/ngx-intersection/src/lib/legacy-directives/exit-viewport.directive.ts b/projects/ngx-intersection/src/lib/directives/alias/exit-viewport.directive.ts similarity index 80% rename from projects/ngx-intersection/src/lib/legacy-directives/exit-viewport.directive.ts rename to projects/ngx-intersection/src/lib/directives/alias/exit-viewport.directive.ts index ab2f86c..48e74f5 100644 --- a/projects/ngx-intersection/src/lib/legacy-directives/exit-viewport.directive.ts +++ b/projects/ngx-intersection/src/lib/directives/alias/exit-viewport.directive.ts @@ -1,5 +1,5 @@ import { Directive, Output, EventEmitter } from '@angular/core'; -import { IntersectionPresentStartExitDirective } from '../directives/public-api'; +import { IntersectionPresentStartExitDirective } from '../public-api'; @Directive({ selector: '[libExitViewport]', diff --git a/projects/ngx-intersection/src/lib/legacy-directives/has-entered-viewport.directive.ts b/projects/ngx-intersection/src/lib/directives/alias/has-entered-viewport.directive.ts similarity index 82% rename from projects/ngx-intersection/src/lib/legacy-directives/has-entered-viewport.directive.ts rename to projects/ngx-intersection/src/lib/directives/alias/has-entered-viewport.directive.ts index 2f700c2..4ac4bfb 100644 --- a/projects/ngx-intersection/src/lib/legacy-directives/has-entered-viewport.directive.ts +++ b/projects/ngx-intersection/src/lib/directives/alias/has-entered-viewport.directive.ts @@ -1,5 +1,5 @@ import { Directive, Output, EventEmitter } from '@angular/core'; -import { IntersectionPastStartDirective } from '../directives/public-api'; +import { IntersectionPastStartDirective } from '../public-api'; @Directive({ selector: '[libHasEnteredViewport]', diff --git a/projects/ngx-intersection/src/lib/legacy-directives/public-api.ts b/projects/ngx-intersection/src/lib/directives/alias/public-api.ts similarity index 77% rename from projects/ngx-intersection/src/lib/legacy-directives/public-api.ts rename to projects/ngx-intersection/src/lib/directives/alias/public-api.ts index bdd314c..b0986eb 100644 --- a/projects/ngx-intersection/src/lib/legacy-directives/public-api.ts +++ b/projects/ngx-intersection/src/lib/directives/alias/public-api.ts @@ -1,5 +1,5 @@ export * from './enter-viewport.directive'; export * from './enter-viewport-once.directive'; export * from './will-enter-viewport.directive'; -// export * from './has-entered-viewport.directive'; +export * from './has-entered-viewport.directive'; export * from './exit-viewport.directive'; diff --git a/projects/ngx-intersection/src/lib/legacy-directives/will-enter-viewport.directive.ts b/projects/ngx-intersection/src/lib/directives/alias/will-enter-viewport.directive.ts similarity index 81% rename from projects/ngx-intersection/src/lib/legacy-directives/will-enter-viewport.directive.ts rename to projects/ngx-intersection/src/lib/directives/alias/will-enter-viewport.directive.ts index 931cc9c..a0cf185 100644 --- a/projects/ngx-intersection/src/lib/legacy-directives/will-enter-viewport.directive.ts +++ b/projects/ngx-intersection/src/lib/directives/alias/will-enter-viewport.directive.ts @@ -1,5 +1,5 @@ import { Directive, Output, EventEmitter } from '@angular/core'; -import { IntersectionFutureStartDirective } from '../directives/public-api'; +import { IntersectionFutureStartDirective } from '../public-api'; @Directive({ selector: '[libWillEnterViewport]', diff --git a/projects/ngx-intersection/src/lib/directives/public-api.ts b/projects/ngx-intersection/src/lib/directives/public-api.ts index 13b1983..2aa0743 100644 --- a/projects/ngx-intersection/src/lib/directives/public-api.ts +++ b/projects/ngx-intersection/src/lib/directives/public-api.ts @@ -1,5 +1,5 @@ export * from './abstract.viewport.directive'; -export * from './intersection-directives.module'; export * from './future/public-api'; export * from './past/public-api'; export * from './present/public-api'; +export * from './alias/public-api'; diff --git a/projects/ngx-intersection/src/lib/modules/angular-intersection.module.ts b/projects/ngx-intersection/src/lib/modules/angular-intersection.module.ts new file mode 100644 index 0000000..9974cc8 --- /dev/null +++ b/projects/ngx-intersection/src/lib/modules/angular-intersection.module.ts @@ -0,0 +1,11 @@ +import { NgModule } from '@angular/core'; +import { directivesAlias } from './intersection-directives-alias.module'; +/** + * This module is here only for legacy-reasons, but since it doesn't hold *any* + * own logic we can easily keep on releasing it. + */ +@NgModule({ + declarations: directivesAlias, + exports: directivesAlias +}) +export class AngularIntersectionModule {} diff --git a/projects/ngx-intersection/src/lib/modules/intersection-directives-alias.module.ts b/projects/ngx-intersection/src/lib/modules/intersection-directives-alias.module.ts new file mode 100644 index 0000000..cf618d4 --- /dev/null +++ b/projects/ngx-intersection/src/lib/modules/intersection-directives-alias.module.ts @@ -0,0 +1,22 @@ +import { NgModule } from '@angular/core'; +import { + EnterViewportDirective, + EnterViewportOnceDirective, + WillEnterViewportDirective, + ExitViewportDirective, + HasEnteredViewportDirective +} from '../directives/alias/public-api'; + +export const directivesAlias = [ + EnterViewportDirective, + EnterViewportOnceDirective, + WillEnterViewportDirective, + ExitViewportDirective, + HasEnteredViewportDirective +]; + +@NgModule({ + declarations: directivesAlias, + exports: directivesAlias +}) +export class IntersectionDirectivesAliasModule {} diff --git a/projects/ngx-intersection/src/lib/directives/intersection-directives.module.ts b/projects/ngx-intersection/src/lib/modules/intersection-directives.module.ts similarity index 94% rename from projects/ngx-intersection/src/lib/directives/intersection-directives.module.ts rename to projects/ngx-intersection/src/lib/modules/intersection-directives.module.ts index 48ded8f..ee1dd55 100644 --- a/projects/ngx-intersection/src/lib/directives/intersection-directives.module.ts +++ b/projects/ngx-intersection/src/lib/modules/intersection-directives.module.ts @@ -8,7 +8,7 @@ import { IntersectionFutureEndOnceExitDirective, IntersectionFutureStartExitDirective, IntersectionFutureStartOnceExitDirective -} from './future/public-api'; +} from '../directives/future/public-api'; import { IntersectionPastEndDirective, IntersectionPastEndOnceDirective, @@ -18,7 +18,7 @@ import { IntersectionPastEndOnceExitDirective, IntersectionPastStartExitDirective, IntersectionPastStartOnceExitDirective -} from './past/public-api'; +} from '../directives/past/public-api'; import { IntersectionPresentEndDirective, IntersectionPresentEndOnceDirective, @@ -28,7 +28,7 @@ import { IntersectionPresentEndOnceExitDirective, IntersectionPresentStartExitDirective, IntersectionPresentStartOnceExitDirective -} from './present/public-api'; +} from '../directives/present/public-api'; export const intersectionDirectives = [ // future diff --git a/projects/ngx-intersection/src/lib/modules/public-api.ts b/projects/ngx-intersection/src/lib/modules/public-api.ts new file mode 100644 index 0000000..09b71cc --- /dev/null +++ b/projects/ngx-intersection/src/lib/modules/public-api.ts @@ -0,0 +1,3 @@ +export * from './intersection-directives.module'; +export * from './intersection-directives-alias.module'; +export * from './angular-intersection.module'; diff --git a/projects/ngx-intersection/src/public-api.ts b/projects/ngx-intersection/src/public-api.ts index 042a2b8..9fb6562 100644 --- a/projects/ngx-intersection/src/public-api.ts +++ b/projects/ngx-intersection/src/public-api.ts @@ -1,11 +1,7 @@ // // MODULES // ============================================================================= -export * from './lib/angular-intersection.module'; -// -// LEGACY DIRECTIVES -// ============================================================================= -export * from './lib/legacy-directives/public-api'; +export * from './lib/modules/public-api'; // // SERVICES // ============================================================================= diff --git a/src/app/components/app.component.styl b/src/app/components/app.component.styl index 08a5213..f20e8d6 100644 --- a/src/app/components/app.component.styl +++ b/src/app/components/app.component.styl @@ -13,6 +13,8 @@ $menu--height = ($space--default * 4) z-index: 10 &.open + mix-blend-mode: normal + svg path fill: $color--primary