-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): correct calculations are only in the accessor
- Loading branch information
Showing
10 changed files
with
113 additions
and
85 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
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
29 changes: 24 additions & 5 deletions
29
projects/demo/src/modules/customization/viewport/examples/2/index.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,17 +1,36 @@ | ||
import {Component} from '@angular/core'; | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {TuiDropdown} from '@taiga-ui/core'; | ||
import {tuiAsPortal, tuiInjectElement, TuiPortals} from '@taiga-ui/cdk'; | ||
import type {TuiRectAccessor} from '@taiga-ui/core'; | ||
import {tuiAsViewport, TuiDropdown, TuiDropdownService} from '@taiga-ui/core'; | ||
|
||
import {PortalHost} from './portal-host'; | ||
@Component({ | ||
standalone: true, | ||
selector: 'portal-host', | ||
template: ` | ||
<ng-content></ng-content> | ||
<ng-container #viewContainer></ng-container> | ||
`, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
providers: [tuiAsPortal(TuiDropdownService), tuiAsViewport(PortalHost)], | ||
}) | ||
class PortalHost extends TuiPortals implements TuiRectAccessor { | ||
private readonly el = tuiInjectElement(); | ||
|
||
public readonly type = 'viewport'; | ||
|
||
public getClientRect(): DOMRect { | ||
return this.el.getBoundingClientRect(); | ||
} | ||
} | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'tui-viewport-example-2', | ||
imports: [PortalHost, TuiDropdown], | ||
templateUrl: './index.html', | ||
styleUrls: ['../1/index.less'], | ||
encapsulation, | ||
changeDetection, | ||
}) | ||
export class Example {} | ||
export default class Example {} |
28 changes: 0 additions & 28 deletions
28
projects/demo/src/modules/customization/viewport/examples/2/portal-host.ts
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
projects/demo/src/modules/customization/viewport/examples/3/index.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,25 @@ | ||
<portal-host class="dropdowns"> | ||
<button | ||
tuiButton | ||
tuiHintDirection="right" | ||
type="button" | ||
class="t-centered-axis-xy" | ||
[tuiHint]="template" | ||
[tuiHintManual]="hintShown" | ||
(click)="toggleHint()" | ||
> | ||
Hint | ||
</button> | ||
</portal-host> | ||
|
||
<ng-template #template> | ||
Use | ||
<a | ||
appearance="action-grayscale" | ||
tuiLink | ||
tuiTheme="dark" | ||
class="link" | ||
> | ||
Hint | ||
</a> | ||
</ng-template> |
41 changes: 41 additions & 0 deletions
41
projects/demo/src/modules/customization/viewport/examples/3/index.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,41 @@ | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {tuiInjectElement, TuiPortals} from '@taiga-ui/cdk'; | ||
import type {TuiRectAccessor} from '@taiga-ui/core'; | ||
import {tuiAsViewport, TuiButton, TuiHint, TuiLink} from '@taiga-ui/core'; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'portal-host', | ||
template: ` | ||
<ng-content></ng-content> | ||
`, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
providers: [tuiAsViewport(PortalHost)], | ||
}) | ||
class PortalHost extends TuiPortals implements TuiRectAccessor { | ||
private readonly el = tuiInjectElement(); | ||
|
||
public readonly type = 'viewport'; | ||
|
||
public getClientRect(): DOMRect { | ||
return this.el.getBoundingClientRect(); | ||
} | ||
} | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [PortalHost, TuiButton, TuiHint, TuiLink], | ||
templateUrl: './index.html', | ||
styleUrls: ['../1/index.less'], | ||
encapsulation, | ||
changeDetection, | ||
}) | ||
export default class Example { | ||
protected hintShown = false; | ||
|
||
protected toggleHint(): void { | ||
this.hintShown = !this.hintShown; | ||
} | ||
} |
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