-
Notifications
You must be signed in to change notification settings - Fork 217
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
Showing
5 changed files
with
38 additions
and
126 deletions.
There are no files selected for viewing
17 changes: 1 addition & 16 deletions
17
examples-standalone/coffee-warehouse/src/app/app.component.html
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,16 +1 @@ | ||
<app-header-component (toggle)="toggleDrawer(drawer)" [selectedPage]="selected"></app-header-component> | ||
<kendo-drawer-container> | ||
<kendo-drawer | ||
#drawer | ||
[items]="items" | ||
[mode]="mode" | ||
[mini]="mini" | ||
[expanded]="true" | ||
[animation]="false" | ||
(select)="onSelect($event)" | ||
> | ||
</kendo-drawer> | ||
<kendo-drawer-content> | ||
<router-outlet></router-outlet> | ||
</kendo-drawer-content> | ||
</kendo-drawer-container> | ||
<app-header-component [selectedPage]="selected"></app-header-component> |
102 changes: 3 additions & 99 deletions
102
examples-standalone/coffee-warehouse/src/app/app.component.ts
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,113 +1,17 @@ | ||
import { Component, OnDestroy, OnInit } from "@angular/core"; | ||
import { NavigationStart, Router, RouterEvent } from "@angular/router"; | ||
import { Component } from "@angular/core"; | ||
import { MessageService } from "@progress/kendo-angular-l10n"; | ||
import { | ||
DrawerComponent, | ||
DrawerMode, | ||
DrawerSelectEvent, | ||
} from "@progress/kendo-angular-layout"; | ||
import { CustomMessagesService } from "./services/custom-messages.service"; | ||
import { gridIcon, chartLineMarkersIcon, calendarIcon, userIcon, infoCircleIcon } from "@progress/kendo-svg-icons"; | ||
|
||
@Component({ | ||
selector: "app-root", | ||
templateUrl: "./app.component.html", | ||
}) | ||
export class AppComponent implements OnInit, OnDestroy { | ||
export class AppComponent { | ||
public selected = "Team"; | ||
public items: Array<any> = []; | ||
public customMsgService: CustomMessagesService; | ||
public mode: DrawerMode = "push"; | ||
public mini = true; | ||
|
||
constructor(private router: Router, public msgService: MessageService) { | ||
constructor(public msgService: MessageService) { | ||
this.customMsgService = this.msgService as CustomMessagesService; | ||
} | ||
|
||
ngOnInit() { | ||
// Update Drawer selected state when change router path | ||
this.router.events.subscribe((route: any) => { | ||
if (route instanceof NavigationStart) { | ||
this.items = this.drawerItems().map((item) => { | ||
if (item.path && item.path === route.url) { | ||
item.selected = true; | ||
return item; | ||
} else { | ||
item.selected = false; | ||
return item; | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
this.setDrawerConfig(); | ||
|
||
this.customMsgService.localeChange.subscribe(() => { | ||
this.items = this.drawerItems(); | ||
}); | ||
|
||
window.addEventListener("resize", () => { | ||
this.setDrawerConfig(); | ||
}); | ||
} | ||
|
||
ngOnDestroy() { | ||
window.removeEventListener("resize", () => {}); | ||
} | ||
|
||
public setDrawerConfig() { | ||
const pageWidth = window.innerWidth; | ||
if (pageWidth <= 840) { | ||
this.mode = "overlay"; | ||
this.mini = false; | ||
} else { | ||
this.mode = "push"; | ||
this.mini = true; | ||
} | ||
} | ||
|
||
public drawerItems() { | ||
return [ | ||
{ | ||
text: this.customMsgService.translate("team"), | ||
svgIcon: gridIcon, | ||
path: "/", | ||
selected: true, | ||
}, | ||
{ | ||
text: this.customMsgService.translate("dashboard"), | ||
svgIcon: chartLineMarkersIcon, | ||
path: "/dashboard", | ||
selected: false, | ||
}, | ||
{ | ||
text: this.customMsgService.translate("planning"), | ||
svgIcon: calendarIcon, | ||
path: "/planning", | ||
selected: false, | ||
}, | ||
{ | ||
text: this.customMsgService.translate("profile"), | ||
svgIcon: userIcon, | ||
path: "/profile", | ||
selected: false, | ||
}, | ||
{ separator: true }, | ||
{ | ||
text: this.customMsgService.translate("info"), | ||
svgIcon: infoCircleIcon, | ||
path: "/info", | ||
selected: false, | ||
}, | ||
]; | ||
} | ||
|
||
public toggleDrawer(drawer: DrawerComponent): void { | ||
drawer.toggle(); | ||
} | ||
|
||
public onSelect(ev: DrawerSelectEvent): void { | ||
this.router.navigate([ev.item.path]); | ||
this.selected = ev.item.text; | ||
} | ||
} |
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