Skip to content

feat(module:splitter): add splitter component - #8987

Merged
Laffery merged 18 commits into
NG-ZORRO:masterfrom
Laffery:feat/splitter
Mar 26, 2025
Merged

feat(module:splitter): add splitter component#8987
Laffery merged 18 commits into
NG-ZORRO:masterfrom
Laffery:feat/splitter

Conversation

@Laffery

@Laffery Laffery commented Jan 21, 2025

Copy link
Copy Markdown
Collaborator

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Application (the showcase website) / infrastructure changes
  • Other... Please describe:

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?

  • Yes
  • No

Other information

@Laffery Laffery self-assigned this Jan 21, 2025
@Laffery Laffery added this to the v19.1 milestone Jan 21, 2025
@Laffery Laffery changed the title feat(module:splitter): add splitter component WIP feat(module:splitter): add splitter component Jan 21, 2025
@zorro-bot

zorro-bot Bot commented Jan 21, 2025

Copy link
Copy Markdown

This preview will be available after the AzureCI is passed.

@codecov

codecov Bot commented Jan 21, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 95.56452% with 11 lines in your changes missing coverage. Please review.

Project coverage is 91.99%. Comparing base (b6f96ee) to head (ab8428c).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
components/splitter/splitter.component.ts 95.58% 0 Missing and 9 partials ⚠️
components/splitter/splitter-bar.component.ts 91.66% 0 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Laffery
Laffery force-pushed the feat/splitter branch 2 times, most recently from 6f96ac0 to 7da5053 Compare January 21, 2025 07:03
@Laffery Laffery modified the milestones: v19.1, v19.2 Feb 19, 2025
@Laffery
Laffery requested a review from CK110 as a code owner March 14, 2025 15:46
@Laffery
Laffery force-pushed the feat/splitter branch 3 times, most recently from 4142df6 to 4cc3d29 Compare March 15, 2025 16:20
})
export class NzSplitterComponent {
/** ------------------- Props ------------------- */
nzLayout = input<NzSplitterLayout>('horizontal');

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Collaborator Author

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!

Copy link
Copy Markdown
Contributor

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(() => {

Copy link
Copy Markdown
Contributor

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?

@Laffery Laffery Mar 16, 2025

Copy link
Copy Markdown
Collaborator Author

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.

Copy link
Copy Markdown
Contributor

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:

  1. sometimes users need access to unstable / internal declarations when NG-ZORRO doesn't behave as expected

  2. 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.

Copy link
Copy Markdown
Contributor

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.

@Laffery

Laffery commented Mar 16, 2025

Copy link
Copy Markdown
Collaborator Author

@lppedd I'd made changes as your suggestions

@Laffery

Laffery commented Mar 16, 2025

Copy link
Copy Markdown
Collaborator Author

This pr is nearly completed, all the use cases of antd are implemented.

There are Todos as follows till now:

  • Restore the previous size when expanding a collapsed panel
  • Observe to resize event of the container
  • RTL support
  • Unit test cases

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

@Laffery Laffery changed the title WIP feat(module:splitter): add splitter component feat(module:splitter): add splitter component Mar 16, 2025

@lppedd lppedd left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread components/splitter/splitter.component.ts Outdated
Comment thread components/splitter/splitter.component.ts Outdated
Comment on lines +112 to +113
readonly destroy$ = inject(NzDestroyService);
readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);

Copy link
Copy Markdown
Contributor

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:

  1. private properties
  2. inputs
  3. outputs
  4. component state (props/functions)

Copy link
Copy Markdown
Collaborator Author

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

  1. inputs
  2. outputs
  3. private properties
  4. 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

Copy link
Copy Markdown
Contributor

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.

Comment thread components/splitter/splitter.component.ts Outdated
Comment thread components/splitter/splitter.component.ts
Comment thread components/splitter/typings.ts
Comment thread components/splitter/doc/index.en-US.md Outdated
Comment thread components/splitter/doc/index.en-US.md Outdated
Comment thread components/splitter/doc/index.en-US.md Outdated
Comment thread components/splitter/splitter-bar.component.ts Outdated
@Laffery
Laffery requested a review from HyperLife1119 March 22, 2025 16:54
@Laffery

Laffery commented Mar 22, 2025

Copy link
Copy Markdown
Collaborator Author

Tests added and all the TODOs done, waiting for kindly code review :)

Comment thread components/splitter/splitter.component.ts Outdated

@HyperLife1119 HyperLife1119 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@WwwHhhYran WwwHhhYran left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Laffery
Laffery merged commit 9b3f62e into NG-ZORRO:master Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants