Skip to content

Commit

Permalink
Modularize the core module
Browse files Browse the repository at this point in the history
  • Loading branch information
belsman committed Jan 11, 2024
1 parent 870c2b9 commit 5ba0211
Show file tree
Hide file tree
Showing 37 changed files with 84 additions and 114 deletions.
2 changes: 1 addition & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AfterViewInit, Component, OnInit } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { LayerRef, LayerService } from '@vcl/ng-vcl';
import { CookiePreferenceComponent } from './components/cookie-preference/cookie-preference.component';
import { CookiePreferenceComponent } from './core/components/cookie-preference/cookie-preference.component';

@Component({
selector: 'app-root',
Expand Down
59 changes: 5 additions & 54 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,7 @@ import { ScrollingModule } from '@angular/cdk/scrolling';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { OverlayModule } from '@angular/cdk/overlay';
import {
VCLDrawerModule,
VCLFontAwesomeModule,
VCLInputModule,
VCLMaterialDesignModule,
VCLPasswordInputModule,
VCLSelectModule,
VCLSelectListModule,
VCLFormControlGroupModule,
VCLTabNavModule,
VCLRadioButtonModule,
VCLFlipSwitchModule,
IconResolverService,
} from '@vcl/ng-vcl';
import { VCLDrawerModule, IconResolverService } from '@vcl/ng-vcl';
import {
TranslateModule,
TranslateLoader,
Expand All @@ -29,69 +16,33 @@ import { MaterialDesignVCLIconAliasResolverService } from './shared/icon-resolve

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { ServiceTeaserComponent } from './components/service-teaser/service-teaser.component';
import { PromotionBarComponent } from './components/promotion-bar/promotion-bar.component';
import { NavigationComponent } from './components/navigation/navigation.component';
import { TopBarComponent } from './components/top-bar/top-bar.component';
import { TopPromotionComponent } from './components/top-promotion/top-promotion.component';
import { NewsletterBarComponent } from './components/newsletter-bar/newsletter-bar.component';
import { FooterTopComponent } from './components/footer-top/footer-top.component';
import { HeaderComponent } from './components/header/header.component';
import { CookiePreferenceComponent } from './components/cookie-preference/cookie-preference.component';

import {
LAZYLOAD_IMAGE_HOOKS,
LazyLoadImageModule,
ScrollHooks,
} from 'ng-lazyload-image';
import { ClickStopPropagation } from './shared/click-stop-propagation.directive';
import { MenuLayerContentComponent } from './components/top-bar/menu-layer-content/menu-layer-content.component';
import { MenuLayerTitleComponent } from './components/top-bar/menu-layer-title/menu-layer-title.component';
import { HoverColorPickerDirective } from './directives/hover-color-picker-directive.service';
import { GraphQLModule } from './graphql.module';
import { ProductsModule } from './features/products/products.module';
import { SharedModule } from './shared/shared.module';
import { CheckoutModule } from './features/checkout/checkout.module';
import { CartModule } from './features/cart/cart.module';
import { CoreModule } from './core/core.module';

export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

const vclModules = [
VCLDrawerModule,
VCLFontAwesomeModule,
VCLInputModule,
VCLMaterialDesignModule,
VCLPasswordInputModule,
VCLSelectModule,
VCLSelectListModule,
VCLTabNavModule,
VCLRadioButtonModule,
VCLFormControlGroupModule,
VCLFlipSwitchModule,
];
const vclModules = [];

@NgModule({
declarations: [
AppComponent,
ServiceTeaserComponent,
PromotionBarComponent,
NavigationComponent,
TopBarComponent,
TopPromotionComponent,
NewsletterBarComponent,
FooterTopComponent,
HeaderComponent,
ClickStopPropagation,
MenuLayerContentComponent,
MenuLayerTitleComponent,
CookiePreferenceComponent,
HoverColorPickerDirective,
],
declarations: [AppComponent, ClickStopPropagation, HoverColorPickerDirective],
imports: [
BrowserModule.withServerTransition({ appId: 'serverApp' }),
BrowserAnimationsModule,
CoreModule,
ProductsModule,
CheckoutModule,
CartModule,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, Optional } from '@angular/core';
import { Component, Optional } from '@angular/core';
import { Router } from '@angular/router';
import { ComponentLayerRef } from '@vcl/ng-vcl';

Expand All @@ -7,7 +7,7 @@ import { ComponentLayerRef } from '@vcl/ng-vcl';
templateUrl: './cookie-preference.component.html',
styleUrls: ['./cookie-preference.component.scss'],
})
export class CookiePreferenceComponent implements OnInit {
export class CookiePreferenceComponent {
constructor(
private router: Router,
@Optional() private layer?: ComponentLayerRef
Expand All @@ -24,8 +24,6 @@ export class CookiePreferenceComponent implements OnInit {
analytics: true,
};

ngOnInit(): void {}

close(newPrefernces: {} = {}) {
const references = { ...this.allPreferences, ...newPrefernces };
this.layer && this.layer.close(references);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-menu-layer-content',
templateUrl: './menu-layer-content.component.html',
styleUrls: ['./menu-layer-content.component.scss'],
})
export class MenuLayerContentComponent {
constructor() {}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { Component, OnInit } from '@angular/core';
import { Component } from '@angular/core';
import { Router } from '@angular/router';

@Component({
selector: 'app-navigation',
templateUrl: './navigation.component.html',
styleUrls: ['./navigation.component.scss']
styleUrls: ['./navigation.component.scss'],
})
export class NavigationComponent implements OnInit {

constructor(private router: Router) { }

ngOnInit(): void { }
export class NavigationComponent {
constructor(private router: Router) {}

public navigate(value: string): void {
this.router.navigateByUrl(value);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-newsletter-bar',
templateUrl: './newsletter-bar.component.html',
styleUrls: ['./newsletter-bar.component.scss']
styleUrls: ['./newsletter-bar.component.scss'],
})
export class NewsletterBarComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}

export class NewsletterBarComponent {
constructor() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-promotion-bar',
templateUrl: './promotion-bar.component.html',
styleUrls: ['./promotion-bar.component.scss']
styleUrls: ['./promotion-bar.component.scss'],
})
export class PromotionBarComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}

export class PromotionBarComponent {
constructor() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@ import { Router } from '@angular/router';
@Component({
selector: 'app-service-teaser',
templateUrl: './service-teaser.component.html',
styleUrls: ['./service-teaser.component.scss']
styleUrls: ['./service-teaser.component.scss'],
})
export class ServiceTeaserComponent implements OnInit {

constructor(private router: Router) { }

ngOnInit(): void {
}
export class ServiceTeaserComponent {
constructor(private router: Router) {}

public navigate(value: string): void {
this.router.navigateByUrl(value);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-top-promotion',
templateUrl: './top-promotion.component.html',
styleUrls: ['./top-promotion.component.scss']
styleUrls: ['./top-promotion.component.scss'],
})
export class TopPromotionComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}

export class TopPromotionComponent {
constructor() {}
}
50 changes: 50 additions & 0 deletions src/app/core/core.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ServiceTeaserComponent } from './components/service-teaser/service-teaser.component';
import { PromotionBarComponent } from './components/promotion-bar/promotion-bar.component';
import { NavigationComponent } from './components/navigation/navigation.component';
import { TopBarComponent } from './components/top-bar/top-bar.component';
import { TopPromotionComponent } from './components/top-promotion/top-promotion.component';
import { NewsletterBarComponent } from './components/newsletter-bar/newsletter-bar.component';
import { FooterTopComponent } from './components/footer-top/footer-top.component';
import { HeaderComponent } from './components/header/header.component';
import { MenuLayerContentComponent } from './components/menu-layer-content/menu-layer-content.component';
import { MenuLayerTitleComponent } from './components/menu-layer-title/menu-layer-title.component';
import {
VCLFlipSwitchModule,
VCLFormControlGroupModule,
VCLSelectListModule,
VCLSelectModule,
} from '@vcl/ng-vcl';
import { SharedModule } from '../shared/shared.module';
import { CartModule } from '../features/cart/cart.module';
import { CookiePreferenceComponent } from './components/cookie-preference/cookie-preference.component';

const vclModules = [
VCLSelectModule,
VCLSelectListModule,
// VCLTabNavModule,
VCLFormControlGroupModule,
VCLFlipSwitchModule,
];

const components = [
ServiceTeaserComponent,
PromotionBarComponent,
NavigationComponent,
TopBarComponent,
TopPromotionComponent,
NewsletterBarComponent,
FooterTopComponent,
HeaderComponent,
MenuLayerContentComponent,
MenuLayerTitleComponent,
CookiePreferenceComponent,
];

@NgModule({
declarations: [...components],
imports: [CommonModule, CartModule, SharedModule, ...vclModules],
exports: [...components],
})
export class CoreModule {}

0 comments on commit 5ba0211

Please sign in to comment.