-
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:splitter): add splitter component #8987
base: master
Are you sure you want to change the base?
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.56% -0.39%
==========================================
Files 559 564 +5
Lines 19773 19975 +202
Branches 3050 3089 +39
==========================================
+ Hits 18181 18290 +109
- Misses 1267 1349 +82
- Partials 325 336 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6f96ac0
to
7da5053
Compare
}) | ||
export class NzSplitterComponent { | ||
/** ------------------- Props ------------------- */ | ||
nzLayout = input<NzSplitterLayout>('horizontal'); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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,@internal
plays 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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.
Left some minor comments / nitpicks.
readonly destroy$ = inject(NzDestroyService); | ||
readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency over order, so that looks good to me.
@Laffery @HyperLife1119 does it have a guideline for refactoring the components to support signal ? It will be a great pleasure to help you on this huge reworking. Take a look and give my review tomorrow if it’s good for you ? |
@Nicoss54 If there is no special situation, existing components will not be migrated to signals. |
Agree. That would be a huge work and I don't think the payoff would be great, and there could be unexpected problems introduced. |
By the way, material still remains in the original implementation as well |
Converting to signals during a component's fix or feature addition might be useful to expose unexpected property writes from inside or outside the component itself. But apart from that I agree and I don't see the urgency (also considering signals are not strictly necessary for zoneless). |
(mousedown)="resizeStartEvent($event)" | ||
(touchstart)="resizeStartEvent($event)" |
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.
Maybe we can use Pointer Event, which supports both mouse and touch.
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.
I tried it and the drag doesn't work very well with a touch screen.
Currently antd uses mousedown
and touchstart
as well, I think we can keep aligning with them.
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