-
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.
feat(navigation-class-handler): styleguide page
- Loading branch information
1 parent
6dd1466
commit d531901
Showing
12 changed files
with
110 additions
and
6 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
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
8 changes: 8 additions & 0 deletions
8
apps/styleguide/src/routes/sg-test-page/sg-test-page-create-query-params.function.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { SgTestRouteQueryParams } from './sg-test-route-query-params.enum' | ||
|
||
export function sgTestPageCreateQueryParams(delay: number, disallow: boolean = false) { | ||
return { | ||
[SgTestRouteQueryParams.DELAY]: delay, | ||
[SgTestRouteQueryParams.DISALLOW]: disallow, | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
apps/styleguide/src/routes/sg-test-page/sg-test-page-sub-1/sg-test-page-sub-1.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<h1>Test Route (Sub 1)</h1> | ||
<p>set query params to change the behavior of the can activate guard:</p> | ||
<ul> | ||
<li> | ||
<a [routerLink]="['../2']" [queryParams]="qp(5000)">delay by 5s, then allow</a> | ||
</li> | ||
<li> | ||
<a [routerLink]="['../2']" [queryParams]="qp(2000,true)">delay by 2s, then disallow</a> | ||
</li> | ||
</ul> | ||
|
4 changes: 4 additions & 0 deletions
4
apps/styleguide/src/routes/sg-test-page/sg-test-page-sub-1/sg-test-page-sub-1.component.scss
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
:host { | ||
display: block; | ||
h1 { font-size: 20px; line-height: 32px;} | ||
} |
16 changes: 16 additions & 0 deletions
16
apps/styleguide/src/routes/sg-test-page/sg-test-page-sub-1/sg-test-page-sub-1.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core' | ||
import { RouterLink } from '@angular/router' | ||
import { sgTestPageCreateQueryParams } from '../sg-test-page-create-query-params.function' | ||
import { SgTestRouteQueryParams } from '../sg-test-route-query-params.enum' | ||
|
||
@Component({ | ||
selector: 'sg-test-page-sub-2', | ||
standalone: true, | ||
imports: [RouterLink], | ||
templateUrl: './sg-test-page-sub-1.component.html', | ||
styleUrls: ['./sg-test-page-sub-1.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class SgTestPageSub1Component { | ||
protected readonly qp = sgTestPageCreateQueryParams | ||
} |
8 changes: 8 additions & 0 deletions
8
apps/styleguide/src/routes/sg-test-page/sg-test-page-sub-2/sg-test-page-sub-2.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<h1>Test Route Sub 2</h1> | ||
<p>set query params to change the behavior of the can activate guard:</p> | ||
<hr> | ||
<a [routerLink]="['../1']" [queryParams]="qp(5000)">delay by 5s, then allow</a> | ||
<hr> | ||
<a [routerLink]="['../1']" [queryParams]="qp(2000, true)">delay by 2s, then disallow</a> | ||
<hr> | ||
|
4 changes: 4 additions & 0 deletions
4
apps/styleguide/src/routes/sg-test-page/sg-test-page-sub-2/sg-test-page-sub-2.component.scss
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
:host { | ||
display: block; | ||
h1 { font-size: 20px; line-height: 32px;} | ||
} |
15 changes: 15 additions & 0 deletions
15
apps/styleguide/src/routes/sg-test-page/sg-test-page-sub-2/sg-test-page-sub-2.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core' | ||
import { RouterLink } from '@angular/router' | ||
import { sgTestPageCreateQueryParams } from '../sg-test-page-create-query-params.function' | ||
|
||
@Component({ | ||
selector: 'sg-test-page-sub-2', | ||
standalone: true, | ||
imports: [RouterLink], | ||
templateUrl: './sg-test-page-sub-2.component.html', | ||
styleUrls: ['./sg-test-page-sub-2.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class SgTestPageSub2Component { | ||
protected readonly qp = sgTestPageCreateQueryParams | ||
} |
27 changes: 27 additions & 0 deletions
27
apps/styleguide/src/routes/sg-test-page/sg-test-page.routes.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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { CanActivateFn, Routes } from '@angular/router' | ||
import { SgTestPageSub1Component } from './sg-test-page-sub-1/sg-test-page-sub-1.component' | ||
import { SgTestPageSub2Component } from './sg-test-page-sub-2/sg-test-page-sub-2.component' | ||
import { SgTestRouteQueryParams } from './sg-test-route-query-params.enum' | ||
|
||
const canActivateByQueryParam: CanActivateFn = async (ars) => { | ||
const delay = Number(ars.queryParams[SgTestRouteQueryParams.DELAY] ?? 0) | ||
const disallow = ars.queryParams[SgTestRouteQueryParams.DISALLOW] === 'true' | ||
await new Promise((resolve) => setTimeout(resolve, delay)) | ||
return !disallow | ||
} | ||
|
||
|
||
const ROUTES: Routes = [ | ||
{ | ||
path: '', | ||
runGuardsAndResolvers: 'always', | ||
canActivateChild: [canActivateByQueryParam], | ||
children: [ | ||
{ path: '', pathMatch: 'full', redirectTo: '1' }, | ||
{ path: '1', component: SgTestPageSub1Component }, | ||
{ path: '2', component: SgTestPageSub2Component }, | ||
], | ||
}, | ||
] | ||
|
||
export default ROUTES |
4 changes: 4 additions & 0 deletions
4
apps/styleguide/src/routes/sg-test-page/sg-test-route-query-params.enum.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum SgTestRouteQueryParams { | ||
DELAY = 'delay', | ||
DISALLOW = 'DISALLOW', | ||
} |
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