-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(module:icon): add provideNzIcon
and provideNzIconPatch
API
#8650
Conversation
This preview will be available after the AzureCI is passed. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8650 +/- ##
==========================================
- Coverage 91.52% 91.52% -0.01%
==========================================
Files 535 536 +1
Lines 18441 18445 +4
Branches 2907 2907
==========================================
+ Hits 16879 16882 +3
- Misses 1242 1243 +1
Partials 320 320 ☔ View full report in Codecov by Sentry. |
components/icon/provide-icon.ts
Outdated
export const provideNzIcon = (icons: IconDefinition[]): EnvironmentProviders => { | ||
return makeEnvironmentProviders([ | ||
{ | ||
provide: NZ_ICONS, | ||
useValue: icons | ||
} | ||
]); | ||
}; | ||
|
||
/** | ||
* Provide icon definitions for NzIcon in feature module or standalone component | ||
* @param icons Icon definitions | ||
*/ | ||
export const provideNzIconPatch = (icons: IconDefinition[]): Provider[] => { | ||
return [ | ||
NzIconPatchService, | ||
{ | ||
provide: NZ_ICONS_PATCH, | ||
useValue: icons | ||
} | ||
]; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NzIconModule 应该可以直接复用这两个函数:
export class NzIconModule {
static forRoot(icons: IconDefinition[]): ModuleWithProviders<NzIconModule> {
return {
ngModule: NzIconModule,
providers: [
provideNzIcon(icons)
]
};
}
static forChild(icons: IconDefinition[]): ModuleWithProviders<NzIconModule> {
return {
ngModule: NzIconModule,
providers: [
provideNzIconPatch(icons)
]
};
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: 这两个函数的命名需要考虑改为复数形式吗?WDYT?
provideNzIcons / provideNzIconsPatch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在之前的 ng g 原理图中,我们还手动定义了一个 provideNzIcons 函数,此时我们需要将它替换为当前的实现。
赞同,我稍后会更新下 schematics。还有上次提到的 doc 里的 app.config.ts
命名我们 follow 之前定义的 provideNzIcons 吧,复数语义上也更合理
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Developer can use
provideNzIcon
API in root andprovideNzIconPatch
in lazy-loading module or standalone component to provide icons now.Of course the former
NzIconModule.forRoot
andNzIconModule.forChild
API are still supported but not recommended in standalone mode any more.[USAGE]
Does this PR introduce a breaking change?
Other information