-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
964434c
commit aa6a663
Showing
8 changed files
with
180 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
<common-ui-header></common-ui-header> | ||
<common-ui-header | ||
title="Lucas Marcolongo" | ||
[navLinks]="navLinks" | ||
></common-ui-header> | ||
<div class="container mx-auto"> | ||
<router-outlet></router-outlet> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,40 @@ | ||
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], | ||
selector: 'app-root', | ||
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', | ||
}, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { HeaderComponent } from './lib/header/header.component'; | ||
export { HeaderComponent, NavLink } from './lib/header/header.component'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<HeaderComponent> = { | ||
component: HeaderComponent, | ||
title: 'HeaderComponent', | ||
decorators: [ | ||
moduleMetadata({ | ||
providers: [ | ||
{ | ||
provide: ActivatedRoute, | ||
useValue: { | ||
snapshot: { | ||
url: [{ path: '/contact' }], | ||
data: {}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}), | ||
], | ||
}; | ||
export default meta; | ||
type Story = StoryObj<HeaderComponent>; | ||
|
||
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' }, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Omit<NavLink, 'items'> & { 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<string>(); | ||
public navLinks = input.required<NavLink[]>(); | ||
} |