From 7d981250ecd979cb33397195f471f60608afe9ac Mon Sep 17 00:00:00 2001 From: Mathew Guest Date: Sun, 4 Aug 2024 05:18:16 -0600 Subject: [PATCH] build: working complete nav with routes, unstyled --- src/app/app.module.ts | 9 +++- .../dropdown-nav-button.component.css | 0 .../dropdown-nav-button.component.html | 14 +++++ .../dropdown-nav-button.component.ts | 26 ++++++++++ .../main-navigation.component.html | 51 +++++++++---------- 5 files changed, 73 insertions(+), 27 deletions(-) create mode 100644 src/app/dropdown-nav-button/dropdown-nav-button.component.css create mode 100644 src/app/dropdown-nav-button/dropdown-nav-button.component.html create mode 100644 src/app/dropdown-nav-button/dropdown-nav-button.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index ea601b6..e9bf266 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -11,6 +11,7 @@ import { HomeComponent } from './home-component/home.component'; import { RouterModule } from '@angular/router'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { MainNavigationComponent } from './main-navigation/main-navigation.component'; +import { DropdownNavButtonComponent } from './dropdown-nav-button/dropdown-nav-button.component'; @NgModule({ imports: [ @@ -22,7 +23,13 @@ import { MainNavigationComponent } from './main-navigation/main-navigation.compo TranslocoRootModule, RouterModule.forRoot([{ path: '', component: ScoutingCryptoComponent }]), ], - declarations: [ScoutingCryptoComponent, HomeComponent, AppComponent, MainNavigationComponent], + declarations: [ + ScoutingCryptoComponent, + HomeComponent, + AppComponent, + MainNavigationComponent, + DropdownNavButtonComponent, + ], providers: [], bootstrap: [AppComponent], }) diff --git a/src/app/dropdown-nav-button/dropdown-nav-button.component.css b/src/app/dropdown-nav-button/dropdown-nav-button.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/dropdown-nav-button/dropdown-nav-button.component.html b/src/app/dropdown-nav-button/dropdown-nav-button.component.html new file mode 100644 index 0000000..6a8d65e --- /dev/null +++ b/src/app/dropdown-nav-button/dropdown-nav-button.component.html @@ -0,0 +1,14 @@ +
+ +
+ + {{ item.label }} + +
+
diff --git a/src/app/dropdown-nav-button/dropdown-nav-button.component.ts b/src/app/dropdown-nav-button/dropdown-nav-button.component.ts new file mode 100644 index 0000000..e0abf60 --- /dev/null +++ b/src/app/dropdown-nav-button/dropdown-nav-button.component.ts @@ -0,0 +1,26 @@ +import { Component, ViewChild, Input } from '@angular/core'; +import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap'; + +@Component({ + selector: 'app-dropdown-nav-button', + templateUrl: './dropdown-nav-button.component.html', + styleUrl: './dropdown-nav-button.component.css', +}) +export class DropdownNavButtonComponent { + @ViewChild('myDrop', { static: false }) myDrop: NgbDropdown; + @Input() buttonLabel: string = 'Dropdown'; // Customizable button label + @Input() items: { label: string; route: string }[] = []; + + private timeout: number; + + onMouseEnter() { + clearTimeout(this.timeout); + this.myDrop.open(); + } + + onMouseLeave() { + this.timeout = setTimeout(() => { + this.myDrop.close(); + }, 140); + } +} diff --git a/src/app/main-navigation/main-navigation.component.html b/src/app/main-navigation/main-navigation.component.html index 1e6ddf3..861aa45 100644 --- a/src/app/main-navigation/main-navigation.component.html +++ b/src/app/main-navigation/main-navigation.component.html @@ -1,30 +1,29 @@