-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(kit): add routable dialog for eager and lazy cases
- Loading branch information
Dima Puris
committed
Feb 17, 2023
1 parent
95d0573
commit 4a7239d
Showing
38 changed files
with
913 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
3 changes: 3 additions & 0 deletions
3
projects/demo-integrations/cypress/support/helpers/click-outside.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,3 @@ | ||
export function tuiClickOutside(): void { | ||
cy.get(`body`).click(0, 0); | ||
} |
30 changes: 30 additions & 0 deletions
30
projects/demo-integrations/cypress/tests/kit/routable/lazy-routable-dialog.cy.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,30 @@ | ||
describe(`LazyRoutableDialog`, () => { | ||
beforeEach(() => { | ||
cy.viewport(`macbook-13`); | ||
}); | ||
|
||
it(`should open lazy loaded dialog by click and then close by outside click`, () => { | ||
cy.tuiVisit(`/dialog/lazy-routable`); | ||
|
||
cy.get(`tui-page-1-example button`).click(); | ||
cy.tuiWaitKitDialog(); | ||
cy.url().should(`include`, `/dialog/lazy-routable/path/to/dialog`); | ||
|
||
cy.tuiClickOutside(); | ||
cy.url() | ||
.should(`include`, `/dialog/lazy-routable`) | ||
.should(`not.include`, `path/to/dialog`); | ||
}); | ||
|
||
it(`should open lazy loaded dialog by direct link and then close by outside click`, () => { | ||
cy.tuiVisit(`/dialog/lazy-routable/path/to/dialog`); | ||
|
||
cy.tuiWaitKitDialog(); | ||
cy.url().should(`include`, `/dialog/lazy-routable/path/to/dialog`); | ||
|
||
cy.tuiClickOutside(); | ||
cy.url() | ||
.should(`include`, `/dialog/lazy-routable`) | ||
.should(`not.include`, `path/to/dialog`); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
projects/demo-integrations/cypress/tests/kit/routable/routable-dialog.cy.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,30 @@ | ||
describe(`RoutableDialog`, () => { | ||
beforeEach(() => { | ||
cy.viewport(`macbook-13`); | ||
}); | ||
|
||
it(`should open dialog by click and then close by outside click`, () => { | ||
cy.tuiVisit(`/dialog/routable`); | ||
|
||
cy.get(`tui-page-1-example button`).click(); | ||
cy.tuiWaitKitDialog(); | ||
cy.url().should(`include`, `/dialog/routable/path/to/dialog`); | ||
|
||
cy.tuiClickOutside(); | ||
cy.url() | ||
.should(`include`, `/dialog/routable`) | ||
.should(`not.include`, `path/to/dialog`); | ||
}); | ||
|
||
it(`should open dialog by direct link and then close by outside click`, () => { | ||
cy.tuiVisit(`/dialog/routable/path/to/dialog`); | ||
|
||
cy.tuiWaitKitDialog(); | ||
cy.url().should(`include`, `/dialog/routable/path/to/dialog`); | ||
|
||
cy.tuiClickOutside(); | ||
cy.url() | ||
.should(`include`, `/dialog/routable`) | ||
.should(`not.include`, `path/to/dialog`); | ||
}); | ||
}); |
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
...ects/demo/src/modules/customization/routable/eager/examples/1/dialog-content.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,8 @@ | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'tui-example-dialog-content', | ||
template: 'Eager loaded dialog content', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class DialogContentComponent {} |
10 changes: 10 additions & 0 deletions
10
projects/demo/src/modules/customization/routable/eager/examples/1/page-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,10 @@ | ||
<button | ||
tuiButton | ||
routerLink="path/to/dialog" | ||
> | ||
Open dialog | ||
</button> | ||
|
||
<!-- step 1: add router-outlet to the page --> | ||
<!-- Needed for opening a dialog over of the page--> | ||
<router-outlet></router-outlet> |
11 changes: 11 additions & 0 deletions
11
projects/demo/src/modules/customization/routable/eager/examples/1/page-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,11 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
|
||
@Component({ | ||
selector: 'tui-page-1-example', | ||
templateUrl: './page-1.component.html', | ||
changeDetection, | ||
encapsulation, | ||
}) | ||
export class TuiPage1ExampleComponent {} |
30 changes: 30 additions & 0 deletions
30
projects/demo/src/modules/customization/routable/eager/examples/1/page-1.module.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,30 @@ | ||
import {NgModule} from '@angular/core'; | ||
import {RouterModule} from '@angular/router'; | ||
import {TuiButtonModule} from '@taiga-ui/core'; | ||
import {tuiGenerateDialogableRoute, TuiRoutableDialogModule} from '@taiga-ui/kit'; | ||
|
||
import {DialogContentComponent} from './dialog-content.component'; | ||
import {TuiPage1ExampleComponent} from './page-1.component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
// step 2: add TuiRoutableDialogModule | ||
TuiRoutableDialogModule, | ||
RouterModule.forChild([ | ||
{ | ||
path: ``, | ||
component: TuiPage1ExampleComponent, | ||
children: [ | ||
// step 3: use tuiGenerateDialogableRoute inside children property | ||
tuiGenerateDialogableRoute(DialogContentComponent, { | ||
path: `path/to/dialog`, | ||
}), | ||
], | ||
}, | ||
]), | ||
TuiButtonModule, | ||
], | ||
declarations: [TuiPage1ExampleComponent, DialogContentComponent], | ||
exports: [TuiPage1ExampleComponent], | ||
}) | ||
export class TuiPage1ExampleModule {} |
3 changes: 3 additions & 0 deletions
3
...mo/src/modules/customization/routable/eager/examples/setup/add-router-outlet.md
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,3 @@ | ||
```html | ||
<router-outlet></router-outlet> | ||
``` |
14 changes: 14 additions & 0 deletions
14
...s/demo/src/modules/customization/routable/eager/examples/setup/import-module.md
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,14 @@ | ||
```ts | ||
import {TuiRoutableDialogModule} from '@taiga-ui/kit'; | ||
|
||
// ... | ||
|
||
@NgModule({ | ||
imports: [ | ||
// ... | ||
TuiRoutableDialogModule, | ||
], | ||
// ... | ||
}) | ||
export class MyPageModule {} | ||
``` |
20 changes: 20 additions & 0 deletions
20
.../src/modules/customization/routable/eager/examples/setup/use-route-generator.md
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,20 @@ | ||
```ts | ||
import {TuiRoutableDialogModule} from '@taiga-ui/kit'; | ||
|
||
// ... | ||
|
||
@NgModule({ | ||
imports: [ | ||
// ... | ||
RouterModule.forChild([ | ||
{ | ||
path: ``, | ||
component: MyPageComponent, | ||
children: [tuiGenerateDialogableRoute(MyDialogComponent, {path: `path/to/dialog`})], | ||
}, | ||
]), | ||
], | ||
// ... | ||
}) | ||
export class MyPageModule {} | ||
``` |
22 changes: 22 additions & 0 deletions
22
projects/demo/src/modules/customization/routable/eager/routable-dialog.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,22 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {TuiDocExample} from '@taiga-ui/addon-doc'; | ||
|
||
@Component({ | ||
selector: 'routable-dialog', | ||
templateUrl: './routable-dialog.template.html', | ||
changeDetection, | ||
}) | ||
export class RoutableDialogComponent { | ||
readonly example1: TuiDocExample = { | ||
'page.template.html': import('./examples/1/page-1.component.html?raw'), | ||
'page.module.ts': import('./examples/1/page-1.module.ts?raw'), | ||
'dialog-content.component.ts': import( | ||
'./examples/1/dialog-content.component.ts?raw' | ||
), | ||
}; | ||
|
||
readonly addRouterOutlet = import('./examples/setup/add-router-outlet.md?raw'); | ||
readonly importModule = import('./examples/setup/import-module.md?raw'); | ||
readonly useRouteGenerator = import('./examples/setup/use-route-generator.md?raw'); | ||
} |
36 changes: 36 additions & 0 deletions
36
projects/demo/src/modules/customization/routable/eager/routable-dialog.module.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,36 @@ | ||
import {CommonModule} from '@angular/common'; | ||
import {NgModule} from '@angular/core'; | ||
import {RouterModule} from '@angular/router'; | ||
import {TuiAddonDocModule} from '@taiga-ui/addon-doc'; | ||
import {TuiButtonModule} from '@taiga-ui/core'; | ||
|
||
import {RoutableDialogComponent} from './routable-dialog.component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
TuiAddonDocModule, | ||
RouterModule.forChild([ | ||
{ | ||
path: ``, | ||
component: RoutableDialogComponent, | ||
children: [ | ||
{ | ||
path: ``, | ||
loadChildren: async () => | ||
(await import(`./examples/1/page-1.module`)) | ||
.TuiPage1ExampleModule, | ||
}, | ||
{ | ||
path: `Setup`, | ||
component: RoutableDialogComponent, | ||
}, | ||
], | ||
}, | ||
]), | ||
TuiButtonModule, | ||
], | ||
declarations: [RoutableDialogComponent], | ||
exports: [RoutableDialogComponent], | ||
}) | ||
export class RoutableDialogModule {} |
Oops, something went wrong.