Skip to content

Commit

Permalink
refactor(module:affix): migrate demo to standalone mode (#8727)
Browse files Browse the repository at this point in the history
  • Loading branch information
Laffery committed Sep 4, 2024
1 parent 3df967c commit eb8ae6a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
13 changes: 6 additions & 7 deletions components/affix/affix.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BidiModule, Dir, Directionality } from '@angular/cdk/bidi';
import { BidiModule, Dir, Direction, Directionality } from '@angular/cdk/bidi';
import { Platform } from '@angular/cdk/platform';
import { DOCUMENT } from '@angular/common';
import { Component, DebugElement, ElementRef, Renderer2, ViewChild } from '@angular/core';
Expand Down Expand Up @@ -358,7 +358,7 @@ describe('affix', () => {
discardPeriodicTasks();
}));

it(`emit false when is unaffixed`, fakeAsync(() => {
it(`emit false when isn't affixed`, fakeAsync(() => {
setupInitialState();
emitScroll(window, defaultOffsetTop + startOffset + 1);
emitScroll(window, defaultOffsetTop + startOffset - 1);
Expand Down Expand Up @@ -524,8 +524,7 @@ describe('affix RTL', () => {
dl = fixture.debugElement;
}));
it('should className correct on dir change', fakeAsync(() => {
const value = 10;
context.newOffsetBottom = value;
context.newOffsetBottom = 10;
context.fakeTarget = window;
fixture.detectChanges();
const el = dl.query(By.css('nz-affix')).nativeElement as HTMLElement;
Expand Down Expand Up @@ -555,7 +554,7 @@ describe('affix RTL', () => {
})
class TestAffixComponent {
@ViewChild(NzAffixComponent, { static: true }) nzAffixComponent!: NzAffixComponent;
fakeTarget: string | Element | Window | null = null;
fakeTarget?: string | Element | Window;
newOffset!: number;
newOffsetBottom!: number;
}
Expand All @@ -572,10 +571,10 @@ class TestAffixComponent {
})
export class TestAffixRtlComponent {
@ViewChild(Dir) dir!: Dir;
direction = 'rtl';
direction: Direction = 'rtl';

@ViewChild(NzAffixComponent, { static: true }) nzAffixComponent!: NzAffixComponent;
fakeTarget: string | Element | Window | null = null;
fakeTarget?: string | Element | Window;
newOffset!: number;
newOffsetBottom!: number;
}
Expand Down
5 changes: 5 additions & 0 deletions components/affix/demo/basic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Component } from '@angular/core';

import { NzAffixModule } from 'ng-zorro-antd/affix';
import { NzButtonModule } from 'ng-zorro-antd/button';

@Component({
standalone: true,
selector: 'nz-demo-affix-basic',
imports: [NzAffixModule, NzButtonModule],
template: `
<nz-affix [nzOffsetTop]="offsetTop">
<button nz-button nzType="primary" (click)="setOffsetTop()">
Expand Down
5 changes: 0 additions & 5 deletions components/affix/demo/module

This file was deleted.

5 changes: 5 additions & 0 deletions components/affix/demo/on-change.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Component } from '@angular/core';

import { NzAffixModule } from 'ng-zorro-antd/affix';
import { NzButtonModule } from 'ng-zorro-antd/button';

@Component({
standalone: true,
selector: 'nz-demo-affix-on-change',
imports: [NzAffixModule, NzButtonModule],
template: `
<nz-affix [nzOffsetTop]="120" (nzChange)="onChange($event)">
<button nz-button>
Expand Down
5 changes: 5 additions & 0 deletions components/affix/demo/target.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Component } from '@angular/core';

import { NzAffixModule } from 'ng-zorro-antd/affix';
import { NzButtonModule } from 'ng-zorro-antd/button';

@Component({
standalone: true,
selector: 'nz-demo-affix-target',
imports: [NzAffixModule, NzButtonModule],
template: `
<div class="scrollable-container" #target>
<div class="background">
Expand Down

0 comments on commit eb8ae6a

Please sign in to comment.