feat(module:splitter): add splitter component - #8987
Conversation
|
This preview will be available after the AzureCI is passed. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8987 +/- ##
==========================================
+ Coverage 91.94% 91.99% +0.04%
==========================================
Files 559 564 +5
Lines 19773 20021 +248
Branches 3050 3104 +54
==========================================
+ Hits 18181 18418 +237
Misses 1267 1267
- Partials 325 336 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6f96ac0 to
7da5053
Compare
4142df6 to
4cc3d29
Compare
| }) | ||
| export class NzSplitterComponent { | ||
| /** ------------------- Props ------------------- */ | ||
| nzLayout = input<NzSplitterLayout>('horizontal'); |
There was a problem hiding this comment.
Now that inputs are Signals, does it make to declare everything as readonly as you did for outputs?
There was a problem hiding this comment.
You're right, although readonly isn't required to inputs, we can still use it to make sure type safe during runtime!
There was a problem hiding this comment.
Indeed. I also like a consistent standard - so readonly by default (where applicable) is how I'd do it.
| lazy = input(false); | ||
| constrainedOffset = input<number>(); | ||
|
|
||
| readonly previewTransform = computed(() => { |
There was a problem hiding this comment.
Another opinion: I see that you used protected for resizeStartEvent, but not for properties (those signals) used in templates. This is another candiate for a project-wide standard: should all template-only props/funs be marked as protected, or should all be public?
There was a problem hiding this comment.
We do not expect user to use those internally-used-only props/funs, which are unstable and may be changed/removed in some refactoring PRs.
We only promise that public props/funs declared at the documentation website are compatible in a minor version. So I think they shall be protected.
But sometimes it's not convenient to access them in unit test cases.
TBH, there is currrently no consistant standard in this project.
We cannot get the acknownledge of how many internal apis are being used by user, what we can do as a popular component library is to keep public apis in stable and avoid exposing too many unstable internal apis.
There was a problem hiding this comment.
TBH, there is no consistant standard in this project.
Yeah that's what I saw by reading the code.
I would go the route of not bothering with specifying protected, and instead keep everything public because:
-
sometimes users need access to unstable / internal declarations when NG-ZORRO doesn't behave as expected
-
you could alternatively mark unstable / internal declarations with TSDoc's
@internal/** @internal */ readonly previewTransform = computed(() => { ... })
to signify to consumers this is not something they should normally use.
Additionaly,@internalplays nicely with stripInternal in case in the future you want to get rid of them in the outputted types.
There was a problem hiding this comment.
Btw, up to you. I was mostly trying to understand if there is a project/team standard, especially now that components are being refactored or created to support signals.
|
@lppedd I'd made changes as your suggestions |
|
This pr is nearly completed, all the use cases of antd are implemented. There are Todos as follows till now:
I will add them next week, and I think they do not have a impact on your review of the code, so could you please take a review on this PR if you have time. @Nicoss54 @HyperLife1119 @OriginRing @lppedd |
lppedd
left a comment
There was a problem hiding this comment.
Left some minor comments / nitpicks.
| readonly destroy$ = inject(NzDestroyService); | ||
| readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef); |
There was a problem hiding this comment.
inject-ed services or elements are best kept private imo.
I'd also keep a consistent structure:
- private properties
- inputs
- outputs
- component state (props/functions)
There was a problem hiding this comment.
I prefer the following order
- inputs
- outputs
- private properties
- component state (props/functions)
Puting inputs/outputs at the very top makes it clear to the person viewing the code how the component is used, just like a instruction manual
There was a problem hiding this comment.
Consistency over order, so that looks good to me.
|
Tests added and all the TODOs done, waiting for kindly code review :) |
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: #8940
What is the new behavior?
Add splitter component, see https://ant.design/components/splitter
Does this PR introduce a breaking change?
Other information