Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit c479f18

Browse files
authored
Merge pull request #3 from maxceem/feature/toggle-sidebar
Toggle Sidebar
2 parents 624b699 + 1c95021 commit c479f18

File tree

7 files changed

+50
-5
lines changed

7 files changed

+50
-5
lines changed

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10.22.1

src/app/app-routing.module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { NgModule } from '@angular/core';
22
import { Routes, RouterModule } from '@angular/router';
33
import { EmptyRouteComponent } from './empty-route/empty-route.component';
4+
import { AuthDemoComponent } from './auth-demo/auth-demo.component';
5+
import { NoSidebarDemoComponent } from './no-sidebar-demo/no-sidebar-demo.component';
46
import { APP_BASE_HREF } from '@angular/common';
57

68
const routes: Routes = [
7-
{ path: '**', component: EmptyRouteComponent }
9+
{ path: 'micro-frontends-angular-route/auth', component: AuthDemoComponent },
10+
{ path: 'micro-frontends-angular-route/no-sidebar', component: NoSidebarDemoComponent },
11+
{ path: '**', component: EmptyRouteComponent },
812
];
913

1014
@NgModule({

src/app/app.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ <h1>Angular child app example</h1>
99

1010
<div><a routerLink="/micro-frontends-react-route">Link to React child app</a></div>
1111

12-
<tc-ex-auth-demo></tc-ex-auth-demo>
12+
<router-outlet></router-outlet>
1313
</div>
1414

15-
<router-outlet></router-outlet>

src/app/constants/appMenu.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@ const appMenu = [
1414
activeIcon: angularActiveIcon,
1515
},
1616
{
17-
title: 'Home',
18-
path: '/micro-frontends-angular-route/home',
17+
title: 'Auth Demo',
18+
path: '/micro-frontends-angular-route/auth',
19+
icon: homeIcon,
20+
activeIcon: homeActiveIcon,
21+
},
22+
{
23+
title: 'No Sidebar Demo',
24+
path: '/micro-frontends-angular-route/no-sidebar',
1925
icon: homeIcon,
2026
activeIcon: homeActiveIcon,
2127
},
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<h2>No Sidebar</h2>
2+
<div>Enable/disable sidebar for routes that match:</div>
3+
<pre>{{route}}</pre>
4+
<div>
5+
<button (click)="enable()">Enable</button>
6+
<button (click)="disable()">Disable</button>
7+
</div>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* This component demonstrates how we can disable sidebar for some subroutes.
3+
*
4+
* For example this component disables sidebar for routes "/micro-frontends-angular-route/no-sidebar/*".
5+
*/
6+
import { Component, OnInit } from '@angular/core';
7+
import {
8+
disableSidebarForRoute,
9+
enableSidebarForRoute,
10+
} from '@topcoder/micro-frontends-navbar-app';
11+
12+
const COMPONENT_ROUTE = "/micro-frontends-angular-route/no-sidebar/*";
13+
14+
@Component({
15+
selector: 'tc-ex-no-sidebar-demo',
16+
templateUrl: './no-sidebar-demo.component.html',
17+
})
18+
export class NoSidebarDemoComponent implements OnInit {
19+
route = COMPONENT_ROUTE
20+
enable = () => enableSidebarForRoute(COMPONENT_ROUTE)
21+
disable = () => disableSidebarForRoute(COMPONENT_ROUTE)
22+
23+
ngOnInit(): void {
24+
disableSidebarForRoute(COMPONENT_ROUTE)
25+
}
26+
}

src/typings.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ declare module '@topcoder/micro-frontends-navbar-app' {
44
export const setAppMenu: any;
55
export const getAuthUserTokens: any;
66
export const getAuthUserProfile: any;
7+
export const disableSidebarForRoute: any;
8+
export const enableSidebarForRoute: any;
79
}
810

911
declare module "*.svg" {

0 commit comments

Comments
 (0)