Skip to content

Commit

Permalink
feat: created structure of components and routes with lazy loading
Browse files Browse the repository at this point in the history
  • Loading branch information
GiselleBarbosa committed Jul 23, 2023
1 parent b5ca748 commit ef74890
Show file tree
Hide file tree
Showing 34 changed files with 314 additions and 66 deletions.
19 changes: 4 additions & 15 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,10 @@
"outputPath": "dist/finances_v2.0",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": [
"zone.js"
],
"polyfills": ["zone.js"],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
"@angular/material/prebuilt-themes/pink-bluegrey.css",
"src/styles.scss"
Expand Down Expand Up @@ -83,16 +78,10 @@
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"polyfills": ["zone.js", "zone.js/testing"],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
"@angular/material/prebuilt-themes/pink-bluegrey.css",
"src/styles.scss"
Expand Down
38 changes: 35 additions & 3 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './features/home/home.component';

const routes: Routes = [];
const routes: Routes = [
{
path: '',
pathMatch: 'full',
component: HomeComponent,
},

{
path: '',
loadChildren: () => import('./routes').then((mod) => mod.home),
},

{
path: 'admin',
loadChildren: () => import('./routes').then((mod) => mod.admin),
},

{
path: '',
loadChildren: () => import('./routes').then((mod) => mod.auth),
},

{
path: 'user',
loadChildren: () => import('./routes').then((mod) => mod.user),
},

{
path: '**',
loadChildren: () => import('./routes').then((mod) => mod.notFoundPage),
},
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
exports: [RouterModule],
})
export class AppRoutingModule { }
export class AppRoutingModule {}
14 changes: 6 additions & 8 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
standalone: true,
imports: [RouterOutlet]
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
standalone: true,
imports: [RouterOutlet],
})
export class AppComponent {

}
export class AppComponent {}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>admin-panel works!</p>
Empty file.
21 changes: 21 additions & 0 deletions src/app/features/admin/admin-panel/admin-panel.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { AdminPanelComponent } from './admin-panel.component';

describe('AdminPanelComponent', () => {
let component: AdminPanelComponent;
let fixture: ComponentFixture<AdminPanelComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [AdminPanelComponent],
});
fixture = TestBed.createComponent(AdminPanelComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
11 changes: 11 additions & 0 deletions src/app/features/admin/admin-panel/admin-panel.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';

@Component({
selector: 'app-admin-panel',
standalone: true,
imports: [CommonModule],
templateUrl: './admin-panel.component.html',
styleUrls: ['./admin-panel.component.scss'],
})
export class AdminPanelComponent {}
1 change: 1 addition & 0 deletions src/app/features/auth/login/login.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>login works!</p>
Empty file.
21 changes: 21 additions & 0 deletions src/app/features/auth/login/login.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { LoginComponent } from './login.component';

describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [LoginComponent],
});
fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
11 changes: 11 additions & 0 deletions src/app/features/auth/login/login.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';

@Component({
selector: 'app-login',
standalone: true,
imports: [CommonModule],
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss'],
})
export class LoginComponent {}
1 change: 1 addition & 0 deletions src/app/features/auth/register/register.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>register works!</p>
Empty file.
21 changes: 21 additions & 0 deletions src/app/features/auth/register/register.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { RegisterComponent } from './register.component';

describe('RegisterComponent', () => {
let component: RegisterComponent;
let fixture: ComponentFixture<RegisterComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [RegisterComponent],
});
fixture = TestBed.createComponent(RegisterComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
11 changes: 11 additions & 0 deletions src/app/features/auth/register/register.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';

@Component({
selector: 'app-register',
standalone: true,
imports: [CommonModule],
templateUrl: './register.component.html',
styleUrls: ['./register.component.scss'],
})
export class RegisterComponent {}
1 change: 1 addition & 0 deletions src/app/features/home/home.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>home works!</p>
Empty file.
27 changes: 27 additions & 0 deletions src/app/features/home/home.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* tslint:disable:no-unused-variable */
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';

import { HomeComponent } from './home.component';

describe('HomeComponent', () => {
let component: HomeComponent;
let fixture: ComponentFixture<HomeComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [HomeComponent],
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(HomeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions src/app/features/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { CommonModule } from '@angular/common';
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-home',
standalone: true,
imports: [CommonModule],
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss'],
})
export class HomeComponent implements OnInit {
constructor() {}

ngOnInit() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>not-found-page works!</p>
Empty file.
21 changes: 21 additions & 0 deletions src/app/features/not-found-page/not-found-page.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { NotFoundPageComponent } from './not-found-page.component';

describe('NotFoundPageComponent', () => {
let component: NotFoundPageComponent;
let fixture: ComponentFixture<NotFoundPageComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [NotFoundPageComponent],
});
fixture = TestBed.createComponent(NotFoundPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
11 changes: 11 additions & 0 deletions src/app/features/not-found-page/not-found-page.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';

@Component({
selector: 'app-not-found-page',
standalone: true,
imports: [CommonModule],
templateUrl: './not-found-page.component.html',
styleUrls: ['./not-found-page.component.scss'],
})
export class NotFoundPageComponent {}
1 change: 1 addition & 0 deletions src/app/features/user-panel/user-panel.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>user-panel works!</p>
Empty file.
21 changes: 21 additions & 0 deletions src/app/features/user-panel/user-panel.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { UserPanelComponent } from './user-panel.component';

describe('UserPanelComponent', () => {
let component: UserPanelComponent;
let fixture: ComponentFixture<UserPanelComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [UserPanelComponent],
});
fixture = TestBed.createComponent(UserPanelComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
11 changes: 11 additions & 0 deletions src/app/features/user-panel/user-panel.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';

@Component({
selector: 'app-user-panel',
standalone: true,
imports: [CommonModule],
templateUrl: './user-panel.component.html',
styleUrls: ['./user-panel.component.scss'],
})
export class UserPanelComponent {}
24 changes: 24 additions & 0 deletions src/app/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Routes } from '@angular/router';
import { AdminPanelComponent } from './features/admin/admin-panel/admin-panel.component';
import { LoginComponent } from './features/auth/login/login.component';
import { RegisterComponent } from './features/auth/register/register.component';
import { HomeComponent } from './features/home/home.component';
import { NotFoundPageComponent } from './features/not-found-page/not-found-page.component';
import { UserPanelComponent } from './features/user-panel/user-panel.component';

export const home: Routes = [{ path: '', component: HomeComponent }];

export const admin: Routes = [
{ path: 'admin', component: AdminPanelComponent },
];

export const auth: Routes = [
{ path: 'auth/login', component: LoginComponent },
{ path: 'auth/register', component: RegisterComponent },
];

export const user: Routes = [{ path: 'user', component: UserPanelComponent }];

export const notFoundPage: Routes = [
{ path: '**', component: NotFoundPageComponent },
];
32 changes: 19 additions & 13 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>FinancesV20</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body class="mat-typography">
<app-root></app-root>
</body>
<head>
<meta charset="utf-8" />
<title>FinancesV20</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet"
/>
</head>
<body class="mat-typography">
<app-root></app-root>
</body>
</html>
Loading

0 comments on commit ef74890

Please sign in to comment.