Refactor layout and add header, navbar, schedule components

Introduced MainLayoutComponent with header and navbar for consistent app layout. Added HeaderComponent, NavbarComponent, ScheduleComponent, and MainComponent. Updated routing to use MainLayout for main and schedule pages. Renamed home-component to home and main-page to main, removing obsolete main-page files.
This commit is contained in:
2025-10-26 02:16:08 +02:00
parent ad23d48ff1
commit 939ef4190e
22 changed files with 150 additions and 22 deletions

View File

@@ -4,19 +4,26 @@ import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing-module';
import { App } from './app';
import { PocModelComponent } from './poc-model-component/poc-model-component';
import { HomeComponent } from './home-component/home-component';
import { HomeComponent } from './home/home.component';
import { provideHttpClient, withFetch } from '@angular/common/http';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { MainPage } from './main-page/main-page';
import { MainLayoutComponent } from './layouts/main-layout/main-layout.component';
import { HeaderComponent } from './header/header.component';
import { NavbarComponent } from './navbar/navbar.component';
import { ScheduleComponent } from './schedule/schedule.component';
import { MainComponent } from './main/main.component';
@NgModule({
declarations: [
App,
PocModelComponent,
HomeComponent,
MainPage
MainLayoutComponent,
HeaderComponent,
NavbarComponent,
ScheduleComponent,
MainComponent
],
imports: [
AppRoutingModule,

View File

@@ -1,13 +1,27 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { PocModelComponent } from './poc-model-component/poc-model-component';
import { HomeComponent } from './home-component/home-component';
import { MainPage } from './main-page/main-page';
import { HomeComponent } from './home/home.component';
import { MainLayoutComponent } from './layouts/main-layout/main-layout.component';
import { MainComponent } from './main/main.component';
import { ScheduleComponent } from './schedule/schedule.component';
const routes: Routes = [
{ path: '', component: MainPage, pathMatch: 'full' },
// Seiten ohne Layout
{ path: 'info', component: HomeComponent },
{ path: 'poc-model', component: PocModelComponent },
// Seiten mit MainLayout
{
path: '',
component: MainLayoutComponent,
children: [
{ path: '', component: MainComponent },
{ path: 'schedule', component: ScheduleComponent },
],
},
// Fallback-Route
{ path: '**', component: HomeComponent },
];

View File

@@ -0,0 +1,9 @@
header {
display: flex;
width: 100%;
}
.header {
height: 60px;
background-color: greenyellow;
}

View File

@@ -0,0 +1,2 @@
<header class="header">
</header>

View File

@@ -0,0 +1,11 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-header',
standalone: false,
templateUrl: './header.component.html',
styleUrl: './header.component.css'
})
export class HeaderComponent {
}

View File

@@ -1,10 +1,10 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-home-component',
selector: 'app-home',
standalone: false,
templateUrl: './home-component.html',
styleUrl: './home-component.css'
templateUrl: './home.component.html',
styleUrl: './home.component.css'
})
export class HomeComponent {

View File

@@ -0,0 +1,22 @@
:host {
display: flex;
flex-direction: column;
height: 100vh;
margin: 0;
}
/* Body: Sidebar + Content */
.body {
display: flex;
flex: 1;
min-height: 0;
}
/* Content rechts */
.content {
flex: 1;
background-color: #004cff;
overflow-y: auto;
box-sizing: border-box;
height: 100%;
}

View File

@@ -0,0 +1,9 @@
<app-header></app-header>
<div class="body">
<app-navbar></app-navbar>
<main class="content">
<router-outlet></router-outlet> <!-- Hier werden die Kinder-Routen geladen -->
</main>
</div>

View File

@@ -0,0 +1,11 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-main-layout',
standalone: false,
templateUrl: './main-layout.component.html',
styleUrl: './main-layout.component.css'
})
export class MainLayoutComponent {
}

View File

@@ -1 +0,0 @@
<p>main-page works!</p>

View File

@@ -1,11 +0,0 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-main-page',
standalone: false,
templateUrl: './main-page.html',
styleUrl: './main-page.css'
})
export class MainPage {
}

View File

@@ -0,0 +1 @@
<p>main works!</p>

View File

@@ -0,0 +1,11 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-main',
standalone: false,
templateUrl: './main.component.html',
styleUrl: './main.component.css'
})
export class MainComponent {
}

View File

@@ -0,0 +1,11 @@
nav {
display: flex;
flex-direction: column;
flex-shrink: 0;
height: 100%;
}
.navbar {
width: 200px;
background-color: #ff0080;
}

View File

@@ -0,0 +1,2 @@
<nav class="navbar">
</nav>

View File

@@ -0,0 +1,11 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-navbar',
standalone: false,
templateUrl: './navbar.component.html',
styleUrl: './navbar.component.css'
})
export class NavbarComponent {
}

View File

@@ -0,0 +1,7 @@
:host {
display: block;
background-color: #fff;
border: 1px solid #ddd;
padding: 1rem;
border-radius: 8px;
}

View File

@@ -0,0 +1 @@
<p>schedule works!</p>

View File

@@ -0,0 +1,11 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-schedule',
standalone: false,
templateUrl: './schedule.component.html',
styleUrl: './schedule.component.css'
})
export class ScheduleComponent {
}