diff --git a/apps/frontend/src/app/app.component.html b/apps/frontend/src/app/app.component.html
index 858c21c..9c22574 100644
--- a/apps/frontend/src/app/app.component.html
+++ b/apps/frontend/src/app/app.component.html
@@ -1,4 +1,7 @@
-
+
diff --git a/apps/frontend/src/app/app.component.ts b/apps/frontend/src/app/app.component.ts
index 54876e8..178a66b 100644
--- a/apps/frontend/src/app/app.component.ts
+++ b/apps/frontend/src/app/app.component.ts
@@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import { RouterModule } from '@angular/router';
-import { HeaderComponent } from '@marcolongo.cloud/common-ui';
+import { HeaderComponent, NavLink } from '@marcolongo.cloud/common-ui';
@Component({
imports: [RouterModule, HeaderComponent],
@@ -8,4 +8,33 @@ import { HeaderComponent } from '@marcolongo.cloud/common-ui';
templateUrl: './app.component.html',
styleUrl: './app.component.scss',
})
-export class AppComponent {}
+export class AppComponent {
+ public navLinks: NavLink[] = [
+ {
+ label: 'Home',
+ url: '/home',
+ icon: 'home',
+ },
+ {
+ label: 'About',
+ icon: 'article',
+ items: [
+ {
+ label: 'Me',
+ url: '/about/me',
+ icon: 'person',
+ },
+ {
+ label: 'Company',
+ url: '/about/company',
+ icon: 'business',
+ },
+ ],
+ },
+ {
+ label: 'Contact',
+ icon: 'email',
+ url: '/contact',
+ },
+ ];
+}
diff --git a/apps/frontend/src/app/app.routes.ts b/apps/frontend/src/app/app.routes.ts
index b4bf6cb..b04943d 100644
--- a/apps/frontend/src/app/app.routes.ts
+++ b/apps/frontend/src/app/app.routes.ts
@@ -3,6 +3,28 @@ import { Route } from '@angular/router';
export const appRoutes: Route[] = [
{
path: '',
+ redirectTo: 'home',
+ pathMatch: 'full',
+ },
+ {
+ path: 'home',
+ loadComponent: () =>
+ import('./home/home.component').then((m) => m.HomeComponent),
+ },
+ {
+ path: 'about',
+ loadComponent: () =>
+ import('./home/home.component').then((m) => m.HomeComponent),
+ children: [
+ {
+ path: 'company',
+ loadComponent: () =>
+ import('./home/home.component').then((m) => m.HomeComponent),
+ },
+ ],
+ },
+ {
+ path: 'contact',
loadComponent: () =>
import('./home/home.component').then((m) => m.HomeComponent),
},
diff --git a/libs/common-ui/src/index.ts b/libs/common-ui/src/index.ts
index 7bbade1..a730e60 100644
--- a/libs/common-ui/src/index.ts
+++ b/libs/common-ui/src/index.ts
@@ -1 +1 @@
-export { HeaderComponent } from './lib/header/header.component';
+export { HeaderComponent, NavLink } from './lib/header/header.component';
diff --git a/libs/common-ui/src/lib/header/header.component.html b/libs/common-ui/src/lib/header/header.component.html
index e46ecfb..4180fed 100644
--- a/libs/common-ui/src/lib/header/header.component.html
+++ b/libs/common-ui/src/lib/header/header.component.html
@@ -21,34 +21,56 @@
tabindex="0"
class="menu menu-sm dropdown-content bg-base-100 rounded-box z-[1] mt-3 w-52 p-2 shadow"
>
- Item 1
+ @for (navLink of navLinks(); track navLink.label){
- Parent
+
+ {{ navLink.label }}
+
+ @if(navLink.items){
+ }
- Item 3
+ }
- Lucas Marcolongo
+ {{
+ title()
+ }}
diff --git a/libs/common-ui/src/lib/header/header.component.spec.ts b/libs/common-ui/src/lib/header/header.component.spec.ts
index 3096a74..ac1cd3e 100644
--- a/libs/common-ui/src/lib/header/header.component.spec.ts
+++ b/libs/common-ui/src/lib/header/header.component.spec.ts
@@ -1,5 +1,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { HeaderComponent } from './header.component';
+import { ActivatedRoute } from '@angular/router';
describe('HeaderComponent', () => {
let component: HeaderComponent;
@@ -8,10 +9,43 @@ describe('HeaderComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [HeaderComponent],
+ providers: [
+ {
+ provide: ActivatedRoute,
+ useValue: {
+ snapshot: {
+ url: [
+ {
+ path: 'contact',
+ },
+ ],
+ },
+ },
+ },
+ ],
}).compileComponents();
fixture = TestBed.createComponent(HeaderComponent);
component = fixture.componentInstance;
+ fixture.componentRef.setInput('title', 'My App');
+ fixture.componentRef.setInput('navLinks', [
+ { label: 'Home', path: '/' },
+ { label: 'About', path: '/about' },
+ {
+ label: 'Contact',
+ path: '/contact',
+ items: [
+ {
+ label: 'Contact Us',
+ path: '/contact',
+ },
+ {
+ label: 'Support',
+ path: '/support',
+ },
+ ],
+ },
+ ]);
fixture.detectChanges();
});
diff --git a/libs/common-ui/src/lib/header/header.component.stories.ts b/libs/common-ui/src/lib/header/header.component.stories.ts
index 59afb62..c0ef7e5 100644
--- a/libs/common-ui/src/lib/header/header.component.stories.ts
+++ b/libs/common-ui/src/lib/header/header.component.stories.ts
@@ -1,13 +1,43 @@
-import type { Meta, StoryObj } from '@storybook/angular';
+import { moduleMetadata, Meta, StoryObj } from '@storybook/angular';
import { HeaderComponent } from './header.component';
+import { ActivatedRoute } from '@angular/router';
const meta: Meta = {
component: HeaderComponent,
title: 'HeaderComponent',
+ decorators: [
+ moduleMetadata({
+ providers: [
+ {
+ provide: ActivatedRoute,
+ useValue: {
+ snapshot: {
+ url: [{ path: '/contact' }],
+ data: {},
+ },
+ },
+ },
+ ],
+ }),
+ ],
};
export default meta;
type Story = StoryObj;
export const Primary: Story = {
- args: {},
+ args: {
+ navLinks: [
+ { label: 'Home', url: '/', icon: 'home' },
+ { label: 'All Posts', url: '/posts', icon: 'article' },
+ {
+ label: 'About',
+ icon: 'info',
+ items: [
+ { label: 'Company', url: '/company', icon: 'business' },
+ { label: 'Team', url: '/team', icon: 'people' },
+ ],
+ },
+ { label: 'Contact', url: '/contact', icon: 'email' },
+ ],
+ },
};
diff --git a/libs/common-ui/src/lib/header/header.component.ts b/libs/common-ui/src/lib/header/header.component.ts
index ed82474..820343c 100644
--- a/libs/common-ui/src/lib/header/header.component.ts
+++ b/libs/common-ui/src/lib/header/header.component.ts
@@ -1,10 +1,28 @@
-import { Component } from '@angular/core';
+import { Component, input } from '@angular/core';
import { CommonModule } from '@angular/common';
+import { RouterLink, RouterLinkActive } from '@angular/router';
+
+export type NavLink = {
+ label: string;
+ icon?: string;
+} & (
+ | {
+ url: string;
+ items?: never;
+ }
+ | {
+ url?: never;
+ items: Array & { url: string }>;
+ }
+);
@Component({
selector: 'common-ui-header',
- imports: [CommonModule],
+ imports: [CommonModule, RouterLink, RouterLinkActive],
templateUrl: './header.component.html',
styleUrl: './header.component.scss',
})
-export class HeaderComponent {}
+export class HeaderComponent {
+ public title = input.required();
+ public navLinks = input.required();
+}