Skip to content

Commit

Permalink
feat(module:page-header): support standalone component (#8235)
Browse files Browse the repository at this point in the history
  • Loading branch information
ParsaArvanehPA authored Dec 1, 2023
1 parent 686b6b0 commit aa91486
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 54 deletions.
38 changes: 20 additions & 18 deletions components/page-header/doc/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,25 @@ import { NzPageHeaderModule } from 'ng-zorro-antd/page-header';
<nz-page-header nzTitle="Page Title"></nz-page-header>
```

### nz-page-header
| Param | Description | Type | Default value | Global Config |
| ----- | ----------- | ---- | ------------- | ------------- |
| `[nzGhost]` | Make background transparent | `boolean` | `true` ||
| `[nzTitle]` | Title string | `string \| TemplateRef<void>` | - | - |
| `[nzSubtitle]` | SubTitle string | `string \| TemplateRef<void>` | - | - |
| `[nzBackIcon]` | Custom back icon | `string \| TemplateRef<void>` | - | - |
| `(nzBack)` | Back icon click event | `EventEmitter<void>` | Call [Location[back]](https://angular.io/api/common/Location#back) when the event not subscribed(you need import [RouterModule](https://angular.io/api/router/RouterModule) or register [Location](https://angular.io/api/common/Location)| - |
### nz-page-header:standalone

| Param | Description | Type | Default value | Global Config |
| -------------- | --------------------------- | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
| `[nzGhost]` | Make background transparent | `boolean` | `true` ||
| `[nzTitle]` | Title string | `string \| TemplateRef<void>` | - | - |
| `[nzSubtitle]` | SubTitle string | `string \| TemplateRef<void>` | - | - |
| `[nzBackIcon]` | Custom back icon | `string \| TemplateRef<void>` | - | - |
| `(nzBack)` | Back icon click event | `EventEmitter<void>` | Call [Location[back]](https://angular.io/api/common/Location#back) when the event not subscribed(you need import [RouterModule](https://angular.io/api/router/RouterModule) or register [Location](https://angular.io/api/common/Location)| - |

### Page header sections
| Element | Description |
| ----- | ----- |
| `nz-page-header-title` | Title section |
| `nz-page-header-subtitle` | Subtitle section, `[nzTitle]` has high priority |
| `nz-page-header-content` | Content section, `[nzSubtitle]` has high priority |
| `nz-page-header-footer` | Footer section |
| `nz-page-header-tags` | Tags container after the title |
| `nz-page-header-extra` | Operating area, at the end of the line of the title line |
| `nz-breadcrumb[nz-page-header-breadcrumb]` | Breadcrumb section |
| `nz-avatar[nz-page-header-avatar]` | Avatar section |

| Element | Description |
| ------------------------------------------ | -------------------------------------------------------- |
| `nz-page-header-title` | Title section |
| `nz-page-header-subtitle` | Subtitle section, `[nzTitle]` has high priority |
| `nz-page-header-content` | Content section, `[nzSubtitle]` has high priority |
| `nz-page-header-footer` | Footer section |
| `nz-page-header-tags` | Tags container after the title |
| `nz-page-header-extra` | Operating area, at the end of the line of the title line |
| `nz-breadcrumb[nz-page-header-breadcrumb]` | Breadcrumb section |
| `nz-avatar[nz-page-header-avatar]` | Avatar section |
37 changes: 19 additions & 18 deletions components/page-header/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,25 @@ import { NzPageHeaderModule } from 'ng-zorro-antd/page-header';
<nz-page-header nzTitle="Page Title"></nz-page-header>
```

### nz-page-header
| 参数 | 说明 | 类型 | 默认值 | 全局配置 |
| --- | --- | --- | --- | --- |
| `[nzGhost]` | 使背景色透明 | `boolean` | `true` ||
| `[nzTitle]` | title 文字 | `string \| TemplateRef<void>` | - | - |
| `[nzSubtitle]` | subTitle 文字 | `string \| TemplateRef<void>` | - | - |
| `[nzBackIcon]` | 自定义 back icon | `string \| TemplateRef<void>` | - | - |
| `(nzBack)` | 返回按钮的点击事件 | `EventEmitter<void>` | 未订阅该事件时默认调用 [Location[back]](https://angular.cn/api/common/Location#back)(需要引入 [RouterModule](https://angular.io/api/router/RouterModule) 或者注册 [Location](https://angular.io/api/common/Location)) | - |
### nz-page-header:standalone

| 参数 | 说明 | 类型 | 默认值 | 全局配置 |
| -------------- | ------------------ | ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `[nzGhost]` | 使背景色透明 | `boolean` | `true` ||
| `[nzTitle]` | title 文字 | `string \| TemplateRef<void>` | - | - |
| `[nzSubtitle]` | subTitle 文字 | `string \| TemplateRef<void>` | - | - |
| `[nzBackIcon]` | 自定义 back icon | `string \| TemplateRef<void>` | - | - |
| `(nzBack)` | 返回按钮的点击事件 | `EventEmitter<void>` | 未订阅该事件时默认调用 [Location[back]](https://angular.cn/api/common/Location#back)(需要引入 [RouterModule](https://angular.io/api/router/RouterModule) 或者注册 [Location](https://angular.io/api/common/Location)) | - |

### Page header 组成部分
| 元素 | 说明 |
| ----- | ----- |
| `nz-page-header-title` | title 部分,`[nzTitle]` 优先级更高 |
| `nz-page-header-subtitle` | subtitle 部分,`[nzSubtitle]` 优先级更高 |
| `nz-page-header-content` | 内容部分 |
| `nz-page-header-footer` | 底部部分 |
| `nz-page-header-tags` | title 旁的 tag 列表容器 |
| `nz-page-header-extra` | title 的行尾操作区部分 |
| `nz-breadcrumb[nz-page-header-breadcrumb]` | 面包屑部分 |
| `nz-avatar[nz-page-header-avatar]` | 头像部分 |

| 元素 | 说明 |
| ------------------------------------------ | ---------------------------------------- |
| `nz-page-header-title` | title 部分,`[nzTitle]` 优先级更高 |
| `nz-page-header-subtitle` | subtitle 部分,`[nzSubtitle]` 优先级更高 |
| `nz-page-header-content` | 内容部分 |
| `nz-page-header-footer` | 底部部分 |
| `nz-page-header-tags` | title 旁的 tag 列表容器 |
| `nz-page-header-extra` | title 的行尾操作区部分 |
| `nz-breadcrumb[nz-page-header-breadcrumb]` | 面包屑部分 |
| `nz-avatar[nz-page-header-avatar]` | 头像部分 |
24 changes: 16 additions & 8 deletions components/page-header/page-header-cells.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { Directive } from '@angular/core';
exportAs: 'nzPageHeaderTitle',
host: {
class: 'ant-page-header-heading-title'
}
},
standalone: true
})
export class NzPageHeaderTitleDirective {}

Expand All @@ -19,7 +20,8 @@ export class NzPageHeaderTitleDirective {}
exportAs: 'nzPageHeaderSubtitle',
host: {
class: 'ant-page-header-heading-sub-title'
}
},
standalone: true
})
export class NzPageHeaderSubtitleDirective {}

Expand All @@ -28,7 +30,8 @@ export class NzPageHeaderSubtitleDirective {}
exportAs: 'nzPageHeaderContent',
host: {
class: 'ant-page-header-content'
}
},
standalone: true
})
export class NzPageHeaderContentDirective {}

Expand All @@ -37,7 +40,8 @@ export class NzPageHeaderContentDirective {}
exportAs: 'nzPageHeaderTags',
host: {
class: 'ant-page-header-heading-tags'
}
},
standalone: true
})
export class NzPageHeaderTagDirective {}

Expand All @@ -46,7 +50,8 @@ export class NzPageHeaderTagDirective {}
exportAs: 'nzPageHeaderExtra',
host: {
class: 'ant-page-header-heading-extra'
}
},
standalone: true
})
export class NzPageHeaderExtraDirective {}

Expand All @@ -55,18 +60,21 @@ export class NzPageHeaderExtraDirective {}
exportAs: 'nzPageHeaderFooter',
host: {
class: 'ant-page-header-footer'
}
},
standalone: true
})
export class NzPageHeaderFooterDirective {}

@Directive({
selector: 'nz-breadcrumb[nz-page-header-breadcrumb]',
exportAs: 'nzPageHeaderBreadcrumb'
exportAs: 'nzPageHeaderBreadcrumb',
standalone: true
})
export class NzPageHeaderBreadcrumbDirective {}

@Directive({
selector: 'nz-avatar[nz-page-header-avatar]',
exportAs: 'nzPageHeaderAvatar'
exportAs: 'nzPageHeaderAvatar',
standalone: true
})
export class NzPageHeaderAvatarDirective {}
8 changes: 6 additions & 2 deletions components/page-header/page-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { Direction, Directionality } from '@angular/cdk/bidi';
import { Location } from '@angular/common';
import { Location, NgIf } from '@angular/common';
import {
AfterViewInit,
ChangeDetectionStrategy,
Expand All @@ -27,6 +27,8 @@ import { map, takeUntil } from 'rxjs/operators';
import { NzResizeObserver } from 'ng-zorro-antd/cdk/resize-observer';
import { NzConfigKey, NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
import { PREFIX } from 'ng-zorro-antd/core/logger';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
import { NzIconModule } from 'ng-zorro-antd/icon';

import { NzPageHeaderBreadcrumbDirective, NzPageHeaderFooterDirective } from './page-header-cells';

Expand Down Expand Up @@ -78,7 +80,9 @@ const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'pageHeader';
'[class.has-breadcrumb]': 'nzPageHeaderBreadcrumb',
'[class.ant-page-header-compact]': 'compact',
'[class.ant-page-header-rtl]': `dir === 'rtl'`
}
},
imports: [NgIf, NzOutletModule, NzIconModule],
standalone: true
})
export class NzPageHeaderComponent implements AfterViewInit, OnDestroy, OnInit {
readonly _nzModuleName: NzConfigKey = NZ_CONFIG_MODULE_NAME;
Expand Down
10 changes: 2 additions & 8 deletions components/page-header/page-header.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

import { BidiModule } from '@angular/cdk/bidi';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';

import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
import { NzIconModule } from 'ng-zorro-antd/icon';

import {
NzPageHeaderAvatarDirective,
NzPageHeaderBreadcrumbDirective,
Expand All @@ -34,8 +29,7 @@ const NzPageHeaderCells = [
];

@NgModule({
imports: [BidiModule, CommonModule, NzOutletModule, NzIconModule],
exports: [NzPageHeaderComponent, NzPageHeaderCells],
declarations: [NzPageHeaderComponent, NzPageHeaderCells]
imports: [NzPageHeaderComponent, NzPageHeaderCells],
exports: [NzPageHeaderComponent, NzPageHeaderCells]
})
export class NzPageHeaderModule {}

0 comments on commit aa91486

Please sign in to comment.